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

Mclag enhacements support code changes. #1331

Merged
merged 69 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
3524229
Mclag enhacements support code changes.
Praveen-Brcm Jun 24, 2020
a5cd48c
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Nov 17, 2020
16e2cf9
Updating code to fix compilation issues.
Praveen-Brcm Nov 18, 2020
bc66c0a
Adding change to allow MCLAG remote MAC move.
Praveen-Brcm Nov 20, 2020
faa00b7
Remove unused code.
Praveen-Brcm Nov 20, 2020
5f521d4
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Dec 1, 2020
36a91d7
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Dec 3, 2020
d634b39
1.Updated the PR-885 latest changes.
Praveen-Brcm Dec 4, 2020
273fec7
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Dec 30, 2020
f8f38bf
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jan 4, 2021
25f1099
Updating fdbsyncd files.
Praveen-Brcm Jan 4, 2021
5d6fed5
Updating the Fdbsyncd and fixing compilation.
Praveen-Brcm Jan 4, 2021
625befc
Updating the change from PR1276 and PR885.
Praveen-Brcm Jan 5, 2021
307480c
Fixed the mac type.
Praveen-Brcm Jan 5, 2021
e159f43
Fix Port_name
Praveen-Brcm Jan 5, 2021
2427f06
Updated the fix from PR885.
Praveen-Brcm Jan 5, 2021
cf19814
Adding new orchfiles to mock_tests
Praveen-Brcm Jan 5, 2021
146874a
Updated the file format to unix.
Praveen-Brcm Feb 5, 2021
923d1be
MCLAG Unique IP support changes.
tapashdas Feb 6, 2021
b395b18
Removed dependency with PR 885.
Praveen-Brcm Apr 19, 2021
0682483
Merge branch 'mclag_enhacements' of https://github.com/Praveen-Brcm/s…
Praveen-Brcm Apr 19, 2021
8b54561
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Apr 20, 2021
936834c
fixed indentation
Praveen-Brcm Apr 20, 2021
8d3b932
fixed indentation.
Praveen-Brcm Apr 20, 2021
26d5277
fixed re-declarations.
Praveen-Brcm Apr 20, 2021
b308254
Removed unused variable.
Praveen-Brcm Apr 20, 2021
ce9194f
Fixed merge issues with master.
Praveen-Brcm Apr 20, 2021
7064b48
Updated the missing key.
Praveen-Brcm Apr 20, 2021
32fd325
Fix compilation error.
Praveen-Brcm Apr 20, 2021
67024ee
Addressed review comments.
Praveen-Brcm Apr 20, 2021
0aa6b21
Addign observer support for mlagorch.
Praveen-Brcm Apr 20, 2021
d85e59d
Fixing compilation due to casting issue with observer.
Praveen-Brcm Apr 20, 2021
521b18c
Fix compilation issue.
Praveen-Brcm Apr 20, 2021
1fbd559
Fixing the compilation issue.
Praveen-Brcm Apr 20, 2021
358482f
Resolving the auto merge duplicate code.
Praveen-Brcm Apr 21, 2021
7a7e3b8
Resolving the auto merge duplicate code.
Praveen-Brcm Apr 21, 2021
f1f3753
Merge branch 'mclag_enhacements' of https://github.com/Praveen-Brcm/s…
Praveen-Brcm Apr 21, 2021
f1b0696
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Apr 29, 2021
b007eef
Fixed FDB notifiation issue
Praveen-Brcm Apr 30, 2021
29d2e00
Fixing ARM build issue.
Praveen-Brcm May 1, 2021
44e430e
Fixed ARM build errors.
Praveen-Brcm May 1, 2021
f1fb39b
Fixing Mlagorch ARM build failures.
Praveen-Brcm May 2, 2021
0a652da
Fixing the test_mclag_fdb type attributes.
Praveen-Brcm May 3, 2021
287777b
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jun 23, 2021
a88f71f
Addressing the review comments.
Praveen-Brcm Jul 5, 2021
74bce31
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jul 5, 2021
c333179
Fix Build error.
Praveen-Brcm Jul 5, 2021
5ec2686
Addressed review comments.
Praveen-Brcm Jul 6, 2021
b80ece8
Fixed build issue.
Praveen-Brcm Jul 8, 2021
1d890a6
updated the orchdaemon.h
Praveen-Brcm Jul 8, 2021
277d7bb
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jul 8, 2021
153ea2c
Fixed py test issue.
Praveen-Brcm Jul 9, 2021
532f1e7
Remove as the change may not be supported on non-brcm for PortChannel…
Praveen-Brcm Jul 9, 2021
b1dcb47
Addressed a review comment.
Praveen-Brcm Jul 9, 2021
c0e1c99
Addressing FIXME alert.
Praveen-Brcm Jul 9, 2021
644fe12
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jul 16, 2021
1462059
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jul 21, 2021
fc21a82
Address review comments.
Praveen-Brcm Jul 27, 2021
e931849
Addressed review comments.
Praveen-Brcm Jul 27, 2021
92b4255
Address review comments.
Praveen-Brcm Jul 27, 2021
0acbd54
Addressed review comments.
Praveen-Brcm Jul 29, 2021
bf81939
Removing the isolation group handling from Mlagorch, Isolation group …
Praveen-Brcm Jul 29, 2021
de4ab05
Fix compilation issue
Praveen-Brcm Jul 29, 2021
eaecfa2
Added back the update function.
Praveen-Brcm Jul 29, 2021
a09d6c7
Merge branch 'master' into mclag_enhacements
Praveen-Brcm Jul 29, 2021
a28f557
Addressed review comments.
Praveen-Brcm Jul 30, 2021
329016b
Addressed review comments.
Praveen-Brcm Jul 31, 2021
dcbf3f4
Addressed review comment.
Praveen-Brcm Aug 2, 2021
7a18eb7
Addressed a build failure.
Praveen-Brcm Aug 2, 2021
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
162 changes: 161 additions & 1 deletion fdbsyncd/fdbsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FdbSync::FdbSync(RedisPipeline *pipelineAppDB, DBConnector *stateDb, DBConnector
m_fdbTable(pipelineAppDB, APP_VXLAN_FDB_TABLE_NAME),
m_imetTable(pipelineAppDB, APP_VXLAN_REMOTE_VNI_TABLE_NAME),
m_fdbStateTable(stateDb, STATE_FDB_TABLE_NAME),
m_mclagRemoteFdbStateTable(stateDb, STATE_MCLAG_REMOTE_FDB_TABLE_NAME),
m_cfgEvpnNvoTable(config_db, CFG_VXLAN_EVPN_NVO_TABLE_NAME)
{
m_AppRestartAssist = new AppRestartAssist(pipelineAppDB, "fdbsyncd", "swss", DEFAULT_FDBSYNC_WARMSTART_TIMER);
Expand All @@ -43,7 +44,6 @@ FdbSync::~FdbSync()
}
}


// Check if interface entries are restored in kernel
bool FdbSync::isIntfRestoreDone()
{
Expand Down Expand Up @@ -180,6 +180,69 @@ void FdbSync::processStateFdb()
}
}

void FdbSync::processStateMclagRemoteFdb()
{
struct m_fdb_info info;
std::deque<KeyOpFieldsValuesTuple> entries;

m_mclagRemoteFdbStateTable.pops(entries);

int count =0 ;
for (auto entry: entries)
{
count++;
std::string key = kfvKey(entry);
std::string op = kfvOp(entry);

std::size_t delimiter = key.find_first_of(":");
auto vlan_name = key.substr(0, delimiter);
auto mac_address = key.substr(delimiter+1);

info.vid = vlan_name;
info.mac = mac_address;

if(op == "SET")
{
info.op_type = FDB_OPER_ADD ;
}
else
{
info.op_type = FDB_OPER_DEL ;
}

SWSS_LOG_INFO("FDBSYNCD STATE FDB updates key=%s, operation=%s\n", key.c_str(), op.c_str());

for (auto i : kfvFieldsValues(entry))
{
SWSS_LOG_INFO(" FDBSYNCD STATE FDB updates : "
"FvFiels %s, FvValues: %s \n", fvField(i).c_str(), fvValue(i).c_str());

if(fvField(i) == "port")
{
info.port_name = fvValue(i);
}

if(fvField(i) == "type")
{
if(fvValue(i) == "dynamic")
{
info.type = FDB_TYPE_DYNAMIC;
}
else if (fvValue(i) == "static")
{
info.type = FDB_TYPE_STATIC;
}
}
}

if (op != "SET" && macCheckSrcDB(&info) == false)
{
continue;
}
updateMclagRemoteMac(&info);
}
}

void FdbSync::macUpdateCache(struct m_fdb_info *info)
{
string key = info->vid + ":" + info->mac;
Expand All @@ -189,6 +252,15 @@ void FdbSync::macUpdateCache(struct m_fdb_info *info)
return;
}

void FdbSync::macUpdateMclagRemoteCache(struct m_fdb_info *info)
{
string key = info->vid + ":" + info->mac;
m_mclag_remote_fdb_mac[key].port_name = info->port_name;
m_mclag_remote_fdb_mac[key].type = info->type;

return;
}

bool FdbSync::macCheckSrcDB(struct m_fdb_info *info)
{
string key = info->vid + ":" + info->mac;
Expand Down Expand Up @@ -331,6 +403,84 @@ void FdbSync::addLocalMac(string key, string op)
return;
}

void FdbSync::updateMclagRemoteMac (struct m_fdb_info *info)
{
char *op;
char *type;
string port_name = "";
string key = info->vid + ":" + info->mac;
short fdb_type; /*dynamic or static*/

if (info->op_type == FDB_OPER_ADD)
{
macUpdateMclagRemoteCache(info);
op = "replace";
port_name = info->port_name;
fdb_type = info->type;
}
else
{
op = "del";
port_name = m_mclag_remote_fdb_mac[key].port_name;
fdb_type = m_mclag_remote_fdb_mac[key].type;
m_mclag_remote_fdb_mac.erase(key);
}

if (fdb_type == FDB_TYPE_DYNAMIC)
{
type = "dynamic";
}
else
{
type = "static";
}

const std::string cmds = std::string("")
+ " bridge fdb " + op + " " + info->mac + " dev "
+ port_name + " master " + type + " vlan " + info->vid.substr(4);

std::string res;
int ret = swss::exec(cmds, res);

SWSS_LOG_INFO("cmd:%s, res=%s, ret=%d", cmds.c_str(), res.c_str(), ret);

return;
}

void FdbSync::updateMclagRemoteMacPort(int ifindex, int vlan, std::string mac)
{
string key = "Vlan" + to_string(vlan) + ":" + mac;
int type = 0;
string port_name = "";

SWSS_LOG_INFO("Updating Intf %d, Vlan:%d MAC:%s Key %s", ifindex, vlan, mac.c_str(), key.c_str());

if (m_mclag_remote_fdb_mac.find(key) != m_mclag_remote_fdb_mac.end())
{
type = m_mclag_remote_fdb_mac[key].type;
port_name = m_mclag_remote_fdb_mac[key].port_name;
SWSS_LOG_INFO(" port %s, type %d\n", port_name.c_str(), type);

if (type == FDB_TYPE_STATIC)
{
const std::string cmds = std::string("")
+ " bridge fdb replace" + " " + mac + " dev "
+ port_name + " master static vlan " + to_string(vlan);

std::string res;
int ret = swss::exec(cmds, res);
if (ret != 0)
{
SWSS_LOG_NOTICE("Failed cmd:%s, res=%s, ret=%d", cmds.c_str(), res.c_str(), ret);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add return here, otherwise you'll get two log messages printed for the failed and the normal case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.


SWSS_LOG_NOTICE("Update cmd:%s, res=%s, ret=%d", cmds.c_str(), res.c_str(), ret);
}
}
return;
}

/*
* This is a special case handling where mac is learned in the ASIC.
* Then MAC is learned in the Kernel, Since this mac is learned in the Kernel
Expand Down Expand Up @@ -573,6 +723,16 @@ void FdbSync::onMsgNbr(int nlmsg_type, struct nl_object *obj)

if (isVxlanIntf == false)
{
if (nlmsg_type == RTM_NEWNEIGH)
{
int vid = rtnl_neigh_get_vlan(neigh);
int state = rtnl_neigh_get_state(neigh);
if (state & NUD_PERMANENT)
{
updateMclagRemoteMacPort(ifindex, vid, macStr);
}
}

if (nlmsg_type != RTM_DELNEIGH)
{
return;
Expand Down
18 changes: 17 additions & 1 deletion fdbsyncd/fdbsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ class FdbSync : public NetMsg
return &m_fdbStateTable;
}

SubscriberStateTable *getMclagRemoteFdbStateTable()
{
return &m_mclagRemoteFdbStateTable;
}

SubscriberStateTable *getCfgEvpnNvoTable()
{
return &m_cfgEvpnNvoTable;
}

void processStateFdb();

void processStateMclagRemoteFdb();

void processCfgEvpnNvo();

bool m_reconcileDone = false;
Expand All @@ -81,6 +88,7 @@ class FdbSync : public NetMsg
ProducerStateTable m_fdbTable;
ProducerStateTable m_imetTable;
SubscriberStateTable m_fdbStateTable;
SubscriberStateTable m_mclagRemoteFdbStateTable;
AppRestartAssist *m_AppRestartAssist;
SubscriberStateTable m_cfgEvpnNvoTable;

Expand All @@ -89,7 +97,9 @@ class FdbSync : public NetMsg
std::string port_name;
short type;/*dynamic or static*/
};
std::unordered_map<std::string, m_local_fdb_info> m_fdb_mac;
std::unordered_map<std::string, m_local_fdb_info> m_fdb_mac;

std::unordered_map<std::string, m_local_fdb_info> m_mclag_remote_fdb_mac;

void macDelVxlanEntry(std::string auxkey, struct m_fdb_info *info);

Expand All @@ -103,6 +113,12 @@ class FdbSync : public NetMsg

void macRefreshStateDB(int vlan, std::string kmac);

void updateMclagRemoteMac(struct m_fdb_info *info);

void updateMclagRemoteMacPort(int ifindex, int vlan, std::string mac);

void macUpdateMclagRemoteCache(struct m_fdb_info *info);

bool checkImetExist(std::string key, uint32_t vni);

bool checkDelImet(std::string key, uint32_t vni);
Expand Down
5 changes: 5 additions & 0 deletions fdbsyncd/fdbsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ int main(int argc, char **argv)
netlink.dumpRequest(RTM_GETNEIGH);

s.addSelectable(sync.getFdbStateTable());
s.addSelectable(sync.getMclagRemoteFdbStateTable());
s.addSelectable(sync.getCfgEvpnNvoTable());
while (true)
{
Expand All @@ -95,6 +96,10 @@ int main(int argc, char **argv)
{
sync.processStateFdb();
}
else if (temps == (Selectable *)sync.getMclagRemoteFdbStateTable())
{
sync.processStateMclagRemoteFdb();
}
else if (temps == (Selectable *)sync.getCfgEvpnNvoTable())
{
sync.processCfgEvpnNvo();
Expand Down
2 changes: 2 additions & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ orchagent_SOURCES = \
chassisorch.cpp \
debugcounterorch.cpp \
natorch.cpp \
mlagorch.cpp \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Praveen-Brcm , @gitsabari,
In https://github.com/Azure/sonic-swss/pull/1349/files we use mclag instead of mlag. Would be good to follow the same naming convention across the feature.

isolationgrouporch.cpp \
muxorch.cpp \
macsecorch.cpp \
lagid.cpp
Expand Down
Loading