@@ -159,8 +159,31 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
159
159
break ;
160
160
161
161
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)
163
184
{
185
+ SWSS_LOG_INFO (" FDB Flush: [ %s , %s ] = { port: - }" ,
186
+ update.entry .mac .to_string ().c_str (), vlanName.c_str ());
164
187
for (auto itr = m_entries.begin (); itr != m_entries.end ();)
165
188
{
166
189
/*
@@ -176,27 +199,52 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
176
199
177
200
storeFdbEntryState (update);
178
201
179
- SWSS_LOG_DEBUG (" FdbOrch notification: mac %s was removed" , update.entry .mac .to_string ().c_str ());
180
-
181
202
for (auto observer: m_observers)
182
203
{
183
204
observer->update (SUBJECT_TYPE_FDB_CHANGE, &update);
184
205
}
185
206
}
186
207
}
187
- else if (bridge_port_id && entry->bv_id == SAI_NULL_OBJECT_ID)
208
+ else if (entry->bv_id == SAI_NULL_OBJECT_ID)
188
209
{
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
+ }
191
233
}
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)
193
235
{
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
+
196
241
}
197
242
else
198
243
{
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 ());
200
248
}
201
249
break ;
202
250
}
@@ -307,10 +355,11 @@ void FdbOrch::doTask(Consumer& consumer)
307
355
}
308
356
}
309
357
358
+ entry.port_name = port;
310
359
/* FDB type is either dynamic or static */
311
360
assert (type == " dynamic" || type == " static" );
312
361
313
- if (addFdbEntry (entry, port, type))
362
+ if (addFdbEntry (entry, type))
314
363
it = consumer.m_toSync .erase (it);
315
364
else
316
365
it++;
@@ -473,12 +522,12 @@ void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
473
522
{
474
523
// try to insert an FDB entry. If the FDB entry is not ready to be inserted yet,
475
524
// 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 );
477
526
}
478
527
}
479
528
}
480
529
481
- bool FdbOrch::addFdbEntry (const FdbEntry& entry, const string& port_name, const string& type)
530
+ bool FdbOrch::addFdbEntry (const FdbEntry& entry, const string& type)
482
531
{
483
532
SWSS_LOG_ENTER ();
484
533
@@ -490,19 +539,19 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const
490
539
491
540
Port port;
492
541
/* Retry until port is created */
493
- if (!m_portsOrch->getPort (port_name, port))
542
+ if (!m_portsOrch->getPort (entry. port_name , port))
494
543
{
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});
497
546
498
547
return true ;
499
548
}
500
549
501
550
/* Retry until port is added to the VLAN */
502
551
if (!port.m_bridge_port_id )
503
552
{
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});
506
555
507
556
return true ;
508
557
}
@@ -531,11 +580,11 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const
531
580
if (status != SAI_STATUS_SUCCESS)
532
581
{
533
582
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);
535
584
return false ; // FIXME: it should be based on status. Some could be retried, some not
536
585
}
537
586
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 ());
539
588
540
589
(void ) m_entries.insert (entry);
541
590
0 commit comments