]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: remove json option from 'sh ip bgp' commands that do not support it
authorDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 22 Aug 2017 19:11:31 +0000 (19:11 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 22 Aug 2017 19:11:31 +0000 (19:11 +0000)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
bgpd/bgp_route.c

index 0c60231ded939738aac7d06c83a8c50e120313b3..d54dec269cf18d7075f0ee09cd82425e48baf776 100644 (file)
@@ -8838,32 +8838,28 @@ DEFUN (show_ip_bgp_large_community,
 static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi,
                           safi_t safi);
 
-/* BGP route print out function. */
+
+/* BGP route print out function without JSON */
 DEFUN (show_ip_bgp,
        show_ip_bgp_cmd,
        "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
-          [<\
-             cidr-only\
-             |dampening <flap-statistics|dampened-paths|parameters>\
-             |route-map WORD\
-             |prefix-list WORD\
-             |filter-list WORD\
-             |statistics\
-             |community [<AA:NN|local-AS|no-advertise|no-export> [exact-match]]\
-             |community-list <(1-500)|WORD> [exact-match]\
-             |A.B.C.D/M longer-prefixes\
-             |X:X::X:X/M longer-prefixes>\
-          ] [json]",
+          <dampening <parameters>\
+           |route-map WORD\
+           |prefix-list WORD\
+           |filter-list WORD\
+           |statistics\
+           |community <AA:NN|local-AS|no-advertise|no-export> [exact-match]\
+           |community-list <(1-500)|WORD> [exact-match]\
+           |A.B.C.D/M longer-prefixes\
+           |X:X::X:X/M longer-prefixes\
+         >",
        SHOW_STR
        IP_STR
        BGP_STR
        BGP_INSTANCE_HELP_STR
        BGP_AFI_HELP_STR
        BGP_SAFI_WITH_LABEL_HELP_STR
-       "Display only routes with non-natural netmasks\n"
        "Display detailed information about dampening\n"
-       "Display flap statistics of routes\n"
-       "Display paths suppressed due to dampening\n"
        "Display detail of configured dampening parameters\n"
        "Display routes matching the route-map\n"
        "A route-map to match on\n"
@@ -8885,13 +8881,11 @@ DEFUN (show_ip_bgp,
        "IPv4 prefix\n"
        "Display route and more specific routes\n"
        "IPv6 prefix\n"
-       "Display route and more specific routes\n"
-       JSON_STR)
+       "Display route and more specific routes\n")
 {
        afi_t afi = AFI_IP6;
        safi_t safi = SAFI_UNICAST;
        int exact_match = 0;
-       enum bgp_show_type sh_type = bgp_show_type_normal;
        struct bgp *bgp = NULL;
        int idx = 0;
 
@@ -8900,23 +8894,8 @@ DEFUN (show_ip_bgp,
        if (!idx)
                return CMD_WARNING;
 
-       int uj = use_json(argc, argv);
-       if (uj)
-               argc--;
-
-       if (argv_find(argv, argc, "cidr-only", &idx))
-               return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
-                               NULL, uj);
-
        if (argv_find(argv, argc, "dampening", &idx)) {
-               if (argv_find(argv, argc, "dampened-paths", &idx))
-                       return bgp_show(vty, bgp, afi, safi,
-                                       bgp_show_type_dampend_paths, NULL, uj);
-               else if (argv_find(argv, argc, "flap-statistics", &idx))
-                       return bgp_show(vty, bgp, afi, safi,
-                                       bgp_show_type_flap_statistics, NULL,
-                                       uj);
-               else if (argv_find(argv, argc, "parameters", &idx))
+               if (argv_find(argv, argc, "parameters", &idx))
                        return bgp_show_dampening_parameters(vty, afi, safi);
        }
 
@@ -8945,10 +8924,6 @@ DEFUN (show_ip_bgp,
                        return bgp_show_community(vty, bgp, argc, argv,
                                                  exact_match, afi, safi);
                }
-               /* show all communities */
-               else
-                       return bgp_show(vty, bgp, afi, safi,
-                                       bgp_show_type_community_all, NULL, uj);
        }
 
        if (argv_find(argv, argc, "community-list", &idx)) {
@@ -8965,6 +8940,66 @@ DEFUN (show_ip_bgp,
                                              safi,
                                              bgp_show_type_prefix_longer);
 
+       return CMD_WARNING;
+}
+
+/* BGP route print out function with JSON */
+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 \
+          >] [json]",
+       SHOW_STR
+       IP_STR
+       BGP_STR
+       BGP_INSTANCE_HELP_STR
+       BGP_AFI_HELP_STR
+       BGP_SAFI_WITH_LABEL_HELP_STR
+       "Display only routes with non-natural netmasks\n"
+       "Display detailed information about dampening\n"
+       "Display flap statistics of routes\n"
+       "Display paths suppressed due to dampening\n"
+       "Display routes matching the communities\n"
+       JSON_STR)
+{
+       afi_t afi = AFI_IP6;
+       safi_t safi = SAFI_UNICAST;
+       enum bgp_show_type sh_type = bgp_show_type_normal;
+       struct bgp *bgp = NULL;
+       int idx = 0;
+
+       bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
+                                           &bgp);
+       if (!idx)
+               return CMD_WARNING;
+
+       int uj = use_json(argc, argv);
+       if (uj)
+               argc--;
+
+       if (argv_find(argv, argc, "cidr-only", &idx))
+               return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
+                               NULL, uj);
+
+       if (argv_find(argv, argc, "dampening", &idx)) {
+               if (argv_find(argv, argc, "dampened-paths", &idx))
+                       return bgp_show(vty, bgp, afi, safi,
+                                       bgp_show_type_dampend_paths, NULL, uj);
+               else if (argv_find(argv, argc, "flap-statistics", &idx))
+                       return bgp_show(vty, bgp, afi, safi,
+                                       bgp_show_type_flap_statistics, NULL,
+                                       uj);
+       }
+
+       if (argv_find(argv, argc, "community", &idx)) {
+               /* show all communities */
+               return bgp_show(vty, bgp, afi, safi,
+                               bgp_show_type_community_all, NULL, uj);
+       }
+
        if (safi == SAFI_MPLS_VPN)
                return bgp_show_mpls_vpn(vty, afi, NULL, bgp_show_type_normal,
                                         NULL, 0, uj);
@@ -11283,6 +11318,7 @@ void bgp_route_init(void)
        /* IPv4 labeled-unicast configuration.  */
        install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd);
        install_element(VIEW_NODE, &show_ip_bgp_cmd);
+       install_element(VIEW_NODE, &show_ip_bgp_json_cmd);
        install_element(VIEW_NODE, &show_ip_bgp_route_cmd);
        install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd);