From 1db37b3fb0ad7bac92356145b1a7e670acad3b52 Mon Sep 17 00:00:00 2001 From: EdenGri Date: Wed, 7 Dec 2022 16:41:35 +0000 Subject: [PATCH 1/3] Fixed set mtu for deleted subintf due to late notification --- cfgmgr/intfmgr.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 9e30e1265f4..8e15631eefb 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -447,9 +447,19 @@ std::string IntfMgr::setHostSubIntfMtu(const string &alias, const string &mtu, c } SWSS_LOG_INFO("subintf %s active mtu: %s", alias.c_str(), subifMtu.c_str()); cmd << IP_CMD " link set " << shellquote(alias) << " mtu " << shellquote(subifMtu); - EXEC_WITH_ERROR_THROW(cmd.str(), res); + std::string cmd_str = cmd.str(); + int ret = swss::exec(cmd_str, res); - return subifMtu; + if (ret && !isIntfStateOk(alias)) + { + // Can happen when a DEL notification is sent by portmgrd immediately followed by a new SET notif + SWSS_LOG_WARN("Setting mtu to alias:%s netdev failed with cmd:%s, rc:%d, error:%s", alias.c_str(), cmd_str.c_str(), ret, res.c_str()); + } + else if(ret) + { + throw runtime_error(cmd_str + " : " + res); + } + return subifMtu; } void IntfMgr::updateSubIntfAdminStatus(const string &alias, const string &admin) @@ -468,7 +478,7 @@ void IntfMgr::updateSubIntfAdminStatus(const string &alias, const string &admin) continue; } std::vector fvVector; - string subintf_admin = setHostSubIntfAdminStatus(intf, m_subIntfList[intf].adminStatus, admin); + string subintf_admin = setHostSubIntfAdminStatus(intf, m_subIntfList[intf].adminStatus, admin); m_subIntfList[intf].currAdminStatus = subintf_admin; FieldValueTuple fvTuple("admin_status", subintf_admin); fvVector.push_back(fvTuple); From 8ae91e4921358c0dd0c514eb5b66db2e53c2e156 Mon Sep 17 00:00:00 2001 From: EdenGri Date: Mon, 12 Dec 2022 12:47:44 +0000 Subject: [PATCH 2/3] change comment and log message after CR --- cfgmgr/intfmgr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 8e15631eefb..c1b46c49f65 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -452,8 +452,9 @@ std::string IntfMgr::setHostSubIntfMtu(const string &alias, const string &mtu, c if (ret && !isIntfStateOk(alias)) { - // Can happen when a DEL notification is sent by portmgrd immediately followed by a new SET notif - SWSS_LOG_WARN("Setting mtu to alias:%s netdev failed with cmd:%s, rc:%d, error:%s", alias.c_str(), cmd_str.c_str(), ret, res.c_str()); + // Can happen when a SET notification on the PORT_TABLE in the State DB + // followed by a new DEL notification that send by portmgrd + SWSS_LOG_WARN("Setting mtu to %s netdev failed with cmd:%s, rc:%d, error:%s", alias.c_str(), cmd_str.c_str(), ret, res.c_str()); } else if(ret) { From 3e64c97298136b797857467089e5c2d32c7a84de Mon Sep 17 00:00:00 2001 From: EdenGri Date: Wed, 21 Dec 2022 13:10:27 +0000 Subject: [PATCH 3/3] Add and remove spaces --- cfgmgr/intfmgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index c1b46c49f65..f0f4ec97fa7 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -456,11 +456,11 @@ std::string IntfMgr::setHostSubIntfMtu(const string &alias, const string &mtu, c // followed by a new DEL notification that send by portmgrd SWSS_LOG_WARN("Setting mtu to %s netdev failed with cmd:%s, rc:%d, error:%s", alias.c_str(), cmd_str.c_str(), ret, res.c_str()); } - else if(ret) + else if (ret) { throw runtime_error(cmd_str + " : " + res); } - return subifMtu; + return subifMtu; } void IntfMgr::updateSubIntfAdminStatus(const string &alias, const string &admin)