]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_evpn_vty.c
Merge pull request #464 from donaldsharp/datacenter
[mirror_frr.git] / bgpd / bgp_evpn_vty.c
1 /* Ethernet-VPN Packet and vty Processing File
2 Copyright (C) 2017 6WIND
3
4 This file is part of FRRouting
5
6 FRRouting 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
9 later version.
10
11 FRRouting 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.
15
16 You should have received a copy of the GNU General Public License
17 along with FRRouting; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21 #include <zebra.h>
22 #include "command.h"
23 #include "prefix.h"
24 #include "lib/json.h"
25
26 #include "bgpd/bgpd.h"
27 #include "bgpd/bgp_table.h"
28 #include "bgpd/bgp_attr.h"
29 #include "bgpd/bgp_route.h"
30 #include "bgpd/bgp_mplsvpn.h"
31 #include "bgpd/bgp_vpn.h"
32 #include "bgpd/bgp_evpn_vty.h"
33 #include "bgpd/bgp_evpn.h"
34
35 #define SHOW_DISPLAY_STANDARD 0
36 #define SHOW_DISPLAY_TAGS 1
37 #define SHOW_DISPLAY_OVERLAY 2
38
39 static int
40 bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
41 enum bgp_show_type type, void *output_arg, int option,
42 u_char use_json)
43 {
44 afi_t afi = AFI_L2VPN;
45 struct bgp *bgp;
46 struct bgp_table *table;
47 struct bgp_node *rn;
48 struct bgp_node *rm;
49 struct bgp_info *ri;
50 int rd_header;
51 int header = 1;
52 char v4_header[] =
53 " Network Next Hop Metric LocPrf Weight Path%s";
54 char v4_header_tag[] =
55 " Network Next Hop In tag/Out tag%s";
56 char v4_header_overlay[] =
57 " Network Next Hop EthTag Overlay Index RouterMac%s";
58
59 unsigned long output_count = 0;
60 unsigned long total_count = 0;
61 json_object *json = NULL;
62 json_object *json_nroute = NULL;
63 json_object *json_array = NULL;
64 json_object *json_scode = NULL;
65 json_object *json_ocode = NULL;
66
67 bgp = bgp_get_default();
68 if (bgp == NULL) {
69 if (!use_json)
70 vty_out(vty, "No BGP process is configured%s",
71 VTY_NEWLINE);
72 return CMD_WARNING;
73 }
74
75 if (use_json) {
76 json_scode = json_object_new_object();
77 json_ocode = json_object_new_object();
78 json = json_object_new_object();
79 json_nroute = json_object_new_object();
80
81 json_object_string_add(json_scode, "suppressed", "s");
82 json_object_string_add(json_scode, "damped", "d");
83 json_object_string_add(json_scode, "history", "h");
84 json_object_string_add(json_scode, "valid", "*");
85 json_object_string_add(json_scode, "best", ">");
86 json_object_string_add(json_scode, "internal", "i");
87
88 json_object_string_add(json_ocode, "igp", "i");
89 json_object_string_add(json_ocode, "egp", "e");
90 json_object_string_add(json_ocode, "incomplete", "?");
91 }
92
93 for (rn = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); rn;
94 rn = bgp_route_next(rn)) {
95 if (use_json)
96 continue; /* XXX json TODO */
97
98 if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
99 continue;
100
101 if ((table = rn->info) != NULL) {
102 rd_header = 1;
103
104 for (rm = bgp_table_top(table); rm;
105 rm = bgp_route_next(rm))
106 for (ri = rm->info; ri; ri = ri->next) {
107 total_count++;
108 if (type == bgp_show_type_neighbor) {
109 union sockunion *su =
110 output_arg;
111
112 if (ri->peer->su_remote == NULL
113 || !sockunion_same(ri->
114 peer->
115 su_remote,
116 su))
117 continue;
118 }
119 if (header == 0) {
120 if (use_json) {
121 if (option ==
122 SHOW_DISPLAY_TAGS) {
123 json_object_int_add
124 (json,
125 "bgpTableVersion",
126 0);
127 json_object_string_add
128 (json,
129 "bgpLocalRouterId",
130 inet_ntoa
131 (bgp->
132 router_id));
133 json_object_object_add
134 (json,
135 "bgpStatusCodes",
136 json_scode);
137 json_object_object_add
138 (json,
139 "bgpOriginCodes",
140 json_ocode);
141 }
142 } else {
143 if (option ==
144 SHOW_DISPLAY_TAGS)
145 vty_out(vty,
146 v4_header_tag,
147 VTY_NEWLINE);
148 else if (option ==
149 SHOW_DISPLAY_OVERLAY)
150 vty_out(vty,
151 v4_header_overlay,
152 VTY_NEWLINE);
153 else {
154 vty_out(vty,
155 "BGP table version is 0, local router ID is %s%s",
156 inet_ntoa
157 (bgp->
158 router_id),
159 VTY_NEWLINE);
160 vty_out(vty,
161 "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
162 VTY_NEWLINE);
163 vty_out(vty,
164 "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
165 VTY_NEWLINE,
166 VTY_NEWLINE);
167 vty_out(vty,
168 v4_header,
169 VTY_NEWLINE);
170 }
171 }
172 header = 0;
173 }
174 if (rd_header) {
175 u_int16_t type;
176 struct rd_as rd_as;
177 struct rd_ip rd_ip;
178 u_char *pnt;
179
180 pnt = rn->p.u.val;
181
182 /* Decode RD type. */
183 type = decode_rd_type(pnt);
184 /* Decode RD value. */
185 if (type == RD_TYPE_AS)
186 decode_rd_as(pnt + 2,
187 &rd_as);
188 else if (type == RD_TYPE_AS4)
189 decode_rd_as4(pnt + 2,
190 &rd_as);
191 else if (type == RD_TYPE_IP)
192 decode_rd_ip(pnt + 2,
193 &rd_ip);
194 if (use_json) {
195 char buffer[BUFSIZ];
196 if (type == RD_TYPE_AS
197 || type ==
198 RD_TYPE_AS4)
199 sprintf(buffer,
200 "%u:%d",
201 rd_as.
202 as,
203 rd_as.
204 val);
205 else if (type ==
206 RD_TYPE_IP)
207 sprintf(buffer,
208 "%s:%d",
209 inet_ntoa
210 (rd_ip.
211 ip),
212 rd_ip.
213 val);
214 json_object_string_add
215 (json_nroute,
216 "routeDistinguisher",
217 buffer);
218 } else {
219 vty_out(vty,
220 "Route Distinguisher: ");
221 if (type == RD_TYPE_AS)
222 vty_out(vty,
223 "as2 %u:%d",
224 rd_as.
225 as,
226 rd_as.
227 val);
228 else if (type ==
229 RD_TYPE_AS4)
230 vty_out(vty,
231 "as4 %u:%d",
232 rd_as.
233 as,
234 rd_as.
235 val);
236 else if (type ==
237 RD_TYPE_IP)
238 vty_out(vty,
239 "ip %s:%d",
240 inet_ntoa
241 (rd_ip.
242 ip),
243 rd_ip.
244 val);
245 vty_out(vty, "%s",
246 VTY_NEWLINE);
247 }
248 rd_header = 0;
249 }
250 if (use_json)
251 json_array =
252 json_object_new_array();
253 else
254 json_array = NULL;
255 if (option == SHOW_DISPLAY_TAGS)
256 route_vty_out_tag(vty, &rm->p,
257 ri, 0,
258 SAFI_EVPN,
259 json_array);
260 else if (option == SHOW_DISPLAY_OVERLAY)
261 route_vty_out_overlay(vty,
262 &rm->p,
263 ri, 0,
264 json_array);
265 else
266 route_vty_out(vty, &rm->p, ri,
267 0, SAFI_EVPN,
268 json_array);
269 output_count++;
270 }
271 /* XXX json */
272 }
273 }
274 if (output_count == 0)
275 vty_out(vty, "No prefixes displayed, %ld exist%s", total_count,
276 VTY_NEWLINE);
277 else
278 vty_out(vty, "%sDisplayed %ld out of %ld total prefixes%s",
279 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
280 return CMD_SUCCESS;
281 }
282
283 DEFUN(show_ip_bgp_l2vpn_evpn,
284 show_ip_bgp_l2vpn_evpn_cmd,
285 "show [ip] bgp l2vpn evpn [json]",
286 SHOW_STR IP_STR BGP_STR L2VPN_HELP_STR EVPN_HELP_STR JSON_STR)
287 {
288 return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_normal, NULL, 0,
289 use_json(argc, argv));
290 }
291
292 DEFUN(show_ip_bgp_l2vpn_evpn_rd,
293 show_ip_bgp_l2vpn_evpn_rd_cmd,
294 "show [ip] bgp l2vpn evpn rd ASN:nn_or_IP-address:nn [json]",
295 SHOW_STR
296 IP_STR
297 BGP_STR
298 L2VPN_HELP_STR
299 EVPN_HELP_STR
300 "Display information for a route distinguisher\n"
301 "VPN Route Distinguisher\n" JSON_STR)
302 {
303 int idx_ext_community = 6;
304 int ret;
305 struct prefix_rd prd;
306
307 ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
308 if (!ret) {
309 vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
310 return CMD_WARNING;
311 }
312 return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 0,
313 use_json(argc, argv));
314 }
315
316 DEFUN(show_ip_bgp_l2vpn_evpn_all_tags,
317 show_ip_bgp_l2vpn_evpn_all_tags_cmd,
318 "show [ip] bgp l2vpn evpn all tags",
319 SHOW_STR
320 IP_STR
321 BGP_STR
322 L2VPN_HELP_STR
323 EVPN_HELP_STR
324 "Display information about all EVPN NLRIs\n"
325 "Display BGP tags for prefixes\n")
326 {
327 return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_normal, NULL, 1,
328 0);
329 }
330
331 DEFUN(show_ip_bgp_l2vpn_evpn_rd_tags,
332 show_ip_bgp_l2vpn_evpn_rd_tags_cmd,
333 "show [ip] bgp l2vpn evpn rd ASN:nn_or_IP-address:nn tags",
334 SHOW_STR
335 IP_STR
336 BGP_STR
337 L2VPN_HELP_STR
338 EVPN_HELP_STR
339 "Display information for a route distinguisher\n"
340 "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n")
341 {
342 int idx_ext_community = 6;
343 int ret;
344 struct prefix_rd prd;
345
346 ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
347 if (!ret) {
348 vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
349 return CMD_WARNING;
350 }
351 return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL, 1,
352 0);
353 }
354
355 DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes,
356 show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd,
357 "show [ip] bgp l2vpn evpn all neighbors A.B.C.D routes [json]",
358 SHOW_STR
359 IP_STR
360 BGP_STR
361 L2VPN_HELP_STR
362 EVPN_HELP_STR
363 "Display information about all EVPN NLRIs\n"
364 "Detailed information on TCP and BGP neighbor connections\n"
365 "Neighbor to display information about\n"
366 "Display routes learned from neighbor\n" JSON_STR)
367 {
368 int idx_ipv4 = 6;
369 union sockunion su;
370 struct peer *peer;
371 int ret;
372 u_char uj = use_json(argc, argv);
373
374 ret = str2sockunion(argv[idx_ipv4]->arg, &su);
375 if (ret < 0) {
376 if (uj) {
377 json_object *json_no = NULL;
378 json_no = json_object_new_object();
379 json_object_string_add(json_no, "warning",
380 "Malformed address");
381 vty_out(vty, "%s%s",
382 json_object_to_json_string(json_no),
383 VTY_NEWLINE);
384 json_object_free(json_no);
385 } else
386 vty_out(vty, "Malformed address: %s%s",
387 argv[idx_ipv4]->arg, VTY_NEWLINE);
388 return CMD_WARNING;
389 }
390
391 peer = peer_lookup(NULL, &su);
392 if (!peer || !peer->afc[AFI_L2VPN][SAFI_EVPN]) {
393 if (uj) {
394 json_object *json_no = NULL;
395 json_no = json_object_new_object();
396 json_object_string_add(json_no, "warning",
397 "No such neighbor or address family");
398 vty_out(vty, "%s%s",
399 json_object_to_json_string(json_no),
400 VTY_NEWLINE);
401 json_object_free(json_no);
402 } else
403 vty_out(vty, "%% No such neighbor or address family%s",
404 VTY_NEWLINE);
405 return CMD_WARNING;
406 }
407
408 return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_neighbor, &su, 0,
409 uj);
410 }
411
412 DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes,
413 show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd,
414 "show [ip] bgp l2vpn evpn rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]",
415 SHOW_STR
416 IP_STR
417 BGP_STR
418 L2VPN_HELP_STR
419 EVPN_HELP_STR
420 "Display information for a route distinguisher\n"
421 "VPN Route Distinguisher\n"
422 "Detailed information on TCP and BGP neighbor connections\n"
423 "Neighbor to display information about\n"
424 "Display routes learned from neighbor\n" JSON_STR)
425 {
426 int idx_ext_community = 6;
427 int idx_ipv4 = 8;
428 int ret;
429 union sockunion su;
430 struct peer *peer;
431 struct prefix_rd prd;
432 u_char uj = use_json(argc, argv);
433
434 ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
435 if (!ret) {
436 if (uj) {
437 json_object *json_no = NULL;
438 json_no = json_object_new_object();
439 json_object_string_add(json_no, "warning",
440 "Malformed Route Distinguisher");
441 vty_out(vty, "%s%s",
442 json_object_to_json_string(json_no),
443 VTY_NEWLINE);
444 json_object_free(json_no);
445 } else
446 vty_out(vty, "%% Malformed Route Distinguisher%s",
447 VTY_NEWLINE);
448 return CMD_WARNING;
449 }
450
451 ret = str2sockunion(argv[idx_ipv4]->arg, &su);
452 if (ret < 0) {
453 if (uj) {
454 json_object *json_no = NULL;
455 json_no = json_object_new_object();
456 json_object_string_add(json_no, "warning",
457 "Malformed address");
458 vty_out(vty, "%s%s",
459 json_object_to_json_string(json_no),
460 VTY_NEWLINE);
461 json_object_free(json_no);
462 } else
463 vty_out(vty, "Malformed address: %s%s",
464 argv[idx_ext_community]->arg, VTY_NEWLINE);
465 return CMD_WARNING;
466 }
467
468 peer = peer_lookup(NULL, &su);
469 if (!peer || !peer->afc[AFI_L2VPN][SAFI_EVPN]) {
470 if (uj) {
471 json_object *json_no = NULL;
472 json_no = json_object_new_object();
473 json_object_string_add(json_no, "warning",
474 "No such neighbor or address family");
475 vty_out(vty, "%s%s",
476 json_object_to_json_string(json_no),
477 VTY_NEWLINE);
478 json_object_free(json_no);
479 } else
480 vty_out(vty, "%% No such neighbor or address family%s",
481 VTY_NEWLINE);
482 return CMD_WARNING;
483 }
484
485 return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_neighbor, &su, 0,
486 uj);
487 }
488
489 DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes,
490 show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd,
491 "show [ip] bgp l2vpn evpn all neighbors A.B.C.D advertised-routes [json]",
492 SHOW_STR
493 IP_STR
494 BGP_STR
495 L2VPN_HELP_STR
496 EVPN_HELP_STR
497 "Display information about all EVPN NLRIs\n"
498 "Detailed information on TCP and BGP neighbor connections\n"
499 "Neighbor to display information about\n"
500 "Display the routes advertised to a BGP neighbor\n" JSON_STR)
501 {
502 int idx_ipv4 = 7;
503 int ret;
504 struct peer *peer;
505 union sockunion su;
506 u_char uj = use_json(argc, argv);
507
508 ret = str2sockunion(argv[idx_ipv4]->arg, &su);
509 if (ret < 0) {
510 if (uj) {
511 json_object *json_no = NULL;
512 json_no = json_object_new_object();
513 json_object_string_add(json_no, "warning",
514 "Malformed address");
515 vty_out(vty, "%s%s",
516 json_object_to_json_string(json_no),
517 VTY_NEWLINE);
518 json_object_free(json_no);
519 } else
520 vty_out(vty, "Malformed address: %s%s",
521 argv[idx_ipv4]->arg, VTY_NEWLINE);
522 return CMD_WARNING;
523 }
524 peer = peer_lookup(NULL, &su);
525 if (!peer || !peer->afc[AFI_L2VPN][SAFI_EVPN]) {
526 if (uj) {
527 json_object *json_no = NULL;
528 json_no = json_object_new_object();
529 json_object_string_add(json_no, "warning",
530 "No such neighbor or address family");
531 vty_out(vty, "%s%s",
532 json_object_to_json_string(json_no),
533 VTY_NEWLINE);
534 json_object_free(json_no);
535 } else
536 vty_out(vty, "%% No such neighbor or address family%s",
537 VTY_NEWLINE);
538 return CMD_WARNING;
539 }
540
541 return show_adj_route_vpn(vty, peer, NULL, AFI_L2VPN, SAFI_EVPN, uj);
542 }
543
544 DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes,
545 show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd,
546 "show [ip] bgp l2vpn evpn rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]",
547 SHOW_STR
548 IP_STR
549 BGP_STR
550 L2VPN_HELP_STR
551 EVPN_HELP_STR
552 "Display information for a route distinguisher\n"
553 "VPN Route Distinguisher\n"
554 "Detailed information on TCP and BGP neighbor connections\n"
555 "Neighbor to display information about\n"
556 "Display the routes advertised to a BGP neighbor\n" JSON_STR)
557 {
558 int idx_ext_community = 6;
559 int idx_ipv4 = 8;
560 int ret;
561 struct peer *peer;
562 struct prefix_rd prd;
563 union sockunion su;
564 u_char uj = use_json(argc, argv);
565
566 ret = str2sockunion(argv[idx_ipv4]->arg, &su);
567 if (ret < 0) {
568 if (uj) {
569 json_object *json_no = NULL;
570 json_no = json_object_new_object();
571 json_object_string_add(json_no, "warning",
572 "Malformed address");
573 vty_out(vty, "%s%s",
574 json_object_to_json_string(json_no),
575 VTY_NEWLINE);
576 json_object_free(json_no);
577 } else
578 vty_out(vty, "Malformed address: %s%s",
579 argv[idx_ext_community]->arg, VTY_NEWLINE);
580 return CMD_WARNING;
581 }
582 peer = peer_lookup(NULL, &su);
583 if (!peer || !peer->afc[AFI_L2VPN][SAFI_EVPN]) {
584 if (uj) {
585 json_object *json_no = NULL;
586 json_no = json_object_new_object();
587 json_object_string_add(json_no, "warning",
588 "No such neighbor or address family");
589 vty_out(vty, "%s%s",
590 json_object_to_json_string(json_no),
591 VTY_NEWLINE);
592 json_object_free(json_no);
593 } else
594 vty_out(vty, "%% No such neighbor or address family%s",
595 VTY_NEWLINE);
596 return CMD_WARNING;
597 }
598
599 ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
600 if (!ret) {
601 if (uj) {
602 json_object *json_no = NULL;
603 json_no = json_object_new_object();
604 json_object_string_add(json_no, "warning",
605 "Malformed Route Distinguisher");
606 vty_out(vty, "%s%s",
607 json_object_to_json_string(json_no),
608 VTY_NEWLINE);
609 json_object_free(json_no);
610 } else
611 vty_out(vty, "%% Malformed Route Distinguisher%s",
612 VTY_NEWLINE);
613 return CMD_WARNING;
614 }
615
616 return show_adj_route_vpn(vty, peer, &prd, AFI_L2VPN, SAFI_EVPN, uj);
617 }
618
619 DEFUN(show_ip_bgp_l2vpn_evpn_all_overlay,
620 show_ip_bgp_l2vpn_evpn_all_overlay_cmd,
621 "show [ip] bgp l2vpn evpn all overlay",
622 SHOW_STR
623 IP_STR
624 BGP_STR
625 L2VPN_HELP_STR
626 EVPN_HELP_STR
627 "Display information about all EVPN NLRIs\n"
628 "Display BGP Overlay Information for prefixes\n")
629 {
630 return bgp_show_ethernet_vpn(vty, NULL, bgp_show_type_normal, NULL,
631 SHOW_DISPLAY_OVERLAY, use_json(argc,
632 argv));
633 }
634
635 DEFUN(show_ip_bgp_evpn_rd_overlay,
636 show_ip_bgp_evpn_rd_overlay_cmd,
637 "show [ip] bgp l2vpn evpn rd ASN:nn_or_IP-address:nn overlay",
638 SHOW_STR
639 IP_STR
640 BGP_STR
641 L2VPN_HELP_STR
642 EVPN_HELP_STR
643 "Display information for a route distinguisher\n"
644 "VPN Route Distinguisher\n"
645 "Display BGP Overlay Information for prefixes\n")
646 {
647 int idx_ext_community = 6;
648 int ret;
649 struct prefix_rd prd;
650
651 ret = str2prefix_rd(argv[idx_ext_community]->arg, &prd);
652 if (!ret) {
653 vty_out(vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
654 return CMD_WARNING;
655 }
656 return bgp_show_ethernet_vpn(vty, &prd, bgp_show_type_normal, NULL,
657 SHOW_DISPLAY_OVERLAY, use_json(argc,
658 argv));
659 }
660
661 /* For testing purpose, static route of MPLS-VPN. */
662 DEFUN(evpnrt5_network,
663 evpnrt5_network_cmd,
664 "network <A.B.C.D/M|X:X::X:X/M> rd ASN:nn_or_IP-address:nn ethtag WORD label WORD esi WORD gwip <A.B.C.D|X:X::X:X> routermac WORD [route-map WORD]",
665 "Specify a network to announce via BGP\n"
666 "IP prefix\n"
667 "IPv6 prefix\n"
668 "Specify Route Distinguisher\n"
669 "VPN Route Distinguisher\n"
670 "Ethernet Tag\n"
671 "Ethernet Tag Value\n"
672 "BGP label\n"
673 "label value\n"
674 "Ethernet Segment Identifier\n"
675 "ESI value ( 00:11:22:33:44:55:66:77:88:99 format) \n"
676 "Gateway IP\n"
677 "Gateway IP ( A.B.C.D )\n"
678 "Gateway IPv6 ( X:X::X:X )\n"
679 "Router Mac Ext Comm\n"
680 "Router Mac address Value ( aa:bb:cc:dd:ee:ff format)\n"
681 "Route-map to modify the attributes\n"
682 "Name of the route map\n")
683 {
684 int idx_ipv4_prefixlen = 1;
685 int idx_ext_community = 3;
686 int idx_word = 7;
687 int idx_esi = 9;
688 int idx_gwip = 11;
689 int idx_ethtag = 5;
690 int idx_routermac = 13;
691 int idx_rmap = 15;
692 return bgp_static_set_safi(SAFI_EVPN, vty,
693 argv[idx_ipv4_prefixlen]->arg,
694 argv[idx_ext_community]->arg,
695 argv[idx_word]->arg,
696 argv[idx_rmap] ? argv[idx_gwip]->arg : NULL,
697 EVPN_IP_PREFIX, argv[idx_esi]->arg,
698 argv[idx_gwip]->arg, argv[idx_ethtag]->arg,
699 argv[idx_routermac]->arg);
700 }
701
702 /* For testing purpose, static route of MPLS-VPN. */
703 DEFUN(no_evpnrt5_network,
704 no_evpnrt5_network_cmd,
705 "no network <A.B.C.D/M|X:X::X:X/M> rd ASN:nn_or_IP-address:nn ethtag WORD label WORD esi WORD gwip <A.B.C.D|X:X::X:X>",
706 NO_STR
707 "Specify a network to announce via BGP\n"
708 "IP prefix\n"
709 "IPv6 prefix\n"
710 "Specify Route Distinguisher\n"
711 "VPN Route Distinguisher\n"
712 "Ethernet Tag\n"
713 "Ethernet Tag Value\n"
714 "BGP label\n"
715 "label value\n"
716 "Ethernet Segment Identifier\n"
717 "ESI value ( 00:11:22:33:44:55:66:77:88:99 format) \n"
718 "Gateway IP\n" "Gateway IP ( A.B.C.D )\n" "Gateway IPv6 ( X:X::X:X )\n")
719 {
720 int idx_ipv4_prefixlen = 2;
721 int idx_ext_community = 4;
722 int idx_label = 8;
723 int idx_ethtag = 6;
724 int idx_esi = 10;
725 int idx_gwip = 12;
726 return bgp_static_unset_safi(SAFI_EVPN, vty,
727 argv[idx_ipv4_prefixlen]->arg,
728 argv[idx_ext_community]->arg,
729 argv[idx_label]->arg, EVPN_IP_PREFIX,
730 argv[idx_esi]->arg, argv[idx_gwip]->arg,
731 argv[idx_ethtag]->arg);
732 }
733
734 void bgp_ethernetvpn_init(void)
735 {
736 install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_cmd);
737 install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_cmd);
738 install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_tags_cmd);
739 install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_rd_tags_cmd);
740 install_element(VIEW_NODE,
741 &show_ip_bgp_l2vpn_evpn_all_neighbor_routes_cmd);
742 install_element(VIEW_NODE,
743 &show_ip_bgp_l2vpn_evpn_rd_neighbor_routes_cmd);
744 install_element(VIEW_NODE,
745 &show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes_cmd);
746 install_element(VIEW_NODE,
747 &show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes_cmd);
748 install_element(VIEW_NODE, &show_ip_bgp_evpn_rd_overlay_cmd);
749 install_element(VIEW_NODE, &show_ip_bgp_l2vpn_evpn_all_overlay_cmd);
750 install_element(BGP_EVPN_NODE, &no_evpnrt5_network_cmd);
751 install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd);
752 }