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