From f2a8972b0b746522ab4442a30f4b27da6f3620a2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 23 Jan 2017 20:50:50 -0500 Subject: [PATCH] bgpd: Cleanup 'view all' command 1) Make [ WORD] consistent 2) Fix inconsistent help string 3) Fix the show .. vrf all command Signed-off-by: Donald Sharp --- bgpd/bgp_nexthop.c | 4 ++-- bgpd/bgp_route.c | 36 ++++++++++-------------------------- bgpd/bgp_vty.c | 6 +++--- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 0a9747b526..0cf96101c2 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -492,7 +492,7 @@ bgp_show_all_instances_nexthops_vty (struct vty *vty) DEFUN (show_ip_bgp_nexthop, show_ip_bgp_nexthop_cmd, - "show [ip] bgp [ VRFNAME] nexthop [detail]", + "show [ip] bgp [ WORD] nexthop [detail]", SHOW_STR IP_STR BGP_STR @@ -501,7 +501,7 @@ DEFUN (show_ip_bgp_nexthop, "Show detailed information\n") { int idx = 0; - char *vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; + char *vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; int detail = argv_find (argv, argc, "detail", &idx) ? 1 : 0; return show_ip_bgp_nexthop_table (vty, vrf, detail); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 8adc6bd971..c9fcbf9fb4 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8067,53 +8067,37 @@ DEFUN (show_ip_bgp_regexp, DEFUN (show_ip_bgp_instance_all, show_ip_bgp_instance_all_cmd, - "show [ip] bgp all []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] [json]", + "show [ip] bgp all [ []] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_ALL_HELP_STR "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" - "Address Family\n" "Address Family modifier\n" - "Address Family\n" "Address Family modifier\n" JSON_STR) { + vrf_id_t vrf = VRF_DEFAULT; afi_t afi = AFI_IP; safi_t safi = SAFI_UNICAST; int idx = 0; - - /* show [ip] bgp */ - if (argv_find (argv, argc, "ip", &idx)) - afi = AFI_IP; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } - - u_char uj = use_json(argc, argv); + idx = bgp_vty_find_and_parse_afi_safi_vrf (vty, argv, argc, idx, &afi, &safi, &vrf); + if (!idx) + { + vty_out (vty, "View/Vrf Specified: %s is unknown", argv[5]->arg); + return CMD_WARNING; + } + int uj = use_json (argc, argv); + if (uj) argc--; bgp_show_all_instances_routes_vty (vty, afi, safi, uj); return CMD_SUCCESS; } - static int bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 7f4bd49d29..fa19308cb1 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8605,7 +8605,7 @@ DEFUN (show_ip_bgp_neighbors, SHOW_STR IP_STR BGP_STR - BGP_INSTANCE_ALL_HELP_STR + BGP_INSTANCE_HELP_STR "Address Family\n" "Address Family\n" "Address Family\n" @@ -9241,7 +9241,7 @@ bgp_show_peer_group_vty (struct vty *vty, const char *name, DEFUN (show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, - "show [ip] bgp [ VRFNAME] peer-group [PGNAME]", + "show [ip] bgp [ WORD] peer-group [PGNAME]", SHOW_STR IP_STR BGP_STR @@ -9253,7 +9253,7 @@ DEFUN (show_ip_bgp_peer_groups, vrf = pg = NULL; int idx = 0; - vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; + vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); -- 2.39.5