From a636c635ae5e79cd877535b4ac013033fe7f32de Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Mon, 26 Sep 2016 18:08:45 +0000 Subject: [PATCH] bgpd: collaps show ip bgp, show ip bgp x.x.x.x, etc calls Signed-off-by: Daniel Walton --- bgpd/bgp_debug.c | 8 - bgpd/bgp_route.c | 6892 +++++++++------------------------------------- bgpd/bgp_vty.c | 391 +-- bgpd/bgp_vty.h | 8 + ospfd/ospf_vty.c | 2 + 5 files changed, 1419 insertions(+), 5882 deletions(-) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 817a8e00a4..39f723a6a4 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -1554,14 +1554,6 @@ DEFUN (debug_bgp_allow_martians, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "undebug bgp allow-martians", - * UNDEBUG_STR - * BGP_STR - * "BGP allow martian next hops\n" - * - */ DEFUN (no_debug_bgp_allow_martians, no_debug_bgp_allow_martians_cmd, "no debug bgp allow-martians", diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 14aaf7eebb..6145b31755 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -60,7 +60,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_mpath.h" #include "bgpd/bgp_nht.h" #include "bgpd/bgp_updgrp.h" -#include "bgpd/bgp_vty.h" /* Extern from bgp_dump.c */ extern const char *bgp_origin_str[]; @@ -4459,64 +4458,32 @@ DEFUN (bgp_network_mask_natural_backdoor, NULL, 1); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no network A.B.C.D/M route-map WORD", - * NO_STR - * "Specify a network to announce via BGP\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * "Route-map to modify the attributes\n" - * "Name of the route map\n" - * - * "no network A.B.C.D/M backdoor", - * NO_STR - * "Specify a network to announce via BGP\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * "Specify a BGP backdoor route\n" - * - */ DEFUN (no_bgp_network, no_bgp_network_cmd, - "no network A.B.C.D/M", + "no network A.B.C.D/M []", NO_STR "Specify a network to announce via BGP\n" - "IP prefix /, e.g., 35.0.0.0/8\n") + "IP prefix /, e.g., 35.0.0.0/8\n" + "Specify a BGP backdoor route\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { int idx_ipv4_prefixlen = 2; return bgp_static_unset (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty)); } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no network A.B.C.D mask A.B.C.D backdoor", - * NO_STR - * "Specify a network to announce via BGP\n" - * "Network number\n" - * "Network mask\n" - * "Network mask\n" - * "Specify a BGP backdoor route\n" - * - * "no network A.B.C.D mask A.B.C.D route-map WORD", - * NO_STR - * "Specify a network to announce via BGP\n" - * "Network number\n" - * "Network mask\n" - * "Network mask\n" - * "Route-map to modify the attributes\n" - * "Name of the route map\n" - * - */ DEFUN (no_bgp_network_mask, no_bgp_network_mask_cmd, - "no network A.B.C.D mask A.B.C.D", + "no network A.B.C.D mask A.B.C.D []", NO_STR "Specify a network to announce via BGP\n" "Network number\n" "Network mask\n" - "Network mask\n") + "Network mask\n" + "Specify a BGP backdoor route\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { int idx_ipv4 = 2; int idx_ipv4_2 = 4; @@ -4534,30 +4501,15 @@ DEFUN (no_bgp_network_mask, bgp_node_safi (vty)); } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no network A.B.C.D backdoor", - * NO_STR - * "Specify a network to announce via BGP\n" - * "Network number\n" - * "Specify a BGP backdoor route\n" - * - * "no network A.B.C.D route-map WORD", - * NO_STR - * "Specify a network to announce via BGP\n" - * "Network number\n" - * "Route-map to modify the attributes\n" - * "Name of the route map\n" - * - */ DEFUN (no_bgp_network_mask_natural, no_bgp_network_mask_natural_cmd, - "no network A.B.C.D", + "no network A.B.C.D []", NO_STR "Specify a network to announce via BGP\n" - "Network number\n") + "Network number\n" + "Specify a BGP backdoor route\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { int idx_ipv4 = 2; int ret; @@ -4574,18 +4526,6 @@ DEFUN (no_bgp_network_mask_natural, bgp_node_safi (vty)); } - - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ipv6 bgp network X:X::X:X/M", - * IPV6_STR - * BGP_STR - * "Specify a network to announce via BGP\n" - * "IPv6 prefix /, e.g., 3ffe::/16\n" - * - */ DEFUN (ipv6_bgp_network, ipv6_bgp_network_cmd, "network X:X::X:X/M", @@ -4611,38 +4551,19 @@ DEFUN (ipv6_bgp_network_route_map, bgp_node_safi (vty), argv[idx_word]->arg, 0); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no network X:X::X:X/M route-map WORD", - * NO_STR - * "Specify a network to announce via BGP\n" - * "IPv6 prefix /\n" - * "Route-map to modify the attributes\n" - * "Name of the route map\n" - * - * "no ipv6 bgp network X:X::X:X/M", - * NO_STR - * IPV6_STR - * BGP_STR - * "Specify a network to announce via BGP\n" - * "IPv6 prefix /, e.g., 3ffe::/16\n" - * - */ DEFUN (no_ipv6_bgp_network, no_ipv6_bgp_network_cmd, - "no network X:X::X:X/M", + "no network X:X::X:X/M [route-map WORD]", NO_STR "Specify a network to announce via BGP\n" - "IPv6 prefix /\n") + "IPv6 prefix /\n" + "Route-map to modify the attributes\n" + "Name of the route map\n") { int idx_ipv6_prefixlen = 2; return bgp_static_unset (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty)); } - - -#endif /* HAVE_IPV6 */ - /* Aggreagete address: advertise-map Set condition to advertise attribute @@ -5352,48 +5273,31 @@ DEFUN (aggregate_address_mask_as_set, 0, AGGREGATE_AS_SET); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "aggregate-address A.B.C.D/M summary-only as-set", - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Filter more specific routes from updates\n" - * "Generate AS set path information\n" - * - */ DEFUN (aggregate_address_as_set_summary, aggregate_address_as_set_summary_cmd, - "aggregate-address A.B.C.D/M as-set summary-only", + "aggregate-address A.B.C.D/M ", "Configure BGP aggregate entries\n" "Aggregate prefix\n" "Generate AS set path information\n" - "Filter more specific routes from updates\n") + "Filter more specific routes from updates\n" + "Filter more specific routes from updates\n" + "Generate AS set path information\n") { int idx_ipv4_prefixlen = 1; return bgp_aggregate_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty), AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "aggregate-address A.B.C.D A.B.C.D summary-only as-set", - * "Configure BGP aggregate entries\n" - * "Aggregate address\n" - * "Aggregate mask\n" - * "Filter more specific routes from updates\n" - * "Generate AS set path information\n" - * - */ DEFUN (aggregate_address_mask_as_set_summary, aggregate_address_mask_as_set_summary_cmd, - "aggregate-address A.B.C.D A.B.C.D as-set summary-only", + "aggregate-address A.B.C.D A.B.C.D ", "Configure BGP aggregate entries\n" "Aggregate address\n" "Aggregate mask\n" "Generate AS set path information\n" - "Filter more specific routes from updates\n") + "Filter more specific routes from updates\n" + "Filter more specific routes from updates\n" + "Generate AS set path information\n") { int idx_ipv4 = 1; int idx_ipv4_2 = 2; @@ -5412,91 +5316,28 @@ DEFUN (aggregate_address_mask_as_set_summary, AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no aggregate-address A.B.C.D/M summary-only", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Filter more specific routes from updates\n" - * - * "no aggregate-address A.B.C.D/M as-set summary-only", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Generate AS set path information\n" - * "Filter more specific routes from updates\n" - * - * "no aggregate-address A.B.C.D/M summary-only as-set", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Filter more specific routes from updates\n" - * "Generate AS set path information\n" - * - * "no aggregate-address A.B.C.D/M as-set", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Generate AS set path information\n" - * - */ DEFUN (no_aggregate_address, no_aggregate_address_cmd, - "no aggregate-address A.B.C.D/M", + "no aggregate-address A.B.C.D/M [as-set] [summary-only]", NO_STR "Configure BGP aggregate entries\n" - "Aggregate prefix\n") + "Aggregate prefix\n" + "Generate AS set path information\n" + "Filter more specific routes from updates\n") { int idx_ipv4_prefixlen = 2; return bgp_aggregate_unset (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, bgp_node_safi (vty)); } - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no aggregate-address A.B.C.D A.B.C.D summary-only as-set", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate address\n" - * "Aggregate mask\n" - * "Filter more specific routes from updates\n" - * "Generate AS set path information\n" - * - * "no aggregate-address A.B.C.D A.B.C.D as-set summary-only", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate address\n" - * "Aggregate mask\n" - * "Generate AS set path information\n" - * "Filter more specific routes from updates\n" - * - * "no aggregate-address A.B.C.D A.B.C.D summary-only", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate address\n" - * "Aggregate mask\n" - * "Filter more specific routes from updates\n" - * - * "no aggregate-address A.B.C.D A.B.C.D as-set", - * NO_STR - * "Configure BGP aggregate entries\n" - * "Aggregate address\n" - * "Aggregate mask\n" - * "Generate AS set path information\n" - * - */ DEFUN (no_aggregate_address_mask, no_aggregate_address_mask_cmd, - "no aggregate-address A.B.C.D A.B.C.D", + "no aggregate-address A.B.C.D A.B.C.D [as-set] [summary-only]", NO_STR "Configure BGP aggregate entries\n" "Aggregate address\n" - "Aggregate mask\n") + "Aggregate mask\n" + "Generate AS set path information\n" + "Filter more specific routes from updates\n") { int idx_ipv4 = 2; int idx_ipv4_2 = 3; @@ -5514,20 +5355,6 @@ DEFUN (no_aggregate_address_mask, return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty)); } - - - - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ipv6 bgp aggregate-address X:X::X:X/M", - * IPV6_STR - * BGP_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * - */ DEFUN (ipv6_aggregate_address, ipv6_aggregate_address_cmd, "aggregate-address X:X::X:X/M", @@ -5538,16 +5365,6 @@ DEFUN (ipv6_aggregate_address, return bgp_aggregate_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, 0, 0); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "ipv6 bgp aggregate-address X:X::X:X/M summary-only", - * IPV6_STR - * BGP_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Filter more specific routes from updates\n" - * - */ DEFUN (ipv6_aggregate_address_summary_only, ipv6_aggregate_address_summary_only_cmd, "aggregate-address X:X::X:X/M summary-only", @@ -5560,16 +5377,6 @@ DEFUN (ipv6_aggregate_address_summary_only, AGGREGATE_SUMMARY_ONLY, 0); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ipv6 bgp aggregate-address X:X::X:X/M", - * NO_STR - * IPV6_STR - * BGP_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * - */ DEFUN (no_ipv6_aggregate_address, no_ipv6_aggregate_address_cmd, "no aggregate-address X:X::X:X/M", @@ -5581,17 +5388,6 @@ DEFUN (no_ipv6_aggregate_address, return bgp_aggregate_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no ipv6 bgp aggregate-address X:X::X:X/M summary-only", - * NO_STR - * IPV6_STR - * BGP_STR - * "Configure BGP aggregate entries\n" - * "Aggregate prefix\n" - * "Filter more specific routes from updates\n" - * - */ DEFUN (no_ipv6_aggregate_address_summary_only, no_ipv6_aggregate_address_summary_only_cmd, "no aggregate-address X:X::X:X/M summary-only", @@ -5604,11 +5400,6 @@ DEFUN (no_ipv6_aggregate_address_summary_only, return bgp_aggregate_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST); } - - - -#endif /* HAVE_IPV6 */ - /* Redistribute route treatment. */ void bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *nexthop, @@ -7326,14 +7117,6 @@ enum bgp_show_type bgp_show_type_community_list, bgp_show_type_community_list_exact, bgp_show_type_flap_statistics, - bgp_show_type_flap_address, - bgp_show_type_flap_prefix, - bgp_show_type_flap_cidr_only, - bgp_show_type_flap_regexp, - bgp_show_type_flap_filter_list, - bgp_show_type_flap_prefix_list, - bgp_show_type_flap_prefix_longer, - bgp_show_type_flap_route_map, bgp_show_type_flap_neighbor, bgp_show_type_dampend_paths, bgp_show_type_damp_neighbor @@ -7359,6 +7142,12 @@ static int 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, + safi_t safi, enum bgp_show_type type); +static int +bgp_show_community (struct vty *vty, const char *view_name, int argc, + struct cmd_token **argv, int exact, afi_t afi, safi_t safi); static int bgp_show_table (struct vty *vty, struct bgp_table *table, @@ -7403,14 +7192,6 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, for (ri = rn->info; ri; ri = ri->next) { if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor || type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) @@ -7418,32 +7199,28 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, if (!(ri->extra && ri->extra->damp_info)) continue; } - if (type == bgp_show_type_regexp - || type == bgp_show_type_flap_regexp) + if (type == bgp_show_type_regexp) { regex_t *regex = output_arg; if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) continue; } - if (type == bgp_show_type_prefix_list - || type == bgp_show_type_flap_prefix_list) + if (type == bgp_show_type_prefix_list) { struct prefix_list *plist = output_arg; if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) continue; } - if (type == bgp_show_type_filter_list - || type == bgp_show_type_flap_filter_list) + if (type == bgp_show_type_filter_list) { struct as_list *as_list = output_arg; if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT) continue; } - if (type == bgp_show_type_route_map - || type == bgp_show_type_flap_route_map) + if (type == bgp_show_type_route_map) { struct route_map *rmap = output_arg; struct bgp_info binfo; @@ -7470,8 +7247,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) continue; } - if (type == bgp_show_type_cidr_only - || type == bgp_show_type_flap_cidr_only) + if (type == bgp_show_type_cidr_only) { u_int32_t destination; @@ -7483,8 +7259,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, if (IN_CLASSA (destination) && rn->p.prefixlen == 8) continue; } - if (type == bgp_show_type_prefix_longer - || type == bgp_show_type_flap_prefix_longer) + if (type == bgp_show_type_prefix_longer) { struct prefix *p = output_arg; @@ -7526,18 +7301,6 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, if (! community_list_exact_match (ri->attr->community, list)) continue; } - if (type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix) - { - struct prefix *p = output_arg; - - if (! prefix_match (&rn->p, p)) - continue; - - if (type == bgp_show_type_flap_prefix) - if (p->prefixlen != rn->p.prefixlen) - continue; - } if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) { @@ -7555,14 +7318,6 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, || type == bgp_show_type_damp_neighbor) vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE); else if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor) vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE); else @@ -7574,14 +7329,6 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, || type == bgp_show_type_damp_neighbor) damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); else if (type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_address - || type == bgp_show_type_flap_prefix - || type == bgp_show_type_flap_cidr_only - || type == bgp_show_type_flap_regexp - || type == bgp_show_type_flap_filter_list - || type == bgp_show_type_flap_prefix_list - || type == bgp_show_type_flap_prefix_longer - || type == bgp_show_type_flap_route_map || type == bgp_show_type_flap_neighbor) flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST, use_json, json_paths); else @@ -7983,4165 +7730,759 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, } /* BGP route print out function. */ -DEFUN (show_ip_bgp, - show_ip_bgp_cmd, - "show ip bgp [json]", - SHOW_STR - IP_STR - BGP_STR - "JavaScript Object Notation\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv4 (unicast|multicast) [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\n" - * "JavaScript Object Notation\n" - * - */ DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show ip bgp ipv4 [json]", + "show [ip] bgp [ WORD] [] [cidr-only|community|<[dampening] >|regexp .LINE|route-map WORD|prefix-list WORD|filter-list WORD|community [exact-match]|community-list <(1-500)|WORD> [exact-match]| longer-prefixes] [json]", SHOW_STR IP_STR BGP_STR + BGP_INSTANCE_HELP_STR + "Address family\n" + "Address Family modifier\n" "Address family\n" "Address Family modifier\n" + "Address family\n" + "Address Family modifier\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" + "Display detailed information about dampening\n" + "Display flap statistics of routes\n" + "Display paths suppressed due to dampening\n" + "Display routes matching the AS path regular expression\n" + "A regular-expression to match the BGP AS paths\n" + "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" + "Display routes conforming to the filter-list\n" + "Regular expression access list name\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" + "Exact match of the communities\n" + "Display routes matching the community-list\n" + "community-list number\n" + "community-list name\n" + "Exact match of the communities\n" + "IPv4 prefix /, e.g., 35.0.0.0/8\n" + "IPv6 prefix /\n" + "Display route and more specific routes\n" "JavaScript Object Notation\n") { - int idx_safi = 4; + int idx_view_vrf = 3; + int idx_vrf = 4; + int idx_afi; + int idx_safi; + int idx_sh_type; + int exact_match = 0; + char *vrf = NULL; + afi_t afi; + safi_t safi; + enum bgp_show_type sh_type = bgp_show_type_normal; + struct bgp *bgp; u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); -} + // dwalton reference + 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_sh_type); + + bgp = bgp_lookup_by_name (vrf); + if (bgp == NULL) + { + vty_out (vty, "Can't find BGP instance %s%s", vrf, VTY_NEWLINE); + return CMD_WARNING; + } + // "show [ip] bgp [ WORD] [] + // [cidr-only|<[dampening] >|regexp .LINE|prefix-list WORD|filter-list WORD| + // community []|community-list <(1-500)|WORD> [exact-match]|A.B.C.D/M longer-prefixes] [json]", + if (strmatch(argv[idx_sh_type]->text, "cidr-only")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj); + + else if (strmatch(argv[idx_sh_type]->text, "dampening")) + { + if (strmatch(argv[idx_sh_type + 1]->text, "dampened-paths")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj); + + else if (strmatch(argv[idx_sh_type + 1]->text, "flap-statistics")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj); + } + + else if (strmatch(argv[idx_sh_type]->text, "dampened-paths")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj); + + else if (strmatch(argv[idx_sh_type]->text, "flap-statistics")) + return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj); + + else if (strmatch(argv[idx_sh_type]->text, "regexp")) + return bgp_show_regexp (vty, argc, argv, afi, safi, bgp_show_type_regexp); + + else if (strmatch(argv[idx_sh_type]->text, "prefix-list")) + return bgp_show_prefix_list (vty, vrf, argv[idx_sh_type + 1]->arg, afi, safi, bgp_show_type_prefix_list); + + else if (strmatch(argv[idx_sh_type]->text, "filter-list")) + return bgp_show_filter_list (vty, vrf, argv[idx_sh_type + 1]->arg, afi, safi, bgp_show_type_filter_list); + + else if (strmatch(argv[idx_sh_type]->text, "route-map")) + return bgp_show_route_map (vty, vrf, argv[idx_sh_type + 1]->arg, afi, safi, bgp_show_type_route_map); + + else if (strmatch(argv[idx_sh_type]->text, "community")) + /* show a specific community */ + if (argv[idx_sh_type + 1]->type == VARIABLE_TKN || + strmatch(argv[idx_sh_type + 1]->text, "local-AS") || + strmatch(argv[idx_sh_type + 1]->text, "no-advertise") || + strmatch(argv[idx_sh_type + 1]->text, "no-export")) + { + if (strmatch(argv[idx_sh_type + 2]->text, "exact_match")) + exact_match = 1; + return bgp_show_community (vty, vrf, argc, argv, exact_match, afi, safi); + } + /* show all communities */ + else + return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, uj); + + else if (strmatch(argv[idx_sh_type]->text, "community-list")) + { + if (strmatch(argv[idx_sh_type + 2]->text, "exact_match")) + exact_match = 1; + return bgp_show_community_list (vty, vrf, argv[idx_sh_type + 1]->arg, exact_match, afi, safi); + } + + /* prefix-longer */ + else if (argv[idx_sh_type]->type == IPV4_TKN || argv[idx_sh_type]->type == IPV6_TKN) + return bgp_show_prefix_longer (vty, vrf, argv[idx_sh_type + 1]->arg, afi, safi, bgp_show_type_prefix_longer); + + return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj); +} DEFUN (show_ip_bgp_route, show_ip_bgp_route_cmd, - "show ip bgp A.B.C.D [json]", + "show [ip] bgp [ WORD] [] [bestpath|multipath] [json]", SHOW_STR IP_STR BGP_STR + BGP_INSTANCE_HELP_STR + "Address family\n" + "Address Family modifier\n" + "Address family\n" + "Address Family modifier\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" + "Address family\n" + "Address Family modifier\n" "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ipv4 = 3; - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_ip_bgp_route_pathtype, - show_ip_bgp_route_pathtype_cmd, - "show ip bgp A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR "IP prefix /, e.g., 35.0.0.0/8\n" + "IPv6 prefix /\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") { - int idx_ipv4 = 3; - int idx_bestpath = 4; + int idx_view_vrf = 3; + int idx_vrf = 4; + int idx_afi; + int idx_safi; + int idx_prefix; + int idx_path_type; + int prefix_check = 0; + char *vrf = NULL; + afi_t afi; + safi_t safi; + enum bgp_path_type path_type; + struct prefix_rd prd; + struct prefix_rd *prd_ptr = NULL; u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); + 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_prefix); + + if (strmatch(argv[idx_afi]->text, "encap") && strmatch(argv[idx_safi + 1]->text, "rd")) + { + str2prefix_rd (argv[idx_safi + 2]->arg, &prd); + prd_ptr = &prd; + } + + if (argv[idx_prefix]->type == IPV4_TKN || argv[idx_prefix]->type == IPV6_TKN) + prefix_check = 0; + else if (argv[idx_prefix]->type == IPV4_PREFIX_TKN || argv[idx_prefix]->type == IPV6_PREFIX_TKN) + prefix_check = 1; + + idx_path_type = idx_prefix + 1; + + if (strmatch(argv[idx_path_type]->text, "bestpath")) + path_type = BGP_PATH_BESTPATH; + else if (strmatch(argv[idx_path_type]->text, "bestpath")) + path_type = BGP_PATH_MULTIPATH; else - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + path_type = BGP_PATH_ALL; + + return bgp_show_route (vty, vrf, argv[idx_prefix]->arg, afi, safi, prd_ptr, prefix_check, path_type, uj); } -DEFUN (show_bgp_ipv4_safi_route_pathtype, - show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 A.B.C.D [json]", +DEFUN (show_ip_bgp_instance_all, + show_ip_bgp_instance_all_cmd, + "show ip bgp all [json]", SHOW_STR + IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" + BGP_INSTANCE_ALL_HELP_STR "JavaScript Object Notation\n") { - int idx_safi = 3; - int idx_ipv4 = 4; - int idx_bestpath = 5; u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - -DEFUN (show_bgp_ipv4_prefix, - show_bgp_ipv4_prefix_cmd, - "show bgp ipv4 A.B.C.D/M [json]", - SHOW_STR - BGP_STR - IP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - JSON_STR) -{ - int idx_ipv4_prefixlen = 3; - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv)); + /* CHECK ME we need to revisit all of the bgp_show_all_ commands */ + bgp_show_all_instances_routes_vty (vty, AFI_IP, SAFI_UNICAST, uj); + return CMD_SUCCESS; } -DEFUN (show_bgp_ipv6_route, - show_bgp_ipv6_route_cmd, - "show bgp ipv6 X:X::X:X [json]", +DEFUN (show_bgp_instance_all, + show_bgp_instance_all_cmd, + "show bgp all [json]", SHOW_STR BGP_STR - "Address family\n" - "Network in the BGP routing table to display\n" - JSON_STR) + BGP_INSTANCE_ALL_HELP_STR + "JavaScript Object Notation\n") { - int idx_ipv6 = 3; - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} + u_char uj = use_json(argc, argv); -DEFUN (show_bgp_ipv6_prefix, - show_bgp_ipv6_prefix_cmd, - "show bgp ipv6 X:X::X:X/M [json]", - SHOW_STR - BGP_STR - IP_STR - "IPv6 prefix /\n" - JSON_STR) -{ - int idx_ipv6_prefixlen = 3; - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv)); + bgp_show_all_instances_routes_vty (vty, AFI_IP6, SAFI_UNICAST, uj); + return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv4 (unicast|multicast) A.B.C.D [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\n" - * "Network in the BGP routing table to display\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_ipv4_route, - show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") +static int +bgp_show_regexp (struct vty *vty, int argc, struct cmd_token **argv, afi_t afi, + safi_t safi, enum bgp_show_type type) { - int idx_safi = 4; - int idx_ipv4 = 5; - u_char uj = use_json(argc, argv); - - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); + 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; + } - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); -} + buffer_putstr (b, argv[i]->arg); + } + buffer_putc (b, '\0'); + regstr = buffer_getstr (b); + buffer_free (b); -DEFUN (show_ip_bgp_vpnv4_all_route, - show_ip_bgp_vpnv4_all_route_cmd, - "show ip bgp vpnv4 all A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ipv4 = 5; - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} + regex = bgp_regcomp (regstr); + XFREE(MTYPE_TMP, regstr); + if (! regex) + { + vty_out (vty, "Can't compile regexp %s%s", argv[0]->arg, + VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_bgp_ipv4_vpn_route, - show_bgp_ipv4_vpn_route_cmd, - "show bgp ipv4 vpn A.B.C.D [json]", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - int idx_ipv4 = 4; - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); + rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); + bgp_regex_free (regex); + return rc; } -DEFUN (show_bgp_ipv6_vpn_route, - show_bgp_ipv6_vpn_route_cmd, - "show bgp ipv6 vpn X:X::X:X [json]", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) +static int +bgp_show_prefix_list (struct vty *vty, const char *name, + const char *prefix_list_str, afi_t afi, + safi_t safi, enum bgp_show_type type) { - int idx_ipv6 = 4; - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} + struct prefix_list *plist; + struct bgp *bgp = NULL; -DEFUN (show_bgp_ipv4_vpn_rd_route, - show_bgp_ipv4_vpn_rd_route_cmd, - "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D [json]", - SHOW_STR - BGP_STR - IP_STR - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - int idx_ext_community = 5; - int idx_ipv4 = 6; - int ret; - struct prefix_rd prd; + if (name && !(bgp = bgp_lookup_by_name(name))) + { + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); + return CMD_WARNING; + } - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + plist = prefix_list_lookup (afi, prefix_list_str); + if (plist == NULL) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% %s is not a valid prefix-list name%s", + prefix_list_str, VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + + return bgp_show (vty, bgp, afi, safi, type, plist, 0); } -DEFUN (show_bgp_ipv6_vpn_rd_route, - show_bgp_ipv6_vpn_rd_route_cmd, - "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X [json]", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) +static int +bgp_show_filter_list (struct vty *vty, const char *name, + const char *filter, afi_t afi, + safi_t safi, enum bgp_show_type type) { - int idx_ext_community = 5; - int idx_ipv6 = 6; - int ret; - struct prefix_rd prd; + struct as_list *as_list; + struct bgp *bgp = NULL; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + if (name && !(bgp = bgp_lookup_by_name(name))) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); -} - -DEFUN (show_ip_bgp_vpnv4_rd_route, - show_ip_bgp_vpnv4_rd_route_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ext_community = 5; - int idx_ipv4 = 6; - int ret; - struct prefix_rd prd; - u_char uj= use_json(argc, argv); - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + as_list = as_list_lookup (filter); + if (as_list == NULL) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); -} -DEFUN (show_ip_bgp_prefix, - show_ip_bgp_prefix_cmd, - "show ip bgp A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int idx_ipv4_prefixlen = 3; - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show (vty, bgp, afi, safi, type, as_list, 0); } -DEFUN (show_ip_bgp_prefix_pathtype, - show_ip_bgp_prefix_pathtype_cmd, - "show ip bgp A.B.C.D/M [json]", +DEFUN (show_ip_bgp_dampening_info, + show_ip_bgp_dampening_params_cmd, + "show ip bgp dampening parameters", SHOW_STR IP_STR BGP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") + "Display detailed information about dampening\n" + "Display detail of configured dampening parameters\n") { - int idx_ipv4_prefixlen = 3; - int idx_bestpath = 4; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv4 (unicast|multicast) A.B.C.D/M [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_ipv4_prefix, - show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 A.B.C.D/M [json]", + +DEFUN (show_ip_bgp_ipv4_dampening_parameters, + show_ip_bgp_ipv4_dampening_parameters_cmd, + "show ip bgp ipv4 dampening parameters", SHOW_STR IP_STR BGP_STR "Address family\n" "Address Family modifier\n" "Address Family modifier\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") + "Display detailed information about dampening\n" + "Display detail of configured dampening parameters\n") { int idx_safi = 4; - int idx_ipv4_prefixlen = 5; - u_char uj = use_json(argc, argv); - - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); + if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * "Display only the bestpath\n" - * "Display only multipaths\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_ipv4_prefix_pathtype, - show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") +static int +bgp_show_route_map (struct vty *vty, const char *name, + const char *rmap_str, afi_t afi, + safi_t safi, enum bgp_show_type type) { - int idx_safi = 4; - int idx_ipv4_prefixlen = 5; - int idx_bestpath = 6; - u_char uj = use_json(argc, argv); + struct route_map *rmap; + struct bgp *bgp = NULL; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} + if (name && !(bgp = bgp_lookup_by_name(name))) + { -DEFUN (show_ip_bgp_vpnv4_all_prefix, - show_ip_bgp_vpnv4_all_prefix_cmd, - "show ip bgp vpnv4 all A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int idx_ipv4_prefixlen = 5; - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_vpnv4_rd_prefix, - show_ip_bgp_vpnv4_rd_prefix_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int idx_ext_community = 5; - int idx_ipv4_prefixlen = 6; - int ret; - struct prefix_rd prd; - - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + rmap = route_map_lookup_by_name (rmap_str); + if (! rmap) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + vty_out (vty, "%% %s is not a valid route-map name%s", + rmap_str, VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); + + return bgp_show (vty, bgp, afi, safi, type, rmap, 0); } -DEFUN (show_ip_bgp_view, - show_ip_bgp_instance_cmd, - "show ip bgp WORD [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "JavaScript Object Notation\n") +static int +bgp_show_community (struct vty *vty, const char *view_name, int argc, + struct cmd_token **argv, int exact, afi_t afi, safi_t safi) { - int idx_word = 4; + struct community *com; + struct buffer *b; struct bgp *bgp; + int i; + char *str; + int first = 0; - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[idx_word]->arg); - if (bgp == NULL) + /* BGP structure lookup */ + if (view_name) + { + bgp = bgp_lookup_by_name (view_name); + if (bgp == NULL) + { + vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); + return CMD_WARNING; + } + } + else + { + bgp = bgp_get_default (); + if (bgp == NULL) { - vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); + vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); return CMD_WARNING; } + } - return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} + 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'); -DEFUN (show_ip_bgp_instance_all, - show_ip_bgp_instance_all_cmd, - "show ip bgp all [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); + str = buffer_getstr (b); + buffer_free (b); - bgp_show_all_instances_routes_vty (vty, AFI_IP, SAFI_UNICAST, uj); - return CMD_SUCCESS; -} + com = community_str2com (str); + XFREE (MTYPE_TMP, str); + if (! com) + { + vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_instance_route, - show_ip_bgp_instance_route_cmd, - "show ip bgp WORD A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_word = 4; - int idx_ipv4 = 5; - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show (vty, bgp, afi, safi, + (exact ? bgp_show_type_community_exact : + bgp_show_type_community), com, 0); } -DEFUN (show_ip_bgp_instance_route_pathtype, - show_ip_bgp_instance_route_pathtype_cmd, - "show ip bgp WORD A.B.C.D [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") +static int +bgp_show_community_list (struct vty *vty, const char *name, + const char *com, int exact, + afi_t afi, safi_t safi) { - int idx_word = 4; - int idx_ipv4 = 5; - int idx_bestpath = 6; - u_char uj = use_json(argc, argv); + struct community_list *list; + struct bgp *bgp = NULL; - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} + if (name && !(bgp = bgp_lookup_by_name(name))) + { + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_instance_prefix, - show_ip_bgp_instance_prefix_cmd, - "show ip bgp WORD A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int idx_word = 4; - int idx_ipv4_prefixlen = 5; - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} + list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); + if (list == NULL) + { + vty_out (vty, "%% %s is not a valid community-list name%s", com, + VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_ip_bgp_instance_prefix_pathtype, - show_ip_bgp_instance_prefix_pathtype_cmd, - "show ip bgp WORD A.B.C.D/M [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_word = 4; - int idx_ipv4_prefixlen = 5; - int idx_bestpath = 6; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show (vty, bgp, afi, safi, + (exact ? bgp_show_type_community_list_exact : + bgp_show_type_community_list), list, 0); } -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp, - show_bgp_cmd, - "show bgp [json]", - SHOW_STR - BGP_STR - "JavaScript Object Notation\n") +static int +bgp_show_prefix_longer (struct vty *vty, const char *name, + const char *prefix, afi_t afi, + safi_t safi, enum bgp_show_type type) { - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); -} + int ret; + struct prefix *p; + struct bgp *bgp = NULL; + if (name && !(bgp = bgp_lookup_by_name(name))) + { + vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); + return CMD_WARNING; + } -DEFUN (show_bgp_ipv6_safi, - show_bgp_ipv6_safi_cmd, - "show bgp ipv6 [json]", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 3; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); + p = prefix_new(); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); -} + ret = str2prefix (prefix, p); + if (! ret) + { + vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); + return CMD_WARNING; + } -static void -bgp_show_ipv6_bgp_deprecate_warning (struct vty *vty) -{ - vty_out (vty, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our" - " next release%sPlese use 'show bgp ipv6' instead%s%s", - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); + ret = bgp_show (vty, bgp, afi, safi, type, p, 0); + prefix_free(p); + return ret; } -/* old command */ -DEFUN (show_ipv6_bgp, - show_ipv6_bgp_cmd, - "show ipv6 bgp [json]", - SHOW_STR - IP_STR - BGP_STR - "JavaScript Object Notation\n") +static struct peer * +peer_lookup_in_view (struct vty *vty, const char *view_name, + const char *ip_str, u_char use_json) { - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); -} + int ret; + struct bgp *bgp; + struct peer *peer; + union sockunion su; -DEFUN (show_bgp_route, - show_bgp_route_cmd, - "show bgp X:X::X:X [json]", - SHOW_STR - BGP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6 = 2; - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} + /* BGP structure lookup. */ + if (view_name) + { + bgp = bgp_lookup_by_name (view_name); + if (! bgp) + { + if (use_json) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Can't find BGP view"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); + return NULL; + } + } + else + { + bgp = bgp_get_default (); + if (! bgp) + { + if (use_json) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No BGP process configured"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); + return NULL; + } + } -DEFUN (show_bgp_ipv6_safi_route, - show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 X:X::X:X [json]", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 3; - int idx_ipv6 = 4; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 X:X::X:X (bestpath|multipath) [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Network in the BGP routing table to display\n" - * "Display only the bestpath\n" - * "Display only multipaths\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_route_pathtype, - show_bgp_route_pathtype_cmd, - "show bgp X:X::X:X [json]", - SHOW_STR - BGP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6 = 2; - int idx_bestpath = 3; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - - -DEFUN (show_bgp_ipv6_safi_route_pathtype, - show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 X:X::X:X [json]", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 3; - int idx_ipv6 = 4; - int idx_bestpath = 5; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - -/* old command */ -DEFUN (show_ipv6_bgp_route, - show_ipv6_bgp_route_cmd, - "show ipv6 bgp X:X::X:X [json]", - SHOW_STR - IP_STR - BGP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6 = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_bgp_prefix, - show_bgp_prefix_cmd, - "show bgp X:X::X:X/M [json]", - SHOW_STR - BGP_STR - "IPv6 prefix /\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6_prefixlen = 2; - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_bgp_ipv6_safi_prefix, - show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 X:X::X:X/M [json]", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IPv6 prefix /, e.g., 3ffe::/16\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 3; - int idx_ipv6_prefixlen = 4; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 X:X::X:X/M (bestpath|multipath) [json]", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "IPv6 prefix /\n" - * "Display only the bestpath\n" - * "Display only multipaths\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_prefix_pathtype, - show_bgp_prefix_pathtype_cmd, - "show bgp X:X::X:X/M [json]", - SHOW_STR - BGP_STR - "IPv6 prefix /\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6_prefixlen = 2; - int idx_bestpath = 3; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - - -DEFUN (show_bgp_ipv6_safi_prefix_pathtype, - show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 X:X::X:X/M [json]", - SHOW_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IPv6 prefix /, e.g., 3ffe::/16\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 3; - int idx_ipv6_prefixlen = 4; - int idx_bestpath = 5; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); - else - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - -/* old command */ -DEFUN (show_ipv6_bgp_prefix, - show_ipv6_bgp_prefix_cmd, - "show ipv6 bgp X:X::X:X/M [json]", - SHOW_STR - IP_STR - BGP_STR - "IPv6 prefix /, e.g., 3ffe::/16\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6_prefixlen = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_view, - show_bgp_instance_cmd, - "show bgp WORD [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "JavaScript Object Notation\n") -{ - int idx_word = 3; - struct bgp *bgp; - - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[idx_word]->arg); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv)); -} - -DEFUN (show_bgp_instance_all, - show_bgp_instance_all_cmd, - "show bgp all [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_ALL_HELP_STR - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - - bgp_show_all_instances_routes_vty (vty, AFI_IP6, SAFI_UNICAST, uj); - return CMD_SUCCESS; -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 X:X::X:X [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Network in the BGP routing table to display\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_route, - show_bgp_instance_route_cmd, - "show bgp WORD X:X::X:X [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_ipv6 = 4; - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 X:X::X:X (bestpath|multipath) [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Network in the BGP routing table to display\n" - * "Display only the bestpath\n" - * "Display only multipaths\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_route_pathtype, - show_bgp_instance_route_pathtype_cmd, - "show bgp WORD X:X::X:X [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Network in the BGP routing table to display\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_ipv6 = 4; - int idx_bestpath = 5; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6]->arg, AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 X:X::X:X/M [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "IPv6 prefix /\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_prefix, - show_bgp_instance_prefix_cmd, - "show bgp WORD X:X::X:X/M [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix /\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_ipv6_prefixlen = 4; - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 X:X::X:X/M (bestpath|multipath) [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "IPv6 prefix /\n" - * "Display only the bestpath\n" - * "Display only multipaths\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_prefix_pathtype, - show_bgp_instance_prefix_pathtype_cmd, - "show bgp WORD X:X::X:X/M [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix /\n" - "Display only the bestpath\n" - "Display only multipaths\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_ipv6_prefixlen = 4; - int idx_bestpath = 5; - u_char uj = use_json(argc, argv); - if (strncmp (argv[idx_bestpath]->arg, "b", 1) == 0) - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 prefix-list WORD", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Display routes conforming to the prefix-list\n" - * "IPv6 prefix-list name\n" - * - */ -DEFUN (show_bgp_instance_prefix_list, - show_bgp_instance_prefix_list_cmd, - "show bgp WORD prefix-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") -{ - int idx_word = 3; - int idx_word_2 = 5; - return bgp_show_prefix_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 filter-list WORD", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Display routes conforming to the filter-list\n" - * "Regular expression access list name\n" - * - */ -DEFUN (show_bgp_instance_filter_list, - show_bgp_instance_filter_list_cmd, - "show bgp WORD filter-list WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 3; - int idx_word_2 = 5; - return bgp_show_filter_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 route-map WORD", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Display routes matching the route-map\n" - * "A route-map to match on\n" - * - */ -DEFUN (show_bgp_instance_route_map, - show_bgp_instance_route_map_cmd, - "show bgp WORD route-map WORD", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_word = 3; - int idx_word_2 = 5; - return bgp_show_route_map (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_route_map); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 community-list (<1-500>|WORD)", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Display routes matching the community-list\n" - * "community-list number\n" - * "community-list name\n" - * - */ -DEFUN (show_bgp_instance_community_list, - show_bgp_instance_community_list_cmd, - "show bgp WORD community-list <(1-500)|WORD>", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - int idx_word = 3; - int idx_comm_list = 5; - return bgp_show_community_list (vty, argv[idx_word]->arg, argv[idx_comm_list]->arg, 0, AFI_IP6, SAFI_UNICAST); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 X:X::X:X/M longer-prefixes", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "IPv6 prefix /\n" - * "Display route and more specific routes\n" - * - */ -DEFUN (show_bgp_instance_prefix_longer, - show_bgp_instance_prefix_longer_cmd, - "show bgp WORD X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IPv6 prefix /\n" - "Display route and more specific routes\n") -{ - int idx_word = 3; - int idx_ipv6_prefixlen = 4; - return bgp_show_prefix_longer (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - - -/* old command */ -DEFUN (show_ipv6_mbgp, - show_ipv6_mbgp_cmd, - "show ipv6 mbgp [json]", - SHOW_STR - IP_STR - MBGP_STR - "JavaScript Object Notation\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, use_json(argc, argv)); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_route, - show_ipv6_mbgp_route_cmd, - "show ipv6 mbgp X:X::X:X [json]", - SHOW_STR - IP_STR - MBGP_STR - "Network in the MBGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6 = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[idx_ipv6]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix, - show_ipv6_mbgp_prefix_cmd, - "show ipv6 mbgp X:X::X:X/M [json]", - SHOW_STR - IP_STR - MBGP_STR - "IPv6 prefix /, e.g., 3ffe::/16\n" - "JavaScript Object Notation\n") -{ - int idx_ipv6_prefixlen = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_route (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} -#endif - - -static int -bgp_show_regexp (struct vty *vty, int argc, struct cmd_token **argv, afi_t afi, - safi_t safi, enum bgp_show_type type) -{ - 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); - return CMD_WARNING; - } - - rc = bgp_show (vty, NULL, afi, safi, type, regex, 0); - bgp_regex_free (regex); - return rc; -} - -DEFUN (show_ip_bgp_regexp, - show_ip_bgp_regexp_cmd, - "show ip bgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_regexp); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics regexp .LINE", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Display routes matching the AS path regular expression\n" - * "A regular-expression to match the BGP AS paths\n" - * - */ -DEFUN (show_ip_bgp_flap_regexp, - show_ip_bgp_flap_regexp_cmd, - "show ip bgp flap-statistics regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_regexp); -} - - -DEFUN (show_ip_bgp_ipv4_regexp, - show_ip_bgp_ipv4_regexp_cmd, - "show ip bgp ipv4 regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - int idx_safi = 4; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, - bgp_show_type_regexp); - - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_regexp); -} - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 regexp .LINE", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes matching the AS path regular expression\n" - * "A regular-expression to match the BGP AS paths\n" - * - */ -DEFUN (show_bgp_regexp, - show_bgp_regexp_cmd, - "show bgp regexp .LINE", - SHOW_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, - bgp_show_type_regexp); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_regexp, - show_ipv6_bgp_regexp_cmd, - "show ipv6 bgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST, - bgp_show_type_regexp); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_regexp, - show_ipv6_mbgp_regexp_cmd, - "show ipv6 mbgp regexp .LINE", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the MBGP AS paths\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_regexp); -} -#endif /* HAVE_IPV6 */ - -static int -bgp_show_prefix_list (struct vty *vty, const char *name, - const char *prefix_list_str, afi_t afi, - safi_t safi, enum bgp_show_type type) -{ - struct prefix_list *plist; - struct bgp *bgp = NULL; - - if (name && !(bgp = bgp_lookup_by_name(name))) - { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); - return CMD_WARNING; - } - - plist = prefix_list_lookup (afi, prefix_list_str); - if (plist == NULL) - { - vty_out (vty, "%% %s is not a valid prefix-list name%s", - prefix_list_str, VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, afi, safi, type, plist, 0); -} - -DEFUN (show_ip_bgp_prefix_list, - show_ip_bgp_prefix_list_cmd, - "show ip bgp prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - int idx_word = 4; - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -DEFUN (show_ip_bgp_instance_prefix_list, - show_ip_bgp_instance_prefix_list_cmd, - "show ip bgp WORD prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - int idx_word = 4; - int idx_word_2 = 6; - return bgp_show_prefix_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics prefix-list WORD", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Display routes conforming to the prefix-list\n" - * "IP prefix-list name\n" - * - */ -DEFUN (show_ip_bgp_flap_prefix_list, - show_ip_bgp_flap_prefix_list_cmd, - "show ip bgp flap-statistics prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - int idx_word = 5; - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix_list); -} - - -DEFUN (show_ip_bgp_ipv4_prefix_list, - show_ip_bgp_ipv4_prefix_list_cmd, - "show ip bgp ipv4 prefix-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes conforming to the prefix-list\n" - "IP prefix-list name\n") -{ - int idx_safi = 4; - int idx_word = 6; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_list); - - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 prefix-list WORD", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes conforming to the prefix-list\n" - * "IPv6 prefix-list name\n" - * - */ -DEFUN (show_bgp_prefix_list, - show_bgp_prefix_list_cmd, - "show bgp prefix-list WORD", - SHOW_STR - BGP_STR - "Display routes conforming to the prefix-list\n" - "IPv6 prefix-list name\n") -{ - int idx_word = 3; - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_prefix_list, - show_ipv6_bgp_prefix_list_cmd, - "show ipv6 bgp prefix-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the prefix-list\n" - "IPv6 prefix-list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_list); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix_list, - show_ipv6_mbgp_prefix_list_cmd, - "show ipv6 mbgp prefix-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the prefix-list\n" - "IPv6 prefix-list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_prefix_list); -} -#endif /* HAVE_IPV6 */ - -static int -bgp_show_filter_list (struct vty *vty, const char *name, - const char *filter, afi_t afi, - safi_t safi, enum bgp_show_type type) -{ - struct as_list *as_list; - struct bgp *bgp = NULL; - - if (name && !(bgp = bgp_lookup_by_name(name))) - { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); - return CMD_WARNING; - } - - as_list = as_list_lookup (filter); - if (as_list == NULL) - { - vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, afi, safi, type, as_list, 0); -} - -DEFUN (show_ip_bgp_filter_list, - show_ip_bgp_filter_list_cmd, - "show ip bgp filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 4; - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -DEFUN (show_ip_bgp_instance_filter_list, - show_ip_bgp_instance_filter_list_cmd, - "show ip bgp WORD filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 4; - int idx_word_2 = 6; - return bgp_show_filter_list (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics filter-list WORD", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Display routes conforming to the filter-list\n" - * "Regular expression access list name\n" - * - */ -DEFUN (show_ip_bgp_flap_filter_list, - show_ip_bgp_flap_filter_list_cmd, - "show ip bgp flap-statistics filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 5; - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_filter_list); -} - - -DEFUN (show_ip_bgp_ipv4_filter_list, - show_ip_bgp_ipv4_filter_list_cmd, - "show ip bgp ipv4 filter-list WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_safi = 4; - int idx_word = 6; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, - bgp_show_type_filter_list); - - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 filter-list WORD", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes conforming to the filter-list\n" - * "Regular expression access list name\n" - * - */ -DEFUN (show_bgp_filter_list, - show_bgp_filter_list_cmd, - "show bgp filter-list WORD", - SHOW_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 3; - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_filter_list, - show_ipv6_bgp_filter_list_cmd, - "show ipv6 bgp filter-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_filter_list); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_filter_list, - show_ipv6_mbgp_filter_list_cmd, - "show ipv6 mbgp filter-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes conforming to the filter-list\n" - "Regular expression access list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_filter_list (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_filter_list); -} -#endif /* HAVE_IPV6 */ - -DEFUN (show_ip_bgp_dampening_info, - show_ip_bgp_dampening_params_cmd, - "show ip bgp dampening parameters", - SHOW_STR - IP_STR - BGP_STR - "Display detailed information about dampening\n" - "Display detail of configured dampening parameters\n") -{ - return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); -} - - -DEFUN (show_ip_bgp_ipv4_dampening_parameters, - show_ip_bgp_ipv4_dampening_parameters_cmd, - "show ip bgp ipv4 dampening parameters", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display detailed information about dampening\n" - "Display detail of configured dampening parameters\n") -{ - int idx_safi = 4; - if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); - - return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); -} - - -DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, - show_ip_bgp_ipv4_dampening_flap_stats_cmd, - "show ip bgp ipv4 dampening flap-statistics", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display detailed information about dampening\n" - "Display flap statistics of routes\n") -{ - int idx_safi = 4; - if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_flap_statistics, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_flap_statistics, NULL, 0); -} - -DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, - show_ip_bgp_ipv4_dampening_dampd_paths_cmd, - "show ip bgp ipv4 dampening dampened-paths", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display detailed information about dampening\n" - "Display paths suppressed due to dampening\n") -{ - int idx_safi = 4; - if (strncmp(argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_dampend_paths, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_dampend_paths, NULL, 0); -} - -static int -bgp_show_route_map (struct vty *vty, const char *name, - const char *rmap_str, afi_t afi, - safi_t safi, enum bgp_show_type type) -{ - struct route_map *rmap; - struct bgp *bgp = NULL; - - if (name && !(bgp = bgp_lookup_by_name(name))) - { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); - return CMD_WARNING; - } - - rmap = route_map_lookup_by_name (rmap_str); - if (! rmap) - { - vty_out (vty, "%% %s is not a valid route-map name%s", - rmap_str, VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, afi, safi, type, rmap, 0); -} - -DEFUN (show_ip_bgp_route_map, - show_ip_bgp_route_map_cmd, - "show ip bgp route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_word = 4; - return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -DEFUN (show_ip_bgp_instance_route_map, - show_ip_bgp_instance_route_map_cmd, - "show ip bgp WORD route-map WORD", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_word = 4; - int idx_word_2 = 6; - return bgp_show_route_map (vty, argv[idx_word]->arg, argv[idx_word_2]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics route-map WORD", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Display routes matching the route-map\n" - * "A route-map to match on\n" - * - */ -DEFUN (show_ip_bgp_flap_route_map, - show_ip_bgp_flap_route_map_cmd, - "show ip bgp flap-statistics route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_word = 5; - return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_route_map); -} - - -DEFUN (show_ip_bgp_ipv4_route_map, - show_ip_bgp_ipv4_route_map_cmd, - "show ip bgp ipv4 route-map WORD", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_safi = 4; - int idx_word = 6; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_MULTICAST, - bgp_show_type_route_map); - - return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 route-map WORD", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes matching the route-map\n" - * "A route-map to match on\n" - * - */ -DEFUN (show_bgp_route_map, - show_bgp_route_map_cmd, - "show bgp route-map WORD", - SHOW_STR - BGP_STR - "Display routes matching the route-map\n" - "A route-map to match on\n") -{ - int idx_word = 3; - return bgp_show_route_map (vty, NULL, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_route_map); -} - - -DEFUN (show_ip_bgp_cidr_only, - show_ip_bgp_cidr_only_cmd, - "show ip bgp cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Display only routes with non-natural netmasks\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_cidr_only, NULL, 0); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics cidr-only", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Display only routes with non-natural netmasks\n" - * - */ -DEFUN (show_ip_bgp_flap_cidr_only, - show_ip_bgp_flap_cidr_only_cmd, - "show ip bgp flap-statistics cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Display only routes with non-natural netmasks\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_cidr_only, NULL, 0); -} - - -DEFUN (show_ip_bgp_ipv4_cidr_only, - show_ip_bgp_ipv4_cidr_only_cmd, - "show ip bgp ipv4 cidr-only", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display only routes with non-natural netmasks\n") -{ - int idx_safi = 4; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_cidr_only, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_cidr_only, NULL, 0); -} - -DEFUN (show_ip_bgp_community_all, - show_ip_bgp_community_all_cmd, - "show ip bgp community", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the communities\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -DEFUN (show_ip_bgp_ipv4_community_all, - show_ip_bgp_ipv4_community_all_cmd, - "show ip bgp ipv4 community", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n") -{ - int idx_safi = 4; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_community_all, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 community", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes matching the communities\n" - * - */ -DEFUN (show_bgp_community_all, - show_bgp_community_all_cmd, - "show bgp community", - SHOW_STR - BGP_STR - "Display routes matching the communities\n") -{ - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_community_all, - show_ipv6_bgp_community_all_cmd, - "show ipv6 bgp community", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_all, - show_ipv6_mbgp_community_all_cmd, - "show ipv6 mbgp community", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the communities\n") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_community_all, NULL, 0); -} -#endif /* HAVE_IPV6 */ - -static int -bgp_show_community (struct vty *vty, const char *view_name, int argc, - struct cmd_token **argv, int exact, afi_t afi, safi_t safi) -{ - struct community *com; - struct buffer *b; - struct bgp *bgp; - int i; - char *str; - int first = 0; - - /* BGP structure lookup */ - if (view_name) - { - bgp = bgp_lookup_by_name (view_name); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); - return CMD_WARNING; - } - } - else - { - bgp = bgp_get_default (); - if (bgp == NULL) - { - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - 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'); - - str = buffer_getstr (b); - buffer_free (b); - - com = community_str2com (str); - XFREE (MTYPE_TMP, str); - if (! com) - { - vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, afi, safi, - (exact ? bgp_show_type_community_exact : - bgp_show_type_community), com, 0); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * 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" - * - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * - */ -DEFUN (show_ip_bgp_community, - show_ip_bgp_community_cmd, - "show ip bgp community ", - SHOW_STR - IP_STR - BGP_STR - "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") -{ - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); -} - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * 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" - * - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * 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" - * 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" - * - */ -DEFUN (show_ip_bgp_ipv4_community, - show_ip_bgp_ipv4_community_cmd, - "show ip bgp ipv4 community ", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\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") -{ - int idx_safi = 4; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); -} - - - - -DEFUN (show_bgp_instance_afi_safi_community_all, - show_bgp_instance_afi_safi_community_all_cmd, - "show bgp WORD community", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the communities\n") -{ - int idx_word = 3; - int idx_afi = 4; - int idx_safi = 5; - int afi; - int safi; - struct bgp *bgp; - - /* BGP structure lookup. */ - bgp = bgp_lookup_by_name (argv[idx_word]->arg); - if (bgp == NULL) - { - vty_out (vty, "Can't find BGP instance %s%s", argv[idx_word]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - - afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Address family\n" - * "Address family modifier\n" - * "Address family modifier\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" - * 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" - * 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" - * - * "show bgp WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Address family\n" - * "Address family modifier\n" - * "Address family modifier\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" - * 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" - * 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" - * 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" - * - * "show bgp WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\n" - * "Address family\n" - * "Address family modifier\n" - * "Address family modifier\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" - * 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" - * - */ -DEFUN (show_bgp_instance_afi_safi_community, - show_bgp_instance_afi_safi_community_cmd, - "show bgp WORD community ", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\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") -{ - int idx_word = 3; - int idx_afi = 4; - int idx_safi = 5; - int afi; - int safi; - - afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - return bgp_show_community (vty, argv[idx_word]->arg, argc, argv, 0, afi, safi); -} - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * 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" - * "Exact match of the communities" - * - */ -DEFUN (show_ip_bgp_community_exact, - show_ip_bgp_community_exact_cmd, - "show ip bgp community exact-match", - SHOW_STR - IP_STR - BGP_STR - "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" - "Exact match of the communities") -{ - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); -} - - - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * "Exact match of the communities" - * - * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\n" - * "Address Family modifier\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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - */ -DEFUN (show_ip_bgp_ipv4_community_exact, - show_ip_bgp_ipv4_community_exact_cmd, - "show ip bgp ipv4 community exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\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" - "Exact match of the communities") -{ - int idx_safi = 4; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); -} - - - - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "Address family\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" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * 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" - * 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" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * 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" - * - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * 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" - * - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * - */ -DEFUN (show_bgp_community, - show_bgp_community_cmd, - "show bgp community ", - SHOW_STR - BGP_STR - "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") -{ - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); -} - - - - - - - - -/* old command */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * 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" - * - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * - */ -DEFUN (show_ipv6_bgp_community, - show_ipv6_bgp_community_cmd, - "show ipv6 bgp community ", - SHOW_STR - IPV6_STR - BGP_STR - "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") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ - -/* old command */ - -/* old command */ - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * "Exact match of the communities" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "Address family\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" - * "Exact match of the communities" - * - * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * BGP_STR - * "Address family\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" - * 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" - * "Exact match of the communities" - * - */ -DEFUN (show_bgp_community_exact, - show_bgp_community_exact_cmd, - "show bgp community exact-match", - SHOW_STR - BGP_STR - "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" - "Exact match of the communities") -{ - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); -} - - - - - - - - -/* old command */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * "Exact match of the communities" - * - * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * 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" - * 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" - * "Exact match of the communities" - * - */ -DEFUN (show_ipv6_bgp_community_exact, - show_ipv6_bgp_community_exact_cmd, - "show ipv6 bgp community exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "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" - "Exact match of the communities") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ - -/* old command */ - -/* old command */ - -/* old command */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * 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" - * - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * 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" - * 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" - * - */ -DEFUN (show_ipv6_mbgp_community, - show_ipv6_mbgp_community_cmd, - "show ipv6 mbgp community ", - SHOW_STR - IPV6_STR - MBGP_STR - "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") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST); -} - -/* old command */ - -/* old command */ - -/* old command */ - -/* old command */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * 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" - * 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" - * "Exact match of the communities" - * - * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", - * SHOW_STR - * IPV6_STR - * MBGP_STR - * "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" - * 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" - * "Exact match of the communities" - * - */ -DEFUN (show_ipv6_mbgp_community_exact, - show_ipv6_mbgp_community_exact_cmd, - "show ipv6 mbgp community exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "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" - "Exact match of the communities") -{ - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST); -} - -/* old command */ - -/* old command */ - -/* old command */ -#endif /* HAVE_IPV6 */ - -static int -bgp_show_community_list (struct vty *vty, const char *name, - const char *com, int exact, - afi_t afi, safi_t safi) -{ - struct community_list *list; - struct bgp *bgp = NULL; - - if (name && !(bgp = bgp_lookup_by_name(name))) - { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); - return CMD_WARNING; - } - - list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER); - if (list == NULL) - { - vty_out (vty, "%% %s is not a valid community-list name%s", com, - VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show (vty, bgp, afi, safi, - (exact ? bgp_show_type_community_list_exact : - bgp_show_type_community_list), list, 0); -} - -DEFUN (show_ip_bgp_community_list, - show_ip_bgp_community_list_cmd, - "show ip bgp community-list <(1-500)|WORD>", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - int idx_comm_list = 4; - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_instance_community_list, - show_ip_bgp_instance_community_list_cmd, - "show ip bgp WORD community-list <(1-500)|WORD>", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - int idx_word = 4; - int idx_comm_list = 6; - return bgp_show_community_list (vty, argv[idx_word]->arg, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_ipv4_community_list, - show_ip_bgp_ipv4_community_list_cmd, - "show ip bgp ipv4 community-list <(1-500)|WORD>", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - int idx_safi = 4; - int idx_comm_list = 6; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_community_list_exact, - show_ip_bgp_community_list_exact_cmd, - "show ip bgp community-list <(1-500)|WORD> exact-match", - SHOW_STR - IP_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - int idx_comm_list = 4; - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_UNICAST); -} - -DEFUN (show_ip_bgp_ipv4_community_list_exact, - show_ip_bgp_ipv4_community_list_exact_cmd, - "show ip bgp ipv4 community-list <(1-500)|WORD> exact-match", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - int idx_safi = 4; - int idx_comm_list = 6; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP, SAFI_UNICAST); -} - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 community-list (<1-500>|WORD)", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes matching the community-list\n" - * "community-list number\n" - * "community-list name\n" - * - */ -DEFUN (show_bgp_community_list, - show_bgp_community_list_cmd, - "show bgp community-list <(1-500)|WORD>", - SHOW_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n") -{ - int idx_comm_list = 3; - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 0, AFI_IP6, SAFI_UNICAST); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_community_list, - show_ipv6_bgp_community_list_cmd, - "show ipv6 bgp community-list WORD", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 0, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_list, - show_ipv6_mbgp_community_list_cmd, - "show ipv6 mbgp community-list WORD", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the community-list\n" - "community-list name\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 0, AFI_IP6, SAFI_MULTICAST); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 community-list (<1-500>|WORD) exact-match", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "Display routes matching the community-list\n" - * "community-list number\n" - * "community-list name\n" - * "Exact match of the communities\n" - * - */ -DEFUN (show_bgp_community_list_exact, - show_bgp_community_list_exact_cmd, - "show bgp community-list <(1-500)|WORD> exact-match", - SHOW_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list number\n" - "community-list name\n" - "Exact match of the communities\n") -{ - int idx_comm_list = 3; - return bgp_show_community_list (vty, NULL, argv[idx_comm_list]->arg, 1, AFI_IP6, SAFI_UNICAST); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_community_list_exact, - show_ipv6_bgp_community_list_exact_cmd, - "show ipv6 bgp community-list WORD exact-match", - SHOW_STR - IPV6_STR - BGP_STR - "Display routes matching the community-list\n" - "community-list name\n" - "Exact match of the communities\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 1, AFI_IP6, SAFI_UNICAST); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_community_list_exact, - show_ipv6_mbgp_community_list_exact_cmd, - "show ipv6 mbgp community-list WORD exact-match", - SHOW_STR - IPV6_STR - MBGP_STR - "Display routes matching the community-list\n" - "community-list name\n" - "Exact match of the communities\n") -{ - int idx_word = 4; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_community_list (vty, NULL, argv[idx_word]->arg, 1, AFI_IP6, SAFI_MULTICAST); -} -#endif /* HAVE_IPV6 */ - -static int -bgp_show_prefix_longer (struct vty *vty, const char *name, - const char *prefix, afi_t afi, - safi_t safi, enum bgp_show_type type) -{ - int ret; - struct prefix *p; - struct bgp *bgp = NULL; - - if (name && !(bgp = bgp_lookup_by_name(name))) - { - vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); - return CMD_WARNING; - } - - p = prefix_new(); - - ret = str2prefix (prefix, p); - if (! ret) - { - vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = bgp_show (vty, bgp, afi, safi, type, p, 0); - prefix_free(p); - return ret; -} - -DEFUN (show_ip_bgp_prefix_longer, - show_ip_bgp_prefix_longer_cmd, - "show ip bgp A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - int idx_ipv4_prefixlen = 3; - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -DEFUN (show_ip_bgp_instance_prefix_longer, - show_ip_bgp_instance_prefix_longer_cmd, - "show ip bgp WORD A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - int idx_word = 4; - int idx_ipv4_prefixlen = 5; - return bgp_show_prefix_longer (vty, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * "Display route and more specific routes\n" - * - */ -DEFUN (show_ip_bgp_flap_prefix_longer, - show_ip_bgp_flap_prefix_longer_cmd, - "show ip bgp flap-statistics A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - int idx_ipv4_prefixlen = 4; - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix_longer); -} - - -DEFUN (show_ip_bgp_ipv4_prefix_longer, - show_ip_bgp_ipv4_prefix_longer_cmd, - "show ip bgp ipv4 A.B.C.D/M longer-prefixes", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "Display route and more specific routes\n") -{ - int idx_safi = 4; - int idx_ipv4_prefixlen = 5; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_longer); - - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics A.B.C.D", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "Network in the BGP routing table to display\n" - * - */ -DEFUN (show_ip_bgp_flap_address, - show_ip_bgp_flap_address_cmd, - "show ip bgp flap-statistics A.B.C.D", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "Network in the BGP routing table to display\n") -{ - int idx_ipv4 = 4; - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_address); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics A.B.C.D/M", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * "IP prefix /, e.g., 35.0.0.0/8\n" - * - */ -DEFUN (show_ip_bgp_flap_prefix, - show_ip_bgp_flap_prefix_cmd, - "show ip bgp flap-statistics A.B.C.D/M", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n" - "IP prefix /, e.g., 35.0.0.0/8\n") -{ - int idx_ipv4_prefixlen = 4; - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_prefix); -} - - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 X:X::X:X/M longer-prefixes", - * SHOW_STR - * BGP_STR - * "Address family\n" - * "IPv6 prefix /\n" - * "Display route and more specific routes\n" - * - */ -DEFUN (show_bgp_prefix_longer, - show_bgp_prefix_longer_cmd, - "show bgp X:X::X:X/M longer-prefixes", - SHOW_STR - BGP_STR - "IPv6 prefix /\n" - "Display route and more specific routes\n") -{ - int idx_ipv6_prefixlen = 2; - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - - -/* old command */ -DEFUN (show_ipv6_bgp_prefix_longer, - show_ipv6_bgp_prefix_longer_cmd, - "show ipv6 bgp X:X::X:X/M longer-prefixes", - SHOW_STR - IPV6_STR - BGP_STR - "IPv6 prefix /, e.g., 3ffe::/16\n" - "Display route and more specific routes\n") -{ - int idx_ipv6_prefixlen = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, - bgp_show_type_prefix_longer); -} - -/* old command */ -DEFUN (show_ipv6_mbgp_prefix_longer, - show_ipv6_mbgp_prefix_longer_cmd, - "show ipv6 mbgp X:X::X:X/M longer-prefixes", - SHOW_STR - IPV6_STR - MBGP_STR - "IPv6 prefix /, e.g., 3ffe::/16\n" - "Display route and more specific routes\n") -{ - int idx_ipv6_prefixlen = 3; - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_prefix_longer (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_prefix_longer); -} -#endif /* HAVE_IPV6 */ - -static struct peer * -peer_lookup_in_view (struct vty *vty, const char *view_name, - const char *ip_str, u_char use_json) -{ - int ret; - struct bgp *bgp; - struct peer *peer; - union sockunion su; - - /* BGP structure lookup. */ - if (view_name) - { - bgp = bgp_lookup_by_name (view_name); - if (! bgp) - { - if (use_json) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Can't find BGP view"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "Can't find BGP instance %s%s", view_name, VTY_NEWLINE); - return NULL; - } - } - else - { - bgp = bgp_get_default (); - if (! bgp) - { - if (use_json) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No BGP process configured"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); - return NULL; - } - } - - /* Get peer sockunion. */ - ret = str2sockunion (ip_str, &su); - if (ret < 0) - { - peer = peer_lookup_by_conf_if (bgp, ip_str); - if (!peer) - { - peer = peer_lookup_by_hostname(bgp, ip_str); - - if (!peer) - { - if (use_json) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "malformedAddressOrName", ip_str); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); - return NULL; - } - } - return peer; - } - - /* Peer structure lookup. */ - peer = peer_lookup (bgp, &su); - if (! peer) - { - if (use_json) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning","No such neighbor"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No such neighbor%s", VTY_NEWLINE); - return NULL; - } - - return peer; -} - -enum bgp_stats -{ - BGP_STATS_MAXBITLEN = 0, - BGP_STATS_RIB, - BGP_STATS_PREFIXES, - BGP_STATS_TOTPLEN, - BGP_STATS_UNAGGREGATEABLE, - BGP_STATS_MAX_AGGREGATEABLE, - BGP_STATS_AGGREGATES, - BGP_STATS_SPACE, - BGP_STATS_ASPATH_COUNT, - BGP_STATS_ASPATH_MAXHOPS, - BGP_STATS_ASPATH_TOTHOPS, - BGP_STATS_ASPATH_MAXSIZE, - BGP_STATS_ASPATH_TOTSIZE, - BGP_STATS_ASN_HIGHEST, - BGP_STATS_MAX, -}; - -static const char *table_stats_strs[] = -{ - [BGP_STATS_PREFIXES] = "Total Prefixes", - [BGP_STATS_TOTPLEN] = "Average prefix length", - [BGP_STATS_RIB] = "Total Advertisements", - [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", - [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", - [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", - [BGP_STATS_SPACE] = "Address space advertised", - [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", - [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", - [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", - [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", - [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", - [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", - [BGP_STATS_MAX] = NULL, -}; - -struct bgp_table_stats -{ - struct bgp_table *table; - unsigned long long counts[BGP_STATS_MAX]; -}; - -#if 0 -#define TALLY_SIGFIG 100000 -static unsigned long -ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) -{ - unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); - unsigned long res = (newtot * TALLY_SIGFIG) / count; - unsigned long ret = newtot / count; - - if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) - return ret + 1; - else - return ret; -} -#endif - -static int -bgp_table_stats_walker (struct thread *t) -{ - struct bgp_node *rn; - struct bgp_node *top; - struct bgp_table_stats *ts = THREAD_ARG (t); - unsigned int space = 0; - - if (!(top = bgp_table_top (ts->table))) - return 0; - - switch (top->p.family) - { - case AF_INET: - space = IPV4_MAX_BITLEN; - break; - case AF_INET6: - space = IPV6_MAX_BITLEN; - break; - } - - ts->counts[BGP_STATS_MAXBITLEN] = space; - - for (rn = top; rn; rn = bgp_route_next (rn)) - { - struct bgp_info *ri; - struct bgp_node *prn = bgp_node_parent_nolock (rn); - unsigned int rinum = 0; - - if (rn == top) - continue; - - if (!rn->info) - continue; - - ts->counts[BGP_STATS_PREFIXES]++; - ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; - -#if 0 - ts->counts[BGP_STATS_AVGPLEN] - = ravg_tally (ts->counts[BGP_STATS_PREFIXES], - ts->counts[BGP_STATS_AVGPLEN], - rn->p.prefixlen); -#endif - - /* check if the prefix is included by any other announcements */ - while (prn && !prn->info) - prn = bgp_node_parent_nolock (prn); - - if (prn == NULL || prn == top) - { - ts->counts[BGP_STATS_UNAGGREGATEABLE]++; - /* announced address space */ - if (space) - ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); - } - else if (prn->info) - ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; - - for (ri = rn->info; ri; ri = ri->next) - { - rinum++; - ts->counts[BGP_STATS_RIB]++; - - if (ri->attr && - (CHECK_FLAG (ri->attr->flag, - ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) - ts->counts[BGP_STATS_AGGREGATES]++; - - /* as-path stats */ - if (ri->attr && ri->attr->aspath) - { - unsigned int hops = aspath_count_hops (ri->attr->aspath); - unsigned int size = aspath_size (ri->attr->aspath); - as_t highest = aspath_highest (ri->attr->aspath); - - ts->counts[BGP_STATS_ASPATH_COUNT]++; - - if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) - ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; - - if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) - ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; - - ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; - ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; -#if 0 - ts->counts[BGP_STATS_ASPATH_AVGHOPS] - = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], - ts->counts[BGP_STATS_ASPATH_AVGHOPS], - hops); - ts->counts[BGP_STATS_ASPATH_AVGSIZE] - = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], - ts->counts[BGP_STATS_ASPATH_AVGSIZE], - size); -#endif - if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) - ts->counts[BGP_STATS_ASN_HIGHEST] = highest; - } - } - } - return 0; -} - -static int -bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) -{ - struct bgp_table_stats ts; - unsigned int i; - - if (!bgp->rib[afi][safi]) - { - vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", - afi, safi, VTY_NEWLINE); - return CMD_WARNING; - } - - memset (&ts, 0, sizeof (ts)); - ts.table = bgp->rib[afi][safi]; - thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); - - vty_out (vty, "BGP %s RIB statistics%s%s", - afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); - - for (i = 0; i < BGP_STATS_MAX; i++) - { - if (!table_stats_strs[i]) - continue; - - switch (i) - { -#if 0 - case BGP_STATS_ASPATH_AVGHOPS: - case BGP_STATS_ASPATH_AVGSIZE: - case BGP_STATS_AVGPLEN: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12.2f", - (float)ts.counts[i] / (float)TALLY_SIGFIG); - break; -#endif - case BGP_STATS_ASPATH_TOTHOPS: - case BGP_STATS_ASPATH_TOTSIZE: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12.2f", - ts.counts[i] ? - (float)ts.counts[i] / - (float)ts.counts[BGP_STATS_ASPATH_COUNT] - : 0); - break; - case BGP_STATS_TOTPLEN: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12.2f", - ts.counts[i] ? - (float)ts.counts[i] / - (float)ts.counts[BGP_STATS_PREFIXES] - : 0); - break; - case BGP_STATS_SPACE: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); - if (ts.counts[BGP_STATS_MAXBITLEN] < 9) - break; - vty_out (vty, "%30s: ", "%% announced "); - vty_out (vty, "%12.2f%s", - 100 * (float)ts.counts[BGP_STATS_SPACE] / - (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), - VTY_NEWLINE); - vty_out (vty, "%30s: ", "/8 equivalent "); - vty_out (vty, "%12.2f%s", - (float)ts.counts[BGP_STATS_SPACE] / - (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), - VTY_NEWLINE); - if (ts.counts[BGP_STATS_MAXBITLEN] < 25) - break; - vty_out (vty, "%30s: ", "/24 equivalent "); - vty_out (vty, "%12.2f", - (float)ts.counts[BGP_STATS_SPACE] / - (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); - break; - default: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12llu", ts.counts[i]); + /* Get peer sockunion. */ + ret = str2sockunion (ip_str, &su); + if (ret < 0) + { + peer = peer_lookup_by_conf_if (bgp, ip_str); + if (!peer) + { + peer = peer_lookup_by_hostname(bgp, ip_str); + + if (!peer) + { + if (use_json) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "malformedAddressOrName", ip_str); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); + return NULL; + } } - - vty_out (vty, "%s", VTY_NEWLINE); + return peer; } - return CMD_SUCCESS; -} -static int -bgp_table_stats_vty (struct vty *vty, const char *name, - const char *afi_str, const char *safi_str) -{ - struct bgp *bgp; - afi_t afi; - safi_t safi; - - if (name) - bgp = bgp_lookup_by_name (name); - else - bgp = bgp_get_default (); - - if (!bgp) - { - vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (strncmp (afi_str, "ipv", 3) == 0) + /* Peer structure lookup. */ + peer = peer_lookup (bgp, &su); + if (! peer) { - if (strncmp (afi_str, "ipv4", 4) == 0) - afi = AFI_IP; - else if (strncmp (afi_str, "ipv6", 4) == 0) - afi = AFI_IP6; - else + if (use_json) { - vty_out (vty, "%% Invalid address family %s%s", - afi_str, VTY_NEWLINE); - return CMD_WARNING; + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning","No such neighbor"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); } - if (strncmp (safi_str, "m", 1) == 0) - safi = SAFI_MULTICAST; - else if (strncmp (safi_str, "u", 1) == 0) - safi = SAFI_UNICAST; - else if (strncmp (safi_str, "e", 1) == 0) - safi = SAFI_ENCAP; - else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) - safi = SAFI_MPLS_VPN; else - { - vty_out (vty, "%% Invalid subsequent address family %s%s", - safi_str, VTY_NEWLINE); - return CMD_WARNING; - } - } - else - { - vty_out (vty, "%% Invalid address family \"%s\"%s", - afi_str, VTY_NEWLINE); - return CMD_WARNING; + vty_out (vty, "No such neighbor%s", VTY_NEWLINE); + return NULL; } - - return bgp_table_stats (vty, bgp, afi, safi); + + return peer; } -DEFUN (show_bgp_statistics, - show_bgp_statistics_cmd, - "show bgp statistics", - SHOW_STR - BGP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "BGP RIB advertisement statistics\n") +enum bgp_stats { - int idx_afi = 2; - int idx_safi = 3; - return bgp_table_stats_vty (vty, NULL, argv[idx_afi]->arg, argv[idx_safi]->arg); -} + BGP_STATS_MAXBITLEN = 0, + BGP_STATS_RIB, + BGP_STATS_PREFIXES, + BGP_STATS_TOTPLEN, + BGP_STATS_UNAGGREGATEABLE, + BGP_STATS_MAX_AGGREGATEABLE, + BGP_STATS_AGGREGATES, + BGP_STATS_SPACE, + BGP_STATS_ASPATH_COUNT, + BGP_STATS_ASPATH_MAXHOPS, + BGP_STATS_ASPATH_TOTHOPS, + BGP_STATS_ASPATH_MAXSIZE, + BGP_STATS_ASPATH_TOTSIZE, + BGP_STATS_ASN_HIGHEST, + BGP_STATS_MAX, +}; -DEFUN (show_bgp_statistics_view, - show_bgp_statistics_view_cmd, - "show bgp WORD statistics", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "BGP RIB advertisement statistics\n") +static const char *table_stats_strs[] = { - int idx_word = 3; - int idx_afi = 4; - return bgp_table_stats_vty (vty, NULL, argv[idx_word]->arg, argv[idx_afi]->arg); -} + [BGP_STATS_PREFIXES] = "Total Prefixes", + [BGP_STATS_TOTPLEN] = "Average prefix length", + [BGP_STATS_RIB] = "Total Advertisements", + [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes", + [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes", + [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements", + [BGP_STATS_SPACE] = "Address space advertised", + [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths", + [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)", + [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)", + [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)", + [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)", + [BGP_STATS_ASN_HIGHEST] = "Highest public ASN", + [BGP_STATS_MAX] = NULL, +}; -enum bgp_pcounts +struct bgp_table_stats { - PCOUNT_ADJ_IN = 0, - PCOUNT_DAMPED, - PCOUNT_REMOVED, - PCOUNT_HISTORY, - PCOUNT_STALE, - PCOUNT_VALID, - PCOUNT_ALL, - PCOUNT_COUNTED, - PCOUNT_PFCNT, /* the figure we display to users */ - PCOUNT_MAX, + struct bgp_table *table; + unsigned long long counts[BGP_STATS_MAX]; }; -static const char *pcount_strs[] = +#if 0 +#define TALLY_SIGFIG 100000 +static unsigned long +ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) { - [PCOUNT_ADJ_IN] = "Adj-in", - [PCOUNT_DAMPED] = "Damped", - [PCOUNT_REMOVED] = "Removed", - [PCOUNT_HISTORY] = "History", - [PCOUNT_STALE] = "Stale", - [PCOUNT_VALID] = "Valid", - [PCOUNT_ALL] = "All RIB", - [PCOUNT_COUNTED] = "PfxCt counted", - [PCOUNT_PFCNT] = "Useable", - [PCOUNT_MAX] = NULL, -}; + unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); + unsigned long res = (newtot * TALLY_SIGFIG) / count; + unsigned long ret = newtot / count; + + if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) + return ret + 1; + else + return ret; +} +#endif -struct peer_pcounts +static int +bgp_table_stats_walker (struct thread *t) { - unsigned int count[PCOUNT_MAX]; - const struct peer *peer; - const struct bgp_table *table; -}; + struct bgp_node *rn; + struct bgp_node *top; + struct bgp_table_stats *ts = THREAD_ARG (t); + unsigned int space = 0; + + if (!(top = bgp_table_top (ts->table))) + return 0; + + switch (top->p.family) + { + case AF_INET: + space = IPV4_MAX_BITLEN; + break; + case AF_INET6: + space = IPV6_MAX_BITLEN; + break; + } + + ts->counts[BGP_STATS_MAXBITLEN] = space; -static int -bgp_peer_count_walker (struct thread *t) -{ - struct bgp_node *rn; - struct peer_pcounts *pc = THREAD_ARG (t); - const struct peer *peer = pc->peer; - - for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) + for (rn = top; rn; rn = bgp_route_next (rn)) { - struct bgp_adj_in *ain; struct bgp_info *ri; + struct bgp_node *prn = bgp_node_parent_nolock (rn); + unsigned int rinum = 0; - for (ain = rn->adj_in; ain; ain = ain->next) - if (ain->peer == peer) - pc->count[PCOUNT_ADJ_IN]++; + if (rn == top) + continue; + + if (!rn->info) + continue; + + ts->counts[BGP_STATS_PREFIXES]++; + ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; +#if 0 + ts->counts[BGP_STATS_AVGPLEN] + = ravg_tally (ts->counts[BGP_STATS_PREFIXES], + ts->counts[BGP_STATS_AVGPLEN], + rn->p.prefixlen); +#endif + + /* check if the prefix is included by any other announcements */ + while (prn && !prn->info) + prn = bgp_node_parent_nolock (prn); + + if (prn == NULL || prn == top) + { + ts->counts[BGP_STATS_UNAGGREGATEABLE]++; + /* announced address space */ + if (space) + ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen); + } + else if (prn->info) + ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; + for (ri = rn->info; ri; ri = ri->next) { - char buf[SU_ADDRSTRLEN]; - - if (ri->peer != peer) - continue; - - pc->count[PCOUNT_ALL]++; + rinum++; + ts->counts[BGP_STATS_RIB]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) - pc->count[PCOUNT_DAMPED]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) - pc->count[PCOUNT_HISTORY]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) - pc->count[PCOUNT_REMOVED]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) - pc->count[PCOUNT_STALE]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) - pc->count[PCOUNT_VALID]++; - if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) - pc->count[PCOUNT_PFCNT]++; + if (ri->attr && + (CHECK_FLAG (ri->attr->flag, + ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) + ts->counts[BGP_STATS_AGGREGATES]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) - { - pc->count[PCOUNT_COUNTED]++; - if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) - zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x", - peer->host, - inet_ntop(rn->p.family, &rn->p.u.prefix, - buf, SU_ADDRSTRLEN), - rn->p.prefixlen, - ri->flags); - } - else + /* as-path stats */ + if (ri->attr && ri->attr->aspath) { - if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) - zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x", - peer->host, - inet_ntop(rn->p.family, &rn->p.u.prefix, - buf, SU_ADDRSTRLEN), - rn->p.prefixlen, - ri->flags); + unsigned int hops = aspath_count_hops (ri->attr->aspath); + unsigned int size = aspath_size (ri->attr->aspath); + as_t highest = aspath_highest (ri->attr->aspath); + + ts->counts[BGP_STATS_ASPATH_COUNT]++; + + if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) + ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; + + if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) + ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; + + ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; + ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; +#if 0 + ts->counts[BGP_STATS_ASPATH_AVGHOPS] + = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], + ts->counts[BGP_STATS_ASPATH_AVGHOPS], + hops); + ts->counts[BGP_STATS_ASPATH_AVGSIZE] + = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], + ts->counts[BGP_STATS_ASPATH_AVGSIZE], + size); +#endif + if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) + ts->counts[BGP_STATS_ASN_HIGHEST] = highest; } } } @@ -12149,556 +8490,376 @@ bgp_peer_count_walker (struct thread *t) } static int -bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_char use_json) +bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) { - struct peer_pcounts pcounts = { .peer = peer }; + struct bgp_table_stats ts; unsigned int i; - json_object *json = NULL; - json_object *json_loop = NULL; - - if (use_json) - { - json = json_object_new_object(); - json_loop = json_object_new_object(); - } - if (!peer || !peer->bgp || !peer->afc[afi][safi] - || !peer->bgp->rib[afi][safi]) + if (!bgp->rib[afi][safi]) { - if (use_json) - { - json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); - json_object_free(json); - } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - + vty_out (vty, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s", + afi, safi, VTY_NEWLINE); return CMD_WARNING; } - memset (&pcounts, 0, sizeof(pcounts)); - pcounts.peer = peer; - pcounts.table = peer->bgp->rib[afi][safi]; - - /* in-place call via thread subsystem so as to record execution time - * * stats for the thread-walk (i.e. ensure this can't be blamed on - * * on just vty_read()). - * */ - thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); - - if (use_json) - { - json_object_string_add(json, "prefixCountsFor", peer->host); - json_object_string_add(json, "multiProtocol", afi_safi_print (afi, safi)); - json_object_int_add(json, "pfxCounter", peer->pcount[afi][safi]); - - for (i = 0; i < PCOUNT_MAX; i++) - json_object_int_add(json_loop, pcount_strs[i], pcounts.count[i]); - - json_object_object_add(json, "ribTableWalkCounters", json_loop); + memset (&ts, 0, sizeof (ts)); + ts.table = bgp->rib[afi][safi]; + thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); - if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) - { - json_object_string_add(json, "pfxctDriftFor", peer->host); - json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); - } - vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); - json_object_free(json); - } - else + vty_out (vty, "BGP %s RIB statistics%s%s", + afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); + + for (i = 0; i < BGP_STATS_MAX; i++) { - - if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) - { - vty_out (vty, "Prefix counts for %s/%s, %s%s", - peer->hostname, peer->host, afi_safi_print (afi, safi), - VTY_NEWLINE); - } - else - { - vty_out (vty, "Prefix counts for %s, %s%s", - peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); - } - - vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); - vty_out (vty, "%sCounts from RIB table walk:%s%s", - VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); - - for (i = 0; i < PCOUNT_MAX; i++) - vty_out (vty, "%20s: %-10d%s", pcount_strs[i], pcounts.count[i], VTY_NEWLINE); - - if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) + if (!table_stats_strs[i]) + continue; + + switch (i) { - vty_out (vty, "%s [pcount] PfxCt drift!%s", - peer->host, VTY_NEWLINE); - vty_out (vty, "Please report this bug, with the above command output%s", - VTY_NEWLINE); +#if 0 + case BGP_STATS_ASPATH_AVGHOPS: + case BGP_STATS_ASPATH_AVGSIZE: + case BGP_STATS_AVGPLEN: + vty_out (vty, "%-30s: ", table_stats_strs[i]); + vty_out (vty, "%12.2f", + (float)ts.counts[i] / (float)TALLY_SIGFIG); + break; +#endif + case BGP_STATS_ASPATH_TOTHOPS: + case BGP_STATS_ASPATH_TOTSIZE: + vty_out (vty, "%-30s: ", table_stats_strs[i]); + vty_out (vty, "%12.2f", + ts.counts[i] ? + (float)ts.counts[i] / + (float)ts.counts[BGP_STATS_ASPATH_COUNT] + : 0); + break; + case BGP_STATS_TOTPLEN: + vty_out (vty, "%-30s: ", table_stats_strs[i]); + vty_out (vty, "%12.2f", + ts.counts[i] ? + (float)ts.counts[i] / + (float)ts.counts[BGP_STATS_PREFIXES] + : 0); + break; + case BGP_STATS_SPACE: + vty_out (vty, "%-30s: ", table_stats_strs[i]); + vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); + if (ts.counts[BGP_STATS_MAXBITLEN] < 9) + break; + vty_out (vty, "%30s: ", "%% announced "); + vty_out (vty, "%12.2f%s", + 100 * (float)ts.counts[BGP_STATS_SPACE] / + (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), + VTY_NEWLINE); + vty_out (vty, "%30s: ", "/8 equivalent "); + vty_out (vty, "%12.2f%s", + (float)ts.counts[BGP_STATS_SPACE] / + (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), + VTY_NEWLINE); + if (ts.counts[BGP_STATS_MAXBITLEN] < 25) + break; + vty_out (vty, "%30s: ", "/24 equivalent "); + vty_out (vty, "%12.2f", + (float)ts.counts[BGP_STATS_SPACE] / + (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); + break; + default: + vty_out (vty, "%-30s: ", table_stats_strs[i]); + vty_out (vty, "%12llu", ts.counts[i]); } + + vty_out (vty, "%s", VTY_NEWLINE); } - return CMD_SUCCESS; } -DEFUN (show_ip_bgp_neighbor_prefix_counts, - show_ip_bgp_neighbor_prefix_counts_cmd, - "show ip bgp neighbors prefix-counts [json]", - SHOW_STR - IP_STR - BGP_STR - "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 detailed prefix count information\n" - "JavaScript Object Notation\n") -{ - int idx_peer = 4; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); -} - -DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, - show_ip_bgp_instance_neighbor_prefix_counts_cmd, - "show ip bgp WORD neighbors prefix-counts [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "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 detailed prefix count information\n" - "JavaScript Object Notation\n") +static int +bgp_table_stats_vty (struct vty *vty, const char *name, + const char *afi_str, const char *safi_str) { - int idx_word = 4; - int idx_peer = 6; - struct peer *peer; - u_char uj = use_json(argc, argv); + struct bgp *bgp; + afi_t afi; + safi_t safi; + + if (name) + bgp = bgp_lookup_by_name (name); + else + bgp = bgp_get_default (); - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; + if (!bgp) + { + vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (strncmp (afi_str, "ipv", 3) == 0) + { + if (strncmp (afi_str, "ipv4", 4) == 0) + afi = AFI_IP; + else if (strncmp (afi_str, "ipv6", 4) == 0) + afi = AFI_IP6; + else + { + vty_out (vty, "%% Invalid address family %s%s", + afi_str, VTY_NEWLINE); + return CMD_WARNING; + } + if (strncmp (safi_str, "m", 1) == 0) + safi = SAFI_MULTICAST; + else if (strncmp (safi_str, "u", 1) == 0) + safi = SAFI_UNICAST; + else if (strncmp (safi_str, "e", 1) == 0) + safi = SAFI_ENCAP; + else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) + safi = SAFI_MPLS_VPN; + else + { + vty_out (vty, "%% Invalid subsequent address family %s%s", + safi_str, VTY_NEWLINE); + return CMD_WARNING; + } + } + else + { + vty_out (vty, "%% Invalid address family \"%s\"%s", + afi_str, VTY_NEWLINE); + return CMD_WARNING; + } - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); + return bgp_table_stats (vty, bgp, afi, safi); } -DEFUN (show_bgp_ipv6_neighbor_prefix_counts, - show_bgp_ipv6_neighbor_prefix_counts_cmd, - "show bgp ipv6 neighbors prefix-counts [json]", +DEFUN (show_bgp_statistics, + show_bgp_statistics_cmd, + "show bgp statistics", SHOW_STR BGP_STR "Address family\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 detailed prefix count information\n" - "JavaScript Object Notation\n") + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "BGP RIB advertisement statistics\n") { - int idx_peer = 4; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); + int idx_afi = 2; + int idx_safi = 3; + return bgp_table_stats_vty (vty, NULL, argv[idx_afi]->arg, argv[idx_safi]->arg); } -DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, - show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, - "show bgp WORD ipv6 neighbors prefix-counts [json]", +DEFUN (show_bgp_statistics_view, + show_bgp_statistics_view_cmd, + "show bgp WORD statistics", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR "Address family\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 detailed prefix count information\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_peer = 6; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); -} - -DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, - show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, - "show ip bgp ipv4 neighbors prefix-counts [json]", - SHOW_STR - IP_STR - BGP_STR "Address family\n" "Address Family modifier\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 detailed prefix count information\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 4; - int idx_peer = 6; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); - - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); -} - -DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, - show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, - "show ip bgp vpnv4 all neighbors prefix-counts [json]", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" "Address Family modifier\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 detailed prefix count information\n" - "JavaScript Object Notation\n") -{ - int idx_peer = 6; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); -} - -static void -show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, - int in, const char *rmap_name, u_char use_json, json_object *json) + "BGP RIB advertisement statistics\n") { - struct bgp_table *table; - struct bgp_adj_in *ain; - struct bgp_adj_out *adj; - unsigned long output_count; - unsigned long filtered_count; - struct bgp_node *rn; - int header1 = 1; - struct bgp *bgp; - int header2 = 1; - struct attr attr; - struct attr_extra extra; - int ret; - struct update_subgroup *subgrp; - json_object *json_scode = NULL; - json_object *json_ocode = NULL; - json_object *json_ar = NULL; - struct peer_af *paf; - - if (use_json) - { - json_scode = json_object_new_object(); - json_ocode = json_object_new_object(); - json_ar = json_object_new_object(); - - json_object_string_add(json_scode, "suppressed", "s"); - json_object_string_add(json_scode, "damped", "d"); - json_object_string_add(json_scode, "history", "h"); - json_object_string_add(json_scode, "valid", "*"); - json_object_string_add(json_scode, "best", ">"); - json_object_string_add(json_scode, "multipath", "="); - json_object_string_add(json_scode, "internal", "i"); - json_object_string_add(json_scode, "ribFailure", "r"); - json_object_string_add(json_scode, "stale", "S"); - json_object_string_add(json_scode, "removed", "R"); - - json_object_string_add(json_ocode, "igp", "i"); - json_object_string_add(json_ocode, "egp", "e"); - json_object_string_add(json_ocode, "incomplete", "?"); - } - - bgp = peer->bgp; + int idx_word = 3; + int idx_afi = 4; + return bgp_table_stats_vty (vty, NULL, argv[idx_word]->arg, argv[idx_afi]->arg); +} - if (! bgp) - { - if (use_json) - { - json_object_string_add(json, "alert", "no BGP"); - vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); - json_object_free(json); - } - else - vty_out (vty, "%% No bgp%s", VTY_NEWLINE); - return; - } +enum bgp_pcounts +{ + PCOUNT_ADJ_IN = 0, + PCOUNT_DAMPED, + PCOUNT_REMOVED, + PCOUNT_HISTORY, + PCOUNT_STALE, + PCOUNT_VALID, + PCOUNT_ALL, + PCOUNT_COUNTED, + PCOUNT_PFCNT, /* the figure we display to users */ + PCOUNT_MAX, +}; - table = bgp->rib[afi][safi]; +static const char *pcount_strs[] = +{ + [PCOUNT_ADJ_IN] = "Adj-in", + [PCOUNT_DAMPED] = "Damped", + [PCOUNT_REMOVED] = "Removed", + [PCOUNT_HISTORY] = "History", + [PCOUNT_STALE] = "Stale", + [PCOUNT_VALID] = "Valid", + [PCOUNT_ALL] = "All RIB", + [PCOUNT_COUNTED] = "PfxCt counted", + [PCOUNT_PFCNT] = "Useable", + [PCOUNT_MAX] = NULL, +}; - output_count = filtered_count = 0; - subgrp = peer_subgroup(peer, afi, safi); +struct peer_pcounts +{ + unsigned int count[PCOUNT_MAX]; + const struct peer *peer; + const struct bgp_table *table; +}; - if (!in && subgrp && CHECK_FLAG (subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) +static int +bgp_peer_count_walker (struct thread *t) +{ + struct bgp_node *rn; + struct peer_pcounts *pc = THREAD_ARG (t); + const struct peer *peer = pc->peer; + + for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) { - if (use_json) - { - json_object_int_add(json, "bgpTableVersion", table->version); - json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); - json_object_object_add(json, "bgpStatusCodes", json_scode); - json_object_object_add(json, "bgpOriginCodes", json_ocode); - json_object_string_add(json, "bgpOriginatingDefaultNetwork", "0.0.0.0"); - } - else - { - vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE); - vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - - vty_out (vty, "Originating default network 0.0.0.0%s%s", - VTY_NEWLINE, VTY_NEWLINE); - } - header1 = 0; - } + struct bgp_adj_in *ain; + struct bgp_info *ri; + + for (ain = rn->adj_in; ain; ain = ain->next) + if (ain->peer == peer) + pc->count[PCOUNT_ADJ_IN]++; - attr.extra = &extra; - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) - { - if (in) + for (ri = rn->info; ri; ri = ri->next) { - for (ain = rn->adj_in; ain; ain = ain->next) + char buf[SU_ADDRSTRLEN]; + + if (ri->peer != peer) + continue; + + pc->count[PCOUNT_ALL]++; + + if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) + pc->count[PCOUNT_DAMPED]++; + if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) + pc->count[PCOUNT_HISTORY]++; + if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)) + pc->count[PCOUNT_REMOVED]++; + if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) + pc->count[PCOUNT_STALE]++; + if (CHECK_FLAG (ri->flags, BGP_INFO_VALID)) + pc->count[PCOUNT_VALID]++; + if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) + pc->count[PCOUNT_PFCNT]++; + + if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) { - if (ain->peer == peer) - { - if (header1) - { - if (use_json) - { - json_object_int_add(json, "bgpTableVersion", 0); - json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); - json_object_object_add(json, "bgpStatusCodes", json_scode); - json_object_object_add(json, "bgpOriginCodes", json_ocode); - } - else - { - vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); - vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - } - header1 = 0; - } - if (header2) - { - if (!use_json) - vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); - header2 = 0; - } - if (ain->attr) - { - bgp_attr_dup(&attr, ain->attr); - if (bgp_input_modifier(peer, &rn->p, &attr, afi, safi, rmap_name) != RMAP_DENY) - { - route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); - output_count++; - } - else - filtered_count++; - } - } + pc->count[PCOUNT_COUNTED]++; + if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) + zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x", + peer->host, + inet_ntop(rn->p.family, &rn->p.u.prefix, + buf, SU_ADDRSTRLEN), + rn->p.prefixlen, + ri->flags); + } + else + { + if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) + zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x", + peer->host, + inet_ntop(rn->p.family, &rn->p.u.prefix, + buf, SU_ADDRSTRLEN), + rn->p.prefixlen, + ri->flags); } } - else - { - for (adj = rn->adj_out; adj; adj = adj->next) - SUBGRP_FOREACH_PEER(adj->subgroup, paf) - if (paf->peer == peer) - { - if (header1) - { - if (use_json) - { - json_object_int_add(json, "bgpTableVersion", table->version); - json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); - json_object_object_add(json, "bgpStatusCodes", json_scode); - json_object_object_add(json, "bgpOriginCodes", json_ocode); - } - else - { - vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, - inet_ntoa (bgp->router_id), VTY_NEWLINE); - vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); - } - header1 = 0; - } - - if (header2) - { - if (!use_json) - vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); - header2 = 0; - } - - if (adj->attr) - { - bgp_attr_dup(&attr, adj->attr); - ret = bgp_output_modifier(peer, &rn->p, &attr, afi, safi, rmap_name); - if (ret != RMAP_DENY) - { - route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); - output_count++; - } - else - filtered_count++; - } - } - } - } - if (use_json) - json_object_object_add(json, "advertisedRoutes", json_ar); - - if (output_count != 0) - { - if (use_json) - json_object_int_add(json, "totalPrefixCounter", output_count); - else - vty_out (vty, "%sTotal number of prefixes %ld%s", - VTY_NEWLINE, output_count, VTY_NEWLINE); - } - if (use_json) - { - vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); - json_object_free(json); } - + return 0; } static int -peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, - int in, const char *rmap_name, u_char use_json) +bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_char use_json) { + struct peer_pcounts pcounts = { .peer = peer }; + unsigned int i; json_object *json = NULL; + json_object *json_loop = NULL; if (use_json) - json = json_object_new_object(); - - if (!peer || !peer->afc[afi][safi]) { - if (use_json) - { - json_object_string_add(json, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); - json_object_free(json); - } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - - return CMD_WARNING; + json = json_object_new_object(); + json_loop = json_object_new_object(); } - - if (in && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) + + if (!peer || !peer->bgp || !peer->afc[afi][safi] + || !peer->bgp->rib[afi][safi]) { if (use_json) { - json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); + json_object_string_add(json, "warning", "No such neighbor or address family"); vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); json_object_free(json); } else - vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE); + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); return CMD_WARNING; } + + memset (&pcounts, 0, sizeof(pcounts)); + pcounts.peer = peer; + pcounts.table = peer->bgp->rib[afi][safi]; + + /* in-place call via thread subsystem so as to record execution time + * * stats for the thread-walk (i.e. ensure this can't be blamed on + * * on just vty_read()). + * */ + thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); - show_adj_route (vty, peer, afi, safi, in, rmap_name, use_json, json); + if (use_json) + { + json_object_string_add(json, "prefixCountsFor", peer->host); + json_object_string_add(json, "multiProtocol", afi_safi_print (afi, safi)); + json_object_int_add(json, "pfxCounter", peer->pcount[afi][safi]); - return CMD_SUCCESS; -} + for (i = 0; i < PCOUNT_MAX; i++) + json_object_int_add(json_loop, pcount_strs[i], pcounts.count[i]); -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp WORD neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "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 routes advertised to a BGP neighbor\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_instance_neighbor_advertised_route, - show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show ip bgp WORD neighbors advertised-routes [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - int idx_word = 4; - int idx_peer = 6; - struct peer *peer; - u_char uj = use_json(argc, argv); + json_object_object_add(json, "ribTableWalkCounters", json_loop); - if (argc == 4 || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); + if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) + { + json_object_string_add(json, "pfxctDriftFor", peer->host); + json_object_string_add(json, "recommended", "Please report this bug, with the above command output"); + } + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); + json_object_free(json); + } else - peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); + { - if (! peer) - return CMD_WARNING; + if (peer->hostname && bgp_flag_check(peer->bgp, BGP_FLAG_SHOW_HOSTNAME)) + { + vty_out (vty, "Prefix counts for %s/%s, %s%s", + peer->hostname, peer->host, afi_safi_print (afi, safi), + VTY_NEWLINE); + } + else + { + vty_out (vty, "Prefix counts for %s, %s%s", + peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); + } + + vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); + vty_out (vty, "%sCounts from RIB table walk:%s%s", + VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); + + for (i = 0; i < PCOUNT_MAX; i++) + vty_out (vty, "%20s: %-10d%s", pcount_strs[i], pcounts.count[i], VTY_NEWLINE); - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, NULL, uj); + if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi]) + { + vty_out (vty, "%s [pcount] PfxCt drift!%s", + peer->host, VTY_NEWLINE); + vty_out (vty, "Please report this bug, with the above command output%s", + VTY_NEWLINE); + } + } + + return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * "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 routes advertised to a BGP neighbor\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_neighbor_advertised_route, - show_ip_bgp_neighbor_advertised_route_cmd, - "show ip bgp neighbors advertised-routes [json]", +DEFUN (show_ip_bgp_neighbor_prefix_counts, + show_ip_bgp_neighbor_prefix_counts_cmd, + "show ip bgp neighbors prefix-counts [json]", SHOW_STR IP_STR BGP_STR @@ -12706,201 +8867,57 @@ DEFUN (show_ip_bgp_neighbor_advertised_route, "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") - { int idx_peer = 4; - int idx_json = 6; struct peer *peer; - const char *rmap_name = NULL; u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - - if (! peer) + if (! peer) return CMD_WARNING; - - if ((argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0) - || (argc == 3)) - rmap_name = argv[idx_json]->arg; - - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); + + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\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 routes advertised to a BGP neighbor\n" - * "Route-map to control what is displayed\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, - show_ip_bgp_ipv4_neighbor_advertised_route_cmd, - "show ip bgp ipv4 neighbors advertised-routes [json]", +DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, + show_ip_bgp_instance_neighbor_prefix_counts_cmd, + "show ip bgp WORD neighbors prefix-counts [json]", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\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 routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - int idx_safi = 4; - int idx_peer = 6; - int idx_json = 8; - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - if ((argc == 4) || (argc == 3 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) - rmap_name = argv[idx_json]->arg; - - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); -} - - -#ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\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 routes advertised to a BGP neighbor\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_neighbor_advertised_route, - show_bgp_instance_neighbor_advertised_route_cmd, - "show bgp WORD neighbors advertised-routes [json]", - SHOW_STR - BGP_STR BGP_INSTANCE_HELP_STR "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 routes advertised to a BGP neighbor\n" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") { - int idx_word = 3; - int idx_peer = 5; + int idx_word = 4; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - if (argc == 4 || (argc == 3 && argv[idx_peer]->arg && strcmp(argv[idx_peer]->arg, "json") != 0)) - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); - else - peer = peer_lookup_in_view (vty, NULL, argv[idx_word]->arg, uj); - + peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, NULL, uj); + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes [json]", - * SHOW_STR - * BGP_STR - * "Address family\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 routes advertised to a BGP neighbor\n" - * "JavaScript Object Notation\n" - * - * "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes [json]", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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 routes advertised to a BGP neighbor\n" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_neighbor_advertised_route, - show_bgp_neighbor_advertised_route_cmd, - "show bgp neighbors advertised-routes [json]", +DEFUN (show_bgp_ipv6_neighbor_prefix_counts, + show_bgp_ipv6_neighbor_prefix_counts_cmd, + "show bgp ipv6 neighbors prefix-counts [json]", SHOW_STR BGP_STR + "Address family\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 routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") - -{ - int idx_peer = 3; - int idx_json = 5; - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - - if (!peer) - return CMD_WARNING; - - if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) - rmap_name = argv[idx_json]->arg; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0, rmap_name, uj); -} - - -/* old command */ - -/* old command */ -DEFUN (ipv6_mbgp_neighbor_advertised_route, - ipv6_mbgp_neighbor_advertised_route_cmd, - "show ipv6 mbgp neighbors advertised-routes [json]", - SHOW_STR - IPV6_STR - MBGP_STR - "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" - "Neighbor on bgp configured interface\n" - "Display the routes advertised to a BGP neighbor\n" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") { int idx_peer = 4; @@ -12908,44 +8925,28 @@ DEFUN (ipv6_mbgp_neighbor_advertised_route, u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) + if (! peer) return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0, NULL, uj); + + return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); } -#endif /* HAVE_IPV6 */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes [json]", - * SHOW_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "Address family\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" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_instance_neighbor_received_routes, - show_bgp_instance_neighbor_received_routes_cmd, - "show bgp WORD neighbors received-routes [json]", +DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, + show_bgp_instance_ipv6_neighbor_prefix_counts_cmd, + "show bgp WORD ipv6 neighbors prefix-counts [json]", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR + "Address family\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" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") { int idx_word = 3; - int idx_peer = 5; + int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); @@ -12953,193 +8954,380 @@ DEFUN (show_bgp_instance_neighbor_received_routes, if (! peer) return CMD_WARNING; - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, NULL, uj); + return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST, uj); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp WORD neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * BGP_INSTANCE_HELP_STR - * "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" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_instance_neighbor_received_routes, - show_ip_bgp_instance_neighbor_received_routes_cmd, - "show ip bgp WORD neighbors received-routes [json]", +DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, + show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, + "show ip bgp ipv4 neighbors prefix-counts [json]", SHOW_STR IP_STR BGP_STR - BGP_INSTANCE_HELP_STR + "Address family\n" + "Address Family modifier\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" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") { - int idx_word = 4; + int idx_safi = 4; int idx_peer = 6; struct peer *peer; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); if (! peer) return CMD_WARNING; - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, NULL, uj); -} + if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * "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" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_neighbor_received_routes, - show_ip_bgp_neighbor_received_routes_cmd, - "show ip bgp neighbors received-routes [json]", +DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, + show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, + "show ip bgp vpnv4 all neighbors prefix-counts [json]", SHOW_STR IP_STR BGP_STR + "Address family\n" + "Address Family modifier\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" + "Display detailed prefix count information\n" "JavaScript Object Notation\n") +{ + int idx_peer = 6; + struct peer *peer; + u_char uj = use_json(argc, argv); + + peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); + if (! peer) + return CMD_WARNING; + + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); +} + +static void +show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, + int in, const char *rmap_name, u_char use_json, json_object *json) +{ + struct bgp_table *table; + struct bgp_adj_in *ain; + struct bgp_adj_out *adj; + unsigned long output_count; + unsigned long filtered_count; + struct bgp_node *rn; + int header1 = 1; + struct bgp *bgp; + int header2 = 1; + struct attr attr; + struct attr_extra extra; + int ret; + struct update_subgroup *subgrp; + json_object *json_scode = NULL; + json_object *json_ocode = NULL; + json_object *json_ar = NULL; + struct peer_af *paf; + + if (use_json) + { + json_scode = json_object_new_object(); + json_ocode = json_object_new_object(); + json_ar = json_object_new_object(); + + json_object_string_add(json_scode, "suppressed", "s"); + json_object_string_add(json_scode, "damped", "d"); + json_object_string_add(json_scode, "history", "h"); + json_object_string_add(json_scode, "valid", "*"); + json_object_string_add(json_scode, "best", ">"); + json_object_string_add(json_scode, "multipath", "="); + json_object_string_add(json_scode, "internal", "i"); + json_object_string_add(json_scode, "ribFailure", "r"); + json_object_string_add(json_scode, "stale", "S"); + json_object_string_add(json_scode, "removed", "R"); + + json_object_string_add(json_ocode, "igp", "i"); + json_object_string_add(json_ocode, "egp", "e"); + json_object_string_add(json_ocode, "incomplete", "?"); + } + + bgp = peer->bgp; + + if (! bgp) + { + if (use_json) + { + json_object_string_add(json, "alert", "no BGP"); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); + json_object_free(json); + } + else + vty_out (vty, "%% No bgp%s", VTY_NEWLINE); + return; + } + + table = bgp->rib[afi][safi]; + + output_count = filtered_count = 0; + subgrp = peer_subgroup(peer, afi, safi); + + if (!in && subgrp && CHECK_FLAG (subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) + { + if (use_json) + { + json_object_int_add(json, "bgpTableVersion", table->version); + json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); + json_object_object_add(json, "bgpStatusCodes", json_scode); + json_object_object_add(json, "bgpOriginCodes", json_ocode); + json_object_string_add(json, "bgpOriginatingDefaultNetwork", "0.0.0.0"); + } + else + { + vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE); + vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + + vty_out (vty, "Originating default network 0.0.0.0%s%s", + VTY_NEWLINE, VTY_NEWLINE); + } + header1 = 0; + } + + attr.extra = &extra; + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + { + if (in) + { + for (ain = rn->adj_in; ain; ain = ain->next) + { + if (ain->peer == peer) + { + if (header1) + { + if (use_json) + { + json_object_int_add(json, "bgpTableVersion", 0); + json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); + json_object_object_add(json, "bgpStatusCodes", json_scode); + json_object_object_add(json, "bgpOriginCodes", json_ocode); + } + else + { + vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); + vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + } + header1 = 0; + } + if (header2) + { + if (!use_json) + vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); + header2 = 0; + } + if (ain->attr) + { + bgp_attr_dup(&attr, ain->attr); + if (bgp_input_modifier(peer, &rn->p, &attr, afi, safi, rmap_name) != RMAP_DENY) + { + route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); + output_count++; + } + else + filtered_count++; + } + } + } + } + else + { + for (adj = rn->adj_out; adj; adj = adj->next) + SUBGRP_FOREACH_PEER(adj->subgroup, paf) + if (paf->peer == peer) + { + if (header1) + { + if (use_json) + { + json_object_int_add(json, "bgpTableVersion", table->version); + json_object_string_add(json, "bgpLocalRouterId", inet_ntoa (bgp->router_id)); + json_object_object_add(json, "bgpStatusCodes", json_scode); + json_object_object_add(json, "bgpOriginCodes", json_ocode); + } + else + { + vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, + inet_ntoa (bgp->router_id), VTY_NEWLINE); + vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE); + } + header1 = 0; + } + + if (header2) + { + if (!use_json) + vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE); + header2 = 0; + } + + if (adj->attr) + { + bgp_attr_dup(&attr, adj->attr); + ret = bgp_output_modifier(peer, &rn->p, &attr, afi, safi, rmap_name); + if (ret != RMAP_DENY) + { + route_vty_out_tmp (vty, &rn->p, &attr, safi, use_json, json_ar); + output_count++; + } + else + filtered_count++; + } + } + } + } + if (use_json) + json_object_object_add(json, "advertisedRoutes", json_ar); + + if (output_count != 0) + { + if (use_json) + json_object_int_add(json, "totalPrefixCounter", output_count); + else + vty_out (vty, "%sTotal number of prefixes %ld%s", + VTY_NEWLINE, output_count, VTY_NEWLINE); + } + if (use_json) + { + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); + json_object_free(json); + } + +} +static int +peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, + int in, const char *rmap_name, u_char use_json) { - int idx_peer = 4; - int idx_json = 6; - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); + json_object *json = NULL; - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); + if (use_json) + json = json_object_new_object(); - if (! peer) - return CMD_WARNING; + if (!peer || !peer->afc[afi][safi]) + { + if (use_json) + { + json_object_string_add(json, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); + json_object_free(json); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + + return CMD_WARNING; + } - if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) - rmap_name = argv[idx_json]->arg; + if (in && !CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) + { + if (use_json) + { + json_object_string_add(json, "warning", "Inbound soft reconfiguration not enabled"); + vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); + json_object_free(json); + } + else + vty_out (vty, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE); - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); -} + return CMD_WARNING; + } + show_adj_route (vty, peer, afi, safi, in, rmap_name, use_json, json); + return CMD_SUCCESS; +} -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD [json]", - * SHOW_STR - * IP_STR - * BGP_STR - * "Address family\n" - * "Address Family modifier\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" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, - show_ip_bgp_ipv4_neighbor_received_routes_cmd, - "show ip bgp ipv4 neighbors received-routes [json]", +DEFUN (show_ip_bgp_instance_neighbor_advertised_route, + show_ip_bgp_instance_neighbor_advertised_route_cmd, + "show [ip] bgp [] WORD [] neighbors [] [json]", SHOW_STR IP_STR BGP_STR + BGP_INSTANCE_HELP_STR + "Address family\n" + "Address Family modifier\n" + "Address family\n" + "Address Family modifier\n" + "Address family\n" + "Address Family modifier\n" "Address family\n" "Address Family modifier\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_safi = 4; - int idx_peer = 6; - int idx_json = 8; + 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; + char *vrf = NULL; + char *rmap_name = NULL; struct peer *peer; - const char *rmap_name = NULL; + afi_t afi; + safi_t safi; u_char uj = use_json(argc, argv); - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - if (argc == 4 || (argc == 3 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) - rmap_name = argv[idx_json]->arg; - - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); -} + 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); + peer = peer_lookup_in_view (vty, vrf, argv[idx_peer]->arg, uj); -DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, - show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, - "show bgp WORD neighbors [json]", - SHOW_STR - BGP_STR - BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\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 advertised routes to neighbor\n" - "Display the received routes from neighbor\n" - "JavaScript Object Notation\n") -{ - int idx_word = 3; - int idx_afi = 4; - int idx_safi = 5; - int idx_peer = 7; - int idx_adv_rcvd_routes = 8; - int afi; - int safi; - int in; - struct peer *peer; - u_char uj = use_json(argc, argv); + if (! peer) + { + vty_out (vty, "No such neighbor%s", VTY_NEWLINE); + return CMD_WARNING; + } - peer = peer_lookup_in_view (vty, argv[idx_word]->arg, argv[idx_peer]->arg, uj); + idx_adv_recv = idx_peer + 1; + idx_rmap = idx_adv_recv + 2; - if (! peer) - return CMD_WARNING; + 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; - afi = (strncmp (argv[idx_afi]->arg, "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - in = (strncmp (argv[idx_adv_rcvd_routes]->arg, "r", 1) == 0) ? 1 : 0; + if (argc > idx_rmap) + rmap_name = argv[idx_rmap]->arg; + } - return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); + 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 neighbors received prefix-filter [json]", @@ -13347,61 +9535,6 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, return CMD_SUCCESS; } #ifdef HAVE_IPV6 -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes [json]", - * SHOW_STR - * BGP_STR - * "Address family\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" - * "JavaScript Object Notation\n" - * - * "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes [json]", - * SHOW_STR - * IPV6_STR - * BGP_STR - * "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" - * "JavaScript Object Notation\n" - * - */ -DEFUN (show_bgp_neighbor_received_routes, - show_bgp_neighbor_received_routes_cmd, - "show bgp neighbors received-routes [json]", - SHOW_STR - BGP_STR - "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" - "JavaScript Object Notation\n") -{ - int idx_peer = 3; - int idx_json = 5; - struct peer *peer; - const char *rmap_name = NULL; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - - if (! peer) - return CMD_WARNING; - - if (argc == 3 || (argc == 2 && argv[idx_json]->arg && strcmp(argv[idx_json]->arg, "json") != 0)) - rmap_name = argv[idx_json]->arg; - - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1, rmap_name, uj); -} - - /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter [json]", @@ -13417,6 +9550,7 @@ DEFUN (show_bgp_neighbor_received_routes, * "JavaScript Object Notation\n" * */ +/* CHECK ME do we even support ORF for ipv6? */ DEFUN (show_bgp_neighbor_received_prefix_filter, show_bgp_neighbor_received_prefix_filter_cmd, "show bgp neighbors received prefix-filter [json]", @@ -13504,35 +9638,6 @@ DEFUN (show_bgp_neighbor_received_prefix_filter, return CMD_SUCCESS; } - -/* old command */ - -/* old command */ -DEFUN (ipv6_mbgp_neighbor_received_routes, - ipv6_mbgp_neighbor_received_routes_cmd, - "show ipv6 mbgp neighbors received-routes [json]", - SHOW_STR - IPV6_STR - MBGP_STR - "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" - "JavaScript Object Notation\n") -{ - int idx_peer = 4; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1, NULL, uj); -} - /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN * "show bgp WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter [json]", @@ -14031,42 +10136,6 @@ DEFUN (show_bgp_neighbor_routes, return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST, bgp_show_type_neighbor, uj); } - - - -/* old command */ - -/* old command */ -DEFUN (ipv6_mbgp_neighbor_routes, - ipv6_mbgp_neighbor_routes_cmd, - "show ipv6 mbgp neighbors routes [json]", - SHOW_STR - IPV6_STR - MBGP_STR - "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" - "JavaScript Object Notation\n") -{ - int idx_peer = 4; - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[idx_peer]->arg, uj); - if (! peer) - return CMD_WARNING; - - bgp_show_ipv6_bgp_deprecate_warning(vty); - return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, - bgp_show_type_neighbor, uj); -} - - - - - #endif /* HAVE_IPV6 */ struct bgp_table *bgp_distance_table; @@ -14279,17 +10348,9 @@ DEFUN (bgp_distance, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no distance bgp", - * NO_STR - * "Define an administrative distance\n" - * "BGP distance\n" - * - */ DEFUN (no_bgp_distance, no_bgp_distance_cmd, - "no distance bgp (1-255) (1-255) (1-255)", + "no distance bgp [(1-255) (1-255) (1-255)]", NO_STR "Define an administrative distance\n" "BGP distance\n" @@ -14424,29 +10485,9 @@ DEFUN (bgp_damp_set, half, reuse, suppress, max); } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no bgp dampening <1-45>", - * NO_STR - * "BGP Specific commands\n" - * "Enable route-flap dampening\n" - * "Half-life time for the penalty\n" - * - * "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>", - * NO_STR - * "BGP Specific commands\n" - * "Enable route-flap dampening\n" - * "Half-life time for the penalty\n" - * "Value to start reusing a route\n" - * "Value to start suppressing a route\n" - * "Maximum duration to suppress a stable route\n" - * - */ DEFUN (bgp_damp_unset, bgp_damp_unset_cmd, - "no bgp dampening", + "no bgp dampening [<1-45> [<1-20000> <1-20000> <1-255>]]", NO_STR "BGP Specific commands\n" "Enable route-flap dampening\n") @@ -14457,54 +10498,6 @@ DEFUN (bgp_damp_unset, return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty)); } - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening dampened-paths", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display paths suppressed due to dampening\n" - * - */ -DEFUN (show_ip_bgp_dampened_paths, - show_ip_bgp_dampened_paths_cmd, - "show ip bgp dampened-paths", - SHOW_STR - IP_STR - BGP_STR - "Display paths suppressed due to dampening\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths, - NULL, 0); -} - - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "show ip bgp dampening flap-statistics", - * SHOW_STR - * IP_STR - * BGP_STR - * "Display detailed information about dampening\n" - * "Display flap statistics of routes\n" - * - */ -DEFUN (show_ip_bgp_flap_statistics, - show_ip_bgp_flap_statistics_cmd, - "show ip bgp flap-statistics", - SHOW_STR - IP_STR - BGP_STR - "Display flap statistics of routes\n") -{ - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_flap_statistics, NULL, 0); -} - - /* Display specified route of BGP table. */ static int bgp_clear_damp_route (struct vty *vty, const char *view_name, @@ -14923,63 +10916,11 @@ bgp_route_init (void) install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd); install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd); - install_element (VIEW_NODE, &show_ip_bgp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_cmd); 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_instance_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); - - install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd); - install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_all_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_community_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); - install_element (VIEW_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); @@ -14987,137 +10928,27 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); - install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); /* Restricted node: VIEW_NODE - (set of dangerous commands) */ install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_all_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd); - install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd); - - install_element (ENABLE_NODE, &show_ip_bgp_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_cmd); + install_element (ENABLE_NODE, &show_ip_bgp_instance_all_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd); install_element (ENABLE_NODE, &show_ip_bgp_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); - - install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_filter_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_route_map_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_community_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_all_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_community_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd); + install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd); install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_routes_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd); install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd); install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd); install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd); install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd); - /* BGP dampening clear commands */ install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd); @@ -15151,45 +10982,9 @@ bgp_route_init (void) /* Old config IPv6 BGP commands. */ - install_element (VIEW_NODE, &show_bgp_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd); - install_element (VIEW_NODE, &show_bgp_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd); - install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_bgp_community_cmd); - install_element (VIEW_NODE, &show_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd); install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd); install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_bgp_instance_cmd); install_element (VIEW_NODE, &show_bgp_instance_all_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_pathtype_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_filter_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_route_map_cmd); - install_element (VIEW_NODE, &show_bgp_instance_community_list_cmd); - install_element (VIEW_NODE, &show_bgp_instance_prefix_longer_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_routes_cmd); install_element (VIEW_NODE, &show_bgp_instance_neighbor_routes_cmd); install_element (VIEW_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); install_element (VIEW_NODE, &show_bgp_instance_neighbor_flap_cmd); @@ -15198,62 +10993,11 @@ bgp_route_init (void) /* Restricted: * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) */ - install_element (RESTRICTED_NODE, &show_bgp_route_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd); - install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd); - install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_community_cmd); - install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_route_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_route_pathtype_cmd); - install_element (RESTRICTED_NODE, &show_bgp_instance_prefix_cmd); install_element (RESTRICTED_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); - install_element (ENABLE_NODE, &show_bgp_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd); - install_element (ENABLE_NODE, &show_bgp_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd); - install_element (ENABLE_NODE, &show_bgp_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_prefix_cmd); - install_element (ENABLE_NODE, &show_bgp_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd); - install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd); - install_element (ENABLE_NODE, &show_bgp_regexp_cmd); - install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd); - install_element (ENABLE_NODE, &show_bgp_filter_list_cmd); - install_element (ENABLE_NODE, &show_bgp_route_map_cmd); - install_element (ENABLE_NODE, &show_bgp_community_all_cmd); - install_element (ENABLE_NODE, &show_bgp_community_cmd); - install_element (ENABLE_NODE, &show_bgp_community_exact_cmd); - install_element (ENABLE_NODE, &show_bgp_community_list_cmd); - install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd); - install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd); - install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd); install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd); install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_cmd); install_element (ENABLE_NODE, &show_bgp_instance_all_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_route_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_route_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_prefix_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_prefix_pathtype_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_prefix_list_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_filter_list_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_route_map_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_community_list_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_neighbor_advertised_route_cmd); - install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_routes_cmd); install_element (ENABLE_NODE, &show_bgp_instance_neighbor_routes_cmd); install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd); install_element (ENABLE_NODE, &show_bgp_instance_neighbor_flap_cmd); @@ -15261,73 +11005,7 @@ bgp_route_init (void) /* Statistics */ install_element (ENABLE_NODE, &show_bgp_statistics_cmd); - //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); - //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); - - /* old command */ - install_element (VIEW_NODE, &show_ipv6_bgp_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); - install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); - - /* old command */ - install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd); - install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd); - install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); - install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); - install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd); - - /* old command */ - install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd); - install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &bgp_distance_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 2fd75baeff..5b965f3f93 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2908,19 +2908,9 @@ DEFUN (neighbor_peer_group, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor remote-as ((1-4294967295)|internal|external)", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR - * "Specify a BGP neighbor\n" - * AS_STR - * - */ DEFUN (no_neighbor, no_neighbor_cmd, - "no neighbor ", + "no neighbor [remote-as <(1-4294967295)|internal|external>]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2) @@ -3168,41 +3158,16 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, return bgp_vty_return (vty, ret); } - -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor local-as (1-4294967295)", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Specify a local-as number\n" - * "AS number used as local AS\n" - * - * "no neighbor local-as (1-4294967295) no-prepend", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Specify a local-as number\n" - * "AS number used as local AS\n" - * "Do not prepend local-as to updates from ebgp peers\n" - * - * "no neighbor local-as (1-4294967295) no-prepend replace-as", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Specify a local-as number\n" - * "AS number used as local AS\n" - * "Do not prepend local-as to updates from ebgp peers\n" - * "Do not prepend local-as to updates from ibgp peers\n" - * - */ DEFUN (no_neighbor_local_as, no_neighbor_local_as_cmd, - "no neighbor local-as", + "no neighbor local-as [(1-4294967295) [no-prepend [replace-as]]]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Specify a local-as number\n") + "Specify a local-as number\n" + "AS number used as local AS\n" + "Do not prepend local-as to updates from ebgp peers\n" + "Do not prepend local-as to updates from ibgp peers\n") { int idx_peer = 2; struct peer *peer; @@ -3279,19 +3244,9 @@ DEFUN (neighbor_password, return bgp_vty_return (vty, ret); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor password LINE", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Set a password\n" - * "The password\n" - * - */ DEFUN (no_neighbor_password, no_neighbor_password_cmd, - "no neighbor password", + "no neighbor password [LINE]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -4532,23 +4487,14 @@ DEFUN (neighbor_ebgp_multihop_ttl, return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor ebgp-multihop (1-255)", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Allow EBGP neighbors not on directly connected networks\n" - * "maximum hop count\n" - * - */ DEFUN (no_neighbor_ebgp_multihop, no_neighbor_ebgp_multihop_cmd, - "no neighbor ebgp-multihop", + "no neighbor ebgp-multihop [(1-255)]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Allow EBGP neighbors not on directly connected networks\n") + "Allow EBGP neighbors not on directly connected networks\n" + "maximum hop count\n") { int idx_peer = 2; return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); @@ -4556,50 +4502,31 @@ DEFUN (no_neighbor_ebgp_multihop, /* disable-connected-check */ -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "neighbor enforce-multihop", - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Enforce EBGP neighbors perform multihop\n" - * - */ DEFUN (neighbor_disable_connected_check, neighbor_disable_connected_check_cmd, - "neighbor disable-connected-check", + "neighbor ", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "one-hop away EBGP peer using loopback address\n") + "one-hop away EBGP peer using loopback address\n" + "Enforce EBGP neighbors perform multihop\n") { int idx_peer = 1; return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor enforce-multihop", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Enforce EBGP neighbors perform multihop\n" - * - */ DEFUN (no_neighbor_disable_connected_check, no_neighbor_disable_connected_check_cmd, - "no neighbor disable-connected-check", + "no neighbor ", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "one-hop away EBGP peer using loopback address\n") + "one-hop away EBGP peer using loopback address\n" + "Enforce EBGP neighbors perform multihop\n") { int idx_peer = 2; return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); } -/* Enforce multihop. */ - -/* Enforce multihop. */ - DEFUN (neighbor_description, neighbor_description_cmd, "neighbor description .LINE", @@ -4628,23 +4555,17 @@ DEFUN (neighbor_description, return CMD_SUCCESS; } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor description .LINE", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Neighbor specific description\n" - * "Up to 80 characters describing this neighbor\n" - * - */ +/* CHECK ME quentin mentioned something about LINE vs .LINE vs LINE... but + * I don't remember what. We need to check all LINE and AA:NN + * */ DEFUN (no_neighbor_description, no_neighbor_description_cmd, - "no neighbor description", + "no neighbor description [LINE]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Neighbor specific description\n") + "Neighbor specific description\n" + "Up to 80 characters describing this neighbor\n") { int idx_peer = 2; struct peer *peer; @@ -4768,24 +4689,15 @@ DEFUN (neighbor_default_originate_rmap, bgp_node_safi (vty), argv[idx_word]->arg, 1); } -/* - * CHECK ME - The following ALIASes need to be implemented in this DEFUN - * "no neighbor default-originate route-map WORD", - * NO_STR - * NEIGHBOR_STR - * NEIGHBOR_ADDR_STR2 - * "Originate default route to this neighbor\n" - * "Route-map to specify criteria to originate default\n" - * "route-map name\n" - * - */ DEFUN (no_neighbor_default_originate, no_neighbor_default_originate_cmd, - "no neighbor default-originate", + "no neighbor default-originate [route-map WORD]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 - "Originate default route to this neighbor\n") + "Originate default route to this neighbor\n" + "Route-map to specify criteria to originate default\n" + "route-map name\n") { int idx_peer = 2; return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), @@ -5842,11 +5754,6 @@ DEFUN (no_neighbor_maximum_prefix, } - - - - - /* "neighbor allowas-in" */ /* * CHECK ME - The following ALIASes need to be implemented in this DEFUN @@ -6220,10 +6127,62 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, return CMD_SUCCESS; } -static void -bgp_get_argv_afi_safi (struct cmd_token **argv, int idx_afi, int idx_safi, - afi_t *afi, safi_t *safi) +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; @@ -6232,6 +6191,9 @@ bgp_get_argv_afi_safi (struct cmd_token **argv, int idx_afi, int idx_safi, *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")) { @@ -6241,17 +6203,31 @@ bgp_get_argv_afi_safi (struct cmd_token **argv, int idx_afi, int idx_safi, *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 */ @@ -6290,11 +6266,10 @@ DEFUN (clear_ip_bgp_all, BGP_SOFT_IN_STR BGP_SOFT_OUT_STR) { - int idx_ip = 1; int idx_view_vrf = 3; int idx_vrf = 4; int idx_clr_sort = 5; - int idx_soft_in_out = argc - 1; + int idx_soft_in_out; int idx_afi; int idx_safi; char *vrf = NULL; @@ -6304,30 +6279,8 @@ DEFUN (clear_ip_bgp_all, enum bgp_clear_type clr_type; char *clr_arg = NULL; - /* - * If the user does "clear ip bgp" then we default the afi safi to ipv4 unicast. - * If the user does "clear 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_vrf--; - idx_clr_sort--; - } - - if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf")) - vrf = argv[idx_vrf]->arg; - else - idx_clr_sort -= 2; + // dwalton + vrf = bgp_get_argv_vrf (argc, argv, &afi, &safi, &idx_view_vrf, &idx_vrf, &idx_clr_sort); /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external> */ if (strmatch(argv[idx_clr_sort]->text, "*")) @@ -6356,7 +6309,8 @@ DEFUN (clear_ip_bgp_all, else if (strmatch(argv[idx_clr_sort]->text, "peer-group")) { clr_sort = clear_group; - clr_arg = argv[idx_clr_sort + 1]->arg; + idx_clr_sort++; + clr_arg = argv[idx_clr_sort]->arg; if (! peer_group_lookup (vty->index, clr_arg)) { @@ -6378,58 +6332,22 @@ DEFUN (clear_ip_bgp_all, } } + /* afi safi */ + idx_afi = idx_clr_sort + 1; + idx_safi = idx_clr_sort + 2; + bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_soft_in_out); + /* soft, soft in, or soft out */ if (strmatch(argv[idx_soft_in_out]->text, "in")) - { - clr_type = BGP_CLEAR_SOFT_IN; - - if (strmatch(argv[idx_soft_in_out-1]->text, "soft")) - { - idx_afi = idx_soft_in_out - 3; - idx_safi = idx_soft_in_out - 2; - } - else - { - idx_afi = idx_soft_in_out - 2; - idx_safi = idx_soft_in_out - 1; - } - } + clr_type = BGP_CLEAR_SOFT_IN; else if (strmatch(argv[idx_soft_in_out]->text, "out")) - { - clr_type = BGP_CLEAR_SOFT_OUT; - - if (strmatch(argv[idx_soft_in_out-1]->text, "soft")) - { - idx_afi = idx_soft_in_out - 3; - idx_safi = idx_soft_in_out - 2; - } - else - { - idx_afi = idx_soft_in_out - 2; - idx_safi = idx_soft_in_out - 1; - } - } + clr_type = BGP_CLEAR_SOFT_OUT; else if (strmatch(argv[idx_soft_in_out]->text, "soft")) - { - clr_type = BGP_CLEAR_SOFT_BOTH; - idx_afi = idx_soft_in_out - 2; - idx_safi = idx_soft_in_out - 1; - } + clr_type = BGP_CLEAR_SOFT_BOTH; else if (strmatch(argv[idx_soft_in_out]->text, "prefix-filter")) - { - clr_type = BGP_CLEAR_SOFT_IN_ORF_PREFIX; - idx_afi = idx_soft_in_out - 3; - idx_safi = idx_soft_in_out - 2; - } + clr_type = BGP_CLEAR_SOFT_IN_ORF_PREFIX; else - { - clr_type = BGP_CLEAR_SOFT_NONE; - idx_afi = idx_soft_in_out - 1; - idx_safi = idx_soft_in_out; - } - - /* afi safi */ - bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); + clr_type = BGP_CLEAR_SOFT_NONE; return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); } @@ -7200,7 +7118,6 @@ DEFUN (show_ip_bgp_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - int idx_ip = 1; int idx_view_vrf = 3; int idx_vrf = 4; int idx_afi; @@ -7210,41 +7127,9 @@ DEFUN (show_ip_bgp_summary, safi_t safi; u_char uj = use_json(argc, argv); - /* - * If the user does "show ip bgp" then we default the afi safi to ipv4 unicast. - * If the user does "show 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_vrf--; - } - - if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf")) - vrf = argv[idx_vrf]->arg; - - if (uj) - { - idx_afi = argc - 3; - idx_safi = argc - 2; - } - else - { - idx_afi = argc - 2; - idx_safi = argc - 1; - } - - /* afi safi */ - bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); + 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, NULL); return bgp_show_summary_vty (vty, vrf, afi, safi, uj); } @@ -9291,52 +9176,24 @@ DEFUN (show_ip_bgp_updgrps, "Detailed info about dynamic update groups\n" "Specific subgroup to display detailed info for\n") { - int idx_ip = 1; int idx_view_vrf = 3; int idx_vrf = 4; int idx_afi; int idx_safi; - int idx_subgroup_id = argc - 1; + int idx_updgrp; + int idx_subgroup_id; char *vrf = NULL; afi_t afi; safi_t safi; uint64_t subgrp_id = 0; - /* - * If the user does "show ip bgp" then we default the afi safi to ipv4 unicast. - * If the user does "show 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_vrf--; - } - - if (strmatch(argv[idx_view_vrf]->text, "view") || strmatch(argv[idx_view_vrf]->text, "vrf")) - vrf = argv[idx_vrf]->arg; - - if (strmatch(argv[idx_subgroup_id]->text, "update-groups")) - { - idx_afi = idx_subgroup_id - 2; - idx_safi = idx_subgroup_id - 1; - } - else - { - VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - idx_afi = idx_subgroup_id - 3; - idx_safi = idx_subgroup_id - 2; - } + 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_updgrp); + idx_subgroup_id = idx_updgrp + 1; - bgp_get_argv_afi_safi (argv, idx_afi, idx_safi, &afi, &safi); + if (! strmatch(argv[idx_subgroup_id]->text, "update-groups")) + VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 382af0984f..936d66131f 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -33,6 +33,14 @@ 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); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c834b11864..09947f49e5 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -9103,6 +9103,8 @@ DEFUN (no_ospf_max_metric_router_lsa_shutdown, return CMD_SUCCESS; } +static void +config_write_stub_router (struct vty *vty, struct ospf *ospf) { struct listnode *ln; struct ospf_area *area; -- 2.39.5