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_outln (vty
,"%% MPLS not turned on in kernel, ignoring command");
60 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
63 vty_outln (vty
, "%% Default VRF does not exist");
69 vty_outln (vty
, "%% No Label Information");
73 out_label
= MPLS_IMP_NULL_LABEL
; /* as initialization */
74 label
= atoi(inlabel_str
);
75 if (!IS_MPLS_UNRESERVED_LABEL(label
))
77 vty_outln (vty
, "%% Invalid label");
85 vty_outln (vty
, "%% No Nexthop Information");
90 vty_outln (vty
, "%% No Outgoing label Information");
96 gtype
= NEXTHOP_TYPE_BLACKHOLE
; /* as initialization */
100 /* Gateway is a IPv4 or IPv6 nexthop. */
101 ret
= inet_pton (AF_INET6
, gate_str
, &gate
.ipv6
);
103 gtype
= NEXTHOP_TYPE_IPV6
;
106 ret
= inet_pton (AF_INET
, gate_str
, &gate
.ipv4
);
108 gtype
= NEXTHOP_TYPE_IPV4
;
111 vty_outln (vty
, "%% Invalid nexthop");
119 if (outlabel_str
[0] == 'i')
120 out_label
= MPLS_IMP_NULL_LABEL
;
121 else if (outlabel_str
[0] == 'e' && gtype
== NEXTHOP_TYPE_IPV4
)
122 out_label
= MPLS_V4_EXP_NULL_LABEL
;
123 else if (outlabel_str
[0] == 'e' && gtype
== NEXTHOP_TYPE_IPV6
)
124 out_label
= MPLS_V6_EXP_NULL_LABEL
;
126 out_label
= atoi(outlabel_str
);
131 #if defined(HAVE_CUMULUS)
132 /* Check that label value is consistent. */
133 if (!zebra_mpls_lsp_label_consistent (zvrf
, in_label
, out_label
, gtype
,
136 vty_outln (vty
,"%% Label value not consistent");
139 #endif /* HAVE_CUMULUS */
141 ret
= zebra_mpls_static_lsp_add (zvrf
, in_label
, out_label
, gtype
,
145 ret
= zebra_mpls_static_lsp_del (zvrf
, in_label
, gtype
, &gate
, 0);
149 vty_outln (vty
, "%% LSP cannot be %s",
150 add_cmd
? "added" : "deleted");
157 DEFUN (mpls_transit_lsp
,
158 mpls_transit_lsp_cmd
,
159 "mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
161 "Establish label switched path\n"
162 "Incoming MPLS label\n"
163 "IPv4 gateway address\n"
164 "IPv6 gateway address\n"
165 "Outgoing MPLS label\n"
166 "Use Explicit-Null label\n"
167 "Use Implicit-Null label\n")
169 return zebra_mpls_transit_lsp (vty
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
);
172 DEFUN (no_mpls_transit_lsp
,
173 no_mpls_transit_lsp_cmd
,
174 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X>",
177 "Establish label switched path\n"
178 "Incoming MPLS label\n"
179 "IPv4 gateway address\n"
180 "IPv6 gateway address\n")
182 return zebra_mpls_transit_lsp (vty
, 0, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
);
185 ALIAS (no_mpls_transit_lsp
,
186 no_mpls_transit_lsp_out_label_cmd
,
187 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
190 "Establish label switched path\n"
191 "Incoming MPLS label\n"
192 "IPv4 gateway address\n"
193 "IPv6 gateway address\n"
194 "Outgoing MPLS label\n"
195 "Use Explicit-Null label\n"
196 "Use Implicit-Null label\n")
198 DEFUN (no_mpls_transit_lsp_all
,
199 no_mpls_transit_lsp_all_cmd
,
200 "no mpls lsp (16-1048575)",
203 "Establish label switched path\n"
204 "Incoming MPLS label\n")
206 return zebra_mpls_transit_lsp (vty
, 0, argv
[3]->arg
, NULL
, NULL
, NULL
);
210 zebra_mpls_bind (struct vty
*vty
, int add_cmd
, const char *prefix
,
211 const char *label_str
)
213 struct zebra_vrf
*zvrf
;
218 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
221 vty_outln (vty
, "%% Default VRF does not exist");
225 memset(&p
, 0, sizeof(struct prefix
));
226 ret
= str2prefix(prefix
, &p
);
229 vty_outln (vty
, "%% Malformed address");
237 vty_outln (vty
, "%% No label binding specified");
241 if (!strcmp(label_str
, "implicit-null"))
242 label
= MPLS_IMP_NULL_LABEL
;
243 else if (!strcmp(label_str
, "explicit-null"))
245 if (p
.family
== AF_INET
)
246 label
= MPLS_V4_EXP_NULL_LABEL
;
248 label
= MPLS_V6_EXP_NULL_LABEL
;
252 label
= atoi(label_str
);
253 if (!IS_MPLS_UNRESERVED_LABEL(label
))
255 vty_outln (vty
, "%% Invalid label");
258 if (zebra_mpls_label_already_bound (zvrf
, label
))
260 vty_outln (vty
,"%% Label already bound to a FEC");
265 ret
= zebra_mpls_static_fec_add (zvrf
, &p
, label
);
268 ret
= zebra_mpls_static_fec_del (zvrf
, &p
);
272 vty_outln (vty
, "%% FEC to label binding cannot be %s",
273 add_cmd
? "added" : "deleted");
280 DEFUN (mpls_label_bind
,
282 "mpls label bind <A.B.C.D/M|X:X::X:X/M> <(16-1048575)|implicit-null|explicit-null>",
284 "Label configuration\n"
285 "Establish FEC to label binding\n"
288 "MPLS Label to bind\n"
289 "Use Implicit-Null Label\n"
290 "Use Explicit-Null Label\n")
292 return zebra_mpls_bind (vty
, 1, argv
[3]->arg
, argv
[4]->arg
);
295 DEFUN (no_mpls_label_bind
,
296 no_mpls_label_bind_cmd
,
297 "no mpls label bind <A.B.C.D/M|X:X::X:X/M> [<(16-1048575)|implicit-null>]",
300 "Label configuration\n"
301 "Establish FEC to label binding\n"
304 "MPLS Label to bind\n"
305 "Use Implicit-Null Label\n")
308 return zebra_mpls_bind (vty
, 0, argv
[4]->arg
, NULL
);
311 /* Static route configuration. */
312 DEFUN (ip_route_label
,
314 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
316 "Establish static routes\n"
317 "IP destination prefix (e.g. 10.0.0.0/8)\n"
318 "IP gateway address\n"
319 "IP gateway interface name\n"
323 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
324 NULL
, NULL
, argv
[5]->arg
);
327 DEFUN (ip_route_tag_label
,
328 ip_route_tag_label_cmd
,
329 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
331 "Establish static routes\n"
332 "IP destination prefix (e.g. 10.0.0.0/8)\n"
333 "IP gateway address\n"
334 "IP gateway interface name\n"
336 "Set tag for this route\n"
340 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
341 NULL
, NULL
, argv
[7]->arg
);
344 /* Mask as A.B.C.D format. */
345 DEFUN (ip_route_mask_label
,
346 ip_route_mask_label_cmd
,
347 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
349 "Establish static routes\n"
350 "IP destination prefix\n"
351 "IP destination prefix mask\n"
352 "IP gateway address\n"
353 "IP gateway interface name\n"
357 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
358 NULL
, NULL
, argv
[6]->arg
);
361 DEFUN (ip_route_mask_tag_label
,
362 ip_route_mask_tag_label_cmd
,
363 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
365 "Establish static routes\n"
366 "IP destination prefix\n"
367 "IP destination prefix mask\n"
368 "IP gateway address\n"
369 "IP gateway interface name\n"
371 "Set tag for this route\n"
376 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
377 NULL
, NULL
, argv
[8]->arg
);
380 /* Distance option value. */
381 DEFUN (ip_route_distance_label
,
382 ip_route_distance_label_cmd
,
383 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
385 "Establish static routes\n"
386 "IP destination prefix (e.g. 10.0.0.0/8)\n"
387 "IP gateway address\n"
388 "IP gateway interface name\n"
390 "Distance value for this route\n"
393 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
,
394 argv
[4]->arg
, NULL
, argv
[6]->arg
);
397 DEFUN (ip_route_tag_distance_label
,
398 ip_route_tag_distance_label_cmd
,
399 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
401 "Establish static routes\n"
402 "IP destination prefix (e.g. 10.0.0.0/8)\n"
403 "IP gateway address\n"
404 "IP gateway interface name\n"
406 "Set tag for this route\n"
408 "Distance value for this route\n"
412 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, argv
[5]->arg
,
413 argv
[6]->arg
, NULL
, argv
[8]->arg
);
416 DEFUN (ip_route_mask_distance_label
,
417 ip_route_mask_distance_label_cmd
,
418 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
420 "Establish static routes\n"
421 "IP destination prefix\n"
422 "IP destination prefix mask\n"
423 "IP gateway address\n"
424 "IP gateway interface name\n"
426 "Distance value for this route\n"
429 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
,
430 argv
[5]->arg
, NULL
, argv
[7]->arg
);
433 DEFUN (ip_route_mask_tag_distance_label
,
434 ip_route_mask_tag_distance_label_cmd
,
435 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
437 "Establish static routes\n"
438 "IP destination prefix\n"
439 "IP destination prefix mask\n"
440 "IP gateway address\n"
441 "IP gateway interface name\n"
443 "Set tag for this route\n"
445 "Distance value for this route\n"
448 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
449 argv
[7]->arg
, NULL
, argv
[9]->arg
);
452 DEFUN (no_ip_route_label
,
453 no_ip_route_label_cmd
,
454 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
457 "Establish static routes\n"
458 "IP destination prefix (e.g. 10.0.0.0/8)\n"
459 "IP gateway address\n"
460 "IP gateway interface name\n"
464 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
465 NULL
, NULL
, argv
[6]->arg
);
468 DEFUN (no_ip_route_tag_label
,
469 no_ip_route_tag_label_cmd
,
470 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
473 "Establish static routes\n"
474 "IP destination prefix (e.g. 10.0.0.0/8)\n"
475 "IP gateway address\n"
476 "IP gateway interface name\n"
478 "Tag of this route\n"
482 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
483 NULL
, NULL
, argv
[8]->arg
);
486 DEFUN (no_ip_route_mask_label
,
487 no_ip_route_mask_label_cmd
,
488 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
491 "Establish static routes\n"
492 "IP destination prefix\n"
493 "IP destination prefix mask\n"
494 "IP gateway address\n"
495 "IP gateway interface name\n"
499 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
500 NULL
, NULL
, argv
[7]->arg
);
503 DEFUN (no_ip_route_mask_tag_label
,
504 no_ip_route_mask_tag_label_cmd
,
505 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
508 "Establish static routes\n"
509 "IP destination prefix\n"
510 "IP destination prefix mask\n"
511 "IP gateway address\n"
512 "IP gateway interface name\n"
514 "Tag of this route\n"
518 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
519 NULL
, NULL
, argv
[9]->arg
);
522 DEFUN (no_ip_route_distance_label
,
523 no_ip_route_distance_label_cmd
,
524 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
527 "Establish static routes\n"
528 "IP destination prefix (e.g. 10.0.0.0/8)\n"
529 "IP gateway address\n"
530 "IP gateway interface name\n"
532 "Distance value for this route\n"
535 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
,
536 argv
[5]->arg
, NULL
, argv
[7]->arg
);
539 DEFUN (no_ip_route_tag_distance_label
,
540 no_ip_route_tag_distance_label_cmd
,
541 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
544 "Establish static routes\n"
545 "IP destination prefix (e.g. 10.0.0.0/8)\n"
546 "IP gateway address\n"
547 "IP gateway interface name\n"
549 "Tag of this route\n"
551 "Distance value for this route\n"
554 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
,
555 argv
[7]->arg
, NULL
, argv
[9]->arg
);
558 DEFUN (no_ip_route_mask_distance_label
,
559 no_ip_route_mask_distance_label_cmd
,
560 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
563 "Establish static routes\n"
564 "IP destination prefix\n"
565 "IP destination prefix mask\n"
566 "IP gateway address\n"
567 "IP gateway interface name\n"
569 "Distance value for this route\n"
572 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
,
573 argv
[6]->arg
, NULL
, argv
[8]->arg
);
576 DEFUN (no_ip_route_mask_tag_distance_label
,
577 no_ip_route_mask_tag_distance_label_cmd
,
578 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
581 "Establish static routes\n"
582 "IP destination prefix\n"
583 "IP destination prefix mask\n"
584 "IP gateway address\n"
585 "IP gateway interface name\n"
587 "Tag of this route\n"
589 "Distance value for this route\n"
592 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0, argv
[3]->arg
, argv
[4]->arg
, argv
[5]->arg
, NULL
, argv
[7]->arg
,
593 argv
[8]->arg
, NULL
, argv
[10]->arg
);
596 DEFUN (ipv6_route_label
,
597 ipv6_route_label_cmd
,
598 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
600 "Establish static routes\n"
601 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
602 "IPv6 gateway address\n"
603 "IPv6 gateway interface name\n"
606 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[5]->arg
);
609 DEFUN (ipv6_route_tag_label
,
610 ipv6_route_tag_label_cmd
,
611 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
613 "Establish static routes\n"
614 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
615 "IPv6 gateway address\n"
616 "IPv6 gateway interface name\n"
617 "Set tag for this route\n"
621 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, argv
[5]->arg
, NULL
, NULL
, argv
[7]->arg
);
624 DEFUN (ipv6_route_ifname_label
,
625 ipv6_route_ifname_label_cmd
,
626 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
628 "Establish static routes\n"
629 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
630 "IPv6 gateway address\n"
631 "IPv6 gateway interface name\n"
634 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
636 DEFUN (ipv6_route_ifname_tag_label
,
637 ipv6_route_ifname_tag_label_cmd
,
638 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
640 "Establish static routes\n"
641 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
642 "IPv6 gateway address\n"
643 "IPv6 gateway interface name\n"
644 "Set tag for this route\n"
648 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
);
651 DEFUN (ipv6_route_pref_label
,
652 ipv6_route_pref_label_cmd
,
653 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
655 "Establish static routes\n"
656 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
657 "IPv6 gateway address\n"
658 "IPv6 gateway interface name\n"
659 "Distance value for this prefix\n"
662 return static_ipv6_func (vty
, 1, argv
[2]->arg
, NULL
, argv
[3]->arg
, NULL
, NULL
, NULL
, argv
[4]->arg
, NULL
, argv
[6]->arg
);
665 DEFUN (ipv6_route_pref_tag_label
,
666 ipv6_route_pref_tag_label_cmd
,
667 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
669 "Establish static routes\n"
670 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
671 "IPv6 gateway address\n"
672 "IPv6 gateway interface name\n"
673 "Set tag for this route\n"
675 "Distance value for this prefix\n"
678 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
);
681 DEFUN (ipv6_route_ifname_pref_label
,
682 ipv6_route_ifname_pref_label_cmd
,
683 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
685 "Establish static routes\n"
686 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
687 "IPv6 gateway address\n"
688 "IPv6 gateway interface name\n"
689 "Distance value for this prefix\n"
692 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
);
695 DEFUN (ipv6_route_ifname_pref_tag_label
,
696 ipv6_route_ifname_pref_tag_label_cmd
,
697 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
699 "Establish static routes\n"
700 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
701 "IPv6 gateway address\n"
702 "IPv6 gateway interface name\n"
703 "Set tag for this route\n"
705 "Distance value for this prefix\n"
708 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
);
711 DEFUN (no_ipv6_route_label
,
712 no_ipv6_route_label_cmd
,
713 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
716 "Establish static routes\n"
717 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
718 "IPv6 gateway address\n"
719 "IPv6 gateway interface name\n"
722 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, NULL
, NULL
, argv
[6]->arg
);
725 DEFUN (no_ipv6_route_tag_label
,
726 no_ipv6_route_tag_label_cmd
,
727 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
730 "Establish static routes\n"
731 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
732 "IPv6 gateway address\n"
733 "IPv6 gateway interface name\n"
734 "Set tag for this route\n"
738 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, argv
[6]->arg
, NULL
, NULL
, argv
[8]->arg
);
741 DEFUN (no_ipv6_route_ifname_label
,
742 no_ipv6_route_ifname_label_cmd
,
743 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
746 "Establish static routes\n"
747 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
748 "IPv6 gateway address\n"
749 "IPv6 gateway interface name\n"
752 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, argv
[5]->arg
, NULL
, NULL
, NULL
, NULL
, argv
[7]->arg
);
755 DEFUN (no_ipv6_route_ifname_tag_label
,
756 no_ipv6_route_ifname_tag_label_cmd
,
757 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
760 "Establish static routes\n"
761 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
762 "IPv6 gateway address\n"
763 "IPv6 gateway interface name\n"
764 "Set tag for this route\n"
768 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
);
771 DEFUN (no_ipv6_route_pref_label
,
772 no_ipv6_route_pref_label_cmd
,
773 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
776 "Establish static routes\n"
777 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
778 "IPv6 gateway address\n"
779 "IPv6 gateway interface name\n"
780 "Distance value for this prefix\n"
783 return static_ipv6_func (vty
, 0, argv
[3]->arg
, NULL
, argv
[4]->arg
, NULL
, NULL
, NULL
, argv
[5]->arg
, NULL
, argv
[7]->arg
);
786 DEFUN (no_ipv6_route_pref_tag_label
,
787 no_ipv6_route_pref_tag_label_cmd
,
788 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
791 "Establish static routes\n"
792 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
793 "IPv6 gateway address\n"
794 "IPv6 gateway interface name\n"
795 "Set tag for this route\n"
797 "Distance value for this prefix\n"
800 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
);
803 DEFUN (no_ipv6_route_ifname_pref_label
,
804 no_ipv6_route_ifname_pref_label_cmd
,
805 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
808 "Establish static routes\n"
809 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
810 "IPv6 gateway address\n"
811 "IPv6 gateway interface name\n"
812 "Distance value for this prefix\n"
815 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
);
818 DEFUN (no_ipv6_route_ifname_pref_tag_label
,
819 no_ipv6_route_ifname_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"
832 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
);
835 /* MPLS LSP configuration write function. */
837 zebra_mpls_config (struct vty
*vty
)
840 struct zebra_vrf
*zvrf
;
842 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
846 write
+= zebra_mpls_write_lsp_config(vty
, zvrf
);
847 write
+= zebra_mpls_write_fec_config(vty
, zvrf
);
848 write
+= zebra_mpls_write_label_block_config (vty
, zvrf
);
852 DEFUN (show_mpls_fec
,
854 "show mpls fec [<A.B.C.D/M|X:X::X:X/M>]",
858 "FEC to display information about\n"
859 "FEC to display information about\n")
861 struct zebra_vrf
*zvrf
;
865 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
870 zebra_mpls_print_fec_table(vty
, zvrf
);
873 memset(&p
, 0, sizeof(struct prefix
));
874 ret
= str2prefix(argv
[3]->arg
, &p
);
877 vty_outln (vty
, "%% Malformed address");
880 zebra_mpls_print_fec (vty
, zvrf
, &p
);
886 DEFUN (show_mpls_table
,
888 "show mpls table [json]",
894 struct zebra_vrf
*zvrf
;
895 u_char uj
= use_json (argc
, argv
);
897 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
898 zebra_mpls_print_lsp_table(vty
, zvrf
, uj
);
902 DEFUN (show_mpls_table_lsp
,
903 show_mpls_table_lsp_cmd
,
904 "show mpls table (16-1048575) [json]",
908 "LSP to display information about\n"
912 struct zebra_vrf
*zvrf
;
913 u_char uj
= use_json (argc
, argv
);
915 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
916 label
= atoi(argv
[3]->arg
);
917 zebra_mpls_print_lsp (vty
, zvrf
, label
, uj
);
921 DEFUN (show_mpls_status
,
922 show_mpls_status_cmd
,
928 vty_outln (vty
, "MPLS support enabled: %s",
929 (mpls_enabled
) ? "yes" : "no (mpls kernel extensions not detected)");
934 zebra_mpls_global_block (struct vty
*vty
, int add_cmd
,
935 const char *start_label_str
, const char *end_label_str
)
938 u_int32_t start_label
;
940 struct zebra_vrf
*zvrf
;
942 zvrf
= zebra_vrf_lookup_by_id(VRF_DEFAULT
);
945 vty_outln (vty
, "%% Default VRF does not exist");
951 if (!start_label_str
|| !end_label_str
)
953 vty_outln (vty
, "%% Labels not specified");
957 start_label
= atoi(start_label_str
);
958 end_label
= atoi(end_label_str
);
959 if (!IS_MPLS_UNRESERVED_LABEL(start_label
) ||
960 !IS_MPLS_UNRESERVED_LABEL(end_label
))
962 vty_outln (vty
, "%% Invalid label");
965 if (end_label
< start_label
)
967 vty_outln (vty
,"%% End label is less than Start label");
971 ret
= zebra_mpls_label_block_add (zvrf
, start_label
, end_label
);
974 ret
= zebra_mpls_label_block_del (zvrf
);
978 vty_outln (vty
, "%% Global label block could not be %s",
979 add_cmd
? "added" : "deleted");
986 DEFUN (mpls_label_global_block
,
987 mpls_label_global_block_cmd
,
988 "mpls label global-block (16-1048575) (16-1048575)",
990 "Label configuration\n"
991 "Configure global label block\n"
995 return zebra_mpls_global_block (vty
, 1, argv
[3]->arg
, argv
[4]->arg
);
998 DEFUN (no_mpls_label_global_block
,
999 no_mpls_label_global_block_cmd
,
1000 "no mpls label global-block [(16-1048575) (16-1048575)]",
1003 "Label configuration\n"
1004 "Configure global label block\n"
1008 return zebra_mpls_global_block (vty
, 0, NULL
, NULL
);
1011 /* MPLS node for MPLS LSP. */
1012 static struct cmd_node mpls_node
= { MPLS_NODE
, "", 1 };
1016 zebra_mpls_vty_init (void)
1018 install_element (VIEW_NODE
, &show_mpls_status_cmd
);
1020 install_node (&mpls_node
, zebra_mpls_config
);
1022 install_element (CONFIG_NODE
, &ip_route_label_cmd
);
1023 install_element (CONFIG_NODE
, &ip_route_tag_label_cmd
);
1024 install_element (CONFIG_NODE
, &ip_route_mask_label_cmd
);
1025 install_element (CONFIG_NODE
, &ip_route_mask_tag_label_cmd
);
1026 install_element (CONFIG_NODE
, &no_ip_route_label_cmd
);
1027 install_element (CONFIG_NODE
, &no_ip_route_tag_label_cmd
);
1028 install_element (CONFIG_NODE
, &no_ip_route_mask_label_cmd
);
1029 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_label_cmd
);
1030 install_element (CONFIG_NODE
, &ip_route_distance_label_cmd
);
1031 install_element (CONFIG_NODE
, &ip_route_tag_distance_label_cmd
);
1032 install_element (CONFIG_NODE
, &ip_route_mask_distance_label_cmd
);
1033 install_element (CONFIG_NODE
, &ip_route_mask_tag_distance_label_cmd
);
1034 install_element (CONFIG_NODE
, &no_ip_route_distance_label_cmd
);
1035 install_element (CONFIG_NODE
, &no_ip_route_tag_distance_label_cmd
);
1036 install_element (CONFIG_NODE
, &no_ip_route_mask_distance_label_cmd
);
1037 install_element (CONFIG_NODE
, &no_ip_route_mask_tag_distance_label_cmd
);
1039 install_element (CONFIG_NODE
, &ipv6_route_label_cmd
);
1040 install_element (CONFIG_NODE
, &ipv6_route_ifname_label_cmd
);
1041 install_element (CONFIG_NODE
, &no_ipv6_route_label_cmd
);
1042 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_label_cmd
);
1043 install_element (CONFIG_NODE
, &ipv6_route_pref_label_cmd
);
1044 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_label_cmd
);
1045 install_element (CONFIG_NODE
, &no_ipv6_route_pref_label_cmd
);
1046 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_label_cmd
);
1047 install_element (CONFIG_NODE
, &ipv6_route_tag_label_cmd
);
1048 install_element (CONFIG_NODE
, &ipv6_route_ifname_tag_label_cmd
);
1049 install_element (CONFIG_NODE
, &ipv6_route_pref_tag_label_cmd
);
1050 install_element (CONFIG_NODE
, &ipv6_route_ifname_pref_tag_label_cmd
);
1051 install_element (CONFIG_NODE
, &no_ipv6_route_tag_label_cmd
);
1052 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_tag_label_cmd
);
1053 install_element (CONFIG_NODE
, &no_ipv6_route_pref_tag_label_cmd
);
1054 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_pref_tag_label_cmd
);
1056 install_element (CONFIG_NODE
, &mpls_transit_lsp_cmd
);
1057 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_cmd
);
1058 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_out_label_cmd
);
1059 install_element (CONFIG_NODE
, &no_mpls_transit_lsp_all_cmd
);
1060 install_element (CONFIG_NODE
, &mpls_label_bind_cmd
);
1061 install_element (CONFIG_NODE
, &no_mpls_label_bind_cmd
);
1063 install_element (CONFIG_NODE
, &mpls_label_global_block_cmd
);
1064 install_element (CONFIG_NODE
, &no_mpls_label_global_block_cmd
);
1066 install_element (VIEW_NODE
, &show_mpls_table_cmd
);
1067 install_element (VIEW_NODE
, &show_mpls_table_lsp_cmd
);
1068 install_element (VIEW_NODE
, &show_mpls_fec_cmd
);