Skip to content

Commit 18a5ebb

Browse files
authored
Drop FDB notifications if they contain invalid OIDs (#428)
1 parent 81f557d commit 18a5ebb

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

syncd/syncd_notifications.cpp

+43-4
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,21 @@ void redisPutFdbEntryToAsicView(
240240
g_redisClient->hset(key, strAttrId, strAttrValue);
241241
}
242242

243-
void check_fdb_event_notification_data(
243+
/**
244+
* @Brief Check FDB event notification data.
245+
*
246+
* Every OID field in notification data as well as all OID attributes are
247+
* checked if given OID (returned from ASIC) is already present in the syncd
248+
* local database. All bridge ports, vlans should be already discovered by
249+
* syncd discovery logic. If vendor SAI will return unknown/invalid OID, this
250+
* function will return false.
251+
*
252+
* @param data FDB event notification data
253+
*
254+
* @return False if any of OID values is not present in local DB, otherwise
255+
* true.
256+
*/
257+
bool check_fdb_event_notification_data(
244258
_In_ const sai_fdb_event_notification_data_t& data)
245259
{
246260
SWSS_LOG_ENTER();
@@ -264,14 +278,24 @@ void check_fdb_event_notification_data(
264278
* state.
265279
*/
266280

281+
bool result = true;
282+
267283
if (!check_rid_exists(data.fdb_entry.bv_id))
284+
{
268285
SWSS_LOG_ERROR("bv_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id,
269286
sai_serialize_fdb_entry(data.fdb_entry).c_str());
270287

288+
result = false;
289+
}
290+
271291
if (!check_rid_exists(data.fdb_entry.switch_id) || data.fdb_entry.switch_id == SAI_NULL_OBJECT_ID)
292+
{
272293
SWSS_LOG_ERROR("switch_id RID 0x%lx is not present on local ASIC DB: %s", data.fdb_entry.bv_id,
273294
sai_serialize_fdb_entry(data.fdb_entry).c_str());
274295

296+
result = false;
297+
}
298+
275299
for (uint32_t i = 0; i < data.attr_count; i++)
276300
{
277301
const sai_attribute_t& attr = data.attr[i];
@@ -289,8 +313,14 @@ void check_fdb_event_notification_data(
289313
continue;
290314

291315
if (!check_rid_exists(attr.value.oid))
316+
{
292317
SWSS_LOG_WARN("RID 0x%lx on %s is not present on local ASIC DB", attr.value.oid, meta->attridname);
318+
319+
result = false;
320+
}
293321
}
322+
323+
return result;
294324
}
295325

296326
void process_on_fdb_event(
@@ -301,11 +331,13 @@ void process_on_fdb_event(
301331

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

334+
bool sendntf = true;
335+
304336
for (uint32_t i = 0; i < count; i++)
305337
{
306338
sai_fdb_event_notification_data_t *fdb = &data[i];
307339

308-
check_fdb_event_notification_data(*fdb);
340+
sendntf &= check_fdb_event_notification_data(*fdb);
309341

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

@@ -324,9 +356,16 @@ void process_on_fdb_event(
324356
redisPutFdbEntryToAsicView(fdb);
325357
}
326358

327-
std::string s = sai_serialize_fdb_event_ntf(count, data);
359+
if (sendntf)
360+
{
361+
std::string s = sai_serialize_fdb_event_ntf(count, data);
328362

329-
send_notification("fdb_event", s);
363+
send_notification("fdb_event", s);
364+
}
365+
else
366+
{
367+
SWSS_LOG_ERROR("FDB notification was not sent since it contain invalid OIDs, bug?");
368+
}
330369
}
331370

332371
void process_on_queue_deadlock_event(

0 commit comments

Comments
 (0)