@@ -31,7 +31,6 @@ using namespace swss;
31
31
32
32
#define VXLAN_VNI 0
33
33
#define VXLAN_RMAC 1
34
- #define VXLAN_VLAN 2
35
34
#define NH_ENCAP_VXLAN 100
36
35
37
36
@@ -93,7 +92,7 @@ void RouteSync::parseRtAttrNested(struct rtattr **tb, int max,
93
92
*
94
93
* Return: void.
95
94
*/
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)
97
96
{
98
97
struct rtattr *tb_encap[3 ] = {0 };
99
98
char mac_buf[MAX_ADDR_SIZE+1 ];
@@ -102,10 +101,9 @@ void RouteSync::parseEncap(struct rtattr *tb, uint32_t &encap_value, string &rma
102
101
parseRtAttrNested (tb_encap, 3 , tb);
103
102
encap_value = *(uint32_t *)RTA_DATA (tb_encap[VXLAN_VNI]);
104
103
memcpy (&mac_buf, RTA_DATA (tb_encap[VXLAN_RMAC]), MAX_ADDR_SIZE);
105
- vlan = *(uint32_t *)RTA_DATA (tb_encap[VXLAN_VLAN]);
106
104
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);
109
107
rmac = mac_val;
110
108
111
109
return ;
@@ -125,9 +123,8 @@ void RouteSync::getEvpnNextHopSep(string& nexthops, string& vni_list,
125
123
void RouteSync::getEvpnNextHopGwIf (char *gwaddr, int vni_value,
126
124
string& nexthops, string& vni_list,
127
125
string& mac_list, string& intf_list,
128
- string rmac, unsigned int vid )
126
+ string rmac, string vlan_id )
129
127
{
130
- string vlan_id = " Vlan" + to_string (vid);
131
128
nexthops+= gwaddr;
132
129
vni_list+= to_string (vni_value);
133
130
mac_list+=rmac;
@@ -148,7 +145,10 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
148
145
int gw_af;
149
146
struct in6_addr ipv6_address;
150
147
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" ;
152
152
153
153
if (tb[RTA_GATEWAY])
154
154
gate = RTA_DATA (tb[RTA_GATEWAY]);
@@ -189,6 +189,19 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
189
189
190
190
inet_ntop (gw_af, gateaddr, nexthopaddr, MAX_ADDR_SIZE);
191
191
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
+
192
205
if (tb[RTA_ENCAP_TYPE])
193
206
{
194
207
encap = *(uint16_t *)RTA_DATA (tb[RTA_ENCAP_TYPE]);
@@ -197,12 +210,12 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
197
210
if (tb[RTA_ENCAP] && tb[RTA_ENCAP_TYPE]
198
211
&& (*(uint16_t *)RTA_DATA (tb[RTA_ENCAP_TYPE]) == NH_ENCAP_VXLAN))
199
212
{
200
- parseEncap (tb[RTA_ENCAP], encap_value, rmac, vlan );
213
+ parseEncap (tb[RTA_ENCAP], encap_value, rmac);
201
214
}
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 () );
204
217
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" ))
206
219
{
207
220
return false ;
208
221
}
@@ -270,6 +283,20 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
270
283
271
284
inet_ntop (gw_af, gateaddr, nexthopaddr, MAX_ADDR_SIZE);
272
285
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
+
273
300
if (subtb[RTA_ENCAP_TYPE])
274
301
{
275
302
encap = *(uint16_t *)RTA_DATA (subtb[RTA_ENCAP_TYPE]);
@@ -278,12 +305,12 @@ bool RouteSync::getEvpnNextHop(struct nlmsghdr *h, int received_bytes,
278
305
if (subtb[RTA_ENCAP] && subtb[RTA_ENCAP_TYPE]
279
306
&& (*(uint16_t *)RTA_DATA (subtb[RTA_ENCAP_TYPE]) == NH_ENCAP_VXLAN))
280
307
{
281
- parseEncap (subtb[RTA_ENCAP], encap_value, rmac, vlan );
308
+ parseEncap (subtb[RTA_ENCAP], encap_value, rmac);
282
309
}
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 () );
285
312
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" ))
287
314
{
288
315
return false ;
289
316
}
0 commit comments