Skip to content

Commit

Permalink
[FPMSYNCD/FDBSYNCD] EVPN Type-5 route removing prefix-len for host ro…
Browse files Browse the repository at this point in the history
…ute and removing junk character present in the mac (sonic-net#1553)

To make EVPN prefix route inline with the existing code, removing the prefix-len for host routes(/32 and /128).
Some Junk character are present in the mac and port name while config MAC in the kernel.
  • Loading branch information
kishorekunal01 authored Dec 18, 2020
1 parent b369bb2 commit 4365bb8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions fdbsyncd/fdbsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void FdbSync::processStateFdb()
auto mac_address = key.substr(delimiter+1);

info.vid = vlan_name;
memcpy(info.mac, mac_address.c_str(),mac_address.length());
info.mac = mac_address;

if(op == "SET")
{
Expand All @@ -126,7 +126,7 @@ void FdbSync::processStateFdb()

if(fvField(i) == "port")
{
memcpy(info.port_name, fvValue(i).c_str(), fvValue(i).length());
info.port_name = fvValue(i);
}

if(fvField(i) == "type")
Expand Down
4 changes: 2 additions & 2 deletions fdbsyncd/fdbsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ enum FDB_TYPE {

struct m_fdb_info
{
char mac[32];
std::string mac;
std::string vid; /*Store as Vlan<ID> */
char port_name[32];
std::string port_name;
short type; /*dynamic or static*/
short op_type; /*add or del*/
};
Expand Down
12 changes: 10 additions & 2 deletions fpmsyncd/routesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,17 @@ void RouteSync::onEvpnRouteMsg(struct nlmsghdr *h, int len)
destipprefix[strlen(destipprefix)] = ':';
}

/* Full mask route append prefix length, or else resync cannot match. */
snprintf(destipprefix + strlen(destipprefix), sizeof(destipprefix) - strlen(destipprefix), "%s/%u",
if((rtm->rtm_family == AF_INET && dst_len == IPV4_MAX_BITLEN)
|| (rtm->rtm_family == AF_INET6 && dst_len == IPV6_MAX_BITLEN))
{
snprintf(destipprefix + strlen(destipprefix), sizeof(destipprefix) - strlen(destipprefix), "%s",
inet_ntop(rtm->rtm_family, dstaddr, buf, MAX_ADDR_SIZE));
}
else
{
snprintf(destipprefix + strlen(destipprefix), sizeof(destipprefix) - strlen(destipprefix), "%s/%u",
inet_ntop(rtm->rtm_family, dstaddr, buf, MAX_ADDR_SIZE), dst_len);
}

SWSS_LOG_INFO("Receive route message dest ip prefix: %s Op:%s",
destipprefix,
Expand Down

0 comments on commit 4365bb8

Please sign in to comment.