From 4365bb85ae1d0df4a99acae575f45432d88e926a Mon Sep 17 00:00:00 2001 From: KISHORE KUNAL <64033340+kishorekunal01@users.noreply.github.com> Date: Fri, 18 Dec 2020 11:14:29 -0800 Subject: [PATCH] [FPMSYNCD/FDBSYNCD] EVPN Type-5 route removing prefix-len for host route and removing junk character present in the mac (#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. --- fdbsyncd/fdbsync.cpp | 4 ++-- fdbsyncd/fdbsync.h | 4 ++-- fpmsyncd/routesync.cpp | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fdbsyncd/fdbsync.cpp b/fdbsyncd/fdbsync.cpp index 45915f40e930..9a88e557bff2 100644 --- a/fdbsyncd/fdbsync.cpp +++ b/fdbsyncd/fdbsync.cpp @@ -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") { @@ -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") diff --git a/fdbsyncd/fdbsync.h b/fdbsyncd/fdbsync.h index 1d79af95ac7e..c8248ffefbb8 100644 --- a/fdbsyncd/fdbsync.h +++ b/fdbsyncd/fdbsync.h @@ -26,9 +26,9 @@ enum FDB_TYPE { struct m_fdb_info { - char mac[32]; + std::string mac; std::string vid; /*Store as Vlan */ - char port_name[32]; + std::string port_name; short type; /*dynamic or static*/ short op_type; /*add or del*/ }; diff --git a/fpmsyncd/routesync.cpp b/fpmsyncd/routesync.cpp index bdbbe004f8d8..d6f857479379 100644 --- a/fpmsyncd/routesync.cpp +++ b/fpmsyncd/routesync.cpp @@ -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,