Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlag]Fix mlag fdb not remove in kernel when remote fdb entry removed #1924

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion fdbsyncd/fdbsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void FdbSync::processStateMclagRemoteFdb()
}
}

if (op != "SET" && macCheckSrcDB(&info) == false)
if (op != "SET" && macCheckMclagDB(&info) == false)
{
continue;
}
Expand Down Expand Up @@ -273,6 +273,18 @@ bool FdbSync::macCheckSrcDB(struct m_fdb_info *info)
return false;
}

bool FdbSync::macCheckMclagDB(struct m_fdb_info *info)
{
string key = info->vid + ":" + info->mac;
if (m_mclag_remote_fdb_mac.find(key) != m_mclag_remote_fdb_mac.end())
{
SWSS_LOG_DEBUG("macCheckMlagDB DEL_KEY %s ", key.c_str());
return true;
}

return false;
}

void FdbSync::macDelVxlanEntry(string auxkey, struct m_fdb_info *info)
{
std::string vtep = m_mac[auxkey].vtep;
Expand Down
2 changes: 2 additions & 0 deletions fdbsyncd/fdbsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class FdbSync : public NetMsg

bool macCheckSrcDB(struct m_fdb_info *info);

bool macCheckMclagDB(struct m_fdb_info *info);

void updateLocalMac(struct m_fdb_info *info);

void updateAllLocalMac();
Expand Down
29 changes: 28 additions & 1 deletion tests/test_mclag_fdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def how_many_entries_exist(db, table):
tbl = swsscommon.Table(db, table)
return len(tbl.getKeys())

def table_contain_key(db, table, key):
tbl = swsscommon.Table(db, table)
return(key in tbl.getKeys())

# Test-1 Verify basic config add

@pytest.mark.dev_sanity
Expand Down Expand Up @@ -144,6 +148,12 @@ def test_mclagFdb_remote_dynamic_mac_add(dvs, testlog):

assert ok, str(extra)

assert how_many_entries_exist(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE") == 1, "The MCLAG fdb entry not inserted to STATE"
assert table_contain_key(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE", "Vlan200:3c:85:99:5e:00:01") == True, "The MCLAG fdb entry not found in STATE"
(exitcode, output) = dvs.runcmd(['sh', '-c', "bridge fdb show | grep " + "3C:85:99:5E:00:01".lower() + " | wc -l"])
num = int(output.strip())
assert num == 1

# Test-3 Remote Dynamic MAC Delete

@pytest.mark.dev_sanity
Expand All @@ -159,6 +169,11 @@ def test_mclagFdb_remote_dynamic_mac_delete(dvs, testlog):
# check that the FDB entry was deleted from ASIC DB
assert how_many_entries_exist(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY") == 0, "The MCLAG fdb entry not deleted"

assert how_many_entries_exist(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE") == 0, "The MCLAG fdb entry not delete to STATE"
assert table_contain_key(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE", "Vlan200:3c:85:99:5e:00:01") == False, "The MCLAG fdb entry found in STATE"

(exitcode, output) = dvs.runcmd(['sh', '-c', "bridge fdb show | grep " + "3C:85:99:5E:00:01".lower()])
assert output == ''

# Test-4 Remote Static MAC Add

Expand All @@ -182,9 +197,15 @@ def test_mclagFdb_remote_static_mac_add(dvs, testlog):
[("mac", "3C:85:99:5E:00:01"), ("bvid", str(dvs.getVlanOid("200")))],
[("SAI_FDB_ENTRY_ATTR_TYPE", "SAI_FDB_ENTRY_TYPE_STATIC")]
)

assert ok, str(extra)

assert how_many_entries_exist(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE") == 1, "The MCLAG fdb entry not inserted to STATE"
assert table_contain_key(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE", "Vlan200:3c:85:99:5e:00:01") == True, "The MCLAG fdb entry not found in STATE"

(exitcode, output) = dvs.runcmd(['sh', '-c', "bridge fdb show | grep " + "3C:85:99:5E:00:01".lower() + " | wc -l"])
num = int(output.strip())
assert num == 1

# Test-5 Remote Static MAC Del

@pytest.mark.dev_sanity
Expand All @@ -200,6 +221,12 @@ def test_mclagFdb_remote_static_mac_del(dvs, testlog):
# check that the FDB entry was deleted from ASIC DB
assert how_many_entries_exist(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY") == 0, "The MCLAG static fdb entry not deleted"

assert how_many_entries_exist(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE") == 0, "The MCLAG fdb entry not delete to STATE"
assert table_contain_key(dvs.sdb, "MCLAG_REMOTE_FDB_TABLE", "Vlan200:3c:85:99:5e:00:01") == False, "The MCLAG fdb entry found in STATE"

(exitcode, output) = dvs.runcmd(['sh', '-c', "bridge fdb show | grep " + "3C:85:99:5E:00:01".lower()])
assert output == ''


# Test-6 Verify Remote to Local Move.

Expand Down