From 4ca997a8f82e442ef3e28a8ae14c0b914adc5e4a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 28 Feb 2018 18:53:44 -0500 Subject: [PATCH 1/4] lib: Use STREAM_GET The addition of some rmac code snuck in the usage of a stream_get instead of a STREAM_GET() We need to be using STREAM_GET() Signed-off-by: Donald Sharp --- lib/zclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zclient.c b/lib/zclient.c index ad91eb504b..01d8838e1f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1085,7 +1085,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) STREAM_GETC(s, api->message); STREAM_GETC(s, api->safi); if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) - stream_get(&(api->rmac), s, sizeof(struct ethaddr)); + STREAM_GET(&(api->rmac), s, sizeof(struct ethaddr)); /* Prefix. */ STREAM_GETC(s, api->prefix.family); From c7bacffe4618f27f45edb954426257c6f935d716 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 28 Feb 2018 18:55:10 -0500 Subject: [PATCH 2/4] zebra: Use the passed in nexthops vrf When decoding and creating the appropriate data structures for a nexthop, use the passed in vrf. Signed-off-by: Donald Sharp --- zebra/zserv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zebra/zserv.c b/zebra/zserv.c index 98cb54f7b8..bca8a509d8 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -1166,12 +1166,12 @@ static int zread_route_add(struct zserv *client, u_short length, switch (api_nh->type) { case NEXTHOP_TYPE_IFINDEX: nexthop = route_entry_nexthop_ifindex_add( - re, api_nh->ifindex, re->vrf_id); + re, api_nh->ifindex, api_nh->vrf_id); break; case NEXTHOP_TYPE_IPV4: nexthop = route_entry_nexthop_ipv4_add( re, &api_nh->gate.ipv4, NULL, - re->vrf_id); + api_nh->vrf_id); break; case NEXTHOP_TYPE_IPV4_IFINDEX: { @@ -1188,7 +1188,7 @@ static int zread_route_add(struct zserv *client, u_short length, nexthop = route_entry_nexthop_ipv4_ifindex_add( re, &api_nh->gate.ipv4, NULL, ifindex, - re->vrf_id); + api_nh->vrf_id); /* if this an EVPN route entry, program the nh as neigh @@ -1211,12 +1211,12 @@ static int zread_route_add(struct zserv *client, u_short length, } case NEXTHOP_TYPE_IPV6: nexthop = route_entry_nexthop_ipv6_add( - re, &api_nh->gate.ipv6, re->vrf_id); + re, &api_nh->gate.ipv6, api_nh->vrf_id); break; case NEXTHOP_TYPE_IPV6_IFINDEX: nexthop = route_entry_nexthop_ipv6_ifindex_add( re, &api_nh->gate.ipv6, api_nh->ifindex, - re->vrf_id); + api_nh->vrf_id); break; case NEXTHOP_TYPE_BLACKHOLE: nexthop = route_entry_nexthop_blackhole_add( From 1374aec98ff77fb02b7a7dba88d6a10fd8058196 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 28 Feb 2018 19:10:02 -0500 Subject: [PATCH 3/4] bgpd: Cleanup api_nh in bgpd a bit The api_nh was being figured 2 times, also refactor the vrf_id placement as well. Signed-off-by: Donald Sharp : --- bgpd/bgp_zebra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index daa7ccbf42..029b3d4d36 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1054,6 +1054,9 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, else continue; + api_nh = &api.nexthops[valid_nh_count]; + api_nh->vrf_id = bgp->vrf_id; + if (nh_family == AF_INET) { struct in_addr *nexthop; @@ -1078,9 +1081,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, nexthop = &mpinfo_cp->attr->nexthop; - api_nh = &api.nexthops[valid_nh_count]; api_nh->gate.ipv4 = *nexthop; - api_nh->vrf_id = bgp->vrf_id; /* EVPN type-2 routes are programmed as onlink on l3-vni SVI */ @@ -1135,7 +1136,6 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, if (ifindex == 0) continue; - api_nh = &api.nexthops[valid_nh_count]; api_nh->gate.ipv6 = *nexthop; api_nh->ifindex = ifindex; api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; From f56ee10fc7a4c028e767161c2503d26cceed194b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 28 Feb 2018 19:16:51 -0500 Subject: [PATCH 4/4] ospfd: Add vrf to nhlfe route add So when a ospf SR is sending down routes to the kernel ensure that the nexthop vrf_id is set appropriately. Yes SR is in the default VRF. But for people who run across this code in the future, they will know to do the right thing from it. Signed-off-by: Donald Sharp --- ospfd/ospf_sr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index 1560977ae8..02cf2636cc 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -675,6 +675,7 @@ static int ospf_zebra_send_mpls_ftn(int cmd, struct sr_nhlfe nhlfe) SET_FLAG(api.message, ZAPI_MESSAGE_LABEL); api_nh->labels[0] = nhlfe.label_out; api_nh->label_num = 1; + api_nh->vrf_id = VRF_DEFAULT; api.nexthop_num = 1; }