]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: add some show commands for vpnv6
authorPhilippe Guibert <philippe.guibert@6wind.com>
Sun, 8 Jan 2017 17:09:04 +0000 (18:09 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 13 Jan 2017 13:19:59 +0000 (14:19 +0100)
Some show commands are added for handling vpnv6.
As the commands was present for vpnv4, but not vpnv6, the handler
routine for vty vpnv4 have been extended for vpnv6.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_mplsvpn.c

index 7747f15797a2f2f70d958950693c71780356b158..a36409c2d1e91b5a5a91d233e40223e803215abd 100644 (file)
@@ -35,11 +35,35 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "bgpd/bgp_attr.h"
 #include "bgpd/bgp_mplsvpn.h"
 #include "bgpd/bgp_packet.h"
+#include "bgpd/bgp_vty.h"
 
 #if ENABLE_BGP_VNC
 #include "bgpd/rfapi/rfapi_backend.h"
 #endif
 
+#define BGP_VPNVX_HELP_STR       \
+  "Address Family \n"   \
+  "Address Family \n"
+
+static int
+argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi)
+{
+  int ret = 0;
+  if (argv_find (argv, argc, "vpnv4", index))
+    {
+      ret = 1;
+      if (afi)
+        *afi = AFI_IP;
+    }
+  else if (argv_find (argv, argc, "vpnv6", index))
+    {
+      ret = 1;
+      if (afi)
+        *afi = AFI_IP6;
+    }
+   return ret;
+}
+
 u_int16_t
 decode_rd_type (u_char *pnt)
 {
@@ -548,7 +572,7 @@ DEFUN (no_vpnv6_network,
 }
 
 static int
-show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json)
+show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json, afi_t afi)
 {
   struct bgp *bgp;
   struct bgp_table *table;
@@ -591,7 +615,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u
       json_object_string_add(json_ocode, "incomplete", "?");
     }
 
-  for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn;
+  for (rn = bgp_table_top (bgp->rib[afi][SAFI_MPLS_VPN]); rn;
        rn = bgp_route_next (rn))
     {
       if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
@@ -948,35 +972,9 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
   return CMD_SUCCESS;
 }
 
-DEFUN (show_bgp_ivp4_vpn,
-       show_bgp_ipv4_vpn_cmd,
-       "show [ip] bgp ipv4 vpn [json]",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "Address Family\n"
-       "Display VPN NLRI specific information\n"
-       JSON_STR)
-{
-  return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
-}
-
-DEFUN (show_bgp_ipv6_vpn,
-       show_bgp_ipv6_vpn_cmd,
-       "show [ip] bgp ipv6 vpn [json]",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "Address Family\n"
-       "Display VPN NLRI specific information\n"
-       JSON_STR)
-{
-  return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
-}
-
-DEFUN (show_bgp_ipv4_vpn_rd,
-       show_bgp_ipv4_vpn_rd_cmd,
-       "show [ip] bgp ipv4 vpn rd ASN:nn_or_IP-address:nn [json]",
+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
@@ -989,97 +987,103 @@ DEFUN (show_bgp_ipv4_vpn_rd,
   int idx_ext_community = 5;
   int ret;
   struct prefix_rd prd;
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
-  if (! ret)
+  if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
     {
-      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      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 bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_bgp_ipv6_vpn_rd,
-       show_bgp_ipv6_vpn_rd_cmd,
-       "show [ip] bgp ipv6 vpn rd ASN:nn_or_IP-address:nn [json]",
+DEFUN (show_ip_bgp_vpn_all,
+       show_ip_bgp_vpn_all_cmd,
+       "show [ip] bgp <vpnv4|vpnv6>",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
-       "Display VPN NLRI specific information\n"
-       "Display information for a route distinguisher\n"
-       "VPN Route Distinguisher\n"
-       JSON_STR)
+       BGP_VPNVX_HELP_STR)
 {
-  int idx_ext_community = 5;
-  int ret;
-  struct prefix_rd prd;
-
-  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_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
-}
+  afi_t afi;
+  int idx = 0;
 
-DEFUN (show_ip_bgp_vpnv4_all,
-       show_ip_bgp_vpnv4_all_cmd,
-       "show [ip] bgp vpnv4 all",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "Address Family\n"
-       "Display information about all VPNv4 NLRIs\n")
-{
-  return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 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_vpnv4_rd,
-       show_ip_bgp_vpnv4_rd_cmd,
-       "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn",
+DEFUN (show_ip_bgp_vpn_rd,
+       show_ip_bgp_vpn_rd_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> rd ASN:nn_or_IP-address:nn",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
+       BGP_VPNVX_HELP_STR
        "Display information for a route distinguisher\n"
        "VPN Route Distinguisher\n")
 {
   int idx_ext_community = 5;
   int ret;
   struct prefix_rd prd;
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
-  if (! ret)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      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, 0);
     }
-  return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, 0);
-}
+  return CMD_SUCCESS;
+ }
 
-DEFUN (show_ip_bgp_vpnv4_all_tags,
-       show_ip_bgp_vpnv4_all_tags_cmd,
-       "show [ip] bgp vpnv4 all tags",
+DEFUN (show_ip_bgp_vpn_all_tags,
+       show_ip_bgp_vpn_all_tags_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> all tags",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
-       "Display information about all VPNv4 NLRIs\n"
+       BGP_VPNVX_HELP_STR
+       "Display information about all VPNv4/VPNV6 NLRIs\n"
        "Display BGP tags for prefixes\n")
 {
-  return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL,  1, 0);
+  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,  1, 0);
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_vpnv4_rd_tags,
-       show_ip_bgp_vpnv4_rd_tags_cmd,
-       "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn tags",
+DEFUN (show_ip_bgp_vpn_rd_tags,
+       show_ip_bgp_vpn_rd_tags_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> rd ASN:nn_or_IP-address:nn tags",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
+       BGP_VPNVX_HELP_STR
        "Display information for a route distinguisher\n"
        "VPN Route Distinguisher\n"
        "Display BGP tags for prefixes\n")
@@ -1087,24 +1091,31 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags,
   int idx_ext_community = 5;
   int ret;
   struct prefix_rd prd;
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
-  if (! ret)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
-      return CMD_WARNING;
+      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, 1, 0);
     }
-  return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1, 0);
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
-       show_ip_bgp_vpnv4_all_neighbor_routes_cmd,
-       "show [ip] bgp vpnv4 all neighbors A.B.C.D routes [json]",
+DEFUN (show_ip_bgp_vpn_all_neighbor_routes,
+       show_ip_bgp_vpn_all_neighbor_routes_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> all neighbors A.B.C.D routes [json]",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
-       "Display information about all VPNv4 NLRIs\n"
+       BGP_VPNVX_HELP_STR
+       "Display information about all VPNv4/VPNv6 NLRIs\n"
        "Detailed information on TCP and BGP neighbor connections\n"
        "Neighbor to display information about\n"
        "Display routes learned from neighbor\n"
@@ -1115,49 +1126,56 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
   struct peer *peer;
   int ret;
   u_char uj = use_json(argc, argv);
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2sockunion (argv[idx_ipv4]->arg, &su);
-  if (ret < 0)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      if (uj)
+      ret = str2sockunion (argv[idx_ipv4]->arg, &su);
+      if (ret < 0)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed address");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed address");
+              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: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  peer = peer_lookup (NULL, &su);
-  if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
-    {
-      if (uj)
+      peer = peer_lookup (NULL, &su);
+      if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN])
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "No such neighbor or address family");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "No such neighbor or address family");
+              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 or address family%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0, uj);
+      return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_neighbor, &su, 0, uj);
+    }
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
-       show_ip_bgp_vpnv4_rd_neighbor_routes_cmd,
-       "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]",
+DEFUN (show_ip_bgp_vpn_rd_neighbor_routes,
+       show_ip_bgp_vpn_rd_neighbor_routes_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
+       BGP_VPNVX_HELP_STR
        "Display information for a route distinguisher\n"
        "VPN Route Distinguisher\n"
        "Detailed information on TCP and BGP neighbor connections\n"
@@ -1172,66 +1190,73 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
   struct peer *peer;
   struct prefix_rd prd;
   u_char uj = use_json(argc, argv);
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
-  if (! ret)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      if (uj)
+      ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
+      if (! ret)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed Route Distinguisher");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed Route Distinguisher");
+              vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
+              json_object_free(json_no);
+            }
+          else
+            vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  ret = str2sockunion (argv[idx_ipv4]->arg, &su);
-  if (ret < 0)
-    {
-      if (uj)
+      ret = str2sockunion (argv[idx_ipv4]->arg, &su);
+      if (ret < 0)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed address");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed address");
+              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: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  peer = peer_lookup (NULL, &su);
-  if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
-    {
-      if (uj)
+      peer = peer_lookup (NULL, &su);
+      if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN])
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "No such neighbor or address family");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "No such neighbor or address family");
+              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 or address family%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0, uj);
+      return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_neighbor, &su, 0, uj);
+    }
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
-       show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd,
-       "show [ip] bgp vpnv4 all neighbors A.B.C.D advertised-routes [json]",
+DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes,
+       show_ip_bgp_vpn_all_neighbor_advertised_routes_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> all neighbors A.B.C.D advertised-routes [json]",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
-       "Display information about all VPNv4 NLRIs\n"
+       BGP_VPNVX_HELP_STR
+       "Display information about all VPNv4/VPNv6 NLRIs\n"
        "Detailed information on TCP and BGP neighbor connections\n"
        "Neighbor to display information about\n"
        "Display the routes advertised to a BGP neighbor\n"
@@ -1242,48 +1267,55 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
   struct peer *peer;
   union sockunion su;
   u_char uj = use_json(argc, argv);
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2sockunion (argv[idx_ipv4]->arg, &su);
-  if (ret < 0)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      if (uj)
+      ret = str2sockunion (argv[idx_ipv4]->arg, &su);
+      if (ret < 0)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed address");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed address");
+              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: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-  peer = peer_lookup (NULL, &su);
-  if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
-    {
-      if (uj)
+      peer = peer_lookup (NULL, &su);
+      if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN])
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "No such neighbor or address family");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "No such neighbor or address family");
+              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 or address family%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  return show_adj_route_vpn (vty, peer, NULL, uj);
+      return show_adj_route_vpn (vty, peer, NULL, uj, afi);
+    }
+  return CMD_SUCCESS;
 }
 
-DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
-       show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd,
-       "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]",
+DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes,
+       show_ip_bgp_vpn_rd_neighbor_advertised_routes_cmd,
+       "show [ip] bgp <vpnv4|vpnv6> rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]",
        SHOW_STR
        IP_STR
        BGP_STR
        "Address Family\n"
+       BGP_VPNVX_HELP_STR
        "Display information for a route distinguisher\n"
        "VPN Route Distinguisher\n"
        "Detailed information on TCP and BGP neighbor connections\n"
@@ -1298,55 +1330,61 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
   struct prefix_rd prd;
   union sockunion su;
   u_char uj = use_json(argc, argv);
+  afi_t afi;
+  int idx = 0;
 
-  ret = str2sockunion (argv[idx_ipv4]->arg, &su);
-  if (ret < 0)
+  if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
     {
-      if (uj)
+      ret = str2sockunion (argv[idx_ipv4]->arg, &su);
+      if (ret < 0)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed address");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed address");
+              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: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
-      return CMD_WARNING;
-    }
-  peer = peer_lookup (NULL, &su);
-  if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
-    {
-      if (uj)
+      peer = peer_lookup (NULL, &su);
+      if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN])
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "No such neighbor or address family");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "No such neighbor or address family");
+              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 or address family%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
-  if (! ret)
-    {
-      if (uj)
+      ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
+      if (! ret)
         {
-          json_object *json_no = NULL;
-          json_no = json_object_new_object();
-          json_object_string_add(json_no, "warning", "Malformed Route Distinguisher");
-          vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
-          json_object_free(json_no);
+          if (uj)
+            {
+              json_object *json_no = NULL;
+              json_no = json_object_new_object();
+              json_object_string_add(json_no, "warning", "Malformed Route Distinguisher");
+              vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
+              json_object_free(json_no);
+            }
+          else
+            vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+          return CMD_WARNING;
         }
-      else
-        vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
-      return CMD_WARNING;
-    }
 
-  return show_adj_route_vpn (vty, peer, &prd, uj);
+      return show_adj_route_vpn (vty, peer, &prd, uj, afi);
+    }
+  return CMD_SUCCESS;
 }
 
 void
@@ -1356,21 +1394,17 @@ bgp_mplsvpn_init (void)
   install_element (BGP_VPNV4_NODE, &vpnv4_network_route_map_cmd);
   install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd);
 
-  install_element (VIEW_NODE, &show_bgp_ipv4_vpn_cmd);
-  install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd);
-
   install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd);
   install_element (BGP_VPNV6_NODE, &vpnv6_network_route_map_cmd);
   install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd);
 
-  install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd);
-  install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd);
-  install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd);
+  install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_all_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_all_tags_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_tags_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_all_neighbor_routes_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_neighbor_routes_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_all_neighbor_advertised_routes_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_neighbor_advertised_routes_cmd);
 }