summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_mpath.c2
-rw-r--r--bgpd/bgp_mplsvpn.c574
-rw-r--r--bgpd/bgp_route.c24
3 files changed, 339 insertions, 261 deletions
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 208f676f1a..1701c70441 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -113,7 +113,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2)
ae2 = bi2->attr->extra;
compare = IPV4_ADDR_CMP (&bi1->attr->nexthop, &bi2->attr->nexthop);
-
if (!compare && ae1 && ae2)
{
if (ae1->mp_nexthop_len == ae2->mp_nexthop_len)
@@ -126,6 +125,7 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2)
&ae2->mp_nexthop_global_in);
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
+ case BGP_ATTR_NHLEN_VPNV6_GLOBAL:
compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global,
&ae2->mp_nexthop_global);
break;
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 49fb3e3949..f5ec33d0de 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -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)
{
@@ -494,8 +518,46 @@ DEFUN (no_vpnv4_network,
return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg);
}
+DEFUN (vpnv6_network,
+ vpnv6_network_cmd,
+ "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD [route-map WORD]",
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
+ "Specify Route Distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "BGP tag\n"
+ "tag value\n")
+{
+ int idx_ipv6_prefix = 1;
+ int idx_ext_community = 3;
+ int idx_word = 5;
+ int idx_word_2 = 7;
+ if (argv[idx_word_2])
+ return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg);
+ else
+ return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL);
+}
+
+/* For testing purpose, static route of MPLS-VPN. */
+DEFUN (no_vpnv6_network,
+ no_vpnv6_network_cmd,
+ "no network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
+ "Specify Route Distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "BGP tag\n"
+ "tag value\n")
+{
+ int idx_ipv6_prefix = 2;
+ int idx_ext_community = 4;
+ int idx_word = 6;
+ return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg);
+}
+
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;
@@ -538,7 +600,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)
@@ -895,39 +957,13 @@ 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]",
+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
- "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]",
- SHOW_STR
- IP_STR
- BGP_STR
- "Address Family\n"
+ BGP_VPNVX_HELP_STR
"Display VPN NLRI specific information\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
@@ -936,97 +972,99 @@ 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")
@@ -1034,24 +1072,30 @@ 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"
@@ -1062,49 +1106,55 @@ 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"
@@ -1119,66 +1169,72 @@ 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"
@@ -1189,48 +1245,54 @@ 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"
@@ -1245,55 +1307,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
@@ -1303,16 +1371,16 @@ 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 (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 (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_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);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index b25101f28f..d2abb40ca9 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2316,6 +2316,7 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
+ case BGP_ATTR_NHLEN_VPNV6_GLOBAL:
ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) ||
IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) ||
IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global));
@@ -4299,6 +4300,7 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
struct bgp_table *table;
struct bgp_static *bgp_static;
u_char tag[3];
+ afi_t afi;
ret = str2prefix (ip_str, &p);
if (! ret)
@@ -4321,11 +4323,19 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
return CMD_WARNING;
}
-
- prn = bgp_node_get (bgp->route[AFI_IP][safi],
+ if (p.family == AF_INET)
+ afi = AFI_IP;
+ else if (p.family == AF_INET6)
+ afi = AFI_IP6;
+ else
+ {
+ vty_out (vty, "%% Non Supported prefix%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ prn = bgp_node_get (bgp->route[afi][safi],
(struct prefix *)&prd);
if (prn->info == NULL)
- prn->info = bgp_table_init (AFI_IP, safi);
+ prn->info = bgp_table_init (afi, safi);
else
bgp_unlock_node (prn);
table = prn->info;
@@ -4358,7 +4368,7 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
rn->info = bgp_static;
bgp_static->valid = 1;
- bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
+ bgp_static_update_safi (bgp, &p, bgp_static, afi, safi);
}
return CMD_SUCCESS;
@@ -10279,7 +10289,7 @@ DEFUN (clear_ip_bgp_dampening_address_mask,
/* also used for encap safi */
static int
-bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
+bgp_config_write_network_vpn (struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi, int *write)
{
struct bgp_node *prn;
@@ -10329,8 +10339,8 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp,
struct bgp_aggregate *bgp_aggregate;
char buf[SU_ADDRSTRLEN];
- if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
- return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
+ if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
+ return bgp_config_write_network_vpn (vty, bgp, afi, safi, write);
/* Network configuration. */
for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))