Skip to content

Commit

Permalink
Ignore "old" interface netlink messages during swss restart (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored and lguohan committed Nov 16, 2017
1 parent 4f2c3cd commit 8f4d3c4
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions portsyncd/linksync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,43 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
nlmsg_type, key.c_str(), admin, oper, addrStr, ifindex, master);
}

/* Insert or update the ifindex to key map */
m_ifindexNameMap[ifindex] = key;

/* teamd instances are dealt in teamsyncd */
if (type && !strcmp(type, TEAM_DRV_NAME))
{
return;
}

/* In the event of swss restart, it is possible to get netlink messages during bridge
* delete, interface delete etc which are part of cleanup. These netlink messages for
* the front-panel interface must not be published or it will update the statedb with
* old interface info and result in subsequent failures. A new interface creation shall
* not have master or admin status iff_up. So if the first netlink message comes with these
* values set, it is considered to be happening during a cleanup process.
* Fix to ignore this and any further messages for this ifindex
*/

static std::map<unsigned int, std::string> m_ifindexOldNameMap;
if (m_ifindexNameMap.find(ifindex) == m_ifindexNameMap.end())
{
if (master)
{
m_ifindexOldNameMap[ifindex] = key;
SWSS_LOG_INFO("nlmsg type:%d Ignoring for %d, master %d", nlmsg_type, ifindex, master);
return;
}
else if (m_ifindexOldNameMap.find(ifindex) != m_ifindexOldNameMap.end())
{
if (m_ifindexOldNameMap[ifindex] == key)
{
SWSS_LOG_INFO("nlmsg type:%d Ignoring message for old interface %d", nlmsg_type, ifindex);
return;
}
}
}

/* Insert or update the ifindex to key map */
m_ifindexNameMap[ifindex] = key;

vector<FieldValueTuple> fvVector;
FieldValueTuple a("admin_status", admin ? "up" : "down");
FieldValueTuple m("mtu", to_string(mtu));
Expand Down

0 comments on commit 8f4d3c4

Please sign in to comment.