@@ -90,15 +90,43 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
90
90
nlmsg_type, key.c_str (), admin, oper, addrStr, ifindex, master);
91
91
}
92
92
93
- /* Insert or update the ifindex to key map */
94
- m_ifindexNameMap[ifindex] = key;
95
-
96
93
/* teamd instances are dealt in teamsyncd */
97
94
if (type && !strcmp (type, TEAM_DRV_NAME))
98
95
{
99
96
return ;
100
97
}
101
98
99
+ /* In the event of swss restart, it is possible to get netlink messages during bridge
100
+ * delete, interface delete etc which are part of cleanup. These netlink messages for
101
+ * the front-panel interface must not be published or it will update the statedb with
102
+ * old interface info and result in subsequent failures. A new interface creation shall
103
+ * not have master or admin status iff_up. So if the first netlink message comes with these
104
+ * values set, it is considered to be happening during a cleanup process.
105
+ * Fix to ignore this and any further messages for this ifindex
106
+ */
107
+
108
+ static std::map<unsigned int , std::string> m_ifindexOldNameMap;
109
+ if (m_ifindexNameMap.find (ifindex) == m_ifindexNameMap.end ())
110
+ {
111
+ if (master)
112
+ {
113
+ m_ifindexOldNameMap[ifindex] = key;
114
+ SWSS_LOG_INFO (" nlmsg type:%d Ignoring for %d, master %d" , nlmsg_type, ifindex, master);
115
+ return ;
116
+ }
117
+ else if (m_ifindexOldNameMap.find (ifindex) != m_ifindexOldNameMap.end ())
118
+ {
119
+ if (m_ifindexOldNameMap[ifindex] == key)
120
+ {
121
+ SWSS_LOG_INFO (" nlmsg type:%d Ignoring message for old interface %d" , nlmsg_type, ifindex);
122
+ return ;
123
+ }
124
+ }
125
+ }
126
+
127
+ /* Insert or update the ifindex to key map */
128
+ m_ifindexNameMap[ifindex] = key;
129
+
102
130
vector<FieldValueTuple> fvVector;
103
131
FieldValueTuple a (" admin_status" , admin ? " up" : " down" );
104
132
FieldValueTuple m (" mtu" , to_string (mtu));
0 commit comments