From 1496eba797f32bce77960e966f27b7f8b944d52f Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 24 Jan 2017 10:13:37 +0100 Subject: [PATCH 1/4] bgpd: remove duplicated vty command to enter in vpn address family node Because the vpn configuration command was duplicate, there was an ambiguity to raise. This is a fix that permits configuring vpnv4 or vpnv6 address-families on bgp. Signed-off-by: Philippe Guibert --- bgpd/bgp_vty.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 2e001b3a9d6c..80efe5f591b6 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -5588,28 +5588,6 @@ DEFUN (address_family_vpnv6, } #endif /* KEEP_OLD_VPN_COMMANDS */ -DEFUN (address_family_ipv4_vpn, - address_family_ipv4_vpn_cmd, - "address-family ipv4 vpn", - "Enter Address Family command mode\n" - "Address Family\n" - "Subsequent Address Family modifier\n") -{ - vty->node = BGP_VPNV4_NODE; - return CMD_SUCCESS; -} - -DEFUN (address_family_ipv6_vpn, - address_family_ipv6_vpn_cmd, - "address-family ipv6 vpn", - "Enter Address Family command mode\n" - "Address Family\n" - "Subsequent Address Family modifier\n") -{ - vty->node = BGP_VPNV6_NODE; - return CMD_SUCCESS; -} - DEFUN (address_family_encap, address_family_encap_cmd, "address-family ", @@ -10717,9 +10695,6 @@ bgp_vty_init (void) install_element (BGP_NODE, &address_family_vpnv4_cmd); install_element (BGP_NODE, &address_family_vpnv6_cmd); #endif /* KEEP_OLD_VPN_COMMANDS */ - install_element (BGP_NODE, &address_family_ipv4_vpn_cmd); - install_element (BGP_NODE, &address_family_ipv6_vpn_cmd); - install_element (BGP_NODE, &address_family_encap_cmd); install_element (BGP_NODE, &address_family_encapv6_cmd); From 4e01997895afbb7df5416510f28d48aa954162f2 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 24 Jan 2017 15:49:47 +0100 Subject: [PATCH 2/4] 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 75a348e3fe86..fe08dbf99106 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 7442c73c47aa..f06dfc128cd4 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 bfbddb6c30c6..51f2984a4ec4 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 336b73616995..97eed3c35adf 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 6faf4742864d..c462d1ee162c 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, From b2f0fa552bf1a8523b7f94fd6c758f4a720b62b6 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 20 Jan 2017 11:44:18 +0100 Subject: [PATCH 3/4] bgpd: move bgp_show_type enumerate to bgp_route.h This bgp_show_type enumerate was duplicated and modified in several places. The commit takes the enumerate with the biggest enumerate, so that it can be used by all the functions using this enumerate. Signed-off-by: Philippe Guibert --- bgpd/bgp_encap.c | 16 ---------------- bgpd/bgp_main.c | 1 + bgpd/bgp_mplsvpn.c | 16 ---------------- bgpd/bgp_route.c | 21 --------------------- bgpd/bgp_route.h | 22 ++++++++++++++++++++++ bgpd/rfapi/rfapi_vty.c | 1 + bgpd/rfapi/vnc_import_bgp.c | 1 + 7 files changed, 25 insertions(+), 53 deletions(-) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index fe08dbf99106..201f7bde0610 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -332,22 +332,6 @@ 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 -}; - int bgp_show_encap ( struct vty *vty, diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 33191f0a982b..23514dece4fa 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -43,6 +43,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_route.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_dump.h" diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 51f2984a4ec4..7a2717acc085 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -733,22 +733,6 @@ 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 -}; - 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) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index c462d1ee162c..f9cdc1a0dbfa 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7214,27 +7214,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, diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 3c7aa83a0e4d..f2e6273b84f7 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -26,6 +26,28 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA struct bgp_nexthop_cache; +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 +}; + + #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\ "h history, * valid, > best, = multipath,%s"\ " i internal, r RIB-failure, S Stale, R Removed%s" diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 3e179b7f7283..1e7941a41db6 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -35,6 +35,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_route.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/rfapi/bgp_rfapi_cfg.h" diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 4801e2906acc..62c31a662ad0 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -37,6 +37,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_route.h" #include "bgpd/bgp_mplsvpn.h" /* for RD_TYPE_IP */ #include "bgpd/rfapi/vnc_export_bgp.h" From 75688c44d98af271ca4eb4f3133ede9e7ae709bb Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 24 Jan 2017 16:17:30 +0100 Subject: [PATCH 4/4] bgpd: fix show ip bgp ipv4|ipv6 vpn command The fix consists in setting the correct safi value. Signed-off-by: Philippe Guibert --- bgpd/bgp_route.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f9cdc1a0dbfa..eea0f86b349b 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7882,15 +7882,9 @@ DEFUN (show_ip_bgp_ipv4, 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, "vpn", &idx)) + safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; } - 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); - } - int uj = use_json (argc, argv); if (uj) argc--;