2 Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30 #include "bgpd/bgpd.h"
31 #include "bgpd/bgp_table.h"
32 #include "bgpd/bgp_route.h"
33 #include "bgpd/bgp_packet.h"
34 #include "bgpd/bgp_attr.h"
35 #include "bgpd/bgp_mplsvpn.h"
36 #include "bgpd/bgp_packet.h"
39 decode_rd_type (u_char *pnt)
43 v = ((u_int16_t) *pnt++ << 8);
44 v |= (u_int16_t) *pnt;
49 decode_label (u_char *pnt)
53 l = ((u_int32_t) *pnt++ << 12);
54 l |= (u_int32_t) *pnt++ << 4;
55 l |= (u_int32_t) ((*pnt & 0xf0) >> 4);
59 /* type == RD_TYPE_AS */
61 decode_rd_as (u_char *pnt, struct rd_as *rd_as)
63 rd_as->as = (u_int16_t) *pnt++ << 8;
64 rd_as->as |= (u_int16_t) *pnt++;
66 rd_as->val = ((u_int32_t) *pnt++ << 24);
67 rd_as->val |= ((u_int32_t) *pnt++ << 16);
68 rd_as->val |= ((u_int32_t) *pnt++ << 8);
69 rd_as->val |= (u_int32_t) *pnt;
72 /* type == RD_TYPE_AS4 */
74 decode_rd_as4 (u_char *pnt, struct rd_as *rd_as)
76 rd_as->as = (u_int32_t) *pnt++ << 24;
77 rd_as->as |= (u_int32_t) *pnt++ << 16;
78 rd_as->as |= (u_int32_t) *pnt++ << 8;
79 rd_as->as |= (u_int32_t) *pnt++;
81 rd_as->val = ((u_int16_t) *pnt++ << 8);
82 rd_as->val |= (u_int16_t) *pnt;
85 /* type == RD_TYPE_IP */
87 decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip)
89 memcpy (&rd_ip->ip, pnt, 4);
92 rd_ip->val = ((u_int16_t) *pnt++ << 8);
93 rd_ip->val |= (u_int16_t) *pnt;
97 bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
98 struct bgp_nlri *packet)
108 struct prefix_rd prd;
111 /* Check peer status. */
112 if (peer->status != Established)
116 prd.family = AF_UNSPEC;
120 lim = pnt + packet->length;
122 #define VPN_PREFIXLEN_MIN_BYTES (3 + 8) /* label + RD */
123 for (; pnt < lim; pnt += psize)
125 /* Clear prefix structure. */
126 memset (&p, 0, sizeof (struct prefix));
128 /* Fetch prefix length. */
130 p.family = afi2family (packet->afi);
131 psize = PSIZE (prefixlen);
133 /* sanity check against packet data */
134 if (prefixlen < VPN_PREFIXLEN_MIN_BYTES*8)
137 "%s [Error] Update packet error / VPNv4"
138 " (prefix length %d less than VPNv4 min length)",
139 peer->host, prefixlen);
142 if ((pnt + psize) > lim)
145 "%s [Error] Update packet error / VPNv4"
146 " (psize %u exceeds packet size (%u)",
148 prefixlen, (uint)(lim-pnt));
152 /* sanity check against storage for the IP address portion */
153 if ((psize - VPN_PREFIXLEN_MIN_BYTES) > (ssize_t) sizeof(p.u))
156 "%s [Error] Update packet error / VPNv4"
157 " (psize %u exceeds storage size (%zu)",
159 prefixlen - VPN_PREFIXLEN_MIN_BYTES*8, sizeof(p.u));
163 /* Sanity check against max bitlen of the address family */
164 if ((psize - VPN_PREFIXLEN_MIN_BYTES) > prefix_blen (&p))
167 "%s [Error] Update packet error / VPNv4"
168 " (psize %u exceeds family (%u) max byte len %u)",
170 prefixlen - VPN_PREFIXLEN_MIN_BYTES*8,
171 p.family, prefix_blen (&p));
175 /* Copyr label to prefix. */
178 /* Copy routing distinguisher to rd. */
179 memcpy (&prd.val, pnt + 3, 8);
181 /* Decode RD type. */
182 type = decode_rd_type (pnt + 3);
187 decode_rd_as (pnt + 5, &rd_as);
191 decode_rd_as4 (pnt + 5, &rd_as);
195 decode_rd_ip (pnt + 5, &rd_ip);
199 zlog_err ("Unknown RD type %d", type);
200 break; /* just report */
203 p.prefixlen = prefixlen - VPN_PREFIXLEN_MIN_BYTES*8;
204 memcpy (&p.u.prefix, pnt + VPN_PREFIXLEN_MIN_BYTES,
205 psize - VPN_PREFIXLEN_MIN_BYTES);
208 bgp_update (peer, &p, attr, packet->afi, SAFI_MPLS_VPN,
209 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
211 bgp_withdraw (peer, &p, attr, packet->afi, SAFI_MPLS_VPN,
212 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
214 /* Packet length consistency check. */
218 "%s [Error] Update packet error / VPNv4"
219 " (%zu data remaining after parsing)",
220 peer->host, lim - pnt);
225 #undef VPN_PREFIXLEN_MIN_BYTES
229 str2prefix_rd (const char *str, struct prefix_rd *prd)
231 int ret; /* ret of called functions */
232 int lret; /* local ret, of this func */
235 struct stream *s = NULL;
241 prd->family = AF_UNSPEC;
245 p = strchr (str, ':');
249 if (! all_digit (p + 1))
252 half = XMALLOC (MTYPE_TMP, (p - str) + 1);
253 memcpy (half, str, (p - str));
254 half[p - str] = '\0';
256 p2 = strchr (str, '.');
260 if (! all_digit (half))
263 stream_putw (s, RD_TYPE_AS);
264 stream_putw (s, atoi (half));
265 stream_putl (s, atol (p + 1));
269 ret = inet_aton (half, &addr);
273 stream_putw (s, RD_TYPE_IP);
274 stream_put_in_addr (s, &addr);
275 stream_putw (s, atol (p + 1));
277 memcpy (prd->val, s->data, 8);
284 XFREE(MTYPE_TMP, half);
289 str2tag (const char *str, u_char *tag)
299 l = strtoul (str, &endptr, 10);
301 if (*endptr != '\0' || errno || l > UINT32_MAX)
306 tag[0] = (u_char)(t >> 12);
307 tag[1] = (u_char)(t >> 4);
308 tag[2] = (u_char)(t << 4);
314 prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size)
321 if (size < RD_ADDRSTRLEN)
326 type = decode_rd_type (pnt);
328 if (type == RD_TYPE_AS)
330 decode_rd_as (pnt + 2, &rd_as);
331 snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val);
334 else if (type == RD_TYPE_AS4)
336 decode_rd_as4 (pnt + 2, &rd_as);
337 snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val);
340 else if (type == RD_TYPE_IP)
342 decode_rd_ip (pnt + 2, &rd_ip);
343 snprintf (buf, size, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
349 /* For testing purpose, static route of MPLS-VPN. */
350 DEFUN (vpnv4_network,
352 "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
353 "Specify a network to announce via BGP\n"
354 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
355 "Specify Route Distinguisher\n"
356 "VPN Route Distinguisher\n"
360 return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL);
363 DEFUN (vpnv4_network_route_map,
364 vpnv4_network_route_map_cmd,
365 "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD",
366 "Specify a network to announce via BGP\n"
367 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
368 "Specify Route Distinguisher\n"
369 "VPN Route Distinguisher\n"
375 return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], argv[3]);
378 /* For testing purpose, static route of MPLS-VPN. */
379 DEFUN (no_vpnv4_network,
380 no_vpnv4_network_cmd,
381 "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
383 "Specify a network to announce via BGP\n"
384 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
385 "Specify Route Distinguisher\n"
386 "VPN Route Distinguisher\n"
390 return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]);
394 show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
397 struct bgp_table *table;
403 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
405 bgp = bgp_get_default ();
408 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
412 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn;
413 rn = bgp_route_next (rn))
415 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
418 if ((table = rn->info) != NULL)
422 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
423 if ((attr = rm->info) != NULL)
427 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
428 inet_ntoa (bgp->router_id), VTY_NEWLINE);
429 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
431 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
432 VTY_NEWLINE, VTY_NEWLINE);
433 vty_out (vty, v4_header, VTY_NEWLINE);
446 /* Decode RD type. */
447 type = decode_rd_type (pnt);
448 /* Decode RD value. */
449 if (type == RD_TYPE_AS)
450 decode_rd_as (pnt + 2, &rd_as);
451 else if (type == RD_TYPE_AS4)
452 decode_rd_as4 (pnt + 2, &rd_as);
453 else if (type == RD_TYPE_IP)
454 decode_rd_ip (pnt + 2, &rd_ip);
456 vty_out (vty, "Route Distinguisher: ");
458 if (type == RD_TYPE_AS)
459 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
460 else if (type == RD_TYPE_AS4)
461 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
462 else if (type == RD_TYPE_IP)
463 vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
465 vty_out (vty, "%s", VTY_NEWLINE);
468 route_vty_out_tmp (vty, &rm->p, attr, SAFI_MPLS_VPN);
477 bgp_show_type_normal,
478 bgp_show_type_regexp,
479 bgp_show_type_prefix_list,
480 bgp_show_type_filter_list,
481 bgp_show_type_neighbor,
482 bgp_show_type_cidr_only,
483 bgp_show_type_prefix_longer,
484 bgp_show_type_community_all,
485 bgp_show_type_community,
486 bgp_show_type_community_exact,
487 bgp_show_type_community_list,
488 bgp_show_type_community_list_exact
495 struct prefix_rd *prd,
496 enum bgp_show_type type,
501 struct bgp_table *table;
507 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
508 char v4_header_tag[] = " Network Next Hop In tag/Out tag%s";
510 unsigned long output_count = 0;
511 unsigned long total_count = 0;
513 bgp = bgp_get_default ();
516 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
520 if ((afi != AFI_IP) && (afi != AFI_IP6))
522 vty_out (vty, "Afi %d not supported%s", afi, VTY_NEWLINE);
526 for (rn = bgp_table_top (bgp->rib[afi][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
528 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
531 if ((table = rn->info) != NULL)
535 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
536 for (ri = rm->info; ri; ri = ri->next)
539 if (type == bgp_show_type_neighbor)
541 union sockunion *su = output_arg;
543 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
549 vty_out (vty, v4_header_tag, VTY_NEWLINE);
552 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
553 inet_ntoa (bgp->router_id), VTY_NEWLINE);
554 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
556 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
557 VTY_NEWLINE, VTY_NEWLINE);
558 vty_out (vty, v4_header, VTY_NEWLINE);
572 /* Decode RD type. */
573 type = decode_rd_type (pnt);
574 /* Decode RD value. */
575 if (type == RD_TYPE_AS)
576 decode_rd_as (pnt + 2, &rd_as);
577 else if (type == RD_TYPE_AS4)
578 decode_rd_as4 (pnt + 2, &rd_as);
579 else if (type == RD_TYPE_IP)
580 decode_rd_ip (pnt + 2, &rd_ip);
582 vty_out (vty, "Route Distinguisher: ");
584 if (type == RD_TYPE_AS)
585 vty_out (vty, "as2 %u:%d", rd_as.as, rd_as.val);
586 else if (type == RD_TYPE_AS4)
587 vty_out (vty, "as4 %u:%d", rd_as.as, rd_as.val);
588 else if (type == RD_TYPE_IP)
589 vty_out (vty, "ip %s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
591 vty_out (vty, "%s", VTY_NEWLINE);
595 route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
597 route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
603 if (output_count == 0)
605 vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
608 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
609 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
614 DEFUN (show_bgp_ipv4_vpn,
615 show_bgp_ipv4_vpn_cmd,
620 "Display VPN NLRI specific information\n")
622 return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0);
625 DEFUN (show_bgp_ipv6_vpn,
626 show_bgp_ipv6_vpn_cmd,
631 "Display VPN NLRI specific information\n")
633 return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0);
636 DEFUN (show_bgp_ipv4_vpn_rd,
637 show_bgp_ipv4_vpn_rd_cmd,
638 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn",
642 "Display VPN NLRI specific information\n"
643 "Display information for a route distinguisher\n"
644 "VPN Route Distinguisher\n")
647 struct prefix_rd prd;
649 ret = str2prefix_rd (argv[0], &prd);
652 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
655 return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0);
658 DEFUN (show_bgp_ipv6_vpn_rd,
659 show_bgp_ipv6_vpn_rd_cmd,
660 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn",
664 "Display VPN NLRI specific information\n"
665 "Display information for a route distinguisher\n"
666 "VPN Route Distinguisher\n")
669 struct prefix_rd prd;
671 ret = str2prefix_rd (argv[0], &prd);
674 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
677 return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0);
681 DEFUN (show_bgp_ipv4_vpn_tags,
682 show_bgp_ipv4_vpn_tags_cmd,
683 "show bgp ipv4 vpn tags",
687 "Display VPN NLRI specific information\n"
688 "Display BGP tags for prefixes\n")
690 return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1);
692 DEFUN (show_bgp_ipv6_vpn_tags,
693 show_bgp_ipv6_vpn_tags_cmd,
694 "show bgp ipv6 vpn tags",
698 "Display VPN NLRI specific information\n"
699 "Display BGP tags for prefixes\n")
701 return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 1);
704 DEFUN (show_bgp_ipv4_vpn_rd_tags,
705 show_bgp_ipv4_vpn_rd_tags_cmd,
706 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn tags",
710 "Display VPN NLRI specific information\n"
711 "Display information for a route distinguisher\n"
712 "VPN Route Distinguisher\n"
713 "Display BGP tags for prefixes\n")
716 struct prefix_rd prd;
718 ret = str2prefix_rd (argv[0], &prd);
721 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
724 return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1);
726 DEFUN (show_bgp_ipv6_vpn_rd_tags,
727 show_bgp_ipv6_vpn_rd_tags_cmd,
728 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn tags",
732 "Display VPN NLRI specific information\n"
733 "Display information for a route distinguisher\n"
734 "VPN Route Distinguisher\n"
735 "Display BGP tags for prefixes\n")
738 struct prefix_rd prd;
740 ret = str2prefix_rd (argv[0], &prd);
743 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
746 return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 1);
749 DEFUN (show_bgp_ipv4_vpn_neighbor_routes,
750 show_bgp_ipv4_vpn_neighbor_routes_cmd,
751 "show bgp ipv4 vpn neighbors (A.B.C.D|X:X::X:X) routes",
755 "Display VPN NLRI specific information\n"
756 "Detailed information on TCP and BGP neighbor connections\n"
757 "Neighbor to display information about\n"
758 "Neighbor to display information about\n"
759 "Display routes learned from neighbor\n")
765 ret = str2sockunion (argv[0], &su);
768 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
772 peer = peer_lookup (NULL, &su);
773 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
775 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
779 return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0);
782 DEFUN (show_bgp_ipv6_vpn_neighbor_routes,
783 show_bgp_ipv6_vpn_neighbor_routes_cmd,
784 "show bgp ipv6 vpn neighbors (A.B.C.D|X:X::X:X) routes",
788 "Display VPN NLRI specific information\n"
789 "Detailed information on TCP and BGP neighbor connections\n"
790 "Neighbor to display information about\n"
791 "Neighbor to display information about\n"
792 "Display routes learned from neighbor\n")
799 ret = str2sockunion (argv[0], &su);
802 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
806 peer = peer_lookup (NULL, &su);
807 if (! peer || ! peer->afc[AFI_IP6][SAFI_MPLS_VPN])
809 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
813 return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_neighbor, &su, 0);
816 DEFUN (show_bgp_ipv4_vpn_neighbor_advertised_routes,
817 show_bgp_ipv4_vpn_neighbor_advertised_routes_cmd,
818 "show bgp ipv4 vpn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
822 "Display VPN NLRI specific information\n"
823 "Detailed information on TCP and BGP neighbor connections\n"
824 "Neighbor to display information about\n"
825 "Display the routes advertised to a BGP neighbor\n")
831 ret = str2sockunion (argv[0], &su);
834 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
837 peer = peer_lookup (NULL, &su);
838 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
840 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
844 return show_adj_route_vpn (vty, peer, NULL);
846 DEFUN (show_bgp_ipv6_vpn_neighbor_advertised_routes,
847 show_bgp_ipv6_vpn_neighbor_advertised_routes_cmd,
848 "show bgp ipv6 vpn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
852 "Display VPN NLRI specific information\n"
853 "Detailed information on TCP and BGP neighbor connections\n"
854 "Neighbor to display information about\n"
855 "Display the routes advertised to a BGP neighbor\n")
861 ret = str2sockunion (argv[0], &su);
864 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
867 peer = peer_lookup (NULL, &su);
868 if (! peer || ! peer->afc[AFI_IP6][SAFI_MPLS_VPN])
870 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
874 return show_adj_route_vpn (vty, peer, NULL);
877 DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
878 show_bgp_ipv4_vpn_rd_neighbor_advertised_routes_cmd,
879 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
883 "Display VPN NLRI specific information\n"
884 "Display information for a route distinguisher\n"
885 "VPN Route Distinguisher\n"
886 "Detailed information on TCP and BGP neighbor connections\n"
887 "Neighbor to display information about\n"
888 "Neighbor to display information about\n"
889 "Display the routes advertised to a BGP neighbor\n")
893 struct prefix_rd prd;
895 ret = str2sockunion (argv[1], &su);
898 vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
901 peer = peer_lookup (NULL, &su);
902 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
904 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
908 ret = str2prefix_rd (argv[0], &prd);
911 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
915 return show_adj_route_vpn (vty, peer, &prd);
917 DEFUN (show_ip_bgp_vpnv6_rd_neighbor_advertised_routes,
918 show_bgp_ipv6_vpn_rd_neighbor_advertised_routes_cmd,
919 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
923 "Display VPN NLRI specific information\n"
924 "Display information for a route distinguisher\n"
925 "VPN Route Distinguisher\n"
926 "Detailed information on TCP and BGP neighbor connections\n"
927 "Neighbor to display information about\n"
928 "Neighbor to display information about\n"
929 "Display the routes advertised to a BGP neighbor\n")
933 struct prefix_rd prd;
935 ret = str2sockunion (argv[1], &su);
938 vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
941 peer = peer_lookup (NULL, &su);
942 if (! peer || ! peer->afc[AFI_IP6][SAFI_MPLS_VPN])
944 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
948 ret = str2prefix_rd (argv[0], &prd);
951 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
955 return show_adj_route_vpn (vty, peer, &prd);
958 DEFUN (show_bgp_ipv4_vpn_rd_neighbor_routes,
959 show_bgp_ipv4_vpn_rd_neighbor_routes_cmd,
960 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
964 "Address Family modifier\n"
965 "Display information for a route distinguisher\n"
966 "VPN Route Distinguisher\n"
967 "Detailed information on TCP and BGP neighbor connections\n"
968 "Neighbor to display information about\n"
969 "Display routes learned from neighbor\n")
974 struct prefix_rd prd;
976 ret = str2prefix_rd (argv[0], &prd);
979 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
983 if (str2sockunion(argv[1], &su))
985 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
989 peer = peer_lookup (NULL, &su);
990 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
992 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
996 return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0);
998 DEFUN (show_bgp_ipv6_vpn_rd_neighbor_routes,
999 show_bgp_ipv6_vpn_rd_neighbor_routes_cmd,
1000 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
1004 "Address Family modifier\n"
1005 "Display information for a route distinguisher\n"
1006 "VPN Route Distinguisher\n"
1007 "Detailed information on TCP and BGP neighbor connections\n"
1008 "Neighbor to display information about\n"
1009 "Display routes learned from neighbor\n")
1014 struct prefix_rd prd;
1016 ret = str2prefix_rd (argv[0], &prd);
1019 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
1023 if (str2sockunion(argv[1], &su))
1025 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
1029 peer = peer_lookup (NULL, &su);
1030 if (! peer || ! peer->afc[AFI_IP6][SAFI_MPLS_VPN])
1032 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
1036 return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0);
1040 bgp_mplsvpn_init (void)
1042 install_element (BGP_VPNV4_NODE, &vpnv4_network_cmd);
1043 install_element (BGP_VPNV4_NODE, &vpnv4_network_route_map_cmd);
1044 install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd);
1046 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_cmd);
1047 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd);
1048 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_tags_cmd);
1049 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_tags_cmd);
1050 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_neighbor_routes_cmd);
1051 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_neighbor_advertised_routes_cmd);
1052 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_neighbor_advertised_routes_cmd);
1053 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_neighbor_routes_cmd);
1055 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd);
1056 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd);
1057 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_tags_cmd);
1058 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_tags_cmd);
1059 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_neighbor_routes_cmd);
1060 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_neighbor_advertised_routes_cmd);
1061 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_neighbor_advertised_routes_cmd);
1062 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_neighbor_routes_cmd);