]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_mpls_vty.c
ubuntu12.04: shorten frr-dbg description
[mirror_frr.git] / zebra / zebra_mpls_vty.c
1 /* Zebra MPLS VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
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
9 * later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #include <zebra.h>
23
24 #include "memory.h"
25 #include "if.h"
26 #include "prefix.h"
27 #include "command.h"
28 #include "table.h"
29 #include "rib.h"
30 #include "nexthop.h"
31 #include "vrf.h"
32 #include "mpls.h"
33 #include "lib/json.h"
34
35 #include "zebra/zserv.h"
36 #include "zebra/zebra_vrf.h"
37 #include "zebra/zebra_mpls.h"
38 #include "zebra/zebra_rnh.h"
39 #include "zebra/redistribute.h"
40 #include "zebra/zebra_routemap.h"
41 #include "zebra/zebra_static.h"
42
43 static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
44 const char *inlabel_str, const char *gate_str,
45 const char *outlabel_str,
46 const char *flag_str)
47 {
48 struct zebra_vrf *zvrf;
49 int ret;
50 enum nexthop_types_t gtype;
51 union g_addr gate;
52 mpls_label_t label;
53 mpls_label_t in_label, out_label;
54
55 if (!mpls_enabled) {
56 vty_out(vty,
57 "%% MPLS not turned on in kernel, ignoring command%s",
58 VTY_NEWLINE);
59 return CMD_WARNING;
60 }
61
62 zvrf = vrf_info_lookup(VRF_DEFAULT);
63 if (!zvrf) {
64 vty_out(vty, "%% Default VRF does not exist%s", VTY_NEWLINE);
65 return CMD_WARNING;
66 }
67
68 if (!inlabel_str) {
69 vty_out(vty, "%% No Label Information%s", VTY_NEWLINE);
70 return CMD_WARNING;
71 }
72
73 out_label = MPLS_IMP_NULL_LABEL; /* as initialization */
74 label = atoi(inlabel_str);
75 if (!IS_MPLS_UNRESERVED_LABEL(label)) {
76 vty_out(vty, "%% Invalid label%s", VTY_NEWLINE);
77 return CMD_WARNING;
78 }
79
80 if (add_cmd) {
81 if (!gate_str) {
82 vty_out(vty, "%% No Nexthop Information%s",
83 VTY_NEWLINE);
84 return CMD_WARNING;
85 }
86 if (!outlabel_str) {
87 vty_out(vty, "%% No Outgoing label Information%s",
88 VTY_NEWLINE);
89 return CMD_WARNING;
90 }
91 }
92
93 in_label = label;
94 gtype = NEXTHOP_TYPE_BLACKHOLE; /* as initialization */
95
96 if (gate_str) {
97 /* Gateway is a IPv4 or IPv6 nexthop. */
98 ret = inet_pton(AF_INET6, gate_str, &gate.ipv6);
99 if (ret)
100 gtype = NEXTHOP_TYPE_IPV6;
101 else {
102 ret = inet_pton(AF_INET, gate_str, &gate.ipv4);
103 if (ret)
104 gtype = NEXTHOP_TYPE_IPV4;
105 else {
106 vty_out(vty, "%% Invalid nexthop%s",
107 VTY_NEWLINE);
108 return CMD_WARNING;
109 }
110 }
111 }
112
113 if (outlabel_str) {
114 if (outlabel_str[0] == 'i')
115 out_label = MPLS_IMP_NULL_LABEL;
116 else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV4)
117 out_label = MPLS_V4_EXP_NULL_LABEL;
118 else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV6)
119 out_label = MPLS_V6_EXP_NULL_LABEL;
120 else
121 out_label = atoi(outlabel_str);
122 }
123
124 if (add_cmd) {
125 #if defined(HAVE_CUMULUS)
126 /* Check that label value is consistent. */
127 if (!zebra_mpls_lsp_label_consistent(zvrf, in_label, out_label,
128 gtype, &gate, NULL, 0)) {
129 vty_out(vty, "%% Label value not consistent%s",
130 VTY_NEWLINE);
131 return CMD_WARNING;
132 }
133 #endif /* HAVE_CUMULUS */
134
135 ret = zebra_mpls_static_lsp_add(zvrf, in_label, out_label,
136 gtype, &gate, NULL, 0);
137 } else
138 ret = zebra_mpls_static_lsp_del(zvrf, in_label, gtype, &gate,
139 NULL, 0);
140
141 if (ret) {
142 vty_out(vty, "%% LSP cannot be %s%s",
143 add_cmd ? "added" : "deleted", VTY_NEWLINE);
144 return CMD_WARNING;
145 }
146
147 return CMD_SUCCESS;
148 }
149
150 DEFUN (mpls_transit_lsp,
151 mpls_transit_lsp_cmd,
152 "mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
153 MPLS_STR
154 "Establish label switched path\n"
155 "Incoming MPLS label\n"
156 "IPv4 gateway address\n"
157 "IPv6 gateway address\n"
158 "Outgoing MPLS label\n"
159 "Use Explicit-Null label\n"
160 "Use Implicit-Null label\n")
161 {
162 return zebra_mpls_transit_lsp(vty, 1, argv[2]->arg, argv[3]->arg,
163 argv[4]->arg, NULL);
164 }
165
166 DEFUN (no_mpls_transit_lsp,
167 no_mpls_transit_lsp_cmd,
168 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X>",
169 NO_STR
170 MPLS_STR
171 "Establish label switched path\n"
172 "Incoming MPLS label\n"
173 "IPv4 gateway address\n"
174 "IPv6 gateway address\n")
175 {
176 return zebra_mpls_transit_lsp(vty, 0, argv[3]->arg, argv[4]->arg, NULL,
177 NULL);
178 }
179
180 ALIAS(no_mpls_transit_lsp, no_mpls_transit_lsp_out_label_cmd,
181 "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>",
182 NO_STR MPLS_STR
183 "Establish label switched path\n"
184 "Incoming MPLS label\n"
185 "IPv4 gateway address\n"
186 "IPv6 gateway address\n"
187 "Outgoing MPLS label\n"
188 "Use Explicit-Null label\n"
189 "Use Implicit-Null label\n")
190
191 DEFUN (no_mpls_transit_lsp_all,
192 no_mpls_transit_lsp_all_cmd,
193 "no mpls lsp (16-1048575)",
194 NO_STR
195 MPLS_STR
196 "Establish label switched path\n"
197 "Incoming MPLS label\n")
198 {
199 return zebra_mpls_transit_lsp(vty, 0, argv[3]->arg, NULL, NULL, NULL);
200 }
201
202 /* Static route configuration. */
203 DEFUN (ip_route_label,
204 ip_route_label_cmd,
205 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
206 IP_STR
207 "Establish static routes\n"
208 "IP destination prefix (e.g. 10.0.0.0/8)\n"
209 "IP gateway address\n"
210 "IP gateway interface name\n"
211 "Null interface\n"
212 "Specify label(s) for this route\n"
213 "One or more labels separated by '/'\n")
214 {
215 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
216 argv[3]->arg, NULL, NULL, NULL, NULL,
217 argv[5]->arg);
218 }
219
220 DEFUN (ip_route_tag_label,
221 ip_route_tag_label_cmd,
222 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
223 IP_STR
224 "Establish static routes\n"
225 "IP destination prefix (e.g. 10.0.0.0/8)\n"
226 "IP gateway address\n"
227 "IP gateway interface name\n"
228 "Null interface\n"
229 "Set tag for this route\n"
230 "Tag value\n"
231 "Specify label(s) for this route\n"
232 "One or more labels separated by '/'\n")
233 {
234 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
235 argv[3]->arg, NULL, argv[5]->arg, NULL, NULL,
236 argv[7]->arg);
237 }
238
239 /* Mask as A.B.C.D format. */
240 DEFUN (ip_route_mask_label,
241 ip_route_mask_label_cmd,
242 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
243 IP_STR
244 "Establish static routes\n"
245 "IP destination prefix\n"
246 "IP destination prefix mask\n"
247 "IP gateway address\n"
248 "IP gateway interface name\n"
249 "Null interface\n"
250 "Specify label(s) for this route\n"
251 "One or more labels separated by '/'\n")
252 {
253 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
254 argv[3]->arg, argv[4]->arg, NULL, NULL, NULL,
255 NULL, argv[6]->arg);
256 }
257
258 DEFUN (ip_route_mask_tag_label,
259 ip_route_mask_tag_label_cmd,
260 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
261 IP_STR
262 "Establish static routes\n"
263 "IP destination prefix\n"
264 "IP destination prefix mask\n"
265 "IP gateway address\n"
266 "IP gateway interface name\n"
267 "Null interface\n"
268 "Set tag for this route\n"
269 "Tag value\n"
270 "Specify label(s) for this route\n"
271 "One or more labels separated by '/'\n")
272 {
273 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
274 argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
275 NULL, NULL, argv[8]->arg);
276 }
277
278 /* Distance option value. */
279 DEFUN (ip_route_distance_label,
280 ip_route_distance_label_cmd,
281 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
282 IP_STR
283 "Establish static routes\n"
284 "IP destination prefix (e.g. 10.0.0.0/8)\n"
285 "IP gateway address\n"
286 "IP gateway interface name\n"
287 "Null interface\n"
288 "Distance value for this route\n"
289 "Specify label(s) for this route\n"
290 "One or more labels separated by '/'\n")
291 {
292 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
293 argv[3]->arg, NULL, NULL, argv[4]->arg, NULL,
294 argv[6]->arg);
295 }
296
297 DEFUN (ip_route_tag_distance_label,
298 ip_route_tag_distance_label_cmd,
299 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
300 IP_STR
301 "Establish static routes\n"
302 "IP destination prefix (e.g. 10.0.0.0/8)\n"
303 "IP gateway address\n"
304 "IP gateway interface name\n"
305 "Null interface\n"
306 "Set tag for this route\n"
307 "Tag value\n"
308 "Distance value for this route\n"
309 "Specify label(s) for this route\n"
310 "One or more labels separated by '/'\n")
311 {
312 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
313 argv[3]->arg, NULL, argv[5]->arg, argv[6]->arg,
314 NULL, argv[8]->arg);
315 }
316
317 DEFUN (ip_route_mask_distance_label,
318 ip_route_mask_distance_label_cmd,
319 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
320 IP_STR
321 "Establish static routes\n"
322 "IP destination prefix\n"
323 "IP destination prefix mask\n"
324 "IP gateway address\n"
325 "IP gateway interface name\n"
326 "Null interface\n"
327 "Distance value for this route\n"
328 "Specify label(s) for this route\n"
329 "One or more labels separated by '/'\n")
330 {
331 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
332 argv[3]->arg, argv[4]->arg, NULL, NULL,
333 argv[5]->arg, NULL, argv[7]->arg);
334 }
335
336 DEFUN (ip_route_mask_tag_distance_label,
337 ip_route_mask_tag_distance_label_cmd,
338 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
339 IP_STR
340 "Establish static routes\n"
341 "IP destination prefix\n"
342 "IP destination prefix mask\n"
343 "IP gateway address\n"
344 "IP gateway interface name\n"
345 "Null interface\n"
346 "Set tag for this route\n"
347 "Tag value\n"
348 "Distance value for this route\n"
349 "Specify label(s) for this route\n"
350 "One or more labels separated by '/'\n")
351 {
352 return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
353 argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
354 argv[7]->arg, NULL, argv[9]->arg);
355 }
356
357 DEFUN (no_ip_route_label,
358 no_ip_route_label_cmd,
359 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
360 NO_STR
361 IP_STR
362 "Establish static routes\n"
363 "IP destination prefix (e.g. 10.0.0.0/8)\n"
364 "IP gateway address\n"
365 "IP gateway interface name\n"
366 "Null interface\n"
367 "Specify label(s) for this route\n"
368 "One or more labels separated by '/'\n")
369 {
370 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
371 argv[4]->arg, NULL, NULL, NULL, NULL,
372 argv[6]->arg);
373 }
374
375 DEFUN (no_ip_route_tag_label,
376 no_ip_route_tag_label_cmd,
377 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
378 NO_STR
379 IP_STR
380 "Establish static routes\n"
381 "IP destination prefix (e.g. 10.0.0.0/8)\n"
382 "IP gateway address\n"
383 "IP gateway interface name\n"
384 "Null interface\n"
385 "Tag of this route\n"
386 "Tag value\n"
387 "Specify label(s) for this route\n"
388 "One or more labels separated by '/'\n")
389 {
390 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
391 argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
392 argv[8]->arg);
393 }
394
395 DEFUN (no_ip_route_mask_label,
396 no_ip_route_mask_label_cmd,
397 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
398 NO_STR
399 IP_STR
400 "Establish static routes\n"
401 "IP destination prefix\n"
402 "IP destination prefix mask\n"
403 "IP gateway address\n"
404 "IP gateway interface name\n"
405 "Null interface\n"
406 "Specify label(s) for this route\n"
407 "One or more labels separated by '/'\n")
408 {
409 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
410 argv[4]->arg, argv[5]->arg, NULL, NULL, NULL,
411 NULL, argv[7]->arg);
412 }
413
414 DEFUN (no_ip_route_mask_tag_label,
415 no_ip_route_mask_tag_label_cmd,
416 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
417 NO_STR
418 IP_STR
419 "Establish static routes\n"
420 "IP destination prefix\n"
421 "IP destination prefix mask\n"
422 "IP gateway address\n"
423 "IP gateway interface name\n"
424 "Null interface\n"
425 "Tag of this route\n"
426 "Tag value\n"
427 "Specify label(s) for this route\n"
428 "One or more labels separated by '/'\n")
429 {
430 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
431 argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
432 NULL, NULL, argv[9]->arg);
433 }
434
435 DEFUN (no_ip_route_distance_label,
436 no_ip_route_distance_label_cmd,
437 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
438 NO_STR
439 IP_STR
440 "Establish static routes\n"
441 "IP destination prefix (e.g. 10.0.0.0/8)\n"
442 "IP gateway address\n"
443 "IP gateway interface name\n"
444 "Null interface\n"
445 "Distance value for this route\n"
446 "Specify label(s) for this route\n"
447 "One or more labels separated by '/'\n")
448 {
449 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
450 argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
451 argv[7]->arg);
452 }
453
454 DEFUN (no_ip_route_tag_distance_label,
455 no_ip_route_tag_distance_label_cmd,
456 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
457 NO_STR
458 IP_STR
459 "Establish static routes\n"
460 "IP destination prefix (e.g. 10.0.0.0/8)\n"
461 "IP gateway address\n"
462 "IP gateway interface name\n"
463 "Null interface\n"
464 "Tag of this route\n"
465 "Tag value\n"
466 "Distance value for this route\n"
467 "Specify label(s) for this route\n"
468 "One or more labels separated by '/'\n")
469 {
470 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
471 argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
472 NULL, argv[9]->arg);
473 }
474
475 DEFUN (no_ip_route_mask_distance_label,
476 no_ip_route_mask_distance_label_cmd,
477 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
478 NO_STR
479 IP_STR
480 "Establish static routes\n"
481 "IP destination prefix\n"
482 "IP destination prefix mask\n"
483 "IP gateway address\n"
484 "IP gateway interface name\n"
485 "Null interface\n"
486 "Distance value for this route\n"
487 "Specify label(s) for this route\n"
488 "One or more labels separated by '/'\n")
489 {
490 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
491 argv[4]->arg, argv[5]->arg, NULL, NULL,
492 argv[6]->arg, NULL, argv[8]->arg);
493 }
494
495 DEFUN (no_ip_route_mask_tag_distance_label,
496 no_ip_route_mask_tag_distance_label_cmd,
497 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
498 NO_STR
499 IP_STR
500 "Establish static routes\n"
501 "IP destination prefix\n"
502 "IP destination prefix mask\n"
503 "IP gateway address\n"
504 "IP gateway interface name\n"
505 "Null interface\n"
506 "Tag of this route\n"
507 "Tag value\n"
508 "Distance value for this route\n"
509 "Specify label(s) for this route\n"
510 "One or more labels separated by '/'\n")
511 {
512 return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
513 argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
514 argv[8]->arg, NULL, argv[10]->arg);
515 }
516
517 DEFUN (ipv6_route_label,
518 ipv6_route_label_cmd,
519 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
520 IP_STR
521 "Establish static routes\n"
522 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
523 "IPv6 gateway address\n"
524 "IPv6 gateway interface name\n"
525 "Specify label(s) for this route\n"
526 "One or more labels separated by '/'\n")
527 {
528 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
529 NULL, NULL, NULL, NULL, argv[5]->arg);
530 }
531
532 DEFUN (ipv6_route_tag_label,
533 ipv6_route_tag_label_cmd,
534 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
535 IP_STR
536 "Establish static routes\n"
537 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
538 "IPv6 gateway address\n"
539 "IPv6 gateway interface name\n"
540 "Set tag for this route\n"
541 "Tag value\n"
542 "Specify label(s) for this route\n"
543 "One or more labels separated by '/'\n")
544 {
545 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
546 NULL, argv[5]->arg, NULL, NULL, argv[7]->arg);
547 }
548
549 DEFUN (ipv6_route_ifname_label,
550 ipv6_route_ifname_label_cmd,
551 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
552 IP_STR
553 "Establish static routes\n"
554 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
555 "IPv6 gateway address\n"
556 "IPv6 gateway interface name\n"
557 "Specify label(s) for this route\n"
558 "One or more labels separated by '/'\n")
559 {
560 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
561 argv[4]->arg, NULL, NULL, NULL, NULL,
562 argv[6]->arg);
563 }
564 DEFUN (ipv6_route_ifname_tag_label,
565 ipv6_route_ifname_tag_label_cmd,
566 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
567 IP_STR
568 "Establish static routes\n"
569 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
570 "IPv6 gateway address\n"
571 "IPv6 gateway interface name\n"
572 "Set tag for this route\n"
573 "Tag value\n"
574 "Specify label(s) for this route\n"
575 "One or more labels separated by '/'\n")
576 {
577 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
578 argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
579 argv[8]->arg);
580 }
581
582 DEFUN (ipv6_route_pref_label,
583 ipv6_route_pref_label_cmd,
584 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
585 IP_STR
586 "Establish static routes\n"
587 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
588 "IPv6 gateway address\n"
589 "IPv6 gateway interface name\n"
590 "Distance value for this prefix\n"
591 "Specify label(s) for this route\n"
592 "One or more labels separated by '/'\n")
593 {
594 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
595 NULL, NULL, argv[4]->arg, NULL, argv[6]->arg);
596 }
597
598 DEFUN (ipv6_route_pref_tag_label,
599 ipv6_route_pref_tag_label_cmd,
600 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
601 IP_STR
602 "Establish static routes\n"
603 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
604 "IPv6 gateway address\n"
605 "IPv6 gateway interface name\n"
606 "Set tag for this route\n"
607 "Tag value\n"
608 "Distance value for this prefix\n"
609 "Specify label(s) for this route\n"
610 "One or more labels separated by '/'\n")
611 {
612 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
613 NULL, argv[5]->arg, argv[6]->arg, NULL,
614 argv[8]->arg);
615 }
616
617 DEFUN (ipv6_route_ifname_pref_label,
618 ipv6_route_ifname_pref_label_cmd,
619 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
620 IP_STR
621 "Establish static routes\n"
622 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
623 "IPv6 gateway address\n"
624 "IPv6 gateway interface name\n"
625 "Distance value for this prefix\n"
626 "Specify label(s) for this route\n"
627 "One or more labels separated by '/'\n")
628 {
629 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
630 argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
631 argv[7]->arg);
632 }
633
634 DEFUN (ipv6_route_ifname_pref_tag_label,
635 ipv6_route_ifname_pref_tag_label_cmd,
636 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
637 IP_STR
638 "Establish static routes\n"
639 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
640 "IPv6 gateway address\n"
641 "IPv6 gateway interface name\n"
642 "Set tag for this route\n"
643 "Tag value\n"
644 "Distance value for this prefix\n"
645 "Specify label(s) for this route\n"
646 "One or more labels separated by '/'\n")
647 {
648 return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
649 argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
650 NULL, argv[9]->arg);
651 }
652
653 DEFUN (no_ipv6_route_label,
654 no_ipv6_route_label_cmd,
655 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
656 NO_STR
657 IP_STR
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 "Specify label(s) for this route\n"
663 "One or more labels separated by '/'\n")
664 {
665 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
666 NULL, NULL, NULL, NULL, argv[6]->arg);
667 }
668
669 DEFUN (no_ipv6_route_tag_label,
670 no_ipv6_route_tag_label_cmd,
671 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
672 NO_STR
673 IP_STR
674 "Establish static routes\n"
675 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
676 "IPv6 gateway address\n"
677 "IPv6 gateway interface name\n"
678 "Set tag for this route\n"
679 "Tag value\n"
680 "Specify label(s) for this route\n"
681 "One or more labels separated by '/'\n")
682 {
683 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
684 NULL, argv[6]->arg, NULL, NULL, argv[8]->arg);
685 }
686
687 DEFUN (no_ipv6_route_ifname_label,
688 no_ipv6_route_ifname_label_cmd,
689 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
690 NO_STR
691 IP_STR
692 "Establish static routes\n"
693 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
694 "IPv6 gateway address\n"
695 "IPv6 gateway interface name\n"
696 "Specify label(s) for this route\n"
697 "One or more labels separated by '/'\n")
698 {
699 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
700 argv[5]->arg, NULL, NULL, NULL, NULL,
701 argv[7]->arg);
702 }
703
704 DEFUN (no_ipv6_route_ifname_tag_label,
705 no_ipv6_route_ifname_tag_label_cmd,
706 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
707 NO_STR
708 IP_STR
709 "Establish static routes\n"
710 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
711 "IPv6 gateway address\n"
712 "IPv6 gateway interface name\n"
713 "Set tag for this route\n"
714 "Tag value\n"
715 "Specify label(s) for this route\n"
716 "One or more labels separated by '/'\n")
717 {
718 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
719 argv[5]->arg, NULL, argv[7]->arg, NULL, NULL,
720 argv[9]->arg);
721 }
722
723 DEFUN (no_ipv6_route_pref_label,
724 no_ipv6_route_pref_label_cmd,
725 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
726 NO_STR
727 IP_STR
728 "Establish static routes\n"
729 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
730 "IPv6 gateway address\n"
731 "IPv6 gateway interface name\n"
732 "Distance value for this prefix\n"
733 "Specify label(s) for this route\n"
734 "One or more labels separated by '/'\n")
735 {
736 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
737 NULL, NULL, argv[5]->arg, NULL, argv[7]->arg);
738 }
739
740 DEFUN (no_ipv6_route_pref_tag_label,
741 no_ipv6_route_pref_tag_label_cmd,
742 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
743 NO_STR
744 IP_STR
745 "Establish static routes\n"
746 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
747 "IPv6 gateway address\n"
748 "IPv6 gateway interface name\n"
749 "Set tag for this route\n"
750 "Tag value\n"
751 "Distance value for this prefix\n"
752 "Specify label(s) for this route\n"
753 "One or more labels separated by '/'\n")
754 {
755 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
756 NULL, argv[6]->arg, argv[7]->arg, NULL,
757 argv[9]->arg);
758 }
759
760 DEFUN (no_ipv6_route_ifname_pref_label,
761 no_ipv6_route_ifname_pref_label_cmd,
762 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
763 NO_STR
764 IP_STR
765 "Establish static routes\n"
766 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
767 "IPv6 gateway address\n"
768 "IPv6 gateway interface name\n"
769 "Distance value for this prefix\n"
770 "Specify label(s) for this route\n"
771 "One or more labels separated by '/'\n")
772 {
773 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
774 argv[5]->arg, NULL, NULL, argv[6]->arg, NULL,
775 argv[8]->arg);
776 }
777
778 DEFUN (no_ipv6_route_ifname_pref_tag_label,
779 no_ipv6_route_ifname_pref_tag_label_cmd,
780 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
781 NO_STR
782 IP_STR
783 "Establish static routes\n"
784 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
785 "IPv6 gateway address\n"
786 "IPv6 gateway interface name\n"
787 "Set tag for this route\n"
788 "Tag value\n"
789 "Distance value for this prefix\n"
790 "Specify label(s) for this route\n"
791 "One or more labels separated by '/'\n")
792 {
793 return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
794 argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg,
795 NULL, argv[10]->arg);
796 }
797
798 /* MPLS LSP configuration write function. */
799 static int zebra_mpls_config(struct vty *vty)
800 {
801 int write = 0;
802 struct zebra_vrf *zvrf;
803
804 zvrf = vrf_info_lookup(VRF_DEFAULT);
805 if (!zvrf)
806 return 0;
807
808 write += zebra_mpls_write_lsp_config(vty, zvrf);
809 return write;
810 }
811
812 DEFUN (show_mpls_table,
813 show_mpls_table_cmd,
814 "show mpls table [json]",
815 SHOW_STR
816 MPLS_STR
817 "MPLS table\n"
818 JSON_STR)
819 {
820 struct zebra_vrf *zvrf;
821 u_char uj = use_json(argc, argv);
822
823 zvrf = vrf_info_lookup(VRF_DEFAULT);
824 zebra_mpls_print_lsp_table(vty, zvrf, uj);
825 return CMD_SUCCESS;
826 }
827
828 DEFUN (show_mpls_table_lsp,
829 show_mpls_table_lsp_cmd,
830 "show mpls table (16-1048575) [json]",
831 SHOW_STR
832 MPLS_STR
833 "MPLS table\n"
834 "LSP to display information about\n"
835 JSON_STR)
836 {
837 u_int32_t label;
838 struct zebra_vrf *zvrf;
839 u_char uj = use_json(argc, argv);
840
841 zvrf = vrf_info_lookup(VRF_DEFAULT);
842 label = atoi(argv[3]->arg);
843 zebra_mpls_print_lsp(vty, zvrf, label, uj);
844 return CMD_SUCCESS;
845 }
846
847 DEFUN (show_mpls_status,
848 show_mpls_status_cmd,
849 "show mpls status",
850 SHOW_STR
851 "MPLS information\n"
852 "MPLS status\n")
853 {
854 vty_out(vty, "MPLS support enabled: %s%s",
855 (mpls_enabled) ? "yes"
856 : "no (mpls kernel extensions not detected)",
857 VTY_NEWLINE);
858 return CMD_SUCCESS;
859 }
860
861 /* MPLS node for MPLS LSP. */
862 static struct cmd_node mpls_node = {MPLS_NODE, "", 1};
863
864 /* MPLS VTY. */
865 void zebra_mpls_vty_init(void)
866 {
867 install_element(VIEW_NODE, &show_mpls_status_cmd);
868
869 install_node(&mpls_node, zebra_mpls_config);
870
871 install_element(CONFIG_NODE, &ip_route_label_cmd);
872 install_element(CONFIG_NODE, &ip_route_tag_label_cmd);
873 install_element(CONFIG_NODE, &ip_route_mask_label_cmd);
874 install_element(CONFIG_NODE, &ip_route_mask_tag_label_cmd);
875 install_element(CONFIG_NODE, &no_ip_route_label_cmd);
876 install_element(CONFIG_NODE, &no_ip_route_tag_label_cmd);
877 install_element(CONFIG_NODE, &no_ip_route_mask_label_cmd);
878 install_element(CONFIG_NODE, &no_ip_route_mask_tag_label_cmd);
879 install_element(CONFIG_NODE, &ip_route_distance_label_cmd);
880 install_element(CONFIG_NODE, &ip_route_tag_distance_label_cmd);
881 install_element(CONFIG_NODE, &ip_route_mask_distance_label_cmd);
882 install_element(CONFIG_NODE, &ip_route_mask_tag_distance_label_cmd);
883 install_element(CONFIG_NODE, &no_ip_route_distance_label_cmd);
884 install_element(CONFIG_NODE, &no_ip_route_tag_distance_label_cmd);
885 install_element(CONFIG_NODE, &no_ip_route_mask_distance_label_cmd);
886 install_element(CONFIG_NODE, &no_ip_route_mask_tag_distance_label_cmd);
887
888 install_element(CONFIG_NODE, &ipv6_route_label_cmd);
889 install_element(CONFIG_NODE, &ipv6_route_ifname_label_cmd);
890 install_element(CONFIG_NODE, &no_ipv6_route_label_cmd);
891 install_element(CONFIG_NODE, &no_ipv6_route_ifname_label_cmd);
892 install_element(CONFIG_NODE, &ipv6_route_pref_label_cmd);
893 install_element(CONFIG_NODE, &ipv6_route_ifname_pref_label_cmd);
894 install_element(CONFIG_NODE, &no_ipv6_route_pref_label_cmd);
895 install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_label_cmd);
896 install_element(CONFIG_NODE, &ipv6_route_tag_label_cmd);
897 install_element(CONFIG_NODE, &ipv6_route_ifname_tag_label_cmd);
898 install_element(CONFIG_NODE, &ipv6_route_pref_tag_label_cmd);
899 install_element(CONFIG_NODE, &ipv6_route_ifname_pref_tag_label_cmd);
900 install_element(CONFIG_NODE, &no_ipv6_route_tag_label_cmd);
901 install_element(CONFIG_NODE, &no_ipv6_route_ifname_tag_label_cmd);
902 install_element(CONFIG_NODE, &no_ipv6_route_pref_tag_label_cmd);
903 install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_label_cmd);
904
905 install_element(CONFIG_NODE, &mpls_transit_lsp_cmd);
906 install_element(CONFIG_NODE, &no_mpls_transit_lsp_cmd);
907 install_element(CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd);
908 install_element(CONFIG_NODE, &no_mpls_transit_lsp_all_cmd);
909
910 install_element(VIEW_NODE, &show_mpls_table_cmd);
911 install_element(VIEW_NODE, &show_mpls_table_lsp_cmd);
912 }