]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: allow advertise-subnet cmd without enabling advertise ipv4 unicast
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Tue, 20 Feb 2018 08:23:06 +0000 (00:23 -0800)
committermitesh <mitesh@cumulusnetworks.com>
Fri, 23 Feb 2018 01:23:07 +0000 (17:23 -0800)
Type-5 routes can be useful in multiple scenarios such as advertise-subnet,
default-originate etc. Currently, the code has a restriction that to allow
advertising type-5 routes, user has to first enable advertise ipvX command.
This restriction is not necessary and should be removed.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn.h
bgpd/bgp_evpn_private.h
bgpd/bgp_evpn_vty.c
bgpd/bgp_route.c

index ec8e2907a69c5b641005259c6df6f30ccbd34627..6a3496a4d0692bf15798c5b18f4c5420c901fc7f 100644 (file)
@@ -2553,10 +2553,12 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,
 static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
 {
        /* delete all ipv4 routes and withdraw from peers */
-       bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
+       if (advertise_type5_routes(bgp_vrf, AFI_IP))
+               bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
 
        /* delete all ipv6 routes and withdraw from peers */
-       bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
+       if (advertise_type5_routes(bgp_vrf, AFI_IP6))
+               bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
 }
 
 /* update and advertise all ipv4 and ipv6 routes in thr vrf table as type-5
@@ -2564,10 +2566,12 @@ static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
 static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
 {
        /* update all ipv4 routes */
-       bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
+       if (advertise_type5_routes(bgp_vrf, AFI_IP))
+               bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
 
        /* update all ipv6 routes */
-       bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
+       if (advertise_type5_routes(bgp_vrf, AFI_IP6))
+               bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
 }
 
 /*
@@ -3189,10 +3193,6 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p,
        struct prefix_evpn evp;
        char buf[PREFIX_STRLEN];
 
-       /* NOTE: Check needed as this is called per-route also. */
-       if (!advertise_type5_routes(bgp_vrf, afi))
-               return;
-
        build_type5_prefix_from_ip_prefix(&evp, p);
        ret = delete_evpn_type5_route(bgp_vrf, &evp);
        if (ret) {
@@ -3211,10 +3211,6 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
        struct bgp_table *table = NULL;
        struct bgp_node *rn = NULL;
 
-       /* 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);
@@ -3235,10 +3231,6 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p,
        struct prefix_evpn evp;
        char buf[PREFIX_STRLEN];
 
-       /* NOTE: Check needed as this is called per-route also. */
-       if (!advertise_type5_routes(bgp_vrf, afi))
-               return;
-
        /* only advertise subnet routes as type-5 */
        if (is_host_route(p))
                return;
@@ -3263,10 +3255,6 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
        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)) {
                /* Need to identify the "selected" route entry to use its
index a8dcbc112b1cc18b4313bec527e4f4d0ecd95403..cd3b7e3af2c8648c1375a68bb8b638fbc68e12cd 100644 (file)
@@ -55,6 +55,23 @@ static inline vni_t label2vni(mpls_label_t *label)
        return vni;
 }
 
+static inline int advertise_type5_routes(struct bgp *bgp_vrf,
+                                        afi_t afi)
+{
+       if (!bgp_vrf->l3vni)
+               return 0;
+
+       if (afi == AFI_IP &&
+           CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
+               return 1;
+
+       if (afi == AFI_IP6 &&
+           CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
+               return 1;
+
+       return 0;
+}
+
 extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
                                           struct prefix *p,
                                           struct attr *src_attr,
index cc0ec82344b3f2c03cad7cc7a4fd1ca1806d82c5..5ff16c39e9727ee091d0477f5fdc9965d9d6bb4b 100644 (file)
@@ -349,23 +349,6 @@ static inline void build_evpn_type3_prefix(struct prefix_evpn *p,
        p->prefix.ip.ipaddr_v4 = originator_ip;
 }
 
-static inline int advertise_type5_routes(struct bgp *bgp_vrf,
-                                        afi_t afi)
-{
-       if (!bgp_vrf->l3vni)
-               return 0;
-
-       if (afi == AFI_IP &&
-           CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
-               return 1;
-
-       if (afi == AFI_IP6 &&
-           CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
-               return 1;
-
-       return 0;
-}
-
 extern void evpn_rt_delete_auto(struct bgp*, vni_t, struct list*);
 extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,
                                                 struct ecommunity *ecomadd);
index 1373afec4ec280173fbae1b795772de0501ccda2..c3cab18d2e77c132e00651d8840acd6e7c919b73 100644 (file)
@@ -2690,14 +2690,6 @@ DEFUN (bgp_evpn_advertise_vni_subnet,
        if (!bgp_vrf)
                return CMD_WARNING;
 
-       if (!(advertise_type5_routes(bgp_vrf, AFI_IP) ||
-             advertise_type5_routes(bgp_vrf, AFI_IP6))) {
-               vty_out(vty,
-                       "%%Please enable ip prefix advertisement under l2vpn evpn in %s",
-                       vrf_id_to_name(bgp_vrf->vrf_id));
-               return CMD_WARNING;
-       }
-
        evpn_set_advertise_subnet(bgp, vpn);
        return CMD_SUCCESS;
 }
@@ -2841,7 +2833,7 @@ DEFUN (no_bgp_evpn_advertise_type5,
 
        if (afi == AFI_IP) {
 
-               /* if we are already advertising ipv4 prefix as type-5
+               /* if we are not advertising ipv4 prefix as type-5
                 * nothing to do
                 */
                if (CHECK_FLAG(bgp_vrf->vrf_flags,
@@ -2852,7 +2844,7 @@ DEFUN (no_bgp_evpn_advertise_type5,
                }
        } else {
 
-               /* if we are already advertising ipv6 prefix as type-5
+               /* if we are not advertising ipv6 prefix as type-5
                 * nothing to do
                 */
                if (CHECK_FLAG(bgp_vrf->vrf_flags,
index 20bf9635a3e040c410038fdc2fd35917d3d54784..0d226f9e72e1c39e6bab4284eec2d05047f246da 100644 (file)
@@ -2228,10 +2228,10 @@ 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 (advertise_type5_routes(bgp, afi) && new_select)
                        bgp_evpn_advertise_type5_route(
                                bgp, &rn->p, new_select->attr, afi, safi);
-               else if (old_select)
+               else if (advertise_type5_routes(bgp, afi) && old_select)
                        bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);
        }