From 4f280b15b1049b42241e9c0ac7d2e4fa0c8e3b22 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Tue, 24 Jan 2017 14:52:06 -0500 Subject: [PATCH] bgpd: more VPN&ENCAP show afi safi related cleanup Issued ID'ed by regression Signed-off-by: Lou Berger --- bgpd/bgp_encap.c | 18 +-- bgpd/bgp_encap.h | 4 +- bgpd/bgp_mplsvpn.c | 65 ++++------ bgpd/bgp_mplsvpn.h | 10 +- bgpd/bgp_route.c | 257 +++++++++++++------------------------ bgpd/bgp_route.h | 21 +++ bgpd/rfapi/rfapi_private.h | 1 + 7 files changed, 147 insertions(+), 229 deletions(-) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 3fe8988b9c..1bc8a67ffc 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -324,23 +324,7 @@ show_adj_route_encap (struct vty *vty, struct peer *peer, struct prefix_rd *prd) return CMD_SUCCESS; } -enum bgp_show_type -{ - bgp_show_type_normal, - bgp_show_type_regexp, - bgp_show_type_prefix_list, - bgp_show_type_filter_list, - bgp_show_type_neighbor, - bgp_show_type_cidr_only, - bgp_show_type_prefix_longer, - bgp_show_type_community_all, - bgp_show_type_community, - bgp_show_type_community_exact, - bgp_show_type_community_list, - bgp_show_type_community_list_exact -}; - -static int +int bgp_show_encap ( struct vty *vty, afi_t afi, diff --git a/bgpd/bgp_encap.h b/bgpd/bgp_encap.h index 7442c73c47..4d57fca79d 100644 --- a/bgpd/bgp_encap.h +++ b/bgpd/bgp_encap.h @@ -21,9 +21,11 @@ #ifndef _QUAGGA_BGP_ENCAP_H #define _QUAGGA_BGP_ENCAP_H +#include "bgpd/bgp_route.h" extern void bgp_encap_init (void); extern int bgp_nlri_parse_encap (struct peer *, struct attr *, struct bgp_nlri *); - +extern int bgp_show_encap (struct vty *vty, afi_t afi, struct prefix_rd *prd, + enum bgp_show_type type, void *output_arg, int tags); #include "bgp_encap_types.h" #endif /* _QUAGGA_BGP_ENCAP_H */ diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 2a2883677f..e0b14a6e4c 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -717,23 +717,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u return CMD_SUCCESS; } -enum bgp_show_type -{ - bgp_show_type_normal, - bgp_show_type_regexp, - bgp_show_type_prefix_list, - bgp_show_type_filter_list, - bgp_show_type_neighbor, - bgp_show_type_cidr_only, - bgp_show_type_prefix_longer, - bgp_show_type_community_all, - bgp_show_type_community, - bgp_show_type_community_exact, - bgp_show_type_community_list, - bgp_show_type_community_list_exact -}; - -static int +int bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, int tags, u_char use_json) { @@ -951,8 +935,8 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, return CMD_SUCCESS; } -DEFUN (show_bgp_ip_vpn_rd, - show_bgp_ip_vpn_rd_cmd, +DEFUN (show_bgp_ip_vpn_all_rd, + show_bgp_ip_vpn_all_rd_cmd, "show bgp "BGP_AFI_CMD_STR" vpn all [rd ASN:nn_or_IP-address:nn] [json]", SHOW_STR IP_STR @@ -989,34 +973,17 @@ DEFUN (show_bgp_ip_vpn_rd, return CMD_SUCCESS; } -#ifdef KEEP_OLD_VPN_COMMANDS -DEFUN (show_ip_bgp_vpn_all, - show_ip_bgp_vpn_all_cmd, - "show [ip] bgp ", - SHOW_STR - IP_STR - BGP_STR - BGP_VPNVX_HELP_STR) -{ - afi_t afi; - int idx = 0; - - if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) - return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0); - return CMD_SUCCESS; -} - DEFUN (show_ip_bgp_vpn_rd, show_ip_bgp_vpn_rd_cmd, - "show [ip] bgp rd ASN:nn_or_IP-address:nn", + "show [ip] bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn", SHOW_STR IP_STR BGP_STR - BGP_VPNVX_HELP_STR + BGP_AFI_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { - int idx_ext_community = 5; + int idx_ext_community = argc-1; int ret; struct prefix_rd prd; afi_t afi; @@ -1035,6 +1002,23 @@ DEFUN (show_ip_bgp_vpn_rd, return CMD_SUCCESS; } +#ifdef KEEP_OLD_VPN_COMMANDS +DEFUN (show_ip_bgp_vpn_all, + show_ip_bgp_vpn_all_cmd, + "show [ip] bgp ", + SHOW_STR + IP_STR + BGP_STR + BGP_VPNVX_HELP_STR) +{ + afi_t afi; + int idx = 0; + + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0); + return CMD_SUCCESS; +} + DEFUN (show_ip_bgp_vpn_all_tags, show_ip_bgp_vpn_all_tags_cmd, "show [ip] bgp all tags", @@ -1370,7 +1354,8 @@ bgp_mplsvpn_init (void) install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd); install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_all_rd_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd); #ifdef KEEP_OLD_VPN_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpn_all_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd); diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 336b736169..201b9bf710 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -21,6 +21,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_MPLSVPN_H #define _QUAGGA_BGP_MPLSVPN_H +#include "bgpd/bgp_route.h" + #define RD_TYPE_AS 0 #define RD_TYPE_IP 1 #define RD_TYPE_AS4 2 @@ -56,8 +58,8 @@ typedef enum { (label) == MPLS_LABEL_IMPLICIT_NULL) #define BGP_VPNVX_HELP_STR \ - "Address Family \n" \ - "Address Family \n" + "Address Family\n" \ + "Address Family\n" struct rd_as { @@ -100,5 +102,7 @@ extern char *prefix_rd2str (struct prefix_rd *, char *, size_t); extern int argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi); - +extern int +bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, + enum bgp_show_type type, void *output_arg, int tags, u_char use_json); #endif /* _QUAGGA_BGP_MPLSVPN_H */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f045d17000..8be76595f7 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -51,6 +51,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_filter.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_mplsvpn.h" +#include "bgpd/bgp_encap.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_damp.h" #include "bgpd/bgp_advertise.h" @@ -5867,7 +5868,8 @@ route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo, vty_out (vty, " "); /* Internal route. */ - if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) + if (binfo->peer && + (binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) vty_out (vty, "i"); else vty_out (vty, " "); @@ -7250,27 +7252,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s" #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s" -enum bgp_show_type -{ - bgp_show_type_normal, - bgp_show_type_regexp, - bgp_show_type_prefix_list, - bgp_show_type_filter_list, - bgp_show_type_route_map, - bgp_show_type_neighbor, - bgp_show_type_cidr_only, - bgp_show_type_prefix_longer, - bgp_show_type_community_all, - bgp_show_type_community, - bgp_show_type_community_exact, - bgp_show_type_community_list, - bgp_show_type_community_list_exact, - bgp_show_type_flap_statistics, - bgp_show_type_flap_neighbor, - bgp_show_type_dampend_paths, - bgp_show_type_damp_neighbor -}; - static int bgp_show_prefix_list (struct vty *vty, const char *name, const char *prefix_list_str, afi_t afi, @@ -7397,7 +7378,8 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, { union sockunion *su = output_arg; - if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) + if (ri->peer == NULL || + ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su)) continue; } if (type == bgp_show_type_cidr_only) @@ -7543,6 +7525,18 @@ bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); return CMD_WARNING; } + /* use MPLS and ENCAP specific shows until they are merged */ + if (safi == SAFI_MPLS_VPN) + { + return bgp_show_mpls_vpn(vty, afi, NULL, type, output_arg, + 0, use_json); + } + if (safi == SAFI_ENCAP) + { + return bgp_show_encap(vty, afi, NULL, type, output_arg, + 0); + } + table = bgp->rib[afi][safi]; @@ -7873,7 +7867,7 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, /* BGP route print out function. */ DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show [ip] bgp [ WORD] [ []]\ + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]\ [<\ cidr-only\ |dampening \ @@ -7889,12 +7883,8 @@ DEFUN (show_ip_bgp_ipv4, IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Display only routes with non-natural netmasks\n" "Display detailed information about dampening\n" "Display flap statistics of routes\n" @@ -7934,19 +7924,10 @@ DEFUN (show_ip_bgp_ipv4, afi = AFI_IP; if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = bgp_vty_safi_from_arg (argv[idx]->text); - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } int uj = use_json (argc, argv); if (uj) argc--; @@ -8015,18 +7996,14 @@ DEFUN (show_ip_bgp_ipv4, DEFUN (show_ip_bgp_route, show_ip_bgp_route_cmd, - "show [ip] bgp [ WORD] [ []]" + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]]" " [] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Network in the BGP routing table to display\n" "IPv4 prefix\n" "Network in the BGP routing table to display\n" @@ -8053,20 +8030,10 @@ DEFUN (show_ip_bgp_route, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } /* */ if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx)) @@ -8100,24 +8067,12 @@ DEFUN (show_ip_bgp_route, DEFUN (show_ip_bgp_regexp, show_ip_bgp_regexp_cmd, - "show [ip] bgp []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] regexp REGEX...", + "show [ip] bgp ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] regexp REGEX...", SHOW_STR IP_STR BGP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { @@ -8126,20 +8081,10 @@ DEFUN (show_ip_bgp_regexp, int idx = 0; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } // get index of regex argv_find (argv, argc, "regexp", &idx); @@ -8153,21 +8098,13 @@ DEFUN (show_ip_bgp_regexp, DEFUN (show_ip_bgp_instance_all, show_ip_bgp_instance_all_cmd, - "show [ip] bgp all []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] [json]", + "show [ip] bgp all ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_ALL_HELP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR JSON_STR) { afi_t afi = AFI_IP; @@ -8178,20 +8115,11 @@ DEFUN (show_ip_bgp_instance_all, /* show [ip] bgp */ if (argv_find (argv, argc, "ip", &idx)) afi = AFI_IP; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } u_char uj = use_json(argc, argv); @@ -9478,21 +9406,13 @@ peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, DEFUN (show_ip_bgp_instance_neighbor_advertised_route, show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show [ip] bgp [ WORD] []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] neighbors [route-map WORD] [json]", + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] neighbors [route-map WORD] [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9520,20 +9440,11 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } /* neighbors */ argv_find (argv, argc, "neighbors", &idx); @@ -9670,21 +9581,13 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, DEFUN (show_ip_bgp_neighbor_routes, show_ip_bgp_neighbor_routes_cmd, - "show [ip] bgp [ WORD] []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] neighbors [json]", + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] neighbors [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -9710,20 +9613,11 @@ DEFUN (show_ip_bgp_neighbor_routes, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } /* neighbors */ argv_find (argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; @@ -9758,6 +9652,32 @@ struct bgp_distance char *access_list; }; +DEFUN (show_bgp_afi_vpn_rd_route, + show_bgp_afi_vpn_rd_route_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn [json]", + SHOW_STR + BGP_STR + BGP_AFI_HELP_STR + "Address Family modifier\n" + "Display information for a route distinguisher\n" + "Route Distinguisher\n" + "Network in the BGP routing table to display\n") +{ + int ret; + struct prefix_rd prd; + afi_t afi = AFI_MAX; + int idx = 0; + + argv_find_and_parse_afi (argv, argc, &idx, &afi); + ret = str2prefix_rd (argv[5]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); +} + static struct bgp_distance * bgp_distance_new (void) { @@ -10575,6 +10495,7 @@ bgp_route_init (void) #ifdef KEEP_OLD_VPN_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpn_all_route_prefix_cmd); #endif /* KEEP_OLD_VPN_COMMANDS */ + install_element (VIEW_NODE, &show_bgp_afi_vpn_rd_route_cmd); /* BGP dampening clear commands */ install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 3c7aa83a0e..21ca64091c 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -241,6 +241,27 @@ bgp_bump_version (struct bgp_node *node) node->version = bgp_table_next_version(bgp_node_table(node)); } +enum bgp_show_type +{ + bgp_show_type_normal, + bgp_show_type_regexp, + bgp_show_type_prefix_list, + bgp_show_type_filter_list, + bgp_show_type_route_map, + bgp_show_type_neighbor, + bgp_show_type_cidr_only, + bgp_show_type_prefix_longer, + bgp_show_type_community_all, + bgp_show_type_community, + bgp_show_type_community_exact, + bgp_show_type_community_list, + bgp_show_type_community_list_exact, + bgp_show_type_flap_statistics, + bgp_show_type_flap_neighbor, + bgp_show_type_dampend_paths, + bgp_show_type_damp_neighbor +}; + /* Prototypes. */ extern void bgp_process_queue_init (void); extern void bgp_route_init (void); diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index 00f90e35fc..e3022a565d 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -31,6 +31,7 @@ #include "lib/workqueue.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_route.h" #include "rfapi.h" -- 2.39.5