From 4e01997895afbb7df5416510f28d48aa954162f2 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 24 Jan 2017 15:49:47 +0100 Subject: [PATCH] bgpd: fix ambiguity between show ip bgp ipv4|ipv6 encap|vpn commands The commit is removed duplicated command show ip bgp ipv4|ipv6 enca|vpn command that is conflicting between bgp_route.c and bgp_mplsvpn.c/bgp_encap.c files. The fix is integrating the call to specific mpls or encap settings from inside bgp_show_route() function. Signed-off-by: Philippe Guibert --- bgpd/bgp_encap.c | 28 +--------------------------- bgpd/bgp_encap.h | 8 ++++++++ bgpd/bgp_mplsvpn.c | 41 +---------------------------------------- bgpd/bgp_mplsvpn.h | 3 +++ bgpd/bgp_route.c | 9 +++++++-- 5 files changed, 20 insertions(+), 69 deletions(-) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 75a348e3fe..fe08dbf991 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -348,7 +348,7 @@ enum bgp_show_type bgp_show_type_community_list_exact }; -static int +int bgp_show_encap ( struct vty *vty, afi_t afi, @@ -473,30 +473,6 @@ bgp_show_encap ( return CMD_SUCCESS; } -DEFUN (show_bgp_ipv4_encap, - show_bgp_ipv4_encap_cmd, - "show [ip] bgp ipv4 encap", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\n") -{ - return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0); -} - -DEFUN (show_bgp_ipv6_encap, - show_bgp_ipv6_encap_cmd, - "show [ip] bgp ipv6 encap", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\n") -{ - return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0); -} - DEFUN (show_bgp_ipv4_encap_rd, show_bgp_ipv4_encap_rd_cmd, "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn", @@ -938,7 +914,6 @@ bgp_encap_init (void) install_element (BGP_ENCAP_NODE, &encap_network_cmd); install_element (BGP_ENCAP_NODE, &no_encap_network_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_encap_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_tags_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_tags_cmd); @@ -947,7 +922,6 @@ bgp_encap_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_advertised_routes_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_encap_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_tags_cmd); diff --git a/bgpd/bgp_encap.h b/bgpd/bgp_encap.h index 7442c73c47..f06dfc128c 100644 --- a/bgpd/bgp_encap.h +++ b/bgpd/bgp_encap.h @@ -24,6 +24,14 @@ extern void bgp_encap_init (void); extern int bgp_nlri_parse_encap (struct peer *, struct attr *, struct bgp_nlri *); +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 bfbddb6c30..51f2984a4e 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -749,7 +749,7 @@ enum bgp_show_type 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) { @@ -967,44 +967,6 @@ 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, - "show [ip] bgp "BGP_AFI_CMD_STR" vpn [rd ASN:nn_or_IP-address:nn] [json]", - SHOW_STR - IP_STR - BGP_STR - BGP_VPNVX_HELP_STR - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - JSON_STR) -{ - int idx_ext_community = 5; - int ret; - struct prefix_rd prd; - afi_t afi; - int idx = 0; - - if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) - { - if (argv[idx_ext_community]->arg) - { - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); - } - else - { - return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); - } - } - return CMD_SUCCESS; -} - #ifdef KEEP_OLD_VPN_COMMANDS DEFUN (show_ip_bgp_vpn_all, show_ip_bgp_vpn_all_cmd, @@ -1386,7 +1348,6 @@ 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); #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..97eed3c35a 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -100,5 +100,8 @@ 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); +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 6faf474286..c462d1ee16 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" @@ -7972,8 +7973,12 @@ DEFUN (show_ip_bgp_ipv4, else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN) return bgp_show_prefix_longer (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer); } - - return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj); + if (safi == SAFI_MPLS_VPN) + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, uj); + else if (safi == SAFI_ENCAP) + return bgp_show_encap (vty, afi, NULL, bgp_show_type_normal, NULL, 0); + else + return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj); } DEFUN (show_ip_bgp_route, -- 2.39.5