@@ -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,
125123void 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 }
0 commit comments