]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_mplsvpn.c
If the .conf file for a process is missing have /etc/init.d/quagga touch it so we...
[mirror_frr.git] / bgpd / bgp_mplsvpn.c
CommitLineData
718e3744 1/* MPLS-VPN
2 Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "command.h"
24#include "prefix.h"
25#include "log.h"
26#include "memory.h"
27#include "stream.h"
28
29#include "bgpd/bgpd.h"
30#include "bgpd/bgp_table.h"
31#include "bgpd/bgp_route.h"
32#include "bgpd/bgp_attr.h"
33#include "bgpd/bgp_mplsvpn.h"
34
94f2b392 35static u_int16_t
718e3744 36decode_rd_type (u_char *pnt)
37{
38 u_int16_t v;
39
40 v = ((u_int16_t) *pnt++ << 8);
41 v |= (u_int16_t) *pnt;
42 return v;
43}
44
45u_int32_t
46decode_label (u_char *pnt)
47{
48 u_int32_t l;
49
50 l = ((u_int32_t) *pnt++ << 12);
51 l |= (u_int32_t) *pnt++ << 4;
52 l |= (u_int32_t) ((*pnt & 0xf0) >> 4);
53 return l;
54}
55
94f2b392 56static void
718e3744 57decode_rd_as (u_char *pnt, struct rd_as *rd_as)
58{
59 rd_as->as = (u_int16_t) *pnt++ << 8;
60 rd_as->as |= (u_int16_t) *pnt++;
61
62 rd_as->val = ((u_int32_t) *pnt++ << 24);
63 rd_as->val |= ((u_int32_t) *pnt++ << 16);
64 rd_as->val |= ((u_int32_t) *pnt++ << 8);
65 rd_as->val |= (u_int32_t) *pnt;
66}
67
94f2b392 68static void
718e3744 69decode_rd_ip (u_char *pnt, struct rd_ip *rd_ip)
70{
71 memcpy (&rd_ip->ip, pnt, 4);
72 pnt += 4;
73
74 rd_ip->val = ((u_int16_t) *pnt++ << 8);
75 rd_ip->val |= (u_int16_t) *pnt;
76}
77
718e3744 78int
79bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr,
80 struct bgp_nlri *packet)
81{
82 u_char *pnt;
83 u_char *lim;
84 struct prefix p;
85 int psize;
86 int prefixlen;
87 u_int32_t label;
88 u_int16_t type;
89 struct rd_as rd_as;
90 struct rd_ip rd_ip;
91 struct prefix_rd prd;
92 u_char *tagpnt;
a82478b9
DS
93 afi_t afi;
94 safi_t safi;
95 u_char addpath_encoded;
96 u_int32_t addpath_id;
718e3744 97
98 /* Check peer status. */
99 if (peer->status != Established)
100 return 0;
101
102 /* Make prefix_rd */
103 prd.family = AF_UNSPEC;
104 prd.prefixlen = 64;
105
106 pnt = packet->nlri;
107 lim = pnt + packet->length;
a82478b9
DS
108 afi = packet->afi;
109 safi = packet->safi;
110 addpath_id = 0;
111
112 addpath_encoded = (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) &&
113 CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV));
718e3744 114
115 for (; pnt < lim; pnt += psize)
116 {
117 /* Clear prefix structure. */
118 memset (&p, 0, sizeof (struct prefix));
119
a82478b9
DS
120 if (addpath_encoded)
121 {
122 addpath_id = ntohl(*((uint32_t*) pnt));
123 pnt += BGP_ADDPATH_ID_LEN;
124 }
125
718e3744 126 /* Fetch prefix length. */
127 prefixlen = *pnt++;
128 p.family = AF_INET;
129 psize = PSIZE (prefixlen);
130
131 if (prefixlen < 88)
132 {
133 zlog_err ("prefix length is less than 88: %d", prefixlen);
134 return -1;
135 }
136
137 label = decode_label (pnt);
138
139 /* Copyr label to prefix. */
140 tagpnt = pnt;;
141
142 /* Copy routing distinguisher to rd. */
143 memcpy (&prd.val, pnt + 3, 8);
144
145 /* Decode RD type. */
146 type = decode_rd_type (pnt + 3);
147
148 /* Decode RD value. */
149 if (type == RD_TYPE_AS)
150 decode_rd_as (pnt + 5, &rd_as);
151 else if (type == RD_TYPE_IP)
152 decode_rd_ip (pnt + 5, &rd_ip);
153 else
154 {
155 zlog_err ("Invalid RD type %d", type);
156 return -1;
157 }
158
159 p.prefixlen = prefixlen - 88;
160 memcpy (&p.u.prefix, pnt + 11, psize - 11);
161
162#if 0
163 if (type == RD_TYPE_AS)
164 zlog_info ("prefix %ld:%ld:%ld:%s/%d", label, rd_as.as, rd_as.val,
165 inet_ntoa (p.u.prefix4), p.prefixlen);
166 else if (type == RD_TYPE_IP)
167 zlog_info ("prefix %ld:%s:%ld:%s/%d", label, inet_ntoa (rd_ip.ip),
168 rd_ip.val, inet_ntoa (p.u.prefix4), p.prefixlen);
169#endif /* 0 */
170
171 if (pnt + psize > lim)
172 return -1;
173
174 if (attr)
a82478b9 175 bgp_update (peer, &p, addpath_id, attr, AFI_IP, SAFI_MPLS_VPN,
94f2b392 176 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
718e3744 177 else
a82478b9 178 bgp_withdraw (peer, &p, addpath_id, attr, AFI_IP, SAFI_MPLS_VPN,
718e3744 179 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
180 }
181
182 /* Packet length consistency check. */
183 if (pnt != lim)
184 return -1;
185
186 return 0;
187}
188
189int
fd79ac91 190str2prefix_rd (const char *str, struct prefix_rd *prd)
718e3744 191{
192 int ret;
5228ad27 193 char *p;
194 char *p2;
718e3744 195 struct stream *s;
5228ad27 196 char *half;
718e3744 197 struct in_addr addr;
198
199 s = stream_new (8);
200
201 prd->family = AF_UNSPEC;
202 prd->prefixlen = 64;
203
204 p = strchr (str, ':');
205 if (! p)
206 return 0;
207
208 if (! all_digit (p + 1))
209 return 0;
210
211 half = XMALLOC (MTYPE_TMP, (p - str) + 1);
212 memcpy (half, str, (p - str));
213 half[p - str] = '\0';
214
215 p2 = strchr (str, '.');
216
217 if (! p2)
218 {
219 if (! all_digit (half))
220 {
221 XFREE (MTYPE_TMP, half);
222 return 0;
223 }
224 stream_putw (s, RD_TYPE_AS);
225 stream_putw (s, atoi (half));
226 stream_putl (s, atol (p + 1));
227 }
228 else
229 {
230 ret = inet_aton (half, &addr);
231 if (! ret)
232 {
233 XFREE (MTYPE_TMP, half);
234 return 0;
235 }
236 stream_putw (s, RD_TYPE_IP);
237 stream_put_in_addr (s, &addr);
238 stream_putw (s, atol (p + 1));
239 }
240 memcpy (prd->val, s->data, 8);
241
242 return 1;
243}
244
245int
fd79ac91 246str2tag (const char *str, u_char *tag)
718e3744 247{
fd79ac91 248 unsigned long l;
249 char *endptr;
250 u_int32_t t;
718e3744 251
664711c1
UW
252 if (*str == '-')
253 return 0;
fd79ac91 254
664711c1
UW
255 errno = 0;
256 l = strtoul (str, &endptr, 10);
257
258 if (*endptr != '\0' || errno || l > UINT32_MAX)
fd79ac91 259 return 0;
718e3744 260
fd79ac91 261 t = (u_int32_t) l;
262
263 tag[0] = (u_char)(t >> 12);
264 tag[1] = (u_char)(t >> 4);
265 tag[2] = (u_char)(t << 4);
718e3744 266
267 return 1;
268}
269
270char *
271prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size)
272{
273 u_char *pnt;
274 u_int16_t type;
275 struct rd_as rd_as;
276 struct rd_ip rd_ip;
277
278 if (size < RD_ADDRSTRLEN)
279 return NULL;
280
281 pnt = prd->val;
282
283 type = decode_rd_type (pnt);
284
285 if (type == RD_TYPE_AS)
286 {
287 decode_rd_as (pnt + 2, &rd_as);
aea339f7 288 snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val);
718e3744 289 return buf;
290 }
291 else if (type == RD_TYPE_IP)
292 {
293 decode_rd_ip (pnt + 2, &rd_ip);
294 snprintf (buf, size, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
295 return buf;
296 }
297
298 return NULL;
299}
300
301/* For testing purpose, static route of MPLS-VPN. */
302DEFUN (vpnv4_network,
303 vpnv4_network_cmd,
304 "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
305 "Specify a network to announce via BGP\n"
306 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
307 "Specify Route Distinguisher\n"
308 "VPN Route Distinguisher\n"
309 "BGP tag\n"
310 "tag value\n")
311{
312 return bgp_static_set_vpnv4 (vty, argv[0], argv[1], argv[2]);
313}
314
315/* For testing purpose, static route of MPLS-VPN. */
316DEFUN (no_vpnv4_network,
317 no_vpnv4_network_cmd,
318 "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
319 NO_STR
320 "Specify a network to announce via BGP\n"
321 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
322 "Specify Route Distinguisher\n"
323 "VPN Route Distinguisher\n"
324 "BGP tag\n"
325 "tag value\n")
326{
327 return bgp_static_unset_vpnv4 (vty, argv[0], argv[1], argv[2]);
328}
329
94f2b392 330static int
718e3744 331show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
332{
333 struct bgp *bgp;
334 struct bgp_table *table;
335 struct bgp_node *rn;
336 struct bgp_node *rm;
337 struct attr *attr;
338 int rd_header;
339 int header = 1;
340 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
341
342 bgp = bgp_get_default ();
343 if (bgp == NULL)
344 {
345 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
346 return CMD_WARNING;
347 }
348
349 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn;
350 rn = bgp_route_next (rn))
351 {
352 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
353 continue;
354
355 if ((table = rn->info) != NULL)
356 {
357 rd_header = 1;
358
359 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
360 if ((attr = rm->info) != NULL)
361 {
362 if (header)
363 {
364 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
365 inet_ntoa (bgp->router_id), VTY_NEWLINE);
366 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
367 VTY_NEWLINE);
368 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
369 VTY_NEWLINE, VTY_NEWLINE);
370 vty_out (vty, v4_header, VTY_NEWLINE);
371 header = 0;
372 }
373
374 if (rd_header)
375 {
376 u_int16_t type;
377 struct rd_as rd_as;
378 struct rd_ip rd_ip;
379 u_char *pnt;
380
381 pnt = rn->p.u.val;
382
383 /* Decode RD type. */
384 type = decode_rd_type (pnt);
385 /* Decode RD value. */
386 if (type == RD_TYPE_AS)
387 decode_rd_as (pnt + 2, &rd_as);
388 else if (type == RD_TYPE_IP)
389 decode_rd_ip (pnt + 2, &rd_ip);
390
391 vty_out (vty, "Route Distinguisher: ");
392
393 if (type == RD_TYPE_AS)
aea339f7 394 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
718e3744 395 else if (type == RD_TYPE_IP)
396 vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
397
398 vty_out (vty, "%s", VTY_NEWLINE);
399 rd_header = 0;
400 }
47fc97cc 401 route_vty_out_tmp (vty, &rm->p, attr, SAFI_MPLS_VPN, NULL);
718e3744 402 }
403 }
404 }
405 return CMD_SUCCESS;
406}
407
408enum bgp_show_type
409{
410 bgp_show_type_normal,
411 bgp_show_type_regexp,
412 bgp_show_type_prefix_list,
413 bgp_show_type_filter_list,
414 bgp_show_type_neighbor,
415 bgp_show_type_cidr_only,
416 bgp_show_type_prefix_longer,
417 bgp_show_type_community_all,
418 bgp_show_type_community,
419 bgp_show_type_community_exact,
420 bgp_show_type_community_list,
421 bgp_show_type_community_list_exact
422};
423
94f2b392 424static int
718e3744 425bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type type,
426 void *output_arg, int tags)
427{
428 struct bgp *bgp;
429 struct bgp_table *table;
430 struct bgp_node *rn;
431 struct bgp_node *rm;
432 struct bgp_info *ri;
433 int rd_header;
434 int header = 1;
435 char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
436 char v4_header_tag[] = " Network Next Hop In tag/Out tag%s";
437
438 bgp = bgp_get_default ();
439 if (bgp == NULL)
440 {
441 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
442 return CMD_WARNING;
443 }
444
445 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
446 {
447 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
448 continue;
449
450 if ((table = rn->info) != NULL)
451 {
452 rd_header = 1;
453
454 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
455 for (ri = rm->info; ri; ri = ri->next)
456 {
457 if (type == bgp_show_type_neighbor)
458 {
459 union sockunion *su = output_arg;
460
461 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
462 continue;
463 }
464 if (header)
465 {
466 if (tags)
467 vty_out (vty, v4_header_tag, VTY_NEWLINE);
468 else
469 {
470 vty_out (vty, "BGP table version is 0, local router ID is %s%s",
471 inet_ntoa (bgp->router_id), VTY_NEWLINE);
472 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
473 VTY_NEWLINE);
474 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
475 VTY_NEWLINE, VTY_NEWLINE);
476 vty_out (vty, v4_header, VTY_NEWLINE);
477 }
478 header = 0;
479 }
480
481 if (rd_header)
482 {
483 u_int16_t type;
484 struct rd_as rd_as;
485 struct rd_ip rd_ip;
486 u_char *pnt;
487
488 pnt = rn->p.u.val;
489
490 /* Decode RD type. */
491 type = decode_rd_type (pnt);
492 /* Decode RD value. */
493 if (type == RD_TYPE_AS)
494 decode_rd_as (pnt + 2, &rd_as);
495 else if (type == RD_TYPE_IP)
496 decode_rd_ip (pnt + 2, &rd_ip);
497
498 vty_out (vty, "Route Distinguisher: ");
499
500 if (type == RD_TYPE_AS)
aea339f7 501 vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
718e3744 502 else if (type == RD_TYPE_IP)
503 vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
504
505 vty_out (vty, "%s", VTY_NEWLINE);
506 rd_header = 0;
507 }
508 if (tags)
509 route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
510 else
47fc97cc 511 route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN, NULL);
718e3744 512 }
513 }
514 }
515 return CMD_SUCCESS;
516}
517
518DEFUN (show_ip_bgp_vpnv4_all,
519 show_ip_bgp_vpnv4_all_cmd,
520 "show ip bgp vpnv4 all",
521 SHOW_STR
522 IP_STR
523 BGP_STR
524 "Display VPNv4 NLRI specific information\n"
525 "Display information about all VPNv4 NLRIs\n")
526{
527 return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_normal, NULL, 0);
528}
529
530DEFUN (show_ip_bgp_vpnv4_rd,
531 show_ip_bgp_vpnv4_rd_cmd,
532 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn",
533 SHOW_STR
534 IP_STR
535 BGP_STR
536 "Display VPNv4 NLRI specific information\n"
537 "Display information for a route distinguisher\n"
538 "VPN Route Distinguisher\n")
539{
540 int ret;
541 struct prefix_rd prd;
542
543 ret = str2prefix_rd (argv[0], &prd);
544 if (! ret)
545 {
546 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
547 return CMD_WARNING;
548 }
549 return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_normal, NULL, 0);
550}
551
552DEFUN (show_ip_bgp_vpnv4_all_tags,
553 show_ip_bgp_vpnv4_all_tags_cmd,
554 "show ip bgp vpnv4 all tags",
555 SHOW_STR
556 IP_STR
557 BGP_STR
558 "Display VPNv4 NLRI specific information\n"
559 "Display information about all VPNv4 NLRIs\n"
560 "Display BGP tags for prefixes\n")
561{
562 return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_normal, NULL, 1);
563}
564
565DEFUN (show_ip_bgp_vpnv4_rd_tags,
566 show_ip_bgp_vpnv4_rd_tags_cmd,
567 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags",
568 SHOW_STR
569 IP_STR
570 BGP_STR
571 "Display VPNv4 NLRI specific information\n"
572 "Display information for a route distinguisher\n"
573 "VPN Route Distinguisher\n"
574 "Display BGP tags for prefixes\n")
575{
576 int ret;
577 struct prefix_rd prd;
578
579 ret = str2prefix_rd (argv[0], &prd);
580 if (! ret)
581 {
582 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
583 return CMD_WARNING;
584 }
585 return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_normal, NULL, 1);
586}
587
588DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
589 show_ip_bgp_vpnv4_all_neighbor_routes_cmd,
590 "show ip bgp vpnv4 all neighbors A.B.C.D routes",
591 SHOW_STR
592 IP_STR
593 BGP_STR
594 "Display VPNv4 NLRI specific information\n"
595 "Display information about all VPNv4 NLRIs\n"
596 "Detailed information on TCP and BGP neighbor connections\n"
597 "Neighbor to display information about\n"
598 "Display routes learned from neighbor\n")
599{
c63b83fe 600 union sockunion su;
718e3744 601 struct peer *peer;
c63b83fe
JBD
602 int ret;
603
604 ret = str2sockunion (argv[0], &su);
605 if (ret < 0)
718e3744 606 {
607 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
c63b83fe 608 return CMD_WARNING;
718e3744 609 }
610
c63b83fe 611 peer = peer_lookup (NULL, &su);
718e3744 612 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
613 {
614 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
615 return CMD_WARNING;
616 }
617
c63b83fe 618 return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_neighbor, &su, 0);
718e3744 619}
620
621DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
622 show_ip_bgp_vpnv4_rd_neighbor_routes_cmd,
623 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes",
624 SHOW_STR
625 IP_STR
626 BGP_STR
627 "Display VPNv4 NLRI specific information\n"
628 "Display information for a route distinguisher\n"
629 "VPN Route Distinguisher\n"
630 "Detailed information on TCP and BGP neighbor connections\n"
631 "Neighbor to display information about\n"
632 "Display routes learned from neighbor\n")
633{
634 int ret;
c63b83fe 635 union sockunion su;
718e3744 636 struct peer *peer;
637 struct prefix_rd prd;
638
639 ret = str2prefix_rd (argv[0], &prd);
640 if (! ret)
641 {
642 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
643 return CMD_WARNING;
644 }
645
c63b83fe
JBD
646 ret = str2sockunion (argv[1], &su);
647 if (ret < 0)
718e3744 648 {
649 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
c63b83fe 650 return CMD_WARNING;
718e3744 651 }
652
c63b83fe 653 peer = peer_lookup (NULL, &su);
718e3744 654 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
655 {
656 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
657 return CMD_WARNING;
658 }
659
c63b83fe 660 return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_neighbor, &su, 0);
718e3744 661}
662
663DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
664 show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd,
665 "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes",
666 SHOW_STR
667 IP_STR
668 BGP_STR
669 "Display VPNv4 NLRI specific information\n"
670 "Display information about all VPNv4 NLRIs\n"
671 "Detailed information on TCP and BGP neighbor connections\n"
672 "Neighbor to display information about\n"
673 "Display the routes advertised to a BGP neighbor\n")
674{
675 int ret;
676 struct peer *peer;
677 union sockunion su;
678
679 ret = str2sockunion (argv[0], &su);
680 if (ret < 0)
681 {
682 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
683 return CMD_WARNING;
684 }
685 peer = peer_lookup (NULL, &su);
686 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
687 {
688 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
689 return CMD_WARNING;
690 }
691
692 return show_adj_route_vpn (vty, peer, NULL);
693}
694
695DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
696 show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd,
697 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes",
698 SHOW_STR
699 IP_STR
700 BGP_STR
701 "Display VPNv4 NLRI specific information\n"
702 "Display information for a route distinguisher\n"
703 "VPN Route Distinguisher\n"
704 "Detailed information on TCP and BGP neighbor connections\n"
705 "Neighbor to display information about\n"
706 "Display the routes advertised to a BGP neighbor\n")
707{
708 int ret;
709 struct peer *peer;
710 struct prefix_rd prd;
711 union sockunion su;
712
713 ret = str2sockunion (argv[1], &su);
714 if (ret < 0)
715 {
716 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
717 return CMD_WARNING;
718 }
719 peer = peer_lookup (NULL, &su);
720 if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN])
721 {
722 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
723 return CMD_WARNING;
724 }
725
726 ret = str2prefix_rd (argv[0], &prd);
727 if (! ret)
728 {
729 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
730 return CMD_WARNING;
731 }
732
733 return show_adj_route_vpn (vty, peer, &prd);
734}
735
736void
94f2b392 737bgp_mplsvpn_init (void)
718e3744 738{
739 install_element (BGP_VPNV4_NODE, &vpnv4_network_cmd);
740 install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd);
741
742
743 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd);
744 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd);
745 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd);
746 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd);
747 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd);
748 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd);
749 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd);
750 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd);
751
752 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_cmd);
753 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_cmd);
754 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_tags_cmd);
755 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd);
756 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd);
757 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd);
758 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd);
759 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd);
760}