@@ -159,8 +159,31 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
159159 break ;
160160
161161 case SAI_FDB_EVENT_FLUSHED:
162- if (bridge_port_id == SAI_NULL_OBJECT_ID && entry->bv_id == SAI_NULL_OBJECT_ID)
162+
163+ SWSS_LOG_INFO (" FDB Flush event received: [ %s , 0x%" PRIx64 " ], \
164+ bridge port ID: 0x%" PRIx64 " ." ,
165+ update.entry .mac .to_string ().c_str (), entry->bv_id ,
166+ bridge_port_id);
167+
168+ string vlanName = " -" ;
169+ if (entry->bv_id ) {
170+ Port vlan;
171+
172+ if (!m_portsOrch->getPort (entry->bv_id , vlan))
173+ {
174+ SWSS_LOG_ERROR (" FdbOrch notification: Failed to locate vlan\
175+ port from bv_id 0x%" PRIx64, entry->bv_id );
176+ return ;
177+ }
178+ vlanName = " Vlan" + to_string (vlan.m_vlan_info .vlan_id );
179+ }
180+
181+
182+ if (bridge_port_id == SAI_NULL_OBJECT_ID &&
183+ entry->bv_id == SAI_NULL_OBJECT_ID)
163184 {
185+ SWSS_LOG_INFO (" FDB Flush: [ %s , %s ] = { port: - }" ,
186+ update.entry .mac .to_string ().c_str (), vlanName.c_str ());
164187 for (auto itr = m_entries.begin (); itr != m_entries.end ();)
165188 {
166189 /*
@@ -176,27 +199,52 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
176199
177200 storeFdbEntryState (update);
178201
179- SWSS_LOG_DEBUG (" FdbOrch notification: mac %s was removed" , update.entry .mac .to_string ().c_str ());
180-
181202 for (auto observer: m_observers)
182203 {
183204 observer->update (SUBJECT_TYPE_FDB_CHANGE, &update);
184205 }
185206 }
186207 }
187- else if (bridge_port_id && entry->bv_id == SAI_NULL_OBJECT_ID)
208+ else if (entry->bv_id == SAI_NULL_OBJECT_ID)
188209 {
189- /* this is a placeholder for flush port fdb case, not supported yet.*/
190- SWSS_LOG_ERROR (" FdbOrch notification: not supported flush port fdb action, port_id = 0x%" PRIx64 " , bv_id = 0x%" PRIx64 " ." , bridge_port_id, entry->bv_id );
210+ /* FLUSH based on port */
211+ SWSS_LOG_INFO (" FDB Flush: [ %s , %s ] = { port: %s }" ,
212+ update.entry .mac .to_string ().c_str (),
213+ vlanName.c_str (), update.port .m_alias .c_str ());
214+
215+ for (auto itr = m_entries.begin (); itr != m_entries.end ();)
216+ {
217+ auto next_item = std::next (itr);
218+ if (itr->port_name == update.port .m_alias )
219+ {
220+ update.entry .mac = itr->mac ;
221+ update.entry .bv_id = itr->bv_id ;
222+ update.add = false ;
223+
224+ storeFdbEntryState (update);
225+
226+ for (auto observer: m_observers)
227+ {
228+ observer->update (SUBJECT_TYPE_FDB_CHANGE, &update);
229+ }
230+ }
231+ itr = next_item;
232+ }
191233 }
192- else if (bridge_port_id == SAI_NULL_OBJECT_ID && entry-> bv_id != SAI_NULL_OBJECT_ID )
234+ else if (bridge_port_id == SAI_NULL_OBJECT_ID)
193235 {
194- /* this is a placeholder for flush vlan fdb case, not supported yet.*/
195- SWSS_LOG_ERROR (" FdbOrch notification: not supported flush vlan fdb action, port_id = 0x%" PRIx64 " , bv_id = 0x%" PRIx64 " ." , bridge_port_id, entry->bv_id );
236+ /* FLUSH based on VLAN - unsupported */
237+ SWSS_LOG_ERROR (" Unsupported FDB Flush: [ %s , %s ] = { port: - }" ,
238+ update.entry .mac .to_string ().c_str (),
239+ vlanName.c_str ());
240+
196241 }
197242 else
198243 {
199- SWSS_LOG_ERROR (" FdbOrch notification: not supported flush fdb action, port_id = 0x%" PRIx64 " , bv_id = 0x%" PRIx64 " ." , bridge_port_id, entry->bv_id );
244+ /* FLUSH based on port and VLAN - unsupported */
245+ SWSS_LOG_ERROR (" Unsupported FDB Flush: [ %s , %s ] = { port: %s }" ,
246+ update.entry .mac .to_string ().c_str (),
247+ vlanName.c_str (), update.port .m_alias .c_str ());
200248 }
201249 break ;
202250 }
@@ -307,10 +355,11 @@ void FdbOrch::doTask(Consumer& consumer)
307355 }
308356 }
309357
358+ entry.port_name = port;
310359 /* FDB type is either dynamic or static */
311360 assert (type == " dynamic" || type == " static" );
312361
313- if (addFdbEntry (entry, port, type))
362+ if (addFdbEntry (entry, type))
314363 it = consumer.m_toSync .erase (it);
315364 else
316365 it++;
@@ -473,12 +522,12 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
473522 {
474523 // try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
475524 // it would be added back to the saved_fdb_entries structure by addFDBEntry()
476- (void )addFdbEntry (fdb.entry , port_name, fdb.type );
525+ (void )addFdbEntry (fdb.entry , fdb.type );
477526 }
478527 }
479528}
480529
481- bool FdbOrch::addFdbEntry (const FdbEntry& entry, const string& port_name, const string& type)
530+ bool FdbOrch::addFdbEntry (const FdbEntry& entry, const string& type)
482531{
483532 SWSS_LOG_ENTER ();
484533
@@ -490,19 +539,19 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const
490539
491540 Port port;
492541 /* Retry until port is created */
493- if (!m_portsOrch->getPort (port_name, port))
542+ if (!m_portsOrch->getPort (entry. port_name , port))
494543 {
495- SWSS_LOG_DEBUG (" Saving a fdb entry until port %s becomes active" , port_name.c_str ());
496- saved_fdb_entries[port_name].push_back ({entry, type});
544+ SWSS_LOG_DEBUG (" Saving a fdb entry until port %s becomes active" , entry. port_name .c_str ());
545+ saved_fdb_entries[entry. port_name ].push_back ({entry, type});
497546
498547 return true ;
499548 }
500549
501550 /* Retry until port is added to the VLAN */
502551 if (!port.m_bridge_port_id )
503552 {
504- SWSS_LOG_DEBUG (" Saving a fdb entry until port %s has got a bridge port ID" , port_name.c_str ());
505- saved_fdb_entries[port_name].push_back ({entry, type});
553+ SWSS_LOG_DEBUG (" Saving a fdb entry until port %s has got a bridge port ID" , entry. port_name .c_str ());
554+ saved_fdb_entries[entry. port_name ].push_back ({entry, type});
506555
507556 return true ;
508557 }
@@ -531,11 +580,11 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const
531580 if (status != SAI_STATUS_SUCCESS)
532581 {
533582 SWSS_LOG_ERROR (" Failed to create %s FDB %s on %s, rv:%d" ,
534- type.c_str (), entry.mac .to_string ().c_str (), port_name.c_str (), status);
583+ type.c_str (), entry.mac .to_string ().c_str (), entry. port_name .c_str (), status);
535584 return false ; // FIXME: it should be based on status. Some could be retried, some not
536585 }
537586
538- SWSS_LOG_NOTICE (" Create %s FDB %s on %s" , type.c_str (), entry.mac .to_string ().c_str (), port_name.c_str ());
587+ SWSS_LOG_NOTICE (" Create %s FDB %s on %s" , type.c_str (), entry.mac .to_string ().c_str (), entry. port_name .c_str ());
539588
540589 (void ) m_entries.insert (entry);
541590
0 commit comments