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"
326 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
327 NULL
, NULL
, argv
[5]->arg
);
330 DEFUN (ip_route_tag_label
,
331 ip_route_tag_label_cmd
,
332 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
334 "Establish static routes\n"
335 "IP destination prefix (e.g. 10.0.0.0/8)\n"
336 "IP gateway address\n"
337 "IP gateway interface name\n"
339 "Set tag for this route\n"
343 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
344 NULL
, NULL
, argv
[7]->arg
);
347 /* Mask as A.B.C.D format. */
348 DEFUN (ip_route_mask_label
,
349 ip_route_mask_label_cmd
,
350 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
352 "Establish static routes\n"
353 "IP destination prefix\n"
354 "IP destination prefix mask\n"
355 "IP gateway address\n"
356 "IP gateway interface name\n"
360 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
361 NULL
, NULL
, argv
[6]->arg
);
364 DEFUN (ip_route_mask_tag_label
,
365 ip_route_mask_tag_label_cmd
,
366 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
368 "Establish static routes\n"
369 "IP destination prefix\n"
370 "IP destination prefix mask\n"
371 "IP gateway address\n"
372 "IP gateway interface name\n"
374 "Set tag for this route\n"
379 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
380 NULL
, NULL
, argv
[8]->arg
);
383 /* Distance option value. */
384 DEFUN (ip_route_distance_label
,
385 ip_route_distance_label_cmd
,
386 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
388 "Establish static routes\n"
389 "IP destination prefix (e.g. 10.0.0.0/8)\n"
390 "IP gateway address\n"
391 "IP gateway interface name\n"
393 "Distance value for this route\n"
396 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
397 argv
[4]->arg
, NULL
, argv
[6]->arg
);
400 DEFUN (ip_route_tag_distance_label
,
401 ip_route_tag_distance_label_cmd
,
402 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
404 "Establish static routes\n"
405 "IP destination prefix (e.g. 10.0.0.0/8)\n"
406 "IP gateway address\n"
407 "IP gateway interface name\n"
409 "Set tag for this route\n"
411 "Distance value for this route\n"
415 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
416 argv
[6]->arg
, NULL
, argv
[8]->arg
);
419 DEFUN (ip_route_mask_distance_label
,
420 ip_route_mask_distance_label_cmd
,
421 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
423 "Establish static routes\n"
424 "IP destination prefix\n"
425 "IP destination prefix mask\n"
426 "IP gateway address\n"
427 "IP gateway interface name\n"
429 "Distance value for this route\n"
432 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
433 argv
[5]->arg
, NULL
, argv
[7]->arg
);
436 DEFUN (ip_route_mask_tag_distance_label
,
437 ip_route_mask_tag_distance_label_cmd
,
438 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
440 "Establish static routes\n"
441 "IP destination prefix\n"
442 "IP destination prefix mask\n"
443 "IP gateway address\n"
444 "IP gateway interface name\n"
446 "Set tag for this route\n"
448 "Distance value for this route\n"
451 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
452 argv
[7]->arg
, NULL
, argv
[9]->arg
);
455 DEFUN (no_ip_route_label
,
456 no_ip_route_label_cmd
,
457 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
460 "Establish static routes\n"
461 "IP destination prefix (e.g. 10.0.0.0/8)\n"
462 "IP gateway address\n"
463 "IP gateway interface name\n"
467 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
468 NULL
, NULL
, argv
[6]->arg
);
471 DEFUN (no_ip_route_tag_label
,
472 no_ip_route_tag_label_cmd
,
473 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
476 "Establish static routes\n"
477 "IP destination prefix (e.g. 10.0.0.0/8)\n"
478 "IP gateway address\n"
479 "IP gateway interface name\n"
481 "Tag of this route\n"
485 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
486 NULL
, NULL
, argv
[8]->arg
);
489 DEFUN (no_ip_route_mask_label
,
490 no_ip_route_mask_label_cmd
,
491 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
494 "Establish static routes\n"
495 "IP destination prefix\n"
496 "IP destination prefix mask\n"
497 "IP gateway address\n"
498 "IP gateway interface name\n"
502 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
503 NULL
, NULL
, argv
[7]->arg
);
506 DEFUN (no_ip_route_mask_tag_label
,
507 no_ip_route_mask_tag_label_cmd
,
508 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
511 "Establish static routes\n"
512 "IP destination prefix\n"
513 "IP destination prefix mask\n"
514 "IP gateway address\n"
515 "IP gateway interface name\n"
517 "Tag of this route\n"
521 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
522 NULL
, NULL
, argv
[9]->arg
);
525 DEFUN (no_ip_route_distance_label
,
526 no_ip_route_distance_label_cmd
,
527 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
530 "Establish static routes\n"
531 "IP destination prefix (e.g. 10.0.0.0/8)\n"
532 "IP gateway address\n"
533 "IP gateway interface name\n"
535 "Distance value for this route\n"
538 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
539 argv
[5]->arg
, NULL
, argv
[7]->arg
);
542 DEFUN (no_ip_route_tag_distance_label
,
543 no_ip_route_tag_distance_label_cmd
,
544 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
547 "Establish static routes\n"
548 "IP destination prefix (e.g. 10.0.0.0/8)\n"
549 "IP gateway address\n"
550 "IP gateway interface name\n"
552 "Tag of this route\n"
554 "Distance value for this route\n"
557 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
558 argv
[7]->arg
, NULL
, argv
[9]->arg
);
561 DEFUN (no_ip_route_mask_distance_label
,
562 no_ip_route_mask_distance_label_cmd
,
563 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
566 "Establish static routes\n"
567 "IP destination prefix\n"
568 "IP destination prefix mask\n"
569 "IP gateway address\n"
570 "IP gateway interface name\n"
572 "Distance value for this route\n"
575 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
576 argv
[6]->arg
, NULL
, argv
[8]->arg
);
579 DEFUN (no_ip_route_mask_tag_distance_label
,
580 no_ip_route_mask_tag_distance_label_cmd
,
581 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
584 "Establish static routes\n"
585 "IP destination prefix\n"
586 "IP destination prefix mask\n"
587 "IP gateway address\n"
588 "IP gateway interface name\n"
590 "Tag of this route\n"
592 "Distance value for this route\n"
595 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
596 argv
[8]->arg
, NULL
, argv
[10]->arg
);
599 DEFUN (ipv6_route_label
,
600 ipv6_route_label_cmd
,
601 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
603 "Establish static routes\n"
604 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
605 "IPv6 gateway address\n"
606 "IPv6 gateway interface name\n"
609 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[5]->arg
);
612 DEFUN (ipv6_route_tag_label
,
613 ipv6_route_tag_label_cmd
,
614 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
616 "Establish static routes\n"
617 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
618 "IPv6 gateway address\n"
619 "IPv6 gateway interface name\n"
620 "Set tag for this route\n"
624 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, argv
[5]->arg
, NULL
, NULL
, argv
[7]->arg
);
627 DEFUN (ipv6_route_ifname_label
,
628 ipv6_route_ifname_label_cmd
,
629 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
631 "Establish static routes\n"
632 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
633 "IPv6 gateway address\n"
634 "IPv6 gateway interface name\n"
637 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
639 DEFUN (ipv6_route_ifname_tag_label
,
640 ipv6_route_ifname_tag_label_cmd
,
641 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
643 "Establish static routes\n"
644 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
645 "IPv6 gateway address\n"
646 "IPv6 gateway interface name\n"
647 "Set tag for this route\n"
651 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
);
654 DEFUN (ipv6_route_pref_label
,
655 ipv6_route_pref_label_cmd
,
656 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
658 "Establish static routes\n"
659 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
660 "IPv6 gateway address\n"
661 "IPv6 gateway interface name\n"
662 "Distance value for this prefix\n"
665 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
);
668 DEFUN (ipv6_route_pref_tag_label
,
669 ipv6_route_pref_tag_label_cmd
,
670 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
672 "Establish static routes\n"
673 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
674 "IPv6 gateway address\n"
675 "IPv6 gateway interface name\n"
676 "Set tag for this route\n"
678 "Distance value for this prefix\n"
681 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
);
684 DEFUN (ipv6_route_ifname_pref_label
,
685 ipv6_route_ifname_pref_label_cmd
,
686 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
688 "Establish static routes\n"
689 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
690 "IPv6 gateway address\n"
691 "IPv6 gateway interface name\n"
692 "Distance value for this prefix\n"
695 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
);
698 DEFUN (ipv6_route_ifname_pref_tag_label
,
699 ipv6_route_ifname_pref_tag_label_cmd
,
700 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
702 "Establish static routes\n"
703 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
704 "IPv6 gateway address\n"
705 "IPv6 gateway interface name\n"
706 "Set tag for this route\n"
708 "Distance value for this prefix\n"
711 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
);
714 DEFUN (no_ipv6_route_label
,
715 no_ipv6_route_label_cmd
,
716 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
719 "Establish static routes\n"
720 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
721 "IPv6 gateway address\n"
722 "IPv6 gateway interface name\n"
725 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
728 DEFUN (no_ipv6_route_tag_label
,
729 no_ipv6_route_tag_label_cmd
,
730 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
733 "Establish static routes\n"
734 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
735 "IPv6 gateway address\n"
736 "IPv6 gateway interface name\n"
737 "Set tag for this route\n"
741 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, argv
[6]->arg
, NULL
, NULL
, argv
[8]->arg
);
744 DEFUN (no_ipv6_route_ifname_label
,
745 no_ipv6_route_ifname_label_cmd
,
746 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
749 "Establish static routes\n"
750 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
751 "IPv6 gateway address\n"
752 "IPv6 gateway interface name\n"
755 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[7]->arg
);
758 DEFUN (no_ipv6_route_ifname_tag_label
,
759 no_ipv6_route_ifname_tag_label_cmd
,
760 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
763 "Establish static routes\n"
764 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
765 "IPv6 gateway address\n"
766 "IPv6 gateway interface name\n"
767 "Set tag for this route\n"
771 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
);
774 DEFUN (no_ipv6_route_pref_label
,
775 no_ipv6_route_pref_label_cmd
,
776 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
779 "Establish static routes\n"
780 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
781 "IPv6 gateway address\n"
782 "IPv6 gateway interface name\n"
783 "Distance value for this prefix\n"
786 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, argv
[5]->arg
, NULL
, argv
[7]->arg
);
789 DEFUN (no_ipv6_route_pref_tag_label
,
790 no_ipv6_route_pref_tag_label_cmd
,
791 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
794 "Establish static routes\n"
795 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
796 "IPv6 gateway address\n"
797 "IPv6 gateway interface name\n"
798 "Set tag for this route\n"
800 "Distance value for this prefix\n"
803 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
);
806 DEFUN (no_ipv6_route_ifname_pref_label
,
807 no_ipv6_route_ifname_pref_label_cmd
,
808 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
811 "Establish static routes\n"
812 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
813 "IPv6 gateway address\n"
814 "IPv6 gateway interface name\n"
815 "Distance value for this prefix\n"
818 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
);
821 DEFUN (no_ipv6_route_ifname_pref_tag_label
,
822 no_ipv6_route_ifname_pref_tag_label_cmd
,
823 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
826 "Establish static routes\n"
827 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
828 "IPv6 gateway address\n"
829 "IPv6 gateway interface name\n"
830 "Set tag for this route\n"
832 "Distance value for this prefix\n"
835 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
);
838 /* MPLS LSP configuration write function. */
840 zebra_mpls_config (struct vty
*vty
)
843 struct zebra_vrf
*zvrf
;
845 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
849 write
+= zebra_mpls_write_lsp_config(vty
, zvrf
);
850 write
+= zebra_mpls_write_fec_config(vty
, zvrf
);
851 write
+= zebra_mpls_write_label_block_config (vty
, zvrf
);
855 DEFUN (show_mpls_fec
,
857 "show mpls fec [<A.B.C.D/M|X:X::X:X/M>]",
861 "FEC to display information about\n"
862 "FEC to display information about\n")
864 struct zebra_vrf
*zvrf
;
868 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
873 zebra_mpls_print_fec_table(vty
, zvrf
);
876 memset(&p
, 0, sizeof(struct prefix
));
877 ret
= str2prefix(argv
[3]->arg
, &p
);
880 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
883 zebra_mpls_print_fec (vty
, zvrf
, &p
);
889 DEFUN (show_mpls_table
,
891 "show mpls table [json]",
897 struct zebra_vrf
*zvrf
;
898 u_char uj
= use_json (argc
, argv
);
900 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
901 zebra_mpls_print_lsp_table(vty
, zvrf
, uj
);
905 DEFUN (show_mpls_table_lsp
,
906 show_mpls_table_lsp_cmd
,
907 "show mpls table (16-1048575) [json]",
911 "LSP to display information about\n"
915 struct zebra_vrf
*zvrf
;
916 u_char uj
= use_json (argc
, argv
);
918 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
919 label
= atoi(argv
[3]->arg
);
920 zebra_mpls_print_lsp (vty
, zvrf
, label
, uj
);
924 DEFUN (show_mpls_status
,
925 show_mpls_status_cmd
,
931 vty_out (vty
, "MPLS support enabled: %s%s", (mpls_enabled
) ? "yes" :
932 "no (mpls kernel extensions not detected)", VTY_NEWLINE
);
937 zebra_mpls_global_block (struct vty
*vty
, int add_cmd
,
938 const char *start_label_str
, const char *end_label_str
)
941 u_int32_t start_label
;
943 struct zebra_vrf
*zvrf
;
945 zvrf
= zebra_vrf_lookup_by_id(VRF_DEFAULT
);
948 vty_out (vty
, "%% Default VRF does not exist%s", VTY_NEWLINE
);
954 if (!start_label_str
|| !end_label_str
)
956 vty_out (vty
, "%% Labels not specified%s", VTY_NEWLINE
);
960 start_label
= atoi(start_label_str
);
961 end_label
= atoi(end_label_str
);
962 if (!IS_MPLS_UNRESERVED_LABEL(start_label
) ||
963 !IS_MPLS_UNRESERVED_LABEL(end_label
))
965 vty_out (vty
, "%% Invalid label%s", VTY_NEWLINE
);
968 if (end_label
< start_label
)
970 vty_out (vty
, "%% End label is less than Start label%s",
975 ret
= zebra_mpls_label_block_add (zvrf
, start_label
, end_label
);
978 ret
= zebra_mpls_label_block_del (zvrf
);
982 vty_out (vty
, "%% Global label block could not be %s%s",
983 add_cmd
? "added" : "deleted", VTY_NEWLINE
);
990 DEFUN (mpls_label_global_block
,
991 mpls_label_global_block_cmd
,
992 "mpls label global-block (16-1048575) (16-1048575)",
994 "Label configuration\n"
995 "Configure global label block\n"
999 return zebra_mpls_global_block (vty
, 1, argv
[3]->arg
, argv
[4]->arg
);
1002 DEFUN (no_mpls_label_global_block
,
1003 no_mpls_label_global_block_cmd
,
1004 "no mpls label global-block [(16-1048575) (16-1048575)]",
1007 "Label configuration\n"
1008 "Configure global label block\n"
1012 return zebra_mpls_global_block (vty
, 0, NULL
, NULL
);
1015 /* MPLS node for MPLS LSP. */
1016 static struct cmd_node mpls_node
= { MPLS_NODE
, "", 1 };
1020 zebra_mpls_vty_init (void)
1022 install_element (VIEW_NODE
, &show_mpls_status_cmd
);
1024 install_node (&mpls_node
, zebra_mpls_config
);
1026 install_element (CONFIG_NODE
, &ip_route_label_cmd
);
1027 install_element (CONFIG_NODE
, &ip_route_tag_label_cmd
);
1028 install_element (CONFIG_NODE
, &ip_route_mask_label_cmd
);
1029 install_element (CONFIG_NODE
, &ip_route_mask_tag_label_cmd
);
1030 install_element (CONFIG_NODE
, &no_ip_route_label_cmd
);
1031 install_element (CONFIG_NODE
, &no_ip_route_tag_label_cmd
);
1032 install_element (CONFIG_NODE
, &no_ip_route_mask_label_cmd
);
1033 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_label_cmd
);
1034 install_element (CONFIG_NODE
, &ip_route_distance_label_cmd
);
1035 install_element (CONFIG_NODE
, &ip_route_tag_distance_label_cmd
);
1036 install_element (CONFIG_NODE
, &ip_route_mask_distance_label_cmd
);
1037 install_element (CONFIG_NODE
, &ip_route_mask_tag_distance_label_cmd
);
1038 install_element (CONFIG_NODE
, &no_ip_route_distance_label_cmd
);
1039 install_element (CONFIG_NODE
, &no_ip_route_tag_distance_label_cmd
);
1040 install_element (CONFIG_NODE
, &no_ip_route_mask_distance_label_cmd
);
1041 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_distance_label_cmd
);
1043 install_element (CONFIG_NODE
, &ipv6_route_label_cmd
);
1044 install_element (CONFIG_NODE
, &ipv6_route_ifname_label_cmd
);
1045 install_element (CONFIG_NODE
, &no_ipv6_route_label_cmd
);
1046 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_label_cmd
);
1047 install_element (CONFIG_NODE
, &ipv6_route_pref_label_cmd
);
1048 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_label_cmd
);
1049 install_element (CONFIG_NODE
, &no_ipv6_route_pref_label_cmd
);
1050 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_label_cmd
);
1051 install_element (CONFIG_NODE
, &ipv6_route_tag_label_cmd
);
1052 install_element (CONFIG_NODE
, &ipv6_route_ifname_tag_label_cmd
);
1053 install_element (CONFIG_NODE
, &ipv6_route_pref_tag_label_cmd
);
1054 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_tag_label_cmd
);
1055 install_element (CONFIG_NODE
, &no_ipv6_route_tag_label_cmd
);
1056 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_tag_label_cmd
);
1057 install_element (CONFIG_NODE
, &no_ipv6_route_pref_tag_label_cmd
);
1058 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_tag_label_cmd
);
1060 install_element (CONFIG_NODE
, &mpls_transit_lsp_cmd
);
1061 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_cmd
);
1062 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_out_label_cmd
);
1063 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_all_cmd
);
1064 install_element (CONFIG_NODE
, &mpls_label_bind_cmd
);
1065 install_element (CONFIG_NODE
, &no_mpls_label_bind_cmd
);
1067 install_element (CONFIG_NODE
, &mpls_label_global_block_cmd
);
1068 install_element (CONFIG_NODE
, &no_mpls_label_global_block_cmd
);
1070 install_element (VIEW_NODE
, &show_mpls_table_cmd
);
1071 install_element (VIEW_NODE
, &show_mpls_table_lsp_cmd
);
1072 install_element (VIEW_NODE
, &show_mpls_fec_cmd
);