From d50e5205670d6abdab7e355f6a03c2dcd9481f7f Mon Sep 17 00:00:00 2001 From: Brad House Date: Tue, 17 Dec 2024 14:51:15 -0500 Subject: [PATCH] portmgrd: prevent runtime failure in setting MTU on portchannel member Do not attempt to set the MTU directly on PortChannel members as it will likely fail. The MTU gets inherited as part of the PortChannel. Signed-off-by: Brad House (@bradh352) --- cfgmgr/portmgr.cpp | 33 ++++++++++++++++++++++++++++++--- cfgmgr/portmgr.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cfgmgr/portmgr.cpp b/cfgmgr/portmgr.cpp index dcc71c6600..dd9dca5c3f 100644 --- a/cfgmgr/portmgr.cpp +++ b/cfgmgr/portmgr.cpp @@ -22,6 +22,28 @@ PortMgr::PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c { } +bool PortMgr::isLag(const std::string &port) +{ + SWSS_LOG_ENTER(); + + vector keys; + m_cfgLagMemberTable.getKeys(keys); + + for (auto key: keys) + { + auto tokens = tokenize(key, config_db_key_delimiter); + auto lag = tokens[0]; + auto member = tokens[1]; + + if (port == member) + { + return true; + } + } + + return false; +} + bool PortMgr::setPortMtu(const string &alias, const string &mtu) { stringstream cmd; @@ -128,6 +150,7 @@ void PortMgr::doSendToIngressPortTask(Consumer &consumer) } + void PortMgr::doTask(Consumer &consumer) { SWSS_LOG_ENTER(); @@ -221,14 +244,18 @@ void PortMgr::doTask(Consumer &consumer) if (!mtu.empty()) { - setPortMtu(alias, mtu); - SWSS_LOG_NOTICE("Configure %s MTU to %s", alias.c_str(), mtu.c_str()); + if (isLag(alias)) { + SWSS_LOG_NOTICE("Skipping Configure %s MTU to %s as interface is part of a PortChannel", alias.c_str(), mtu.c_str()); + } else { + SWSS_LOG_NOTICE("Configure %s MTU to %s", alias.c_str(), mtu.c_str()); + setPortMtu(alias, mtu); + } } if (!admin_status.empty()) { - setPortAdminStatus(alias, admin_status == "up"); SWSS_LOG_NOTICE("Configure %s admin status to %s", alias.c_str(), admin_status.c_str()); + setPortAdminStatus(alias, admin_status == "up"); } } else if (op == DEL_COMMAND) diff --git a/cfgmgr/portmgr.h b/cfgmgr/portmgr.h index 3d6f0365bf..bd6cb55f0c 100644 --- a/cfgmgr/portmgr.h +++ b/cfgmgr/portmgr.h @@ -37,6 +37,7 @@ class PortMgr : public Orch bool setPortMtu(const std::string &alias, const std::string &mtu); bool setPortAdminStatus(const std::string &alias, const bool up); bool isPortStateOk(const std::string &alias); + bool isLag(const std::string &port); }; }