Skip to content

Commit

Permalink
Drop FDB notifications if they contain invalid OIDs (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Mar 4, 2019
1 parent 81f557d commit 18a5ebb
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions syncd/syncd_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,21 @@ void redisPutFdbEntryToAsicView(
g_redisClient->hset(key, strAttrId, strAttrValue);
}

void check_fdb_event_notification_data(
/**
* @Brief Check FDB event notification data.
*
* Every OID field in notification data as well as all OID attributes are
* checked if given OID (returned from ASIC) is already present in the syncd
* local database. All bridge ports, vlans should be already discovered by
* syncd discovery logic. If vendor SAI will return unknown/invalid OID, this
* function will return false.
*
* @param data FDB event notification data
*
* @return False if any of OID values is not present in local DB, otherwise
* true.
*/
bool check_fdb_event_notification_data(
_In_ const sai_fdb_event_notification_data_t& data)
{
SWSS_LOG_ENTER();
Expand All @@ -264,14 +278,24 @@ void check_fdb_event_notification_data(
* state.
*/

bool result = true;

if (!check_rid_exists(data.fdb_entry.bv_id))
{
SWSS_LOG_ERROR("bv_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id,
sai_serialize_fdb_entry(data.fdb_entry).c_str());

result = false;
}

if (!check_rid_exists(data.fdb_entry.switch_id) || data.fdb_entry.switch_id == SAI_NULL_OBJECT_ID)
{
SWSS_LOG_ERROR("switch_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id,
sai_serialize_fdb_entry(data.fdb_entry).c_str());

result = false;
}

for (uint32_t i = 0; i < data.attr_count; i++)
{
const sai_attribute_t& attr = data.attr[i];
Expand All @@ -289,8 +313,14 @@ void check_fdb_event_notification_data(
continue;

if (!check_rid_exists(attr.value.oid))
{
SWSS_LOG_WARN("RID 0x%lx on %s is not present on local ASIC DB", attr.value.oid, meta->attridname);

result = false;
}
}

return result;
}

void process_on_fdb_event(
Expand All @@ -301,11 +331,13 @@ void process_on_fdb_event(

SWSS_LOG_INFO("fdb event count: %u", count);

bool sendntf = true;

for (uint32_t i = 0; i < count; i++)
{
sai_fdb_event_notification_data_t *fdb = &data[i];

check_fdb_event_notification_data(*fdb);
sendntf &= check_fdb_event_notification_data(*fdb);

SWSS_LOG_DEBUG("fdb %u: type: %d", i, fdb->event_type);

Expand All @@ -324,9 +356,16 @@ void process_on_fdb_event(
redisPutFdbEntryToAsicView(fdb);
}

std::string s = sai_serialize_fdb_event_ntf(count, data);
if (sendntf)
{
std::string s = sai_serialize_fdb_event_ntf(count, data);

send_notification("fdb_event", s);
send_notification("fdb_event", s);
}
else
{
SWSS_LOG_ERROR("FDB notification was not sent since it contain invalid OIDs, bug?");
}
}

void process_on_queue_deadlock_event(
Expand Down

0 comments on commit 18a5ebb

Please sign in to comment.