]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix broken show community commands
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 4 Oct 2018 17:46:52 +0000 (17:46 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 4 Oct 2018 17:46:52 +0000 (17:46 +0000)
SHA c5f1e1b broke about half of the community-related show commands; fix
them

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_route.c

index 715393b91db62ffdc6cc2fb265a78e5606aaecd5..755e9b7f97c5f664cea0980e54d5a1130a0e0566 100644 (file)
@@ -9087,10 +9087,6 @@ DEFUN (show_ip_bgp,
            |prefix-list WORD\
            |filter-list WORD\
            |statistics\
-           |community <AA:NN|local-AS|no-advertise|no-export|graceful-shutdown\
-           no-peer|blackhole|llgr-stale|no-llgr|accept-own|accept-own-nexthop\
-           route-filter-v6|route-filter-v4|route-filter-translated-v6|\
-           route-filter-translated-v4> [exact-match]\
            |community-list <(1-500)|WORD> [exact-match]\
            |A.B.C.D/M longer-prefixes\
            |X:X::X:X/M longer-prefixes\
@@ -9110,23 +9106,6 @@ DEFUN (show_ip_bgp,
        "Display routes conforming to the filter-list\n"
        "Regular expression access list name\n"
        "BGP RIB advertisement statistics\n"
-       "Display routes matching the communities\n"
-       COMMUNITY_AANN_STR
-       "Do not send outside local AS (well-known community)\n"
-       "Do not advertise to any peer (well-known community)\n"
-       "Do not export to next AS (well-known community)\n"
-       "Graceful shutdown (well-known community)\n"
-       "Do not export to any peer (well-known community)\n"
-       "Inform EBGP peers to blackhole traffic to prefix (well-known community)\n"
-       "Staled Long-lived Graceful Restart VPN route (well-known community)\n"
-       "Removed because Long-lived Graceful Restart was not enabled for VPN route (well-known community)\n"
-       "Should accept local VPN route if exported and imported into different VRF (well-known community)\n"
-       "Should accept VPN route with local nexthop (well-known community)\n"
-       "RT VPNv6 route filtering (well-known community)\n"
-       "RT VPNv4 route filtering (well-known community)\n"
-       "RT translated VPNv6 route filtering (well-known community)\n"
-       "RT translated VPNv4 route filtering (well-known community)\n"
-       "Exact match of the communities\n"
        "Display routes matching the community-list\n"
        "community-list number\n"
        "community-list name\n"
@@ -9188,11 +9167,14 @@ DEFUN (show_ip_bgp,
 DEFUN (show_ip_bgp_json,
        show_ip_bgp_json_cmd,
        "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
-          [<\
-             cidr-only\
-             |dampening <flap-statistics|dampened-paths>\
-             |community [<AA:NN|local-AS|no-advertise|no-export|graceful-shutdown>] [exact-match]\
-          >] [json]",
+          [cidr-only\
+          |dampening <flap-statistics|dampened-paths>\
+          |community [AA:NN|local-AS|no-advertise|no-export\
+                     |graceful-shutdown|no-peer|blackhole|llgr-stale|no-llgr\
+                     |accept-own|accept-own-nexthop|route-filter-v6\
+                     |route-filter-v4|route-filter-translated-v6\
+                     |route-filter-translated-v4] [exact-match]\
+          ] [json]",
        SHOW_STR
        IP_STR
        BGP_STR
@@ -9209,6 +9191,16 @@ DEFUN (show_ip_bgp_json,
        "Do not advertise to any peer (well-known community)\n"
        "Do not export to next AS (well-known community)\n"
        "Graceful shutdown (well-known community)\n"
+       "Do not export to any peer (well-known community)\n"
+       "Inform EBGP peers to blackhole traffic to prefix (well-known community)\n"
+       "Staled Long-lived Graceful Restart VPN route (well-known community)\n"
+       "Removed because Long-lived Graceful Restart was not enabled for VPN route (well-known community)\n"
+       "Should accept local VPN route if exported and imported into different VRF (well-known community)\n"
+       "Should accept VPN route with local nexthop (well-known community)\n"
+       "RT VPNv6 route filtering (well-known community)\n"
+       "RT VPNv4 route filtering (well-known community)\n"
+       "RT translated VPNv6 route filtering (well-known community)\n"
+       "RT translated VPNv4 route filtering (well-known community)\n"
        "Exact match of the communities\n"
        JSON_STR)
 {
@@ -9217,7 +9209,6 @@ DEFUN (show_ip_bgp_json,
        enum bgp_show_type sh_type = bgp_show_type_normal;
        struct bgp *bgp = NULL;
        int idx = 0;
-       int idx_community_type = 0;
        int exact_match = 0;
        bool uj = use_json(argc, argv);
 
@@ -9244,29 +9235,23 @@ DEFUN (show_ip_bgp_json,
        }
 
        if (argv_find(argv, argc, "community", &idx)) {
+               char *maybecomm = idx + 1 < argc ? argv[idx + 1]->text : NULL;
+               char *community = NULL;
 
-               /* show a specific community */
-               if (argv_find(argv, argc, "local-AS", &idx_community_type) ||
-                       argv_find(argv, argc, "no-advertise",
-                                       &idx_community_type) ||
-                       argv_find(argv, argc, "no-export",
-                                       &idx_community_type) ||
-                       argv_find(argv, argc, "graceful-shutdown",
-                                       &idx_community_type) ||
-                       argv_find(argv, argc, "AA:NN", &idx_community_type)) {
-                       if (argv_find(argv, argc, "exact-match", &idx))
-                               exact_match = 1;
-
-                       return (bgp_show_community(vty, bgp,
-                                               argv[idx_community_type]->arg,
-                                               exact_match, afi, safi, uj));
-               } else {
+               if (maybecomm && !strmatch(maybecomm, "json")
+                   && !strmatch(maybecomm, "exact-match"))
+                       community = maybecomm;
+
+               if (argv_find(argv, argc, "exact-match", &idx))
+                       exact_match = 1;
 
-                       /* show all communities */
+               if (community)
+                       return bgp_show_community(vty, bgp, community,
+                                                 exact_match, afi, safi, uj);
+               else
                        return (bgp_show(vty, bgp, afi, safi,
-                                       bgp_show_type_community_all, NULL,
-                                       uj));
-               }
+                                        bgp_show_type_community_all, NULL,
+                                        uj));
        }
 
        return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj);