1 /* Zebra MPLS VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
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 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
34 #include "zebra/zserv.h"
35 #include "zebra/zebra_vrf.h"
36 #include "zebra/zebra_mpls.h"
37 #include "zebra/zebra_rnh.h"
38 #include "zebra/redistribute.h"
39 #include "zebra/zebra_routemap.h"
40 #include "zebra/zebra_static.h"
43 zebra_mpls_transit_lsp (struct vty
*vty
, int add_cmd
, const char *inlabel_str
,
44 const char *gate_str
, const char *outlabel_str
,
47 struct zebra_vrf
*zvrf
;
49 enum nexthop_types_t gtype
;
52 mpls_label_t in_label
, out_label
;
56 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
61 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
64 vty_out (vty
, "%% Default VRF does not exist%s", VTY_NEWLINE
);
70 vty_out (vty
, "%% No Label Information%s", VTY_NEWLINE
);
74 out_label
= MPLS_IMP_NULL_LABEL
; /* as initialization */
75 label
= atoi(inlabel_str
);
76 if (!IS_MPLS_UNRESERVED_LABEL(label
))
78 vty_out (vty
, "%% Invalid label%s", VTY_NEWLINE
);
86 vty_out (vty
, "%% No Nexthop Information%s", VTY_NEWLINE
);
91 vty_out (vty
, "%% No Outgoing label Information%s", VTY_NEWLINE
);
97 gtype
= NEXTHOP_TYPE_BLACKHOLE
; /* as initialization */
101 /* Gateway is a IPv4 or IPv6 nexthop. */
102 ret
= inet_pton (AF_INET6
, gate_str
, &gate
.ipv6
);
104 gtype
= NEXTHOP_TYPE_IPV6
;
107 ret
= inet_pton (AF_INET
, gate_str
, &gate
.ipv4
);
109 gtype
= NEXTHOP_TYPE_IPV4
;
112 vty_out (vty
, "%% Invalid nexthop%s", VTY_NEWLINE
);
120 if (outlabel_str
[0] == 'i')
121 out_label
= MPLS_IMP_NULL_LABEL
;
122 else if (outlabel_str
[0] == 'e' && gtype
== NEXTHOP_TYPE_IPV4
)
123 out_label
= MPLS_V4_EXP_NULL_LABEL
;
124 else if (outlabel_str
[0] == 'e' && gtype
== NEXTHOP_TYPE_IPV6
)
125 out_label
= MPLS_V6_EXP_NULL_LABEL
;
127 out_label
= atoi(outlabel_str
);
132 #if defined(HAVE_CUMULUS)
133 /* Check that label value is consistent. */
134 if (!zebra_mpls_lsp_label_consistent (zvrf
, in_label
, out_label
, gtype
,
137 vty_out (vty
, "%% Label value not consistent%s",
141 #endif /* HAVE_CUMULUS */
143 ret
= zebra_mpls_static_lsp_add (zvrf
, in_label
, out_label
, gtype
,
147 ret
= zebra_mpls_static_lsp_del (zvrf
, in_label
, gtype
, &gate
, 0);
151 vty_out (vty
, "%% LSP cannot be %s%s",
152 add_cmd
? "added" : "deleted", VTY_NEWLINE
);
159 DEFUN (mpls_transit_lsp
,
160 mpls_transit_lsp_cmd
,
161 "mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
163 "Establish label switched path\n"
164 "Incoming MPLS label\n"
165 "IPv4 gateway address\n"
166 "IPv6 gateway address\n"
167 "Outgoing MPLS label\n"
168 "Use Explicit-Null label\n"
169 "Use Implicit-Null label\n")
171 return zebra_mpls_transit_lsp (vty
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
);
174 DEFUN (no_mpls_transit_lsp
,
175 no_mpls_transit_lsp_cmd
,
176 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X>",
179 "Establish label switched path\n"
180 "Incoming MPLS label\n"
181 "IPv4 gateway address\n"
182 "IPv6 gateway address\n")
184 return zebra_mpls_transit_lsp (vty
, 0, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
);
187 ALIAS (no_mpls_transit_lsp
,
188 no_mpls_transit_lsp_out_label_cmd
,
189 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
192 "Establish label switched path\n"
193 "Incoming MPLS label\n"
194 "IPv4 gateway address\n"
195 "IPv6 gateway address\n"
196 "Outgoing MPLS label\n"
197 "Use Explicit-Null label\n"
198 "Use Implicit-Null label\n")
200 DEFUN (no_mpls_transit_lsp_all
,
201 no_mpls_transit_lsp_all_cmd
,
202 "no mpls lsp (16-1048575)",
205 "Establish label switched path\n"
206 "Incoming MPLS label\n")
208 return zebra_mpls_transit_lsp (vty
, 0, argv
[3]->arg
, NULL
, NULL
, NULL
);
212 zebra_mpls_bind (struct vty
*vty
, int add_cmd
, const char *prefix
,
213 const char *label_str
)
215 struct zebra_vrf
*zvrf
;
220 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
223 vty_out (vty
, "%% Default VRF does not exist%s", VTY_NEWLINE
);
227 memset(&p
, 0, sizeof(struct prefix
));
228 ret
= str2prefix(prefix
, &p
);
231 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
239 vty_out (vty
, "%% No label binding specified%s", VTY_NEWLINE
);
243 if (!strcmp(label_str
, "implicit-null"))
244 label
= MPLS_IMP_NULL_LABEL
;
245 else if (!strcmp(label_str
, "explicit-null"))
247 if (p
.family
== AF_INET
)
248 label
= MPLS_V4_EXP_NULL_LABEL
;
250 label
= MPLS_V6_EXP_NULL_LABEL
;
254 label
= atoi(label_str
);
255 if (!IS_MPLS_UNRESERVED_LABEL(label
))
257 vty_out (vty
, "%% Invalid label%s", VTY_NEWLINE
);
260 if (zebra_mpls_label_already_bound (zvrf
, label
))
262 vty_out (vty
, "%% Label already bound to a FEC%s",
268 ret
= zebra_mpls_static_fec_add (zvrf
, &p
, label
);
271 ret
= zebra_mpls_static_fec_del (zvrf
, &p
);
275 vty_out (vty
, "%% FEC to label binding cannot be %s%s",
276 add_cmd
? "added" : "deleted", VTY_NEWLINE
);
283 DEFUN (mpls_label_bind
,
285 "mpls label bind <A.B.C.D/M|X:X::X:X/M> <(16-1048575)|implicit-null|explicit-null>",
287 "Label configuration\n"
288 "Establish FEC to label binding\n"
291 "MPLS Label to bind\n"
292 "Use Implicit-Null Label\n"
293 "Use Explicit-Null Label\n")
295 return zebra_mpls_bind (vty
, 1, argv
[3]->arg
, argv
[4]->arg
);
298 DEFUN (no_mpls_label_bind
,
299 no_mpls_label_bind_cmd
,
300 "no mpls label bind <A.B.C.D/M|X:X::X:X/M> [<(16-1048575)|implicit-null>]",
303 "Label configuration\n"
304 "Establish FEC to label binding\n"
307 "MPLS Label to bind\n"
308 "Use Implicit-Null Label\n")
311 return zebra_mpls_bind (vty
, 0, argv
[4]->arg
, NULL
);
314 /* Static route configuration. */
315 DEFUN (ip_route_label
,
317 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
319 "Establish static routes\n"
320 "IP destination prefix (e.g. 10.0.0.0/8)\n"
321 "IP gateway address\n"
322 "IP gateway interface name\n"
324 "Specify label(s) for this route\n"
325 "One or more labels separated by '/'\n")
327 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
328 NULL
, NULL
, argv
[5]->arg
);
331 DEFUN (ip_route_tag_label
,
332 ip_route_tag_label_cmd
,
333 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
335 "Establish static routes\n"
336 "IP destination prefix (e.g. 10.0.0.0/8)\n"
337 "IP gateway address\n"
338 "IP gateway interface name\n"
340 "Set tag for this route\n"
342 "Specify label(s) for this route\n"
343 "One or more labels separated by '/'\n")
345 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
346 NULL
, NULL
, argv
[7]->arg
);
349 /* Mask as A.B.C.D format. */
350 DEFUN (ip_route_mask_label
,
351 ip_route_mask_label_cmd
,
352 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
354 "Establish static routes\n"
355 "IP destination prefix\n"
356 "IP destination prefix mask\n"
357 "IP gateway address\n"
358 "IP gateway interface name\n"
360 "Specify label(s) for this route\n"
361 "One or more labels separated by '/'\n")
363 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
364 NULL
, NULL
, argv
[6]->arg
);
367 DEFUN (ip_route_mask_tag_label
,
368 ip_route_mask_tag_label_cmd
,
369 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
371 "Establish static routes\n"
372 "IP destination prefix\n"
373 "IP destination prefix mask\n"
374 "IP gateway address\n"
375 "IP gateway interface name\n"
377 "Set tag for this route\n"
379 "Specify label(s) for this route\n"
380 "One or more labels separated by '/'\n")
383 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
384 NULL
, NULL
, argv
[8]->arg
);
387 /* Distance option value. */
388 DEFUN (ip_route_distance_label
,
389 ip_route_distance_label_cmd
,
390 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
392 "Establish static routes\n"
393 "IP destination prefix (e.g. 10.0.0.0/8)\n"
394 "IP gateway address\n"
395 "IP gateway interface name\n"
397 "Distance value for this route\n"
398 "Specify label(s) for this route\n"
399 "One or more labels separated by '/'\n")
401 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
402 argv
[4]->arg
, NULL
, argv
[6]->arg
);
405 DEFUN (ip_route_tag_distance_label
,
406 ip_route_tag_distance_label_cmd
,
407 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
409 "Establish static routes\n"
410 "IP destination prefix (e.g. 10.0.0.0/8)\n"
411 "IP gateway address\n"
412 "IP gateway interface name\n"
414 "Set tag for this route\n"
416 "Distance value for this route\n"
417 "Specify label(s) for this route\n"
418 "One or more labels separated by '/'\n")
421 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
422 argv
[6]->arg
, NULL
, argv
[8]->arg
);
425 DEFUN (ip_route_mask_distance_label
,
426 ip_route_mask_distance_label_cmd
,
427 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
429 "Establish static routes\n"
430 "IP destination prefix\n"
431 "IP destination prefix mask\n"
432 "IP gateway address\n"
433 "IP gateway interface name\n"
435 "Distance value for this route\n"
436 "Specify label(s) for this route\n"
437 "One or more labels separated by '/'\n")
439 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
440 argv
[5]->arg
, NULL
, argv
[7]->arg
);
443 DEFUN (ip_route_mask_tag_distance_label
,
444 ip_route_mask_tag_distance_label_cmd
,
445 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
447 "Establish static routes\n"
448 "IP destination prefix\n"
449 "IP destination prefix mask\n"
450 "IP gateway address\n"
451 "IP gateway interface name\n"
453 "Set tag for this route\n"
455 "Distance value for this route\n"
456 "Specify label(s) for this route\n"
457 "One or more labels separated by '/'\n")
459 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
460 argv
[7]->arg
, NULL
, argv
[9]->arg
);
463 DEFUN (no_ip_route_label
,
464 no_ip_route_label_cmd
,
465 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
468 "Establish static routes\n"
469 "IP destination prefix (e.g. 10.0.0.0/8)\n"
470 "IP gateway address\n"
471 "IP gateway interface name\n"
473 "Specify label(s) for this route\n"
474 "One or more labels separated by '/'\n")
476 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
477 NULL
, NULL
, argv
[6]->arg
);
480 DEFUN (no_ip_route_tag_label
,
481 no_ip_route_tag_label_cmd
,
482 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
485 "Establish static routes\n"
486 "IP destination prefix (e.g. 10.0.0.0/8)\n"
487 "IP gateway address\n"
488 "IP gateway interface name\n"
490 "Tag of this route\n"
492 "Specify label(s) for this route\n"
493 "One or more labels separated by '/'\n")
495 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
496 NULL
, NULL
, argv
[8]->arg
);
499 DEFUN (no_ip_route_mask_label
,
500 no_ip_route_mask_label_cmd
,
501 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
504 "Establish static routes\n"
505 "IP destination prefix\n"
506 "IP destination prefix mask\n"
507 "IP gateway address\n"
508 "IP gateway interface name\n"
510 "Specify label(s) for this route\n"
511 "One or more labels separated by '/'\n")
513 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
514 NULL
, NULL
, argv
[7]->arg
);
517 DEFUN (no_ip_route_mask_tag_label
,
518 no_ip_route_mask_tag_label_cmd
,
519 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
522 "Establish static routes\n"
523 "IP destination prefix\n"
524 "IP destination prefix mask\n"
525 "IP gateway address\n"
526 "IP gateway interface name\n"
528 "Tag of this route\n"
530 "Specify label(s) for this route\n"
531 "One or more labels separated by '/'\n")
533 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
534 NULL
, NULL
, argv
[9]->arg
);
537 DEFUN (no_ip_route_distance_label
,
538 no_ip_route_distance_label_cmd
,
539 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
542 "Establish static routes\n"
543 "IP destination prefix (e.g. 10.0.0.0/8)\n"
544 "IP gateway address\n"
545 "IP gateway interface name\n"
547 "Distance value for this route\n"
548 "Specify label(s) for this route\n"
549 "One or more labels separated by '/'\n")
551 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
552 argv
[5]->arg
, NULL
, argv
[7]->arg
);
555 DEFUN (no_ip_route_tag_distance_label
,
556 no_ip_route_tag_distance_label_cmd
,
557 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
560 "Establish static routes\n"
561 "IP destination prefix (e.g. 10.0.0.0/8)\n"
562 "IP gateway address\n"
563 "IP gateway interface name\n"
565 "Tag of this route\n"
567 "Distance value for this route\n"
568 "Specify label(s) for this route\n"
569 "One or more labels separated by '/'\n")
571 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
572 argv
[7]->arg
, NULL
, argv
[9]->arg
);
575 DEFUN (no_ip_route_mask_distance_label
,
576 no_ip_route_mask_distance_label_cmd
,
577 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
580 "Establish static routes\n"
581 "IP destination prefix\n"
582 "IP destination prefix mask\n"
583 "IP gateway address\n"
584 "IP gateway interface name\n"
586 "Distance value for this route\n"
587 "Specify label(s) for this route\n"
588 "One or more labels separated by '/'\n")
590 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
591 argv
[6]->arg
, NULL
, argv
[8]->arg
);
594 DEFUN (no_ip_route_mask_tag_distance_label
,
595 no_ip_route_mask_tag_distance_label_cmd
,
596 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
599 "Establish static routes\n"
600 "IP destination prefix\n"
601 "IP destination prefix mask\n"
602 "IP gateway address\n"
603 "IP gateway interface name\n"
605 "Tag of this route\n"
607 "Distance value for this route\n"
608 "Specify label(s) for this route\n"
609 "One or more labels separated by '/'\n")
611 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
612 argv
[8]->arg
, NULL
, argv
[10]->arg
);
615 DEFUN (ipv6_route_label
,
616 ipv6_route_label_cmd
,
617 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
619 "Establish static routes\n"
620 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
621 "IPv6 gateway address\n"
622 "IPv6 gateway interface name\n"
623 "Specify label(s) for this route\n"
624 "One or more labels separated by '/'\n")
626 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[5]->arg
);
629 DEFUN (ipv6_route_tag_label
,
630 ipv6_route_tag_label_cmd
,
631 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
633 "Establish static routes\n"
634 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
635 "IPv6 gateway address\n"
636 "IPv6 gateway interface name\n"
637 "Set tag for this route\n"
639 "Specify label(s) for this route\n"
640 "One or more labels separated by '/'\n")
642 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, argv
[5]->arg
, NULL
, NULL
, argv
[7]->arg
);
645 DEFUN (ipv6_route_ifname_label
,
646 ipv6_route_ifname_label_cmd
,
647 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
649 "Establish static routes\n"
650 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
651 "IPv6 gateway address\n"
652 "IPv6 gateway interface name\n"
653 "Specify label(s) for this route\n"
654 "One or more labels separated by '/'\n")
656 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
658 DEFUN (ipv6_route_ifname_tag_label
,
659 ipv6_route_ifname_tag_label_cmd
,
660 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
662 "Establish static routes\n"
663 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
664 "IPv6 gateway address\n"
665 "IPv6 gateway interface name\n"
666 "Set tag for this route\n"
668 "Specify label(s) for this route\n"
669 "One or more labels separated by '/'\n")
671 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
, NULL
, NULL
, argv
[8]->arg
);
674 DEFUN (ipv6_route_pref_label
,
675 ipv6_route_pref_label_cmd
,
676 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
678 "Establish static routes\n"
679 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
680 "IPv6 gateway address\n"
681 "IPv6 gateway interface name\n"
682 "Distance value for this prefix\n"
683 "Specify label(s) for this route\n"
684 "One or more labels separated by '/'\n")
686 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
);
689 DEFUN (ipv6_route_pref_tag_label
,
690 ipv6_route_pref_tag_label_cmd
,
691 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
693 "Establish static routes\n"
694 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
695 "IPv6 gateway address\n"
696 "IPv6 gateway interface name\n"
697 "Set tag for this route\n"
699 "Distance value for this prefix\n"
700 "Specify label(s) for this route\n"
701 "One or more labels separated by '/'\n")
703 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, argv
[5]->arg
, argv
[6]->arg
, NULL
, argv
[8]->arg
);
706 DEFUN (ipv6_route_ifname_pref_label
,
707 ipv6_route_ifname_pref_label_cmd
,
708 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
710 "Establish static routes\n"
711 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
712 "IPv6 gateway address\n"
713 "IPv6 gateway interface name\n"
714 "Distance value for this prefix\n"
715 "Specify label(s) for this route\n"
716 "One or more labels separated by '/'\n")
718 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
, argv
[5]->arg
, NULL
, argv
[7]->arg
);
721 DEFUN (ipv6_route_ifname_pref_tag_label
,
722 ipv6_route_ifname_pref_tag_label_cmd
,
723 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
725 "Establish static routes\n"
726 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
727 "IPv6 gateway address\n"
728 "IPv6 gateway interface name\n"
729 "Set tag for this route\n"
731 "Distance value for this prefix\n"
732 "Specify label(s) for this route\n"
733 "One or more labels separated by '/'\n")
735 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
, argv
[7]->arg
, NULL
, argv
[9]->arg
);
738 DEFUN (no_ipv6_route_label
,
739 no_ipv6_route_label_cmd
,
740 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
743 "Establish static routes\n"
744 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
745 "IPv6 gateway address\n"
746 "IPv6 gateway interface name\n"
747 "Specify label(s) for this route\n"
748 "One or more labels separated by '/'\n")
750 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
753 DEFUN (no_ipv6_route_tag_label
,
754 no_ipv6_route_tag_label_cmd
,
755 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
758 "Establish static routes\n"
759 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
760 "IPv6 gateway address\n"
761 "IPv6 gateway interface name\n"
762 "Set tag for this route\n"
764 "Specify label(s) for this route\n"
765 "One or more labels separated by '/'\n")
767 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, argv
[6]->arg
, NULL
, NULL
, argv
[8]->arg
);
770 DEFUN (no_ipv6_route_ifname_label
,
771 no_ipv6_route_ifname_label_cmd
,
772 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
775 "Establish static routes\n"
776 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
777 "IPv6 gateway address\n"
778 "IPv6 gateway interface name\n"
779 "Specify label(s) for this route\n"
780 "One or more labels separated by '/'\n")
782 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[7]->arg
);
785 DEFUN (no_ipv6_route_ifname_tag_label
,
786 no_ipv6_route_ifname_tag_label_cmd
,
787 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
790 "Establish static routes\n"
791 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
792 "IPv6 gateway address\n"
793 "IPv6 gateway interface name\n"
794 "Set tag for this route\n"
796 "Specify label(s) for this route\n"
797 "One or more labels separated by '/'\n")
799 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
, NULL
, NULL
, argv
[9]->arg
);
802 DEFUN (no_ipv6_route_pref_label
,
803 no_ipv6_route_pref_label_cmd
,
804 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
807 "Establish static routes\n"
808 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
809 "IPv6 gateway address\n"
810 "IPv6 gateway interface name\n"
811 "Distance value for this prefix\n"
812 "Specify label(s) for this route\n"
813 "One or more labels separated by '/'\n")
815 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, argv
[5]->arg
, NULL
, argv
[7]->arg
);
818 DEFUN (no_ipv6_route_pref_tag_label
,
819 no_ipv6_route_pref_tag_label_cmd
,
820 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
823 "Establish static routes\n"
824 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
825 "IPv6 gateway address\n"
826 "IPv6 gateway interface name\n"
827 "Set tag for this route\n"
829 "Distance value for this prefix\n"
830 "Specify label(s) for this route\n"
831 "One or more labels separated by '/'\n")
833 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, argv
[6]->arg
, argv
[7]->arg
, NULL
, argv
[9]->arg
);
836 DEFUN (no_ipv6_route_ifname_pref_label
,
837 no_ipv6_route_ifname_pref_label_cmd
,
838 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
841 "Establish static routes\n"
842 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
843 "IPv6 gateway address\n"
844 "IPv6 gateway interface name\n"
845 "Distance value for this prefix\n"
846 "Specify label(s) for this route\n"
847 "One or more labels separated by '/'\n")
849 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
, argv
[6]->arg
, NULL
, argv
[8]->arg
);
852 DEFUN (no_ipv6_route_ifname_pref_tag_label
,
853 no_ipv6_route_ifname_pref_tag_label_cmd
,
854 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
857 "Establish static routes\n"
858 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
859 "IPv6 gateway address\n"
860 "IPv6 gateway interface name\n"
861 "Set tag for this route\n"
863 "Distance value for this prefix\n"
864 "Specify label(s) for this route\n"
865 "One or more labels separated by '/'\n")
867 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
, argv
[8]->arg
, NULL
, argv
[10]->arg
);
870 /* MPLS LSP configuration write function. */
872 zebra_mpls_config (struct vty
*vty
)
875 struct zebra_vrf
*zvrf
;
877 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
881 write
+= zebra_mpls_write_lsp_config(vty
, zvrf
);
882 write
+= zebra_mpls_write_fec_config(vty
, zvrf
);
883 write
+= zebra_mpls_write_label_block_config (vty
, zvrf
);
887 DEFUN (show_mpls_fec
,
889 "show mpls fec [<A.B.C.D/M|X:X::X:X/M>]",
893 "FEC to display information about\n"
894 "FEC to display information about\n")
896 struct zebra_vrf
*zvrf
;
900 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
905 zebra_mpls_print_fec_table(vty
, zvrf
);
908 memset(&p
, 0, sizeof(struct prefix
));
909 ret
= str2prefix(argv
[3]->arg
, &p
);
912 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
915 zebra_mpls_print_fec (vty
, zvrf
, &p
);
921 DEFUN (show_mpls_table
,
923 "show mpls table [json]",
929 struct zebra_vrf
*zvrf
;
930 u_char uj
= use_json (argc
, argv
);
932 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
933 zebra_mpls_print_lsp_table(vty
, zvrf
, uj
);
937 DEFUN (show_mpls_table_lsp
,
938 show_mpls_table_lsp_cmd
,
939 "show mpls table (16-1048575) [json]",
943 "LSP to display information about\n"
947 struct zebra_vrf
*zvrf
;
948 u_char uj
= use_json (argc
, argv
);
950 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
951 label
= atoi(argv
[3]->arg
);
952 zebra_mpls_print_lsp (vty
, zvrf
, label
, uj
);
956 DEFUN (show_mpls_status
,
957 show_mpls_status_cmd
,
963 vty_out (vty
, "MPLS support enabled: %s%s", (mpls_enabled
) ? "yes" :
964 "no (mpls kernel extensions not detected)", VTY_NEWLINE
);
969 zebra_mpls_global_block (struct vty
*vty
, int add_cmd
,
970 const char *start_label_str
, const char *end_label_str
)
973 u_int32_t start_label
;
975 struct zebra_vrf
*zvrf
;
977 zvrf
= zebra_vrf_lookup_by_id(VRF_DEFAULT
);
980 vty_out (vty
, "%% Default VRF does not exist%s", VTY_NEWLINE
);
986 if (!start_label_str
|| !end_label_str
)
988 vty_out (vty
, "%% Labels not specified%s", VTY_NEWLINE
);
992 start_label
= atoi(start_label_str
);
993 end_label
= atoi(end_label_str
);
994 if (!IS_MPLS_UNRESERVED_LABEL(start_label
) ||
995 !IS_MPLS_UNRESERVED_LABEL(end_label
))
997 vty_out (vty
, "%% Invalid label%s", VTY_NEWLINE
);
1000 if (end_label
< start_label
)
1002 vty_out (vty
, "%% End label is less than Start label%s",
1007 ret
= zebra_mpls_label_block_add (zvrf
, start_label
, end_label
);
1010 ret
= zebra_mpls_label_block_del (zvrf
);
1014 vty_out (vty
, "%% Global label block could not be %s%s",
1015 add_cmd
? "added" : "deleted", VTY_NEWLINE
);
1022 DEFUN (mpls_label_global_block
,
1023 mpls_label_global_block_cmd
,
1024 "mpls label global-block (16-1048575) (16-1048575)",
1026 "Label configuration\n"
1027 "Configure global label block\n"
1031 return zebra_mpls_global_block (vty
, 1, argv
[3]->arg
, argv
[4]->arg
);
1034 DEFUN (no_mpls_label_global_block
,
1035 no_mpls_label_global_block_cmd
,
1036 "no mpls label global-block [(16-1048575) (16-1048575)]",
1039 "Label configuration\n"
1040 "Configure global label block\n"
1044 return zebra_mpls_global_block (vty
, 0, NULL
, NULL
);
1047 /* MPLS node for MPLS LSP. */
1048 static struct cmd_node mpls_node
= { MPLS_NODE
, "", 1 };
1052 zebra_mpls_vty_init (void)
1054 install_element (VIEW_NODE
, &show_mpls_status_cmd
);
1056 install_node (&mpls_node
, zebra_mpls_config
);
1058 install_element (CONFIG_NODE
, &ip_route_label_cmd
);
1059 install_element (CONFIG_NODE
, &ip_route_tag_label_cmd
);
1060 install_element (CONFIG_NODE
, &ip_route_mask_label_cmd
);
1061 install_element (CONFIG_NODE
, &ip_route_mask_tag_label_cmd
);
1062 install_element (CONFIG_NODE
, &no_ip_route_label_cmd
);
1063 install_element (CONFIG_NODE
, &no_ip_route_tag_label_cmd
);
1064 install_element (CONFIG_NODE
, &no_ip_route_mask_label_cmd
);
1065 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_label_cmd
);
1066 install_element (CONFIG_NODE
, &ip_route_distance_label_cmd
);
1067 install_element (CONFIG_NODE
, &ip_route_tag_distance_label_cmd
);
1068 install_element (CONFIG_NODE
, &ip_route_mask_distance_label_cmd
);
1069 install_element (CONFIG_NODE
, &ip_route_mask_tag_distance_label_cmd
);
1070 install_element (CONFIG_NODE
, &no_ip_route_distance_label_cmd
);
1071 install_element (CONFIG_NODE
, &no_ip_route_tag_distance_label_cmd
);
1072 install_element (CONFIG_NODE
, &no_ip_route_mask_distance_label_cmd
);
1073 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_distance_label_cmd
);
1075 install_element (CONFIG_NODE
, &ipv6_route_label_cmd
);
1076 install_element (CONFIG_NODE
, &ipv6_route_ifname_label_cmd
);
1077 install_element (CONFIG_NODE
, &no_ipv6_route_label_cmd
);
1078 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_label_cmd
);
1079 install_element (CONFIG_NODE
, &ipv6_route_pref_label_cmd
);
1080 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_label_cmd
);
1081 install_element (CONFIG_NODE
, &no_ipv6_route_pref_label_cmd
);
1082 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_label_cmd
);
1083 install_element (CONFIG_NODE
, &ipv6_route_tag_label_cmd
);
1084 install_element (CONFIG_NODE
, &ipv6_route_ifname_tag_label_cmd
);
1085 install_element (CONFIG_NODE
, &ipv6_route_pref_tag_label_cmd
);
1086 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_tag_label_cmd
);
1087 install_element (CONFIG_NODE
, &no_ipv6_route_tag_label_cmd
);
1088 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_tag_label_cmd
);
1089 install_element (CONFIG_NODE
, &no_ipv6_route_pref_tag_label_cmd
);
1090 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_tag_label_cmd
);
1092 install_element (CONFIG_NODE
, &mpls_transit_lsp_cmd
);
1093 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_cmd
);
1094 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_out_label_cmd
);
1095 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_all_cmd
);
1096 install_element (CONFIG_NODE
, &mpls_label_bind_cmd
);
1097 install_element (CONFIG_NODE
, &no_mpls_label_bind_cmd
);
1099 install_element (CONFIG_NODE
, &mpls_label_global_block_cmd
);
1100 install_element (CONFIG_NODE
, &no_mpls_label_global_block_cmd
);
1102 install_element (VIEW_NODE
, &show_mpls_table_cmd
);
1103 install_element (VIEW_NODE
, &show_mpls_table_lsp_cmd
);
1104 install_element (VIEW_NODE
, &show_mpls_fec_cmd
);