Skip to content

Commit

Permalink
Fix for [EVPN] When MAC moves from remote end point to local, ASIC DB…
Browse files Browse the repository at this point in the history
… fields are not updated properly for the mac #11503Update NotificationProcessor.cpp (#1118)

In case of a mac move event, remove the existing FDB entry from ASIC DB first and then set the new one.
  • Loading branch information
anilkpan authored Dec 14, 2022
1 parent 559bd5b commit 5887d31
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions syncd/NotificationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ void NotificationProcessor::redisPutFdbEntryToAsicView(

if (fdb->event_type == SAI_FDB_EVENT_LEARNED || fdb->event_type == SAI_FDB_EVENT_MOVE)
{
if (fdb->event_type == SAI_FDB_EVENT_MOVE)
{
SWSS_LOG_DEBUG("remove fdb entry %s for SAI_FDB_EVENT_MOVE",
sai_serialize_object_meta_key(metaKey).c_str());

m_client->removeAsicObject(metaKey);
}
// currently we need to add type manually since fdb event don't contain type
sai_attribute_t attr;

Expand Down
24 changes: 24 additions & 0 deletions unittest/syncd/TestNotificationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,28 @@ TEST(NotificationProcessor, NotificationProcessorTest)

translator->eraseRidAndVid(0x21000000000000,0x210000000000);
translator->eraseRidAndVid(0x3000000000048,0x30000000048);

// Test FDB MOVE event
std::string key = "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000001\",\"mac\":\"00:00:00:00:00:01\",\"switch_id\":\"oid:0x210000000000\"}";
dbAsic->hset(key, "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID", "oid:0x3a000000000a98");
dbAsic->hset(key, "SAI_FDB_ENTRY_ATTR_TYPE", "SAI_FDB_ENTRY_TYPE_STATIC");
dbAsic->hset(key, "SAI_FDB_ENTRY_ATTR_ENDPOINT_IP", "10.0.0.1");

translator->insertRidAndVid(0x21000000000000,0x210000000000);
translator->insertRidAndVid(0x1003a0000004a,0x3a000000000a99);
translator->insertRidAndVid(0x2600000001,0x26000000000001);

static std::string fdb_data = "[{\"fdb_entry\":\"{\\\"bvid\\\":\\\"oid:0x2600000001\\\",\\\"mac\\\":\\\"00:00:00:00:00:01\\\",\\\"switch_id\\\":\\\"oid:0x21000000000000\\\"}\",\"fdb_event\":\"SAI_FDB_EVENT_MOVE\",\"list\":[{\"id\":\"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID\",\"value\":\"oid:0x1003a0000004a\"}]}]";
std::vector<swss::FieldValueTuple> fdb_entry;
swss::KeyOpFieldsValuesTuple item(SAI_SWITCH_NOTIFICATION_NAME_FDB_EVENT, fdb_data, fdb_entry);

notificationProcessor->syncProcessNotification(item);
translator->eraseRidAndVid(0x21000000000000,0x210000000000);
translator->eraseRidAndVid(0x1003a0000004a,0x3a000000000a99);
translator->eraseRidAndVid(0x2600000001,0x26000000000001);
auto bridgeport = dbAsic->hget(key, "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID");
auto ip = dbAsic->hget(key, "SAI_FDB_ENTRY_ATTR_ENDPOINT_IP");
EXPECT_NE(bridgeport, nullptr);
EXPECT_EQ(*bridgeport, "oid:0x3a000000000a99");
EXPECT_EQ(ip, nullptr);
}

0 comments on commit 5887d31

Please sign in to comment.