From: vivek Date: Fri, 19 Jan 2018 17:29:49 +0000 (-0800) Subject: bgpd: Ensure EVPN routes are not injected back into EVPN X-Git-Tag: frr-5.0-dev~191^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=25f2ca5307e4c7ad5a65cbf4639ee4d13a906cb4;p=mirror%2Ffrr.git bgpd: Ensure EVPN routes are not injected back into EVPN EVPN type-2 and type-5 routes received with a L3 VNI and corresponding RTs are installed into the appropriate BGP RIB. Ensure that these routes are not re-injected back into EVPN as type-5 routes when type-5 advertisement is enabled; only regular IPv4 routes (and IPv6 routes in future) in the RIB should be injected into EVPN. As a benefit of this change, no longer restrict that EVPN type-5 routes should be non-host routes - i.e., allow /32 IPv4 routes (and /128 IPv6 routes in future). Signed-off-by: Vivek Venkatraman Signed-off-by: Donald Sharp Signed-off-by: Mitesh Kanjariya Ticket: CM-19456 Reviewed By: CCR-7117 Testing Done: 1. Manual replication of problem and verification of fix 2. evpn-min --- diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index c7d5f8d111..a69c3465e3 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -3210,15 +3210,25 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, { struct bgp_table *table = NULL; struct bgp_node *rn = NULL; + struct bgp_info *ri; /* Bail out early if we don't have to advertise type-5 routes. */ if (!advertise_type5_routes(bgp_vrf, afi)) return; table = bgp_vrf->rib[afi][safi]; - for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) - bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p, afi, safi); - + for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { + /* Only care about "selected" routes - non-imported. */ + /* TODO: Support for AddPath for EVPN. */ + for (ri = rn->info; ri; ri = ri->next) { + if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) && + (!ri->extra || !ri->extra->parent)) { + bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p, + afi, safi); + break; + } + } + } } /* @@ -3239,10 +3249,6 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p, if (!advertise_type5_routes(bgp_vrf, afi)) return; - /* only advertise subnet routes as type-5 */ - if (is_host_route(p)) - return; - build_type5_prefix_from_ip_prefix(&evp, p); ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr); if (ret) @@ -3270,11 +3276,12 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, table = bgp_vrf->rib[afi][safi]; for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { /* Need to identify the "selected" route entry to use its - * attribute. + * attribute. Also, we only consider "non-imported" routes. * TODO: Support for AddPath for EVPN. */ for (ri = rn->info; ri; ri = ri->next) { - if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED)) { + if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) && + (!ri->extra || !ri->extra->parent)) { bgp_evpn_advertise_type5_route(bgp_vrf, &rn->p, ri->attr, afi, safi); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 36e0c92482..fe2c5d11a1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2225,11 +2225,13 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, /* advertise/withdraw type-5 routes */ if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { - if (new_select) + if (new_select && + (!new_select->extra || !new_select->extra->parent)) bgp_evpn_advertise_type5_route(bgp, &rn->p, new_select->attr, afi, safi); - else if (old_select) + else if (old_select && + (!old_select->extra || !old_select->extra->parent)) bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi); }