]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix use of ROUTE_IMPORTED for EVPN 1993/head
authorvivek <vivek@cumulusnetworks.com>
Fri, 30 Mar 2018 00:24:00 +0000 (00:24 +0000)
committervivek <vivek@cumulusnetworks.com>
Fri, 30 Mar 2018 00:24:00 +0000 (00:24 +0000)
Ensure that only EVPN routes are flagged as such when installing into or
withdrawing from zebra, the earlier check broke L3VPN or VRF route-leaked
routes. Also, fix an incorrect check related to imported routes in path
selection.

Updates: bgpd: Use BGP_ROUTE_IMPORTED for EVPN [vivek]
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
bgpd/bgp_evpn.h
bgpd/bgp_route.c
bgpd/bgp_zebra.c

index 343327a667c9db07d4ec084bc73e99413f4275a8..dd8d6e2e8e903cced9e3ecceb9c6464fc451af2a 100644 (file)
@@ -74,6 +74,32 @@ static inline int advertise_type5_routes(struct bgp *bgp_vrf,
        return 0;
 }
 
+/* Flag if the route's parent is a EVPN route. */
+static inline int is_route_parent_evpn(struct bgp_info *ri)
+{
+       struct bgp_info *parent_ri;
+       struct bgp_table *table;
+       struct bgp_node *rn;
+
+       /* If not imported (or doesn't have a parent), bail. */
+       if (ri->sub_type != BGP_ROUTE_IMPORTED ||
+           !ri->extra ||
+           !ri->extra->parent)
+               return 0;
+
+       /* See if the parent is of family L2VPN/EVPN */
+       parent_ri = (struct bgp_info *)ri->extra->parent;
+       rn = parent_ri->net;
+       if (!rn)
+               return 0;
+       table = bgp_node_table(rn);
+       if (table &&
+           table->afi == AFI_L2VPN &&
+           table->safi == SAFI_EVPN)
+               return 1;
+       return 0;
+}
+
 extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
                                           struct prefix *p,
                                           struct attr *src_attr, afi_t afi,
index a37e709f10b33d30aff63815cc3f5a1833eccd8f..1bdcf5e27f3b9eab4dd1cd6e6c6a9b01e637dcc4 100644 (file)
@@ -567,7 +567,7 @@ static int bgp_info_cmp(struct bgp *bgp, struct bgp_info *new,
        }
 
        if (!(exist->sub_type == BGP_ROUTE_NORMAL ||
-             new->sub_type == BGP_ROUTE_IMPORTED)) {
+             exist->sub_type == BGP_ROUTE_IMPORTED)) {
                if (debug)
                        zlog_debug(
                                "%s: %s loses to %s due to preferred BGP_ROUTE type",
index 269dcc7cb67b00d5c7384173584518d0e517f59e..6af04a60c451cc9fbc84d91c885d93b9538d569b 100644 (file)
@@ -1097,11 +1097,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
        if (info->sub_type == BGP_ROUTE_AGGREGATE)
                zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
 
-       /* If it is an EVPN route mark as such.
-        * Currently presence of rmac in attr denotes
-        * this is an EVPN type-2 route
-        */
-       if (info->sub_type == BGP_ROUTE_IMPORTED)
+       /* If the route's source is EVPN, flag as such. */
+       if (is_route_parent_evpn(info))
                SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
 
        if (peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED
@@ -1398,11 +1395,8 @@ void bgp_zebra_withdraw(struct prefix *p, struct bgp_info *info,
        api.safi = safi;
        api.prefix = *p;
 
-       /* If it is an EVPN route mark as such.
-        * Currently presence of rmac in attr denotes
-        * this is an EVPN type-2 route
-        */
-       if (info->sub_type == BGP_ROUTE_IMPORTED)
+       /* If the route's source is EVPN, flag as such. */
+       if (is_route_parent_evpn(info))
                SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
 
        if (peer->sort == BGP_PEER_IBGP) {