]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: follow AFI/SAFI style for advertising/withdrawing type-5 routes
authorMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Sun, 5 Nov 2017 01:24:02 +0000 (18:24 -0700)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 14 Dec 2017 18:57:08 +0000 (10:57 -0800)
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn.h
bgpd/bgp_evpn_vty.c
lib/.prefix.h.swo [new file with mode: 0644]

index 4724f402606748bad350d6b1c5b7304fd18b170e..1921a9553e10c64b2335f45627d805e7174df816 100644 (file)
@@ -2442,10 +2442,10 @@ 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);
+       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);
+       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
@@ -2453,10 +2453,10 @@ 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);
+       bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
 
        /* update all ipv6 routes */
-       bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6);
+       bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
 }
 
 /*
@@ -3049,7 +3049,7 @@ static void bgp_evpn_handle_export_rt_change_for_vrf(struct bgp *bgp_vrf)
 
 /* withdraw all type-5 routes for an address family */
 void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
-                                   afi_t afi)
+                                   afi_t afi, safi_t safi)
 {
        struct bgp_table *table = NULL;
        struct bgp_node *rn = NULL;
@@ -3057,7 +3057,7 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
        if (!advertise_type5_routes(bgp_vrf, afi))
                return;
 
-       table = bgp_vrf->rib[afi][SAFI_UNICAST];
+       table = bgp_vrf->rib[afi][safi];
        for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
 
                int ret = 0;
@@ -3078,7 +3078,7 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
 
 /* advertise all type-5 routes for an address family */
 void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
-                                    afi_t afi)
+                                    afi_t afi, safi_t safi)
 {
        struct bgp_table *table = NULL;
        struct bgp_node *rn = NULL;
@@ -3086,7 +3086,7 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
        if (!advertise_type5_routes(bgp_vrf, afi))
                return;
 
-       table = bgp_vrf->rib[afi][SAFI_UNICAST];
+       table = bgp_vrf->rib[afi][safi];
        for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
 
                int ret = 0;
index 63985a59a06ec3c412331b00157ba179105f63c9..15e1a438541896b5b2218f42ab4aa9ae32437fd6 100644 (file)
@@ -34,8 +34,10 @@ static inline int is_evpn_enabled(void)
        return bgp ? bgp->advertise_all_vni : 0;
 }
 
-extern void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi);
-extern void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi);
+extern void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi,
+                                          safi_t safi);
+extern void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
+                                           safi_t safi);
 extern void bgp_evpn_vrf_delete(struct bgp *);
 extern void bgp_evpn_handle_router_id_update(struct bgp *bgp, int withdraw);
 extern char *bgp_evpn_label2str(mpls_label_t *label, char *buf, int len);
index 1cff40f703a914bd2b8256f41b245bd1dc4e3b30..0130b33cf85f4683e039ac65aaf7c3d5cc73a41e 100644 (file)
@@ -2437,28 +2437,33 @@ DEFUN (no_bgp_evpn_advertise_all_vni,
 
 DEFUN (bgp_evpn_advertise_type5,
        bgp_evpn_advertise_type5_cmd,
-       "advertise <ipv4|ipv6|both>",
+       "advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR,
        "Advertise prefix routes\n"
-       "advertise ipv4 prefix only\n"
-       "advertise ipv6 prefix only\n"
-       "advertise both ipv4/ipv6 prefix\n")
+       BGP_AFI_HELP_STR
+       BGP_SAFI_HELP_STR)
 {
        struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp); /* bgp vrf instance */
-       uint32_t type = 0;
-
-       if (strcmp(argv[1]->text, "ipv4")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
-       } else if (strcmp(argv[1]->text, "ipv6")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
-       } else if (strcmp(argv[1]->text, "both")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN |
-                      BGP_VRF_ADVERTISE_IPV6_IN_EVPN;
-       } else {
-               vty_out(vty, "%%invalid command");
+       int idx_afi = 0;
+       int idx_safi = 0;
+       afi_t afi = 0;
+       safi_t safi = 0;
+
+       argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
+       argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);
+
+       if (!(afi == AFI_IP) || (afi == AFI_IP6)) {
+               vty_out(vty,
+                       "%%only ipv4 or ipv6 address families are supported");
                return CMD_WARNING;
        }
 
-       if (CHECK_FLAG(type, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
+       if (safi != SAFI_UNICAST) {
+               vty_out(vty,
+                       "%%only ipv4 unicast or ipv6 unicast are supported");
+               return CMD_WARNING;
+       }
+
+       if (afi == AFI_IP) {
 
                /* if we are already advertising ipv4 prefix as type-5
                 * nothing to do */
@@ -2466,8 +2471,7 @@ DEFUN (bgp_evpn_advertise_type5,
                                BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
                        SET_FLAG(bgp_vrf->vrf_flags,
                                 BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
-                       bgp_evpn_advertise_type5_routes(bgp_vrf,
-                                                       AFI_IP);
+                       bgp_evpn_advertise_type5_routes(bgp_vrf, afi, safi);
                }
        } else {
 
@@ -2477,45 +2481,48 @@ DEFUN (bgp_evpn_advertise_type5,
                                BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) {
                        SET_FLAG(bgp_vrf->vrf_flags,
                                 BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
-                       bgp_evpn_advertise_type5_routes(bgp_vrf,
-                                                       AFI_IP6);
+                       bgp_evpn_advertise_type5_routes(bgp_vrf, afi, safi);
                }
        }
-
        return CMD_SUCCESS;
 }
 
 DEFUN (no_bgp_evpn_advertise_type5,
        no_bgp_evpn_advertise_type5_cmd,
-       "no advertise <ipv4|ipv6|both>",
+       "no advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR,
        NO_STR
        "Advertise prefix routes\n"
-       "advertise ipv4 prefix only\n"
-       "advertise ipv6 prefix only\n"
-       "advertise both ipv4/ipv6 prefix\n")
+       BGP_AFI_HELP_STR
+       BGP_SAFI_HELP_STR)
 {
        struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp); /* bgp vrf instance */
-       uint32_t type = 0;
-
-       if (strcmp(argv[1]->text, "ipv4")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
-       } else if (strcmp(argv[1]->text, "ipv6")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
-       } else if (strcmp(argv[1]->text, "both")) {
-               type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN |
-                      BGP_VRF_ADVERTISE_IPV6_IN_EVPN;
-       } else {
-               vty_out(vty, "%%invalid command");
+       int idx_afi = 0;
+       int idx_safi = 0;
+       afi_t afi = 0;
+       safi_t safi = 0;
+
+       argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
+       argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);
+
+       if (!(afi == AFI_IP) || (afi == AFI_IP6)) {
+               vty_out(vty,
+                       "%%only ipv4 or ipv6 address families are supported");
+               return CMD_WARNING;
+       }
+
+       if (safi != SAFI_UNICAST) {
+               vty_out(vty,
+                       "%%only ipv4 unicast or ipv6 unicast are supported");
                return CMD_WARNING;
        }
 
-       if (CHECK_FLAG(type, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
+       if (afi == AFI_IP) {
 
                /* if we are already advertising ipv4 prefix as type-5
                 * nothing to do */
                if (CHECK_FLAG(bgp_vrf->vrf_flags,
                               BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
-                       bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP);
+                       bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
                        UNSET_FLAG(bgp_vrf->vrf_flags,
                                   BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
                }
@@ -2525,8 +2532,7 @@ DEFUN (no_bgp_evpn_advertise_type5,
                 * nothing to do */
                if (CHECK_FLAG(bgp_vrf->vrf_flags,
                               BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) {
-                       bgp_evpn_withdraw_type5_routes(bgp_vrf,
-                                                      AFI_IP6);
+                       bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
                        UNSET_FLAG(bgp_vrf->vrf_flags,
                                   BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
                }
diff --git a/lib/.prefix.h.swo b/lib/.prefix.h.swo
new file mode 100644 (file)
index 0000000..51fe596
Binary files /dev/null and b/lib/.prefix.h.swo differ