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 <vivek@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>

Ticket: CM-19456
Reviewed By: CCR-7117
Testing Done:
1. Manual replication of problem and verification of fix
2. evpn-min
This commit is contained in:
vivek 2018-01-19 09:29:49 -08:00 committed by mitesh
parent 509d742fb3
commit 25f2ca5307
2 changed files with 20 additions and 11 deletions

View File

@ -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);

View File

@ -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);
}