Skip to content

Commit 850001f

Browse files
[FPMSYNCD] Evpn/Vxlan related changes to support FRR7.5(#1585)
1) With FRR7.5 upgrade Netlink Msg from FRR has NLA_F_NESTED flag set in RTA_TYPE while sending VNI and RMAC. 2) In the new patch to keep it in line with FRR upstreaming, we are not sending the VLAN ID from FRR as it can be extracted from ifindex inside the nexthop information.
1 parent 64ca9bb commit 850001f

File tree

3 files changed

+57
-18
lines changed

3 files changed

+57
-18
lines changed

fpmsyncd/fpmlink.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ void netlink_parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta,
1818
{
1919
tb[rta->rta_type] = rta;
2020
}
21+
else
22+
{
23+
/* FRR 7.5 is sending RTA_ENCAP with NLA_F_NESTED bit set*/
24+
if (rta->rta_type & NLA_F_NESTED)
25+
{
26+
int rta_type = rta->rta_type & ~NLA_F_NESTED;
27+
if (rta_type <= max)
28+
{
29+
tb[rta_type] = rta;
30+
}
31+
}
32+
}
2133
rta = RTA_NEXT(rta, len);
2234
}
2335
}

fpmsyncd/routesync.cpp

+43-16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ using namespace swss;
3131

3232
#define VXLAN_VNI 0
3333
#define VXLAN_RMAC 1
34-
#define VXLAN_VLAN 2
3534
#define NH_ENCAP_VXLAN 100
3635

3736

@@ -93,7 +92,7 @@ void RouteSync::parseRtAttrNested(struct rtattr **tb, int max,
9392
*
9493
* Return: void.
9594
*/
96-
void RouteSync::parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rmac, uint32_t &vlan)
95+
void RouteSync::parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rmac)
9796
{
9897
struct rtattr *tb_encap[3] = {0};
9998
char mac_buf[MAX_ADDR_SIZE+1];
@@ -102,10 +101,9 @@ void RouteSync::parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rma
102101
parseRtAttrNested(tb_encap, 3, tb);
103102
encap_value = *(uint32_t *)RTA_DATA(tb_encap[VXLAN_VNI]);
104103
memcpy(&mac_buf, RTA_DATA(tb_encap[VXLAN_RMAC]), MAX_ADDR_SIZE);
105-
vlan = *(uint32_t *)RTA_DATA(tb_encap[VXLAN_VLAN]);
106104

107-
SWSS_LOG_INFO("Rx MAC %s VNI %d Vlan %d",
108-
prefixMac2Str(mac_buf, mac_val, ETHER_ADDR_STRLEN), encap_value, vlan);
105+
SWSS_LOG_INFO("Rx MAC %s VNI %d",
106+
prefixMac2Str(mac_buf, mac_val, ETHER_ADDR_STRLEN), encap_value);
109107
rmac = mac_val;
110108

111109
return;
@@ -125,9 +123,8 @@ void RouteSync::getEvpnNextHopSep(string& nexthops, string& vni_list,
125123
void RouteSync::getEvpnNextHopGwIf(char *gwaddr, int vni_value,
126124
string& nexthops, string& vni_list,
127125
string& mac_list, string& intf_list,
128-
string rmac, unsigned int vid)
126+
string rmac, string vlan_id)
129127
{
130-
string vlan_id = "Vlan" + to_string(vid);
131128
nexthops+= gwaddr;
132129
vni_list+= to_string(vni_value);
133130
mac_list+=rmac;
@@ -148,7 +145,10 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
148145
int gw_af;
149146
struct in6_addr ipv6_address;
150147
string rmac;
151-
uint32_t vlan = 0;
148+
string vlan;
149+
int index;
150+
char if_name[IFNAMSIZ] = "0";
151+
char ifname_unknown[IFNAMSIZ] = "unknown";
152152

153153
if (tb[RTA_GATEWAY])
154154
gate = RTA_DATA(tb[RTA_GATEWAY]);
@@ -189,6 +189,19 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
189189

190190
inet_ntop(gw_af, gateaddr, nexthopaddr, MAX_ADDR_SIZE);
191191

192+
if (tb[RTA_OIF])
193+
{
194+
index = *(int *)RTA_DATA(tb[RTA_OIF]);
195+
196+
/* If we cannot get the interface name */
197+
if (!getIfName(index, if_name, IFNAMSIZ))
198+
{
199+
strcpy(if_name, ifname_unknown);
200+
}
201+
202+
vlan = if_name;
203+
}
204+
192205
if (tb[RTA_ENCAP_TYPE])
193206
{
194207
encap = *(uint16_t *)RTA_DATA(tb[RTA_ENCAP_TYPE]);
@@ -197,12 +210,12 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
197210
if (tb[RTA_ENCAP] && tb[RTA_ENCAP_TYPE]
198211
&& (*(uint16_t *)RTA_DATA(tb[RTA_ENCAP_TYPE]) == NH_ENCAP_VXLAN))
199212
{
200-
parseEncap(tb[RTA_ENCAP], encap_value, rmac, vlan);
213+
parseEncap(tb[RTA_ENCAP], encap_value, rmac);
201214
}
202-
SWSS_LOG_DEBUG("Rx MsgType:%d Nexthop:%s encap:%d encap_value:%d rmac:%s vlan:%d", h->nlmsg_type,
203-
nexthopaddr, encap, encap_value, rmac.c_str(), vlan);
215+
SWSS_LOG_DEBUG("Rx MsgType:%d Nexthop:%s encap:%d encap_value:%d rmac:%s vlan:%s", h->nlmsg_type,
216+
nexthopaddr, encap, encap_value, rmac.c_str(), vlan.c_str());
204217

205-
if (encap_value == 0 || vlan == 0 || MacAddress(rmac) == MacAddress("00:00:00:00:00:00"))
218+
if (encap_value == 0 || !(vlan.compare(ifname_unknown)) || MacAddress(rmac) == MacAddress("00:00:00:00:00:00"))
206219
{
207220
return false;
208221
}
@@ -270,6 +283,20 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
270283

271284
inet_ntop(gw_af, gateaddr, nexthopaddr, MAX_ADDR_SIZE);
272285

286+
287+
if (rtnh->rtnh_ifindex)
288+
{
289+
index = rtnh->rtnh_ifindex;
290+
291+
/* If we cannot get the interface name */
292+
if (!getIfName(index, if_name, IFNAMSIZ))
293+
{
294+
strcpy(if_name, ifname_unknown);
295+
}
296+
297+
vlan = if_name;
298+
}
299+
273300
if (subtb[RTA_ENCAP_TYPE])
274301
{
275302
encap = *(uint16_t *)RTA_DATA(subtb[RTA_ENCAP_TYPE]);
@@ -278,12 +305,12 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
278305
if (subtb[RTA_ENCAP] && subtb[RTA_ENCAP_TYPE]
279306
&& (*(uint16_t *)RTA_DATA(subtb[RTA_ENCAP_TYPE]) == NH_ENCAP_VXLAN))
280307
{
281-
parseEncap(subtb[RTA_ENCAP], encap_value, rmac, vlan);
308+
parseEncap(subtb[RTA_ENCAP], encap_value, rmac);
282309
}
283-
SWSS_LOG_DEBUG("Multipath Nexthop:%s encap:%d encap_value:%d rmac:%s vlan:%d",
284-
nexthopaddr, encap, encap_value, rmac.c_str(), vlan);
310+
SWSS_LOG_DEBUG("Multipath Nexthop:%s encap:%d encap_value:%d rmac:%s vlan:%s",
311+
nexthopaddr, encap, encap_value, rmac.c_str(), vlan.c_str());
285312

286-
if (encap_value == 0 || vlan == 0 || MacAddress(rmac) == MacAddress("00:00:00:00:00:00"))
313+
if (encap_value == 0 || !(vlan.compare(ifname_unknown)) || MacAddress(rmac) == MacAddress("00:00:00:00:00:00"))
287314
{
288315
return false;
289316
}

fpmsyncd/routesync.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RouteSync : public NetMsg
4141
/* Handle regular route (include VRF route) */
4242
void onRouteMsg(int nlmsg_type, struct nl_object *obj, char *vrf);
4343

44-
void parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rmac, uint32_t &vlan);
44+
void parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rmac);
4545

4646
void parseRtAttrNested(struct rtattr **tb, int max,
4747
struct rtattr *rta);
@@ -64,7 +64,7 @@ class RouteSync : public NetMsg
6464
void getEvpnNextHopGwIf(char *gwaddr, int vni_value,
6565
string& nexthops, string& vni_list,
6666
string& mac_list, string& intf_list,
67-
string rmac, unsigned int vid);
67+
string rmac, string vlan_id);
6868

6969
bool getEvpnNextHop(struct nlmsghdr *h, int received_bytes, struct rtattr *tb[],
7070
string& nexthops, string& vni_list, string& mac_list,

0 commit comments

Comments
 (0)