Skip to content

Commit

Permalink
[meta] Flush fdb entries after flush api success (#581)
Browse files Browse the repository at this point in the history
* [meta] Flush fdb entries after flush api success
* [meta] Use correct fdb entry type
* [meta] Use correct enum values for fdb entry
  • Loading branch information
kcudnik committed Apr 1, 2020
1 parent 54b2510 commit d13521e
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,61 @@ sai_status_t Meta::flushFdbEntries(

if (status == SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("TODO, remove all matching fdb entries here, currently removed in FDB notification");
// use same logic as notification, so create notification event

std::vector<int32_t> types;

auto *et = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_ENTRY_TYPE, attr_count, attr_list);

if (et)
{
switch (et->value.s32)
{
case SAI_FDB_FLUSH_ENTRY_TYPE_DYNAMIC:
types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
break;

case SAI_FDB_FLUSH_ENTRY_TYPE_STATIC:
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
break;

default:
types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
break;
}
}
else
{
// no type specified so we need to flush static and dynamic entries

types.push_back(SAI_FDB_ENTRY_TYPE_DYNAMIC);
types.push_back(SAI_FDB_ENTRY_TYPE_STATIC);
}

for (auto type: types)
{
sai_fdb_event_notification_data_t data = {};

auto *bv_id = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_BV_ID, attr_count, attr_list);
auto *bp_id = sai_metadata_get_attr_by_id(SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID, attr_count, attr_list);

sai_attribute_t list[2];

list[0].id = SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID;
list[0].value.oid = bp_id ? bp_id->value.oid : SAI_NULL_OBJECT_ID;

list[1].id = SAI_FDB_ENTRY_ATTR_TYPE;
list[1].value.s32 = type;

data.event_type = SAI_FDB_EVENT_FLUSHED;
data.fdb_entry.switch_id = switch_id;
data.fdb_entry.bv_id = (bv_id) ? bv_id->value.oid : SAI_NULL_OBJECT_ID;
data.attr_count = 2;
data.attr = list;

meta_sai_on_fdb_flush_event_consolidated(data);
}
}

return status;
Expand Down

0 comments on commit d13521e

Please sign in to comment.