From 8c3deaae5179988a422dd7942b7e1c78c0c21e38 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 24 Oct 2016 22:24:40 +0000 Subject: [PATCH] bgpd: Fixup / add back some BGP show commands Signed-off-by: Quentin Young --- bgpd/bgp_route.c | 370 ++++++++++++++++++++++++++++------------------- bgpd/bgp_vty.c | 179 +++++------------------ bgpd/bgp_vty.h | 8 - 3 files changed, 257 insertions(+), 300 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7977bed4ab..229e6f5b29 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7430,7 +7430,7 @@ bgp_show_prefix_longer (struct vty *vty, const char *name, const char *prefix, afi_t afi, safi_t safi, enum bgp_show_type type); static int -bgp_show_regexp (struct vty *vty, int argc, struct cmd_token **argv, afi_t afi, +bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type); static int bgp_show_community (struct vty *vty, const char *view_name, int argc, @@ -8029,7 +8029,7 @@ DEFUN (show_ip_bgp_ipv4, [<\ cidr-only\ |community\ - |dampening \ + |dampening \ |route-map WORD\ |prefix-list WORD\ |filter-list WORD\ @@ -8043,15 +8043,15 @@ DEFUN (show_ip_bgp_ipv4, IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" "Display only routes with non-natural netmasks\n" "Display routes matching the communities\n" @@ -8061,7 +8061,7 @@ DEFUN (show_ip_bgp_ipv4, "Display routes matching the route-map\n" "A route-map to match on\n" "Display routes conforming to the prefix-list\n" - "prefix-list name\n" + "Prefix-list name\n" "Display routes conforming to the filter-list\n" "Regular expression access list name\n" "Display routes matching the communities\n" @@ -8075,6 +8075,7 @@ DEFUN (show_ip_bgp_ipv4, "community-list name\n" "Exact match of the communities\n" "IPv4 prefix /, e.g., 35.0.0.0/8\n" + "Display route and more specific routes\n" "IPv6 prefix /\n" "Display route and more specific routes\n" "JavaScript Object Notation\n") @@ -8120,14 +8121,15 @@ DEFUN (show_ip_bgp_ipv4, if (strmatch(argv[idx]->text, "cidr-only")) return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj); - else if (strmatch(argv[idx]->text, "dampened-paths")) - return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj); - - else if (strmatch(argv[idx]->text, "flap-statistics")) - return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj); - - else if (strmatch(argv[idx]->text, "regexp")) - return bgp_show_regexp (vty, argc, argv, afi, safi, bgp_show_type_regexp); + else if (strmatch(argv[idx]->text, "dampening")) + { + 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)) + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); + } else if (strmatch(argv[idx]->text, "prefix-list")) return bgp_show_prefix_list (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_list); @@ -8156,9 +8158,10 @@ DEFUN (show_ip_bgp_ipv4, } else if (strmatch(argv[idx]->text, "community-list")) { - if (strmatch(argv[idx + 2]->text, "exact_match")) + const char *clist_number_or_name = argv[++idx]->arg; + if (++idx < argc && strmatch (argv[idx]->arg, "exact-match")) exact_match = 1; - return bgp_show_community_list (vty, vrf, argv[idx + 1]->arg, exact_match, afi, safi); + return bgp_show_community_list (vty, vrf, clist_number_or_name, exact_match, afi, safi); } /* prefix-longer */ else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN) @@ -8176,20 +8179,19 @@ DEFUN (show_ip_bgp_route, IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" "Network in the BGP routing table to display\n" "IP prefix /, e.g., 35.0.0.0/8\n" + "Network in the BGP routing table to display\n" "IPv6 prefix /\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8258,6 +8260,55 @@ DEFUN (show_ip_bgp_route, return bgp_show_route (vty, vrf, prefix, afi, safi, NULL, prefix_check, path_type, uj); } +DEFUN (show_ip_bgp_regexp, + show_ip_bgp_regexp_cmd, + "show [ip] bgp []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] regexp REGEX...", + SHOW_STR + IP_STR + BGP_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" + "Display routes matching the AS path regular expression\n" + "A regular-expression to match the BGP AS paths\n") +{ + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + + int idx = 0; + + /* []|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); + } + + // get index of regex + argv_find (argv, argc, "regexp", &idx); + idx++; + + char *regstr = argv_concat (argv, argc, idx); + int rc = bgp_show_regexp (vty, (const char *) regstr, afi, safi, bgp_show_type_regexp); + XFREE (MTYPE_TMP, regstr); + return rc; +} + DEFUN (show_ip_bgp_instance_all, show_ip_bgp_instance_all_cmd, "show [ip] bgp all []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] [json]", @@ -8265,6 +8316,16 @@ DEFUN (show_ip_bgp_instance_all, 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" "JavaScript Object Notation\n") { afi_t afi = AFI_IP; @@ -8298,52 +8359,24 @@ DEFUN (show_ip_bgp_instance_all, static int -bgp_show_regexp (struct vty *vty, int argc, struct cmd_token **argv, afi_t afi, +bgp_show_regexp (struct vty *vty, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type) { return CMD_SUCCESS; -/* XXX(vtysh-grammar): Needs updating for new CLI backend. - int i; - struct buffer *b; - char *regstr; - int first; regex_t *regex; int rc; - first = 0; - b = buffer_new (1024); - for (i = 0; i < argc; i++) - { - if (first) - buffer_putc (b, ' '); - else - { - if ((strcmp (argv[i]->arg, "unicast") == 0) || (strcmp (argv[i]->arg, "multicast") == 0)) - continue; - first = 1; - } - - buffer_putstr (b, argv[i]->arg); - } - buffer_putc (b, '\0'); - - regstr = buffer_getstr (b); - buffer_free (b); - regex = bgp_regcomp (regstr); - XFREE(MTYPE_TMP, regstr); if (! regex) { - vty_out (vty, "Can't compile regexp %s%s", argv[0]->arg, - VTY_NEWLINE); + vty_out (vty, "Can't compile regexp %s%s", regstr, VTY_NEWLINE); return CMD_WARNING; } rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); bgp_regex_free (regex); return rc; -*/ } static int @@ -8414,7 +8447,7 @@ DEFUN (show_ip_bgp_ipv4_dampening_parameters, SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Display detailed information about dampening\n" @@ -8975,8 +9008,8 @@ DEFUN (show_bgp_statistics, "show bgp statistics", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" @@ -8994,8 +9027,8 @@ DEFUN (show_bgp_statistics_view, SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Address Family modifier\n" @@ -9253,7 +9286,7 @@ DEFUN (show_bgp_ipv6_neighbor_prefix_counts, "show bgp ipv6 neighbors prefix-counts [json]", SHOW_STR BGP_STR - "Address family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9278,7 +9311,7 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9304,7 +9337,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -9335,7 +9368,7 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -9598,52 +9631,70 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, DEFUN (show_ip_bgp_instance_neighbor_advertised_route, show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show [ip] bgp [] WORD [] neighbors [] [json]", + "show [ip] bgp [] WORD []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] neighbors [ [route-map WORD]] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" + "Address Family modifier\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" + "Neighbor on bgp configured interface\n" "Display the received routes from neighbor\n" - "Route-map to modify the attributes\n" - "Name of the route map\n" "Display the routes advertised to a BGP neighbor\n" "Route-map to modify the attributes\n" "Name of the route map\n" "JavaScript Object Notation\n") { - int idx_view_vrf = 3; - int idx_vrf = 4; - int idx_afi = 5; - int idx_safi = 6; - int idx_peer; - int idx_adv_recv; - int idx_rmap; - int rcvd = 0; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; char *vrf = NULL; char *rmap_name = NULL; + char *peerstr = NULL; + int rcvd; + struct peer *peer; - afi_t afi; - safi_t safi; - u_char uj = use_json(argc, argv); - vrf = bgp_get_argv_vrf (argc, argv, &afi, &safi, &idx_view_vrf, &idx_vrf, &idx_afi); - idx_safi = idx_afi + 1; - bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_peer); + int idx = 0; - peer = peer_lookup_in_view (vty, vrf, argv[idx_peer]->arg, uj); + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [ WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* []|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); + } + + /* neighbors */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; + + u_char uj = use_json(argc, argv); + + peer = peer_lookup_in_view (vty, vrf, peerstr, uj); if (! peer) { @@ -9651,32 +9702,24 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, return CMD_WARNING; } - idx_adv_recv = idx_peer + 1; - idx_rmap = idx_adv_recv + 2; - - if (argc > idx_adv_recv) - { - if (strmatch(argv[idx_adv_recv]->text, "received-routes")) - rcvd = 1; - else if (strmatch(argv[idx_adv_recv]->text, "advertised-routes")) - rcvd = 0; - - if (argc > idx_rmap) - rmap_name = argv[idx_rmap]->arg; - } + if (argv_find (argv, argc, "received-routes", &idx)) + rcvd = 1; + if (argv_find (argv, argc, "advertised-routes", &idx)) + rcvd = 0; + if (argv_find (argv, argc, "route-map", &idx)) + rmap_name = argv[++idx]->arg; return peer_adj_routes (vty, peer, afi, safi, rcvd, rmap_name, uj); } DEFUN (show_ip_bgp_neighbor_received_prefix_filter, show_ip_bgp_neighbor_received_prefix_filter_cmd, - "show [ip] bgp [ WORD] [ [unicast]] neighbors received prefix-filter [json]", + "show [ip] bgp [ [unicast]] neighbors received prefix-filter [json]", SHOW_STR IP_STR BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" @@ -9686,35 +9729,41 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, "Display the prefixlist filter\n" "JavaScript Object Notation\n") { - int idx_view_vrf = 3; - int idx_vrf = 4; - int idx_afi; - int idx_safi; - int idx_neighbors; - int idx_peer; - afi_t afi; - safi_t safi; + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; + char *peerstr = NULL; + char name[BUFSIZ]; union sockunion su; struct peer *peer; int count, ret; - u_char uj = use_json(argc, argv); - bgp_get_argv_vrf (argc, argv, &afi, &safi, &idx_view_vrf, &idx_vrf, &idx_afi); - idx_safi = idx_afi + 1; - bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_neighbors); - idx_peer = idx_neighbors + 1; + int idx = 0; - ret = str2sockunion (argv[idx_peer]->arg, &su); + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [ [unicast]] */ + if (argv_find (argv, argc, "ipv4", &idx)) + afi = AFI_IP; + if (argv_find (argv, argc, "ipv6", &idx)) + afi = AFI_IP6; + /* neighbors */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; + + u_char uj = use_json(argc, argv); + + ret = str2sockunion (peerstr, &su); if (ret < 0) { - peer = peer_lookup_by_conf_if (NULL, argv[idx_peer]->arg); + peer = peer_lookup_by_conf_if (NULL, peerstr); if (! peer) { if (uj) vty_out (vty, "{}%s", VTY_NEWLINE); else - vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); + vty_out (vty, "%% Malformed address or name: %s%s", peerstr, VTY_NEWLINE); return CMD_WARNING; } } @@ -9736,7 +9785,7 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, if (count) { if (!uj) - vty_out (vty, "Address family: %s%s", afi_safi_print(afi, safi), VTY_NEWLINE); + vty_out (vty, "Address Family: %s%s", afi_safi_print(afi, safi), VTY_NEWLINE); prefix_bgp_show_prefix_list (vty, afi, name, uj); } else @@ -9774,61 +9823,79 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, DEFUN (show_ip_bgp_neighbor_routes, show_ip_bgp_neighbor_routes_cmd, - "show [ip] bgp [ WORD] [] neighbors [json]", + "show [ip] bgp [ WORD] []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] neighbors [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family\n" - "Address family\n" + "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\n" "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" - "Display routes learned from neighbor\n" - "Display the dampened routes received from neighbor\n" "Display flap statistics of the routes learned from neighbor\n" + "Display the dampened routes received from neighbor\n" + "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { - int idx_view_vrf = 3; - int idx_vrf = 4; - int idx_afi; - int idx_safi; - int idx_peer; - int idx_sh_type; char *vrf = NULL; - afi_t afi; - safi_t safi; + char *peerstr = NULL; + + afi_t afi = AFI_IP6; + safi_t safi = SAFI_UNICAST; struct peer *peer; enum bgp_show_type sh_type = bgp_show_type_neighbor; - u_char uj = use_json(argc, argv); - vrf = bgp_get_argv_vrf (argc, argv, &afi, &safi, &idx_view_vrf, &idx_vrf, &idx_afi); - idx_safi = idx_afi + 1; - bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_peer); + int idx = 0; - peer = peer_lookup_in_view (vty, vrf, argv[idx_peer]->arg, uj); + /* show [ip] bgp */ + if (argv_find (argv, argc, "ip", &idx)) + afi = AFI_IP; + /* [ WORD] */ + if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) + vrf = argv[++idx]->arg; + /* []|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); + } + /* neighbors */ + argv_find (argv, argc, "neighbors", &idx); + peerstr = argv[++idx]->arg; + + u_char uj = use_json(argc, argv); + + peer = peer_lookup_in_view (vty, vrf, peerstr, uj); if (! peer) { vty_out (vty, "No such neighbor%s", VTY_NEWLINE); return CMD_WARNING; } - idx_sh_type = idx_peer + 1; - - if (strmatch(argv[idx_sh_type]->text, "routes")) - sh_type = bgp_show_type_neighbor; - - else if (strmatch(argv[idx_sh_type]->text, "dampened-routes")) - sh_type = bgp_show_type_damp_neighbor; - - else if (strmatch(argv[idx_sh_type]->text, "flap-statistics")) + if (argv_find (argv, argc, "flap-statistics", &idx)) sh_type = bgp_show_type_flap_neighbor; + else if (argv_find (argv, argc, "dampened-routes", &idx)) + sh_type = bgp_show_type_damp_neighbor; + else if (argv_find (argv, argc, "routes", &idx)) + sh_type = bgp_show_type_neighbor; return bgp_show_neighbor_route (vty, peer, afi, safi, sh_type, uj); } @@ -10672,6 +10739,7 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); install_element (VIEW_NODE, &show_ip_bgp_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 9589cde841..b780814bc8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -5673,12 +5673,12 @@ DEFUN (no_neighbor_addpath_tx_bestpath_per_as, } -/* Address family configuration. */ +/* Address Family configuration. */ DEFUN (address_family_ipv4, address_family_ipv4_cmd, "address-family ipv4", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_IPV4_NODE; return CMD_SUCCESS; @@ -5688,7 +5688,7 @@ DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, "address-family ipv4 ", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n") { @@ -5705,7 +5705,7 @@ DEFUN (address_family_ipv6, address_family_ipv6_cmd, "address-family ipv6", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_IPV6_NODE; return CMD_SUCCESS; @@ -5715,7 +5715,7 @@ DEFUN (address_family_ipv6_safi, address_family_ipv6_safi_cmd, "address-family ipv6 ", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n") { @@ -5732,7 +5732,7 @@ DEFUN (address_family_vpnv4, address_family_vpnv4_cmd, "address-family vpnv4 [unicast]", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_VPNV4_NODE; @@ -5743,7 +5743,7 @@ DEFUN (address_family_vpnv6, address_family_vpnv6_cmd, "address-family vpnv6 [unicast]", "Enter Address Family command mode\n" - "Address family\n" + "Address Family\n" "Address Family Modifier\n") { vty->node = BGP_VPNV6_NODE; @@ -5754,8 +5754,8 @@ DEFUN (address_family_encap, address_family_encap_cmd, "address-family ", "Enter Address Family command mode\n" - "Address family\n" - "Address family\n") + "Address Family\n" + "Address Family\n") { vty->node = BGP_ENCAP_NODE; return CMD_SUCCESS; @@ -5766,7 +5766,7 @@ DEFUN (address_family_encapv6, address_family_encapv6_cmd, "address-family encapv6", "Enter Address Family command mode\n" - "Address family\n") + "Address Family\n") { vty->node = BGP_ENCAPV6_NODE; return CMD_SUCCESS; @@ -5870,109 +5870,6 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, return CMD_SUCCESS; } -char * -bgp_get_argv_vrf (int argc, struct cmd_token **argv, afi_t *afi, safi_t *safi, - int *idx_view_vrf, int *idx_vrf, int *idx_next_token) -{ - /* - * The DEFUN that calls this MUST begin with one of the following - * clear [ip] bgp [ WORD] - * show [ip] bgp [ WORD] - * - * We will do the following - * - set the afi/safi - * - decrement the idx_view_vrf and idx_vrf pointers if needed - * - return a pointer to the vrf name - */ - int idx_ip = 1; - - /* - * If the user does " ip bgp" then we default the afi safi to ipv4 unicast. - * If the user does " bgp" then we default the afi safi to ipv6 unicast. - * This may be over-written later in the command if they explicitly - * specify an afi safi. - */ - if (strmatch(argv[idx_ip]->text, "ip")) - { - *afi = AFI_IP; - *safi = SAFI_UNICAST; - } - else - { - *afi = AFI_IP6; - *safi = SAFI_UNICAST; - *idx_view_vrf = *idx_view_vrf - 1; - *idx_vrf = *idx_vrf - 1; - } - - if (argc > *idx_vrf) - if (strmatch(argv[*idx_view_vrf]->text, "view") || strmatch(argv[*idx_view_vrf]->text, "vrf")) - { - *idx_next_token = *idx_vrf + 1; - return argv[*idx_vrf]->arg; - } - - *idx_next_token = *idx_view_vrf; - return NULL; -} - -void -bgp_get_argv_afi_safi (int argc, struct cmd_token **argv, - int idx_afi, int idx_safi, - afi_t *afi, safi_t *safi, - int *idx_next_token) -{ - /* - * The DEFUN that calls this must use - * - */ - if (strmatch(argv[idx_afi]->text, "ipv4")) - { - *afi = AFI_IP; - - if (strmatch(argv[idx_safi]->text, "unicast")) - *safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - *safi = SAFI_MULTICAST; - - if (idx_next_token) - *idx_next_token = idx_safi + 1; - } - else if (strmatch(argv[idx_afi]->text, "ipv6")) - { - *afi = AFI_IP6; - - if (strmatch(argv[idx_safi]->text, "unicast")) - *safi = SAFI_UNICAST; - else if (strmatch(argv[idx_safi]->text, "multicast")) - *safi = SAFI_MULTICAST; - - if (idx_next_token) - *idx_next_token = idx_safi + 1; - } - else if (strmatch(argv[idx_afi]->text, "encap")) - { - *afi = AFI_IP; - *safi = SAFI_ENCAP; - - if (idx_next_token) - *idx_next_token = idx_safi + 1; - } - else if (strmatch(argv[idx_afi]->text, "vpnv4")) - { - *afi = AFI_IP; - - if (idx_next_token) - *idx_next_token = idx_safi + 1; - *safi = SAFI_MPLS_VPN; - } - else - { - if (idx_next_token) - *idx_next_token = idx_afi; - } -} - /* one clear bgp command to rule them all */ DEFUN (clear_ip_bgp_all, clear_ip_bgp_all_cmd, @@ -5989,24 +5886,21 @@ DEFUN (clear_ip_bgp_all, "Clear all external peers\n" "Clear all members of peer-group\n" "BGP peer-group name\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" + "Address Family modifier\n" + "Address Family\n" "Address Family modifier\n" - BGP_SOFT_STR BGP_SOFT_STR BGP_SOFT_IN_STR - BGP_SOFT_STR BGP_SOFT_OUT_STR BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n" - BGP_SOFT_IN_STR BGP_SOFT_OUT_STR) { char *vrf = NULL; @@ -6142,7 +6036,7 @@ DEFUN (clear_bgp_ipv6_safi_prefix, "clear bgp ipv6 prefix X:X::X:X/M", CLEAR_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family Modifier\n" "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") @@ -6161,7 +6055,7 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix, CLEAR_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family Modifier\n" "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") @@ -6863,15 +6757,15 @@ DEFUN (show_ip_bgp_summary, IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") @@ -8046,7 +7940,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) { - vty_out (vty, " Address family %s:", afi_safi_print (afi, safi)); + vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); if (p->afc_adv[afi][safi]) vty_out (vty, " advertised"); if (p->afc_recv[afi][safi]) @@ -8751,8 +8645,8 @@ DEFUN (show_ip_bgp_neighbors, IP_STR BGP_STR BGP_INSTANCE_ALL_HELP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -8804,7 +8698,7 @@ DEFUN (show_ip_bgp_ipv4_paths, SHOW_STR IP_STR BGP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "Path information\n") @@ -8910,15 +8804,15 @@ DEFUN (show_ip_bgp_updgrps, IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" - "Address family\n" + "Address Family\n" "Address Family modifier\n" "Detailed info about dynamic update groups\n" "Specific subgroup to display detailed info for\n") @@ -9071,8 +8965,8 @@ DEFUN (show_bgp_updgrps_afi_adj, "show bgp update-groups ", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "BGP update groups\n" @@ -9178,8 +9072,8 @@ DEFUN (show_bgp_updgrps_afi_adj_s, "show bgp update-groups SUBGROUP-ID ", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" + "Address Family\n" + "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" "BGP update groups\n" @@ -10104,6 +9998,7 @@ bgp_vty_init (void) /* "bgp config-type" commands. */ install_element (CONFIG_NODE, &bgp_config_type_cmd); + install_element (CONFIG_NODE, &no_bgp_config_type_cmd); /* bgp route-map delay-timer commands. */ install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); @@ -11053,6 +10948,8 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); + install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); /* "show ip bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 936d66131f..382af0984f 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -33,14 +33,6 @@ extern int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp); extern int bgp_config_write_listen(struct vty *vty, struct bgp *bgp); extern int bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp); extern int bgp_vty_return (struct vty *vty, int ret); -extern char *bgp_get_argv_vrf (int argc, struct cmd_token **argv, - afi_t *afi, safi_t *safi, - int *idx_view_vrf, int *idx_vrf, - int *idx_next_token); -extern void bgp_get_argv_afi_safi (int argc, struct cmd_token **argv, - int idx_afi, int idx_safi, - afi_t *afi, safi_t *safi, - int *idx_next_token); extern struct peer * peer_and_group_lookup_vty (struct vty *vty, const char *peer_str); -- 2.39.5