Skip to content

Commit

Permalink
[202205] Fixed set mtu for deleted subintf due to late notification (#…
Browse files Browse the repository at this point in the history
…2595)

PR against 202205 based on the following PR: #2571

- What I did
Ignores errors on the set MTU command for subinterface when the subinterface state is not OK.

- Why I did it
A race condition between the portmgrd and the intfmgrd sometimes causes running a set MTU command on a deleted subinterface.
The logs and the error:

INFO swss#supervisord: intfmgrd Cannot find device "Ethernet32.58"
ERR swss#intfmgrd: :- main: Runtime error: /sbin/ip link set "Ethernet32.58" mtu "9100" :
INFO swss#supervisord 2022-11-08 05:53:33,057 INFO exited: intfmgrd (exit status 255; not expected)

- How I verified it
Run the test_loopback_action_reload test and saw no errors in the logs.
  • Loading branch information
dprital authored Jan 3, 2023
1 parent d8e46b9 commit 8c9092c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +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);

if (ret && !isIntfStateOk(alias))
{
// 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)
{
throw runtime_error(cmd_str + " : " + res);
}
return subifMtu;
}

Expand All @@ -468,7 +479,7 @@ void IntfMgr::updateSubIntfAdminStatus(const string &alias, const string &admin)
continue;
}
std::vector<FieldValueTuple> 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);
Expand Down

0 comments on commit 8c9092c

Please sign in to comment.