Skip to content

Commit

Permalink
Mclag enhacements support code changes. (sonic-net#1331)
Browse files Browse the repository at this point in the history
* Mclag enhacements support code changes.
* Adding change to allow MCLAG remote MAC move.
* Added support for adding mclag remote mac to kernel, on top of PR-1276
* Updating the change from PR1276 and PR885.
* Adding new orchfiles to mock_tests
* MCLAG Unique IP support changes.
* Removed dependency with PR 885.
* Adding observer support for mlagorch.
* Fixed FDB notifiation issue
* Fixing the test_mclag_fdb type attributes.
* Remove as the change may not be supported on non-brcm for PortChannel settings.
* Removing the isolation group handling from Mlagorch, Isolation group now will be added/updated only via mclagsyncd updates.
* Added back the update function.

Co-authored-by: Tapash Das <tapash.das@broadcom.com>
  • Loading branch information
Praveen-Brcm and tapashdas authored Aug 4, 2021
1 parent 72a72f8 commit 7aca82d
Show file tree
Hide file tree
Showing 19 changed files with 2,450 additions and 53 deletions.
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;
}

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 \
isolationgrouporch.cpp \
muxorch.cpp \
macsecorch.cpp \
lagid.cpp
Expand Down
Loading

0 comments on commit 7aca82d

Please sign in to comment.