]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Ensure EVPN routes are not injected back into EVPN
authorvivek <vivek@cumulusnetworks.com>
Fri, 19 Jan 2018 17:29:49 +0000 (09:29 -0800)
committermitesh <mitesh@cumulusnetworks.com>
Fri, 9 Feb 2018 07:02:05 +0000 (23:02 -0800)
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

bgpd/bgp_evpn.c
bgpd/bgp_route.c

index c7d5f8d1118c785b30704f475dfec5e0afb75594..a69c3465e389afe7a1bf038bb4182b8ab3676e97 100644 (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);
index 36e0c92482a832d29bc5156fd737812968d7b1a6..fe2c5d11a11a7d1a5666467016cc286e571b46ca 100644 (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);
        }