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
31 #include "bgpd/bgpd.h"
32 #include "bgpd/bgp_table.h"
33 #include "bgpd/bgp_route.h"
34 #include "bgpd/bgp_attr.h"
35 #include "bgpd/bgp_mplsvpn.h"
38 decode_rd_type (u_char
*pnt
)
42 v
= ((u_int16_t
) *pnt
++ << 8);
43 v
|= (u_int16_t
) *pnt
;
48 decode_label (u_char
*pnt
)
52 l
= ((u_int32_t
) *pnt
++ << 12);
53 l
|= (u_int32_t
) *pnt
++ << 4;
54 l
|= (u_int32_t
) ((*pnt
& 0xf0) >> 4);
59 decode_rd_as (u_char
*pnt
, struct rd_as
*rd_as
)
61 rd_as
->as
= (u_int16_t
) *pnt
++ << 8;
62 rd_as
->as
|= (u_int16_t
) *pnt
++;
64 rd_as
->val
= ((u_int32_t
) *pnt
++ << 24);
65 rd_as
->val
|= ((u_int32_t
) *pnt
++ << 16);
66 rd_as
->val
|= ((u_int32_t
) *pnt
++ << 8);
67 rd_as
->val
|= (u_int32_t
) *pnt
;
71 decode_rd_ip (u_char
*pnt
, struct rd_ip
*rd_ip
)
73 memcpy (&rd_ip
->ip
, pnt
, 4);
76 rd_ip
->val
= ((u_int16_t
) *pnt
++ << 8);
77 rd_ip
->val
|= (u_int16_t
) *pnt
;
81 bgp_nlri_parse_vpnv4 (struct peer
*peer
, struct attr
*attr
,
82 struct bgp_nlri
*packet
)
96 u_char addpath_encoded
;
99 /* Check peer status. */
100 if (peer
->status
!= Established
)
104 prd
.family
= AF_UNSPEC
;
108 lim
= pnt
+ packet
->length
;
113 addpath_encoded
= (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
114 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
116 for (; pnt
< lim
; pnt
+= psize
)
118 /* Clear prefix structure. */
119 memset (&p
, 0, sizeof (struct prefix
));
124 /* When packet overflow occurs return immediately. */
125 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
128 addpath_id
= ntohl(*((uint32_t*) pnt
));
129 pnt
+= BGP_ADDPATH_ID_LEN
;
132 /* Fetch prefix length. */
135 psize
= PSIZE (prefixlen
);
139 zlog_err ("prefix length is less than 88: %d", prefixlen
);
143 /* Copyr label to prefix. */
146 /* Copy routing distinguisher to rd. */
147 memcpy (&prd
.val
, pnt
+ 3, 8);
149 /* Decode RD type. */
150 type
= decode_rd_type (pnt
+ 3);
152 /* Decode RD value. */
153 if (type
== RD_TYPE_AS
)
154 decode_rd_as (pnt
+ 5, &rd_as
);
155 else if (type
== RD_TYPE_IP
)
156 decode_rd_ip (pnt
+ 5, &rd_ip
);
159 zlog_err ("Invalid RD type %d", type
);
163 p
.prefixlen
= prefixlen
- 88;
164 memcpy (&p
.u
.prefix
, pnt
+ 11, psize
- 11);
167 if (type
== RD_TYPE_AS
)
168 zlog_info ("prefix %ld:%ld:%ld:%s/%d", label
, rd_as
.as
, rd_as
.val
,
169 inet_ntoa (p
.u
.prefix4
), p
.prefixlen
);
170 else if (type
== RD_TYPE_IP
)
171 zlog_info ("prefix %ld:%s:%ld:%s/%d", label
, inet_ntoa (rd_ip
.ip
),
172 rd_ip
.val
, inet_ntoa (p
.u
.prefix4
), p
.prefixlen
);
175 if (pnt
+ psize
> lim
)
179 bgp_update (peer
, &p
, addpath_id
, attr
, AFI_IP
, SAFI_MPLS_VPN
,
180 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, &prd
, tagpnt
, 0);
182 bgp_withdraw (peer
, &p
, addpath_id
, attr
, AFI_IP
, SAFI_MPLS_VPN
,
183 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, &prd
, tagpnt
);
186 /* Packet length consistency check. */
194 str2prefix_rd (const char *str
, struct prefix_rd
*prd
)
205 prd
->family
= AF_UNSPEC
;
208 p
= strchr (str
, ':');
212 if (! all_digit (p
+ 1))
215 half
= XMALLOC (MTYPE_TMP
, (p
- str
) + 1);
216 memcpy (half
, str
, (p
- str
));
217 half
[p
- str
] = '\0';
219 p2
= strchr (str
, '.');
223 if (! all_digit (half
))
225 XFREE (MTYPE_TMP
, half
);
228 stream_putw (s
, RD_TYPE_AS
);
229 stream_putw (s
, atoi (half
));
230 stream_putl (s
, atol (p
+ 1));
234 ret
= inet_aton (half
, &addr
);
237 XFREE (MTYPE_TMP
, half
);
240 stream_putw (s
, RD_TYPE_IP
);
241 stream_put_in_addr (s
, &addr
);
242 stream_putw (s
, atol (p
+ 1));
244 memcpy (prd
->val
, s
->data
, 8);
246 XFREE(MTYPE_TMP
, half
);
251 str2tag (const char *str
, u_char
*tag
)
261 l
= strtoul (str
, &endptr
, 10);
263 if (*endptr
!= '\0' || errno
|| l
> UINT32_MAX
)
268 tag
[0] = (u_char
)(t
>> 12);
269 tag
[1] = (u_char
)(t
>> 4);
270 tag
[2] = (u_char
)(t
<< 4);
276 prefix_rd2str (struct prefix_rd
*prd
, char *buf
, size_t size
)
283 if (size
< RD_ADDRSTRLEN
)
288 type
= decode_rd_type (pnt
);
290 if (type
== RD_TYPE_AS
)
292 decode_rd_as (pnt
+ 2, &rd_as
);
293 snprintf (buf
, size
, "%u:%d", rd_as
.as
, rd_as
.val
);
296 else if (type
== RD_TYPE_IP
)
298 decode_rd_ip (pnt
+ 2, &rd_ip
);
299 snprintf (buf
, size
, "%s:%d", inet_ntoa (rd_ip
.ip
), rd_ip
.val
);
306 /* For testing purpose, static route of MPLS-VPN. */
307 DEFUN (vpnv4_network
,
309 "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
310 "Specify a network to announce via BGP\n"
311 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
312 "Specify Route Distinguisher\n"
313 "VPN Route Distinguisher\n"
317 return bgp_static_set_vpnv4 (vty
, argv
[0], argv
[1], argv
[2]);
320 /* For testing purpose, static route of MPLS-VPN. */
321 DEFUN (no_vpnv4_network
,
322 no_vpnv4_network_cmd
,
323 "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
325 "Specify a network to announce via BGP\n"
326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
327 "Specify Route Distinguisher\n"
328 "VPN Route Distinguisher\n"
332 return bgp_static_unset_vpnv4 (vty
, argv
[0], argv
[1], argv
[2]);
336 show_adj_route_vpn (struct vty
*vty
, struct peer
*peer
, struct prefix_rd
*prd
, u_char use_json
)
339 struct bgp_table
*table
;
345 char v4_header
[] = " Network Next Hop Metric LocPrf Weight Path%s";
346 json_object
*json
= NULL
;
347 json_object
*json_scode
= NULL
;
348 json_object
*json_ocode
= NULL
;
349 json_object
*json_routes
= NULL
;
350 json_object
*json_array
= NULL
;
352 bgp
= bgp_get_default ();
356 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
362 json_scode
= json_object_new_object();
363 json_ocode
= json_object_new_object();
364 json_routes
= json_object_new_object();
365 json
= json_object_new_object();
367 json_object_string_add(json_scode
, "suppressed", "s");
368 json_object_string_add(json_scode
, "damped", "d");
369 json_object_string_add(json_scode
, "history", "h");
370 json_object_string_add(json_scode
, "valid", "*");
371 json_object_string_add(json_scode
, "best", ">");
372 json_object_string_add(json_scode
, "internal", "i");
374 json_object_string_add(json_ocode
, "igp", "i");
375 json_object_string_add(json_ocode
, "egp", "e");
376 json_object_string_add(json_ocode
, "incomplete", "?");
379 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
;
380 rn
= bgp_route_next (rn
))
382 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
385 if ((table
= rn
->info
) != NULL
)
388 json_array
= json_object_new_array();
394 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
396 if ((attr
= rm
->info
) != NULL
)
402 json_object_int_add(json
, "bgpTableVersion", 0);
403 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
404 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
405 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
409 vty_out (vty
, "BGP table version is 0, local router ID is %s%s",
410 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
411 vty_out (vty
, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
413 vty_out (vty
, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
414 VTY_NEWLINE
, VTY_NEWLINE
);
415 vty_out (vty
, v4_header
, VTY_NEWLINE
);
429 /* Decode RD type. */
430 type
= decode_rd_type (pnt
);
431 /* Decode RD value. */
432 if (type
== RD_TYPE_AS
)
433 decode_rd_as (pnt
+ 2, &rd_as
);
434 else if (type
== RD_TYPE_IP
)
435 decode_rd_ip (pnt
+ 2, &rd_ip
);
440 if (type
== RD_TYPE_AS
)
441 sprintf (buffer
, "%u:%d", rd_as
.as
, rd_as
.val
);
442 else if (type
== RD_TYPE_IP
)
443 sprintf (buffer
, "%u:%d", rd_as
.as
, rd_as
.val
);
444 json_object_string_add(json_routes
, "routeDistinguisher", buffer
);
448 vty_out (vty
, "Route Distinguisher: ");
450 if (type
== RD_TYPE_AS
)
451 vty_out (vty
, "%u:%d", rd_as
.as
, rd_as
.val
);
452 else if (type
== RD_TYPE_IP
)
453 vty_out (vty
, "%s:%d", inet_ntoa (rd_ip
.ip
), rd_ip
.val
);
455 vty_out (vty
, "%s", VTY_NEWLINE
);
459 route_vty_out_tmp (vty
, &rm
->p
, attr
, SAFI_MPLS_VPN
, use_json
, json_array
);
468 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
), p
->prefixlen
);
469 json_object_object_add(json_routes
, buf_a
, json_array
);
475 json_object_object_add(json
, "routes", json_routes
);
476 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
477 json_object_free(json
);
484 bgp_show_type_normal
,
485 bgp_show_type_regexp
,
486 bgp_show_type_prefix_list
,
487 bgp_show_type_filter_list
,
488 bgp_show_type_neighbor
,
489 bgp_show_type_cidr_only
,
490 bgp_show_type_prefix_longer
,
491 bgp_show_type_community_all
,
492 bgp_show_type_community
,
493 bgp_show_type_community_exact
,
494 bgp_show_type_community_list
,
495 bgp_show_type_community_list_exact
499 bgp_show_mpls_vpn (struct vty
*vty
, struct prefix_rd
*prd
, enum bgp_show_type type
,
500 void *output_arg
, int tags
, u_char use_json
)
503 struct bgp_table
*table
;
509 char v4_header
[] = " Network Next Hop Metric LocPrf Weight Path%s";
510 char v4_header_tag
[] = " Network Next Hop In tag/Out tag%s";
511 json_object
*json
= NULL
;
512 json_object
*json_mroute
= NULL
;
513 json_object
*json_nroute
= NULL
;
514 json_object
*json_array
= NULL
;
515 json_object
*json_scode
= NULL
;
516 json_object
*json_ocode
= NULL
;
518 bgp
= bgp_get_default ();
522 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
528 json_scode
= json_object_new_object();
529 json_ocode
= json_object_new_object();
530 json
= json_object_new_object();
531 json_mroute
= json_object_new_object();
532 json_nroute
= json_object_new_object();
534 json_object_string_add(json_scode
, "suppressed", "s");
535 json_object_string_add(json_scode
, "damped", "d");
536 json_object_string_add(json_scode
, "history", "h");
537 json_object_string_add(json_scode
, "valid", "*");
538 json_object_string_add(json_scode
, "best", ">");
539 json_object_string_add(json_scode
, "internal", "i");
541 json_object_string_add(json_ocode
, "igp", "i");
542 json_object_string_add(json_ocode
, "egp", "e");
543 json_object_string_add(json_ocode
, "incomplete", "?");
546 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
548 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
551 if ((table
= rn
->info
) != NULL
)
555 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
558 json_array
= json_object_new_array();
562 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
564 if (type
== bgp_show_type_neighbor
)
566 union sockunion
*su
= output_arg
;
568 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
577 json_object_int_add(json
, "bgpTableVersion", 0);
578 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
579 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
580 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
586 vty_out (vty
, v4_header_tag
, VTY_NEWLINE
);
589 vty_out (vty
, "BGP table version is 0, local router ID is %s%s",
590 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
591 vty_out (vty
, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
593 vty_out (vty
, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
594 VTY_NEWLINE
, VTY_NEWLINE
);
595 vty_out (vty
, v4_header
, VTY_NEWLINE
);
610 /* Decode RD type. */
611 type
= decode_rd_type (pnt
);
612 /* Decode RD value. */
613 if (type
== RD_TYPE_AS
)
614 decode_rd_as (pnt
+ 2, &rd_as
);
615 else if (type
== RD_TYPE_IP
)
616 decode_rd_ip (pnt
+ 2, &rd_ip
);
621 if (type
== RD_TYPE_AS
)
622 sprintf (buffer
, "%u:%d", rd_as
.as
, rd_as
.val
);
623 else if (type
== RD_TYPE_IP
)
624 sprintf (buffer
, "%s:%d", inet_ntoa (rd_ip
.ip
), rd_ip
.val
);
625 json_object_string_add(json_nroute
, "routeDistinguisher", buffer
);
629 vty_out (vty
, "Route Distinguisher: ");
631 if (type
== RD_TYPE_AS
)
632 vty_out (vty
, "%u:%d", rd_as
.as
, rd_as
.val
);
633 else if (type
== RD_TYPE_IP
)
634 vty_out (vty
, "%s:%d", inet_ntoa (rd_ip
.ip
), rd_ip
.val
);
635 vty_out (vty
, "%s", VTY_NEWLINE
);
640 route_vty_out_tag (vty
, &rm
->p
, ri
, 0, SAFI_MPLS_VPN
, json_array
);
642 route_vty_out (vty
, &rm
->p
, ri
, 0, SAFI_MPLS_VPN
, json_array
);
651 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
), p
->prefixlen
);
652 json_object_object_add(json_mroute
, buf_a
, json_array
);
662 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
), p
->prefixlen
);
663 json_object_object_add(json_nroute
, buf_a
, json_mroute
);
670 json_object_object_add(json
, "routes", json_nroute
);
671 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
672 json_object_free(json
);
677 DEFUN (show_ip_bgp_vpnv4_all
,
678 show_ip_bgp_vpnv4_all_cmd
,
679 "show ip bgp vpnv4 all",
683 "Display VPNv4 NLRI specific information\n"
684 "Display information about all VPNv4 NLRIs\n")
686 return bgp_show_mpls_vpn (vty
, NULL
, bgp_show_type_normal
, NULL
, 0, 0);
689 DEFUN (show_ip_bgp_vpnv4_rd
,
690 show_ip_bgp_vpnv4_rd_cmd
,
691 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn",
695 "Display VPNv4 NLRI specific information\n"
696 "Display information for a route distinguisher\n"
697 "VPN Route Distinguisher\n")
700 struct prefix_rd prd
;
702 ret
= str2prefix_rd (argv
[0], &prd
);
705 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
708 return bgp_show_mpls_vpn (vty
, &prd
, bgp_show_type_normal
, NULL
, 0, 0);
711 DEFUN (show_ip_bgp_vpnv4_all_tags
,
712 show_ip_bgp_vpnv4_all_tags_cmd
,
713 "show ip bgp vpnv4 all tags",
717 "Display VPNv4 NLRI specific information\n"
718 "Display information about all VPNv4 NLRIs\n"
719 "Display BGP tags for prefixes\n")
721 return bgp_show_mpls_vpn (vty
, NULL
, bgp_show_type_normal
, NULL
, 1, 0);
724 DEFUN (show_ip_bgp_vpnv4_rd_tags
,
725 show_ip_bgp_vpnv4_rd_tags_cmd
,
726 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags",
730 "Display VPNv4 NLRI specific information\n"
731 "Display information for a route distinguisher\n"
732 "VPN Route Distinguisher\n"
733 "Display BGP tags for prefixes\n")
736 struct prefix_rd prd
;
738 ret
= str2prefix_rd (argv
[0], &prd
);
741 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
744 return bgp_show_mpls_vpn (vty
, &prd
, bgp_show_type_normal
, NULL
, 1, 0);
747 DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes
,
748 show_ip_bgp_vpnv4_all_neighbor_routes_cmd
,
749 "show ip bgp vpnv4 all neighbors A.B.C.D routes {json}",
753 "Display VPNv4 NLRI specific information\n"
754 "Display information about all VPNv4 NLRIs\n"
755 "Detailed information on TCP and BGP neighbor connections\n"
756 "Neighbor to display information about\n"
757 "Display routes learned from neighbor\n"
758 "JavaScript Object Notation\n")
763 u_char use_json
= (argv
[1] != NULL
);
765 ret
= str2sockunion (argv
[0], &su
);
770 json_object
*json_no
= NULL
;
771 json_no
= json_object_new_object();
772 json_object_string_add(json_no
, "warning", "Malformed address");
773 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
774 json_object_free(json_no
);
777 vty_out (vty
, "Malformed address: %s%s", argv
[0], VTY_NEWLINE
);
781 peer
= peer_lookup (NULL
, &su
);
782 if (! peer
|| ! peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
786 json_object
*json_no
= NULL
;
787 json_no
= json_object_new_object();
788 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
789 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
790 json_object_free(json_no
);
793 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
797 return bgp_show_mpls_vpn (vty
, NULL
, bgp_show_type_neighbor
, &su
, 0, use_json
);
800 DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes
,
801 show_ip_bgp_vpnv4_rd_neighbor_routes_cmd
,
802 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes {json}",
806 "Display VPNv4 NLRI specific information\n"
807 "Display information for a route distinguisher\n"
808 "VPN Route Distinguisher\n"
809 "Detailed information on TCP and BGP neighbor connections\n"
810 "Neighbor to display information about\n"
811 "Display routes learned from neighbor\n"
812 "JavaScript Object Notation\n")
817 struct prefix_rd prd
;
818 u_char use_json
= (argv
[2] != NULL
);
820 ret
= str2prefix_rd (argv
[0], &prd
);
825 json_object
*json_no
= NULL
;
826 json_no
= json_object_new_object();
827 json_object_string_add(json_no
, "warning", "Malformed Route Distinguisher");
828 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
829 json_object_free(json_no
);
832 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
836 ret
= str2sockunion (argv
[1], &su
);
841 json_object
*json_no
= NULL
;
842 json_no
= json_object_new_object();
843 json_object_string_add(json_no
, "warning", "Malformed address");
844 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
845 json_object_free(json_no
);
848 vty_out (vty
, "Malformed address: %s%s", argv
[0], VTY_NEWLINE
);
852 peer
= peer_lookup (NULL
, &su
);
853 if (! peer
|| ! peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
857 json_object
*json_no
= NULL
;
858 json_no
= json_object_new_object();
859 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
860 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
861 json_object_free(json_no
);
864 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
868 return bgp_show_mpls_vpn (vty
, &prd
, bgp_show_type_neighbor
, &su
, 0, use_json
);
871 DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes
,
872 show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd
,
873 "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes {json}",
877 "Display VPNv4 NLRI specific information\n"
878 "Display information about all VPNv4 NLRIs\n"
879 "Detailed information on TCP and BGP neighbor connections\n"
880 "Neighbor to display information about\n"
881 "Display the routes advertised to a BGP neighbor\n"
882 "JavaScript Object Notation\n")
887 u_char use_json
= (argv
[1] != NULL
);
889 ret
= str2sockunion (argv
[0], &su
);
894 json_object
*json_no
= NULL
;
895 json_no
= json_object_new_object();
896 json_object_string_add(json_no
, "warning", "Malformed address");
897 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
898 json_object_free(json_no
);
901 vty_out (vty
, "Malformed address: %s%s", argv
[0], VTY_NEWLINE
);
904 peer
= peer_lookup (NULL
, &su
);
905 if (! peer
|| ! peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
909 json_object
*json_no
= NULL
;
910 json_no
= json_object_new_object();
911 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
912 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
913 json_object_free(json_no
);
916 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
920 return show_adj_route_vpn (vty
, peer
, NULL
, use_json
);
923 DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes
,
924 show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd
,
925 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes {json}",
929 "Display VPNv4 NLRI specific information\n"
930 "Display information for a route distinguisher\n"
931 "VPN Route Distinguisher\n"
932 "Detailed information on TCP and BGP neighbor connections\n"
933 "Neighbor to display information about\n"
934 "Display the routes advertised to a BGP neighbor\n"
935 "JavaScript Object Notation\n")
939 struct prefix_rd prd
;
941 u_char use_json
= (argv
[2] != NULL
);
943 ret
= str2sockunion (argv
[1], &su
);
948 json_object
*json_no
= NULL
;
949 json_no
= json_object_new_object();
950 json_object_string_add(json_no
, "warning", "Malformed address");
951 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
952 json_object_free(json_no
);
955 vty_out (vty
, "Malformed address: %s%s", argv
[0], VTY_NEWLINE
);
958 peer
= peer_lookup (NULL
, &su
);
959 if (! peer
|| ! peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
963 json_object
*json_no
= NULL
;
964 json_no
= json_object_new_object();
965 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
966 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
967 json_object_free(json_no
);
970 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
974 ret
= str2prefix_rd (argv
[0], &prd
);
979 json_object
*json_no
= NULL
;
980 json_no
= json_object_new_object();
981 json_object_string_add(json_no
, "warning", "Malformed Route Distinguisher");
982 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
983 json_object_free(json_no
);
986 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
990 return show_adj_route_vpn (vty
, peer
, &prd
, use_json
);
994 bgp_mplsvpn_init (void)
996 install_element (BGP_VPNV4_NODE
, &vpnv4_network_cmd
);
997 install_element (BGP_VPNV4_NODE
, &no_vpnv4_network_cmd
);
1000 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_cmd
);
1001 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_cmd
);
1002 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_tags_cmd
);
1003 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_tags_cmd
);
1004 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd
);
1005 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd
);
1006 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd
);
1007 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd
);
1009 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_cmd
);
1010 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_cmd
);
1011 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_tags_cmd
);
1012 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_tags_cmd
);
1013 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd
);
1014 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd
);
1015 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd
);
1016 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd
);