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