]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix ambiguity between show ip bgp ipv4|ipv6 encap|vpn commands
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 24 Jan 2017 14:49:47 +0000 (15:49 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 24 Jan 2017 15:18:55 +0000 (16:18 +0100)
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 <philippe.guibert@6wind.com>
bgpd/bgp_encap.c
bgpd/bgp_encap.h
bgpd/bgp_mplsvpn.c
bgpd/bgp_mplsvpn.h
bgpd/bgp_route.c

index 75a348e3fe86a24aad60679fbf828c14beccd3f7..fe08dbf9910641dc88a15ac04db7da33898a1f1d 100644 (file)
@@ -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);
index 7442c73c47aadbc255473ba4de1098c834307f5f..f06dfc128cd472ed077014896196c8f0ca9f5d2f 100644 (file)
 
 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 */
index bfbddb6c30c6778717776780f8543436dd1a2030..51f2984a4ec4050fe2f68b1a937333d2560679fb 100644 (file)
@@ -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);
index 336b736169950ab0aa397011374117ec1ae9f62d..97eed3c35adfa38033784bcb90906a7960e8d9c3 100644 (file)
@@ -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 */
index 6faf4742864daecbbd54437c38279a756d762ad2..c462d1ee162cbb44504923148a3d390be01648e9 100644 (file)
@@ -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,