Skip to content

Commit 0d5f2be

Browse files
vasant17kcudnik
authored andcommitted
[meta] Flush fdb entries after flush api success (sonic-net#581) (sonic-net#585)
* [meta] Flush fdb entries after flush api success * [meta] Use correct fdb entry type * [meta] Use correct enum values for fdb entry Co-authored-by: Kamil Cudnik <[email protected]>
1 parent 7a694b9 commit 0d5f2be

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

meta/sai_meta.cpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6747,7 +6747,66 @@ sai_status_t meta_sai_flush_fdb_entries(
67476747
// there are no mandatory attributes
67486748
// there are no conditional attributes
67496749

6750-
return flush_fdb_entries(switch_id, attr_count, attr_list);
6750+
auto status = flush_fdb_entries(switch_id, attr_count, attr_list);
6751+
6752+
if (status = SAI_STATUS_SUCCESS)
6753+
{
6754+
// use same logic as notification, so create notification event
6755+
6756+
std::vector<int32_t> types;
6757+
6758+
auto *et = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_ENTRY_TYPE, attr_count, attr_list);
6759+
6760+
if (et)
6761+
{
6762+
switch (et->value.s32)
6763+
{
6764+
case SAI_FDB_FLUSH_ENTRY_TYPE_DYNAMIC:
6765+
types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
6766+
break;
6767+
6768+
case SAI_FDB_FLUSH_ENTRY_TYPE_STATIC:
6769+
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
6770+
break;
6771+
6772+
default:
6773+
types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
6774+
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
6775+
break;
6776+
}
6777+
}
6778+
else
6779+
{
6780+
// no type specified so we need to flush static and dynamic entries
6781+
6782+
types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
6783+
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
6784+
}
6785+
6786+
for (auto type: types)
6787+
{
6788+
sai_fdb_event_notification_data_t data = {};
6789+
6790+
auto *bv_id = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_BV_ID, attr_count, attr_list);
6791+
auto *bp_id = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID, attr_count, attr_list);
6792+
6793+
sai_attribute_t list[2];
6794+
6795+
list[0].id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;
6796+
list[0].value.oid = bp_id ? bp_id->value.oid : SAI_NULL_OBJECT_ID;
6797+
6798+
list[1].id = SAI_FDB_ENTRY_ATTR_TYPE;
6799+
list[1].value.s32 = type;
6800+
6801+
data.event_type = SAI_FDB_EVENT_FLUSHED;
6802+
data.fdb_entry.switch_id = switch_id;
6803+
data.fdb_entry.bv_id = (bv_id) ? bv_id->value.oid : SAI_NULL_OBJECT_ID;
6804+
data.attr_count = 2;
6805+
data.attr = list;
6806+
6807+
meta_sai_on_fdb_flush_event_consolidated(data);
6808+
}
6809+
}
67516810
}
67526811

67536812
// NAT

0 commit comments

Comments
 (0)