Skip to content

Commit

Permalink
portmgrd: prevent runtime failure in setting MTU on portchannel member
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
bradh352 committed Jan 7, 2025
1 parent c20902f commit 201d5b1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
33 changes: 30 additions & 3 deletions cfgmgr/portmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ PortMgr::PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
{
}

bool PortMgr::isLag(const std::string &port)
{
SWSS_LOG_ENTER();

vector<string> 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;
Expand Down Expand Up @@ -128,6 +150,7 @@ void PortMgr::doSendToIngressPortTask(Consumer &consumer)

}


void PortMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/portmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

}

0 comments on commit 201d5b1

Please sign in to comment.