]>
Commit | Line | Data |
---|---|---|
41675b4c RW |
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 | * | |
896014f4 DL |
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 | |
41675b4c RW |
19 | */ |
20 | ||
21 | #include <zebra.h> | |
22 | ||
41675b4c RW |
23 | #include "memory.h" |
24 | #include "if.h" | |
25 | #include "prefix.h" | |
26 | #include "command.h" | |
27 | #include "table.h" | |
28 | #include "rib.h" | |
29 | #include "nexthop.h" | |
30 | #include "vrf.h" | |
31 | #include "mpls.h" | |
32 | #include "lib/json.h" | |
33 | ||
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" | |
41 | ||
d62a17ae | 42 | static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd, |
43 | const char *inlabel_str, const char *gate_str, | |
44 | const char *outlabel_str, | |
45 | const char *flag_str) | |
41675b4c | 46 | { |
d62a17ae | 47 | struct zebra_vrf *zvrf; |
48 | int ret; | |
49 | enum nexthop_types_t gtype; | |
50 | union g_addr gate; | |
51 | mpls_label_t label; | |
52 | mpls_label_t in_label, out_label; | |
53 | ||
54 | if (!mpls_enabled) { | |
55 | vty_out(vty, | |
56 | "%% MPLS not turned on in kernel, ignoring command\n"); | |
57 | return CMD_WARNING_CONFIG_FAILED; | |
58 | } | |
59 | ||
60 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
61 | if (!zvrf) { | |
62 | vty_out(vty, "%% Default VRF does not exist\n"); | |
63 | return CMD_WARNING_CONFIG_FAILED; | |
64 | } | |
65 | ||
66 | if (!inlabel_str) { | |
67 | vty_out(vty, "%% No Label Information\n"); | |
68 | return CMD_WARNING_CONFIG_FAILED; | |
69 | } | |
70 | ||
71 | out_label = MPLS_IMP_NULL_LABEL; /* as initialization */ | |
72 | label = atoi(inlabel_str); | |
73 | if (!IS_MPLS_UNRESERVED_LABEL(label)) { | |
74 | vty_out(vty, "%% Invalid label\n"); | |
75 | return CMD_WARNING_CONFIG_FAILED; | |
76 | } | |
77 | ||
78 | if (add_cmd) { | |
79 | if (!gate_str) { | |
80 | vty_out(vty, "%% No Nexthop Information\n"); | |
81 | return CMD_WARNING_CONFIG_FAILED; | |
82 | } | |
83 | if (!outlabel_str) { | |
84 | vty_out(vty, "%% No Outgoing label Information\n"); | |
85 | return CMD_WARNING_CONFIG_FAILED; | |
86 | } | |
87 | } | |
88 | ||
89 | in_label = label; | |
90 | gtype = NEXTHOP_TYPE_BLACKHOLE; /* as initialization */ | |
91 | ||
92 | if (gate_str) { | |
93 | /* Gateway is a IPv4 or IPv6 nexthop. */ | |
94 | ret = inet_pton(AF_INET6, gate_str, &gate.ipv6); | |
95 | if (ret) | |
96 | gtype = NEXTHOP_TYPE_IPV6; | |
97 | else { | |
98 | ret = inet_pton(AF_INET, gate_str, &gate.ipv4); | |
99 | if (ret) | |
100 | gtype = NEXTHOP_TYPE_IPV4; | |
101 | else { | |
102 | vty_out(vty, "%% Invalid nexthop\n"); | |
103 | return CMD_WARNING_CONFIG_FAILED; | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | if (outlabel_str) { | |
109 | if (outlabel_str[0] == 'i') | |
110 | out_label = MPLS_IMP_NULL_LABEL; | |
111 | else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV4) | |
112 | out_label = MPLS_V4_EXP_NULL_LABEL; | |
113 | else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV6) | |
114 | out_label = MPLS_V6_EXP_NULL_LABEL; | |
115 | else | |
116 | out_label = atoi(outlabel_str); | |
117 | } | |
118 | ||
119 | if (add_cmd) { | |
41675b4c | 120 | #if defined(HAVE_CUMULUS) |
d62a17ae | 121 | /* Check that label value is consistent. */ |
122 | if (!zebra_mpls_lsp_label_consistent(zvrf, in_label, out_label, | |
123 | gtype, &gate, 0)) { | |
124 | vty_out(vty, "%% Label value not consistent\n"); | |
125 | return CMD_WARNING_CONFIG_FAILED; | |
126 | } | |
41675b4c RW |
127 | #endif /* HAVE_CUMULUS */ |
128 | ||
d62a17ae | 129 | ret = zebra_mpls_static_lsp_add(zvrf, in_label, out_label, |
130 | gtype, &gate, 0); | |
131 | } else | |
132 | ret = zebra_mpls_static_lsp_del(zvrf, in_label, gtype, &gate, | |
133 | 0); | |
41675b4c | 134 | |
d62a17ae | 135 | if (ret) { |
136 | vty_out(vty, "%% LSP cannot be %s\n", | |
137 | add_cmd ? "added" : "deleted"); | |
138 | return CMD_WARNING_CONFIG_FAILED; | |
139 | } | |
41675b4c | 140 | |
d62a17ae | 141 | return CMD_SUCCESS; |
41675b4c RW |
142 | } |
143 | ||
144 | DEFUN (mpls_transit_lsp, | |
145 | mpls_transit_lsp_cmd, | |
e52702f2 | 146 | "mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>", |
41675b4c RW |
147 | MPLS_STR |
148 | "Establish label switched path\n" | |
149 | "Incoming MPLS label\n" | |
150 | "IPv4 gateway address\n" | |
151 | "IPv6 gateway address\n" | |
152 | "Outgoing MPLS label\n" | |
e64f3c32 | 153 | "Use Explicit-Null label\n" |
41675b4c RW |
154 | "Use Implicit-Null label\n") |
155 | { | |
d62a17ae | 156 | return zebra_mpls_transit_lsp(vty, 1, argv[2]->arg, argv[3]->arg, |
157 | argv[4]->arg, NULL); | |
41675b4c RW |
158 | } |
159 | ||
160 | DEFUN (no_mpls_transit_lsp, | |
161 | no_mpls_transit_lsp_cmd, | |
e52702f2 | 162 | "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X>", |
41675b4c RW |
163 | NO_STR |
164 | MPLS_STR | |
165 | "Establish label switched path\n" | |
166 | "Incoming MPLS label\n" | |
167 | "IPv4 gateway address\n" | |
168 | "IPv6 gateway address\n") | |
169 | { | |
d62a17ae | 170 | return zebra_mpls_transit_lsp(vty, 0, argv[3]->arg, argv[4]->arg, NULL, |
171 | NULL); | |
41675b4c RW |
172 | } |
173 | ||
d62a17ae | 174 | ALIAS(no_mpls_transit_lsp, no_mpls_transit_lsp_out_label_cmd, |
175 | "no mpls lsp (16-1048575) <A.B.C.D|X:X::X:X> <(16-1048575)|explicit-null|implicit-null>", | |
176 | NO_STR MPLS_STR | |
177 | "Establish label switched path\n" | |
178 | "Incoming MPLS label\n" | |
179 | "IPv4 gateway address\n" | |
180 | "IPv6 gateway address\n" | |
181 | "Outgoing MPLS label\n" | |
182 | "Use Explicit-Null label\n" | |
183 | "Use Implicit-Null label\n") | |
184 | ||
41675b4c RW |
185 | DEFUN (no_mpls_transit_lsp_all, |
186 | no_mpls_transit_lsp_all_cmd, | |
e52702f2 | 187 | "no mpls lsp (16-1048575)", |
41675b4c RW |
188 | NO_STR |
189 | MPLS_STR | |
190 | "Establish label switched path\n" | |
191 | "Incoming MPLS label\n") | |
192 | { | |
d62a17ae | 193 | return zebra_mpls_transit_lsp(vty, 0, argv[3]->arg, NULL, NULL, NULL); |
41675b4c RW |
194 | } |
195 | ||
d62a17ae | 196 | static int zebra_mpls_bind(struct vty *vty, int add_cmd, const char *prefix, |
197 | const char *label_str) | |
f31e084c | 198 | { |
d62a17ae | 199 | struct zebra_vrf *zvrf; |
200 | struct prefix p; | |
201 | u_int32_t label; | |
202 | int ret; | |
203 | ||
204 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
205 | if (!zvrf) { | |
206 | vty_out(vty, "%% Default VRF does not exist\n"); | |
207 | return CMD_WARNING_CONFIG_FAILED; | |
208 | } | |
209 | ||
210 | memset(&p, 0, sizeof(struct prefix)); | |
211 | ret = str2prefix(prefix, &p); | |
212 | if (ret <= 0) { | |
213 | vty_out(vty, "%% Malformed address\n"); | |
214 | return CMD_WARNING_CONFIG_FAILED; | |
215 | } | |
216 | ||
217 | if (add_cmd) { | |
218 | if (!label_str) { | |
219 | vty_out(vty, "%% No label binding specified\n"); | |
220 | return CMD_WARNING_CONFIG_FAILED; | |
221 | } | |
222 | ||
223 | if (!strcmp(label_str, "implicit-null")) | |
224 | label = MPLS_IMP_NULL_LABEL; | |
225 | else if (!strcmp(label_str, "explicit-null")) { | |
226 | if (p.family == AF_INET) | |
227 | label = MPLS_V4_EXP_NULL_LABEL; | |
228 | else | |
229 | label = MPLS_V6_EXP_NULL_LABEL; | |
230 | } else { | |
231 | label = atoi(label_str); | |
232 | if (!IS_MPLS_UNRESERVED_LABEL(label)) { | |
233 | vty_out(vty, "%% Invalid label\n"); | |
234 | return CMD_WARNING_CONFIG_FAILED; | |
235 | } | |
236 | if (zebra_mpls_label_already_bound(zvrf, label)) { | |
237 | vty_out(vty, | |
238 | "%% Label already bound to a FEC\n"); | |
239 | return CMD_WARNING_CONFIG_FAILED; | |
240 | } | |
241 | } | |
242 | ||
243 | ret = zebra_mpls_static_fec_add(zvrf, &p, label); | |
244 | } else | |
245 | ret = zebra_mpls_static_fec_del(zvrf, &p); | |
246 | ||
247 | if (ret) { | |
248 | vty_out(vty, "%% FEC to label binding cannot be %s\n", | |
249 | add_cmd ? "added" : "deleted"); | |
250 | return CMD_WARNING_CONFIG_FAILED; | |
251 | } | |
252 | ||
253 | return CMD_SUCCESS; | |
f31e084c DS |
254 | } |
255 | ||
256 | DEFUN (mpls_label_bind, | |
257 | mpls_label_bind_cmd, | |
bf995813 | 258 | "mpls label bind <A.B.C.D/M|X:X::X:X/M> <(16-1048575)|implicit-null|explicit-null>", |
f31e084c DS |
259 | MPLS_STR |
260 | "Label configuration\n" | |
261 | "Establish FEC to label binding\n" | |
262 | "IPv4 prefix\n" | |
263 | "IPv6 prefix\n" | |
264 | "MPLS Label to bind\n" | |
bf995813 DS |
265 | "Use Implicit-Null Label\n" |
266 | "Use Explicit-Null Label\n") | |
f31e084c | 267 | { |
d62a17ae | 268 | return zebra_mpls_bind(vty, 1, argv[3]->arg, argv[4]->arg); |
f31e084c DS |
269 | } |
270 | ||
271 | DEFUN (no_mpls_label_bind, | |
272 | no_mpls_label_bind_cmd, | |
273 | "no mpls label bind <A.B.C.D/M|X:X::X:X/M> [<(16-1048575)|implicit-null>]", | |
274 | NO_STR | |
275 | MPLS_STR | |
276 | "Label configuration\n" | |
277 | "Establish FEC to label binding\n" | |
278 | "IPv4 prefix\n" | |
279 | "IPv6 prefix\n" | |
280 | "MPLS Label to bind\n" | |
281 | "Use Implicit-Null Label\n") | |
f31e084c | 282 | { |
d62a17ae | 283 | return zebra_mpls_bind(vty, 0, argv[4]->arg, NULL); |
f31e084c DS |
284 | } |
285 | ||
41675b4c RW |
286 | /* Static route configuration. */ |
287 | DEFUN (ip_route_label, | |
288 | ip_route_label_cmd, | |
e52702f2 | 289 | "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD", |
41675b4c RW |
290 | IP_STR |
291 | "Establish static routes\n" | |
292 | "IP destination prefix (e.g. 10.0.0.0/8)\n" | |
293 | "IP gateway address\n" | |
294 | "IP gateway interface name\n" | |
295 | "Null interface\n" | |
6feb1a21 | 296 | MPLS_LABEL_HELPSTR) |
41675b4c | 297 | { |
d62a17ae | 298 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, |
299 | argv[3]->arg, NULL, NULL, NULL, NULL, | |
300 | argv[5]->arg); | |
41675b4c RW |
301 | } |
302 | ||
303 | DEFUN (ip_route_tag_label, | |
304 | ip_route_tag_label_cmd, | |
e52702f2 | 305 | "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", |
41675b4c RW |
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" | |
6feb1a21 | 314 | MPLS_LABEL_HELPSTR) |
41675b4c | 315 | { |
d62a17ae | 316 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, |
317 | argv[3]->arg, NULL, argv[5]->arg, NULL, NULL, | |
318 | argv[7]->arg); | |
41675b4c RW |
319 | } |
320 | ||
321 | /* Mask as A.B.C.D format. */ | |
322 | DEFUN (ip_route_mask_label, | |
323 | ip_route_mask_label_cmd, | |
e52702f2 | 324 | "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD", |
41675b4c RW |
325 | IP_STR |
326 | "Establish static routes\n" | |
327 | "IP destination prefix\n" | |
328 | "IP destination prefix mask\n" | |
329 | "IP gateway address\n" | |
330 | "IP gateway interface name\n" | |
331 | "Null interface\n" | |
6feb1a21 | 332 | MPLS_LABEL_HELPSTR) |
41675b4c | 333 | { |
d62a17ae | 334 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, |
335 | argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, | |
336 | NULL, argv[6]->arg); | |
41675b4c RW |
337 | } |
338 | ||
339 | DEFUN (ip_route_mask_tag_label, | |
340 | ip_route_mask_tag_label_cmd, | |
e52702f2 | 341 | "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", |
41675b4c RW |
342 | IP_STR |
343 | "Establish static routes\n" | |
344 | "IP destination prefix\n" | |
345 | "IP destination prefix mask\n" | |
346 | "IP gateway address\n" | |
347 | "IP gateway interface name\n" | |
348 | "Null interface\n" | |
349 | "Set tag for this route\n" | |
350 | "Tag value\n" | |
6feb1a21 | 351 | MPLS_LABEL_HELPSTR) |
41675b4c | 352 | { |
d62a17ae | 353 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, |
354 | argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, | |
355 | NULL, NULL, argv[8]->arg); | |
41675b4c RW |
356 | } |
357 | ||
358 | /* Distance option value. */ | |
359 | DEFUN (ip_route_distance_label, | |
360 | ip_route_distance_label_cmd, | |
e52702f2 | 361 | "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD", |
41675b4c RW |
362 | IP_STR |
363 | "Establish static routes\n" | |
364 | "IP destination prefix (e.g. 10.0.0.0/8)\n" | |
365 | "IP gateway address\n" | |
366 | "IP gateway interface name\n" | |
367 | "Null interface\n" | |
368 | "Distance value for this route\n" | |
6feb1a21 | 369 | MPLS_LABEL_HELPSTR) |
41675b4c | 370 | { |
d62a17ae | 371 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, |
372 | argv[3]->arg, NULL, NULL, argv[4]->arg, NULL, | |
373 | argv[6]->arg); | |
41675b4c RW |
374 | } |
375 | ||
376 | DEFUN (ip_route_tag_distance_label, | |
377 | ip_route_tag_distance_label_cmd, | |
e52702f2 | 378 | "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
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 | "Set tag for this route\n" | |
386 | "Tag value\n" | |
387 | "Distance value for this route\n" | |
6feb1a21 | 388 | MPLS_LABEL_HELPSTR) |
41675b4c | 389 | { |
d62a17ae | 390 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, |
391 | argv[3]->arg, NULL, argv[5]->arg, argv[6]->arg, | |
392 | NULL, argv[8]->arg); | |
41675b4c RW |
393 | } |
394 | ||
395 | DEFUN (ip_route_mask_distance_label, | |
396 | ip_route_mask_distance_label_cmd, | |
e52702f2 | 397 | "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD", |
41675b4c RW |
398 | IP_STR |
399 | "Establish static routes\n" | |
400 | "IP destination prefix\n" | |
401 | "IP destination prefix mask\n" | |
402 | "IP gateway address\n" | |
403 | "IP gateway interface name\n" | |
404 | "Null interface\n" | |
405 | "Distance value for this route\n" | |
6feb1a21 | 406 | MPLS_LABEL_HELPSTR) |
41675b4c | 407 | { |
d62a17ae | 408 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, |
409 | argv[3]->arg, argv[4]->arg, NULL, NULL, | |
410 | argv[5]->arg, NULL, argv[7]->arg); | |
41675b4c RW |
411 | } |
412 | ||
413 | DEFUN (ip_route_mask_tag_distance_label, | |
414 | ip_route_mask_tag_distance_label_cmd, | |
e52702f2 | 415 | "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
416 | IP_STR |
417 | "Establish static routes\n" | |
418 | "IP destination prefix\n" | |
419 | "IP destination prefix mask\n" | |
420 | "IP gateway address\n" | |
421 | "IP gateway interface name\n" | |
422 | "Null interface\n" | |
423 | "Set tag for this route\n" | |
424 | "Tag value\n" | |
425 | "Distance value for this route\n" | |
6feb1a21 | 426 | MPLS_LABEL_HELPSTR) |
41675b4c | 427 | { |
d62a17ae | 428 | return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, |
429 | argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, | |
430 | argv[7]->arg, NULL, argv[9]->arg); | |
41675b4c RW |
431 | } |
432 | ||
433 | DEFUN (no_ip_route_label, | |
434 | no_ip_route_label_cmd, | |
e52702f2 | 435 | "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD", |
41675b4c RW |
436 | NO_STR |
437 | IP_STR | |
438 | "Establish static routes\n" | |
439 | "IP destination prefix (e.g. 10.0.0.0/8)\n" | |
440 | "IP gateway address\n" | |
441 | "IP gateway interface name\n" | |
442 | "Null interface\n" | |
6feb1a21 | 443 | MPLS_LABEL_HELPSTR) |
41675b4c | 444 | { |
d62a17ae | 445 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, |
446 | argv[4]->arg, NULL, NULL, NULL, NULL, | |
447 | argv[6]->arg); | |
41675b4c RW |
448 | } |
449 | ||
450 | DEFUN (no_ip_route_tag_label, | |
451 | no_ip_route_tag_label_cmd, | |
e52702f2 | 452 | "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", |
41675b4c RW |
453 | NO_STR |
454 | IP_STR | |
455 | "Establish static routes\n" | |
456 | "IP destination prefix (e.g. 10.0.0.0/8)\n" | |
457 | "IP gateway address\n" | |
458 | "IP gateway interface name\n" | |
459 | "Null interface\n" | |
460 | "Tag of this route\n" | |
461 | "Tag value\n" | |
6feb1a21 | 462 | MPLS_LABEL_HELPSTR) |
41675b4c | 463 | { |
d62a17ae | 464 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, |
465 | argv[4]->arg, NULL, argv[6]->arg, NULL, NULL, | |
466 | argv[8]->arg); | |
41675b4c RW |
467 | } |
468 | ||
469 | DEFUN (no_ip_route_mask_label, | |
470 | no_ip_route_mask_label_cmd, | |
e52702f2 | 471 | "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD", |
41675b4c RW |
472 | NO_STR |
473 | IP_STR | |
474 | "Establish static routes\n" | |
475 | "IP destination prefix\n" | |
476 | "IP destination prefix mask\n" | |
477 | "IP gateway address\n" | |
478 | "IP gateway interface name\n" | |
479 | "Null interface\n" | |
6feb1a21 | 480 | MPLS_LABEL_HELPSTR) |
41675b4c | 481 | { |
d62a17ae | 482 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, |
483 | argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, | |
484 | NULL, argv[7]->arg); | |
41675b4c RW |
485 | } |
486 | ||
487 | DEFUN (no_ip_route_mask_tag_label, | |
488 | no_ip_route_mask_tag_label_cmd, | |
e52702f2 | 489 | "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD", |
41675b4c RW |
490 | NO_STR |
491 | IP_STR | |
492 | "Establish static routes\n" | |
493 | "IP destination prefix\n" | |
494 | "IP destination prefix mask\n" | |
495 | "IP gateway address\n" | |
496 | "IP gateway interface name\n" | |
497 | "Null interface\n" | |
498 | "Tag of this route\n" | |
499 | "Tag value\n" | |
6feb1a21 | 500 | MPLS_LABEL_HELPSTR) |
41675b4c | 501 | { |
d62a17ae | 502 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, |
503 | argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, | |
504 | NULL, NULL, argv[9]->arg); | |
41675b4c RW |
505 | } |
506 | ||
507 | DEFUN (no_ip_route_distance_label, | |
508 | no_ip_route_distance_label_cmd, | |
e52702f2 | 509 | "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD", |
41675b4c RW |
510 | NO_STR |
511 | IP_STR | |
512 | "Establish static routes\n" | |
513 | "IP destination prefix (e.g. 10.0.0.0/8)\n" | |
514 | "IP gateway address\n" | |
515 | "IP gateway interface name\n" | |
516 | "Null interface\n" | |
517 | "Distance value for this route\n" | |
6feb1a21 | 518 | MPLS_LABEL_HELPSTR) |
41675b4c | 519 | { |
d62a17ae | 520 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, |
521 | argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, | |
522 | argv[7]->arg); | |
41675b4c RW |
523 | } |
524 | ||
525 | DEFUN (no_ip_route_tag_distance_label, | |
526 | no_ip_route_tag_distance_label_cmd, | |
e52702f2 | 527 | "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
528 | NO_STR |
529 | IP_STR | |
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" | |
534 | "Null interface\n" | |
535 | "Tag of this route\n" | |
536 | "Tag value\n" | |
537 | "Distance value for this route\n" | |
6feb1a21 | 538 | MPLS_LABEL_HELPSTR) |
41675b4c | 539 | { |
d62a17ae | 540 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, |
541 | argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, | |
542 | NULL, argv[9]->arg); | |
41675b4c RW |
543 | } |
544 | ||
545 | DEFUN (no_ip_route_mask_distance_label, | |
546 | no_ip_route_mask_distance_label_cmd, | |
dab8cd00 | 547 | "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD", |
41675b4c RW |
548 | NO_STR |
549 | IP_STR | |
550 | "Establish static routes\n" | |
551 | "IP destination prefix\n" | |
552 | "IP destination prefix mask\n" | |
553 | "IP gateway address\n" | |
554 | "IP gateway interface name\n" | |
555 | "Null interface\n" | |
556 | "Distance value for this route\n" | |
6feb1a21 | 557 | MPLS_LABEL_HELPSTR) |
41675b4c | 558 | { |
d62a17ae | 559 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, |
560 | argv[4]->arg, argv[5]->arg, NULL, NULL, | |
561 | argv[6]->arg, NULL, argv[8]->arg); | |
41675b4c RW |
562 | } |
563 | ||
564 | DEFUN (no_ip_route_mask_tag_distance_label, | |
565 | no_ip_route_mask_tag_distance_label_cmd, | |
e52702f2 | 566 | "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
567 | NO_STR |
568 | IP_STR | |
569 | "Establish static routes\n" | |
570 | "IP destination prefix\n" | |
571 | "IP destination prefix mask\n" | |
572 | "IP gateway address\n" | |
573 | "IP gateway interface name\n" | |
574 | "Null interface\n" | |
575 | "Tag of this route\n" | |
576 | "Tag value\n" | |
577 | "Distance value for this route\n" | |
6feb1a21 | 578 | MPLS_LABEL_HELPSTR) |
41675b4c | 579 | { |
d62a17ae | 580 | return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, |
581 | argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, | |
582 | argv[8]->arg, NULL, argv[10]->arg); | |
41675b4c RW |
583 | } |
584 | ||
585 | DEFUN (ipv6_route_label, | |
586 | ipv6_route_label_cmd, | |
e52702f2 | 587 | "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD", |
41675b4c RW |
588 | IP_STR |
589 | "Establish static routes\n" | |
590 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
591 | "IPv6 gateway address\n" | |
592 | "IPv6 gateway interface name\n" | |
6feb1a21 | 593 | MPLS_LABEL_HELPSTR) |
41675b4c | 594 | { |
d62a17ae | 595 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, |
596 | NULL, NULL, NULL, NULL, argv[5]->arg); | |
41675b4c RW |
597 | } |
598 | ||
599 | DEFUN (ipv6_route_tag_label, | |
600 | ipv6_route_tag_label_cmd, | |
e52702f2 | 601 | "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD", |
41675b4c RW |
602 | IP_STR |
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" | |
607 | "Set tag for this route\n" | |
608 | "Tag value\n" | |
6feb1a21 | 609 | MPLS_LABEL_HELPSTR) |
41675b4c | 610 | { |
d62a17ae | 611 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, |
612 | NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); | |
41675b4c RW |
613 | } |
614 | ||
615 | DEFUN (ipv6_route_ifname_label, | |
616 | ipv6_route_ifname_label_cmd, | |
617 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD", | |
618 | IP_STR | |
619 | "Establish static routes\n" | |
620 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
621 | "IPv6 gateway address\n" | |
622 | "IPv6 gateway interface name\n" | |
6feb1a21 | 623 | MPLS_LABEL_HELPSTR) |
41675b4c | 624 | { |
d62a17ae | 625 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, |
626 | argv[4]->arg, NULL, NULL, NULL, NULL, | |
627 | argv[6]->arg); | |
41675b4c RW |
628 | } |
629 | DEFUN (ipv6_route_ifname_tag_label, | |
630 | ipv6_route_ifname_tag_label_cmd, | |
e52702f2 | 631 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD", |
41675b4c RW |
632 | IP_STR |
633 | "Establish static routes\n" | |
634 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
635 | "IPv6 gateway address\n" | |
636 | "IPv6 gateway interface name\n" | |
637 | "Set tag for this route\n" | |
638 | "Tag value\n" | |
6feb1a21 | 639 | MPLS_LABEL_HELPSTR) |
41675b4c | 640 | { |
d62a17ae | 641 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, |
642 | argv[4]->arg, NULL, argv[6]->arg, NULL, NULL, | |
643 | argv[8]->arg); | |
41675b4c RW |
644 | } |
645 | ||
646 | DEFUN (ipv6_route_pref_label, | |
647 | ipv6_route_pref_label_cmd, | |
e52702f2 | 648 | "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD", |
41675b4c RW |
649 | IP_STR |
650 | "Establish static routes\n" | |
651 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
652 | "IPv6 gateway address\n" | |
653 | "IPv6 gateway interface name\n" | |
654 | "Distance value for this prefix\n" | |
6feb1a21 | 655 | MPLS_LABEL_HELPSTR) |
41675b4c | 656 | { |
d62a17ae | 657 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, |
658 | NULL, NULL, argv[4]->arg, NULL, argv[6]->arg); | |
41675b4c RW |
659 | } |
660 | ||
661 | DEFUN (ipv6_route_pref_tag_label, | |
662 | ipv6_route_pref_tag_label_cmd, | |
e52702f2 | 663 | "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
664 | IP_STR |
665 | "Establish static routes\n" | |
666 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
667 | "IPv6 gateway address\n" | |
668 | "IPv6 gateway interface name\n" | |
669 | "Set tag for this route\n" | |
670 | "Tag value\n" | |
671 | "Distance value for this prefix\n" | |
6feb1a21 | 672 | MPLS_LABEL_HELPSTR) |
41675b4c | 673 | { |
d62a17ae | 674 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, |
675 | NULL, argv[5]->arg, argv[6]->arg, NULL, | |
676 | argv[8]->arg); | |
41675b4c RW |
677 | } |
678 | ||
679 | DEFUN (ipv6_route_ifname_pref_label, | |
680 | ipv6_route_ifname_pref_label_cmd, | |
e52702f2 | 681 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD", |
41675b4c RW |
682 | IP_STR |
683 | "Establish static routes\n" | |
684 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
685 | "IPv6 gateway address\n" | |
686 | "IPv6 gateway interface name\n" | |
687 | "Distance value for this prefix\n" | |
6feb1a21 | 688 | MPLS_LABEL_HELPSTR) |
41675b4c | 689 | { |
d62a17ae | 690 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, |
691 | argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, | |
692 | argv[7]->arg); | |
41675b4c RW |
693 | } |
694 | ||
695 | DEFUN (ipv6_route_ifname_pref_tag_label, | |
696 | ipv6_route_ifname_pref_tag_label_cmd, | |
e52702f2 | 697 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
698 | IP_STR |
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" | |
704 | "Tag value\n" | |
705 | "Distance value for this prefix\n" | |
6feb1a21 | 706 | MPLS_LABEL_HELPSTR) |
41675b4c | 707 | { |
d62a17ae | 708 | return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, |
709 | argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, | |
710 | NULL, argv[9]->arg); | |
41675b4c RW |
711 | } |
712 | ||
713 | DEFUN (no_ipv6_route_label, | |
714 | no_ipv6_route_label_cmd, | |
e52702f2 | 715 | "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD", |
41675b4c RW |
716 | NO_STR |
717 | IP_STR | |
718 | "Establish static routes\n" | |
719 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
720 | "IPv6 gateway address\n" | |
721 | "IPv6 gateway interface name\n" | |
6feb1a21 | 722 | MPLS_LABEL_HELPSTR) |
41675b4c | 723 | { |
d62a17ae | 724 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, |
725 | NULL, NULL, NULL, NULL, argv[6]->arg); | |
41675b4c RW |
726 | } |
727 | ||
728 | DEFUN (no_ipv6_route_tag_label, | |
729 | no_ipv6_route_tag_label_cmd, | |
e52702f2 | 730 | "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD", |
41675b4c RW |
731 | NO_STR |
732 | IP_STR | |
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" | |
738 | "Tag value\n" | |
6feb1a21 | 739 | MPLS_LABEL_HELPSTR) |
41675b4c | 740 | { |
d62a17ae | 741 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, |
742 | NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); | |
41675b4c RW |
743 | } |
744 | ||
745 | DEFUN (no_ipv6_route_ifname_label, | |
746 | no_ipv6_route_ifname_label_cmd, | |
747 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD", | |
748 | NO_STR | |
749 | IP_STR | |
750 | "Establish static routes\n" | |
751 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
752 | "IPv6 gateway address\n" | |
753 | "IPv6 gateway interface name\n" | |
6feb1a21 | 754 | MPLS_LABEL_HELPSTR) |
41675b4c | 755 | { |
d62a17ae | 756 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, |
757 | argv[5]->arg, NULL, NULL, NULL, NULL, | |
758 | argv[7]->arg); | |
41675b4c RW |
759 | } |
760 | ||
761 | DEFUN (no_ipv6_route_ifname_tag_label, | |
762 | no_ipv6_route_ifname_tag_label_cmd, | |
e52702f2 | 763 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD", |
41675b4c RW |
764 | NO_STR |
765 | IP_STR | |
766 | "Establish static routes\n" | |
767 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
768 | "IPv6 gateway address\n" | |
769 | "IPv6 gateway interface name\n" | |
770 | "Set tag for this route\n" | |
771 | "Tag value\n" | |
6feb1a21 | 772 | MPLS_LABEL_HELPSTR) |
41675b4c | 773 | { |
d62a17ae | 774 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, |
775 | argv[5]->arg, NULL, argv[7]->arg, NULL, NULL, | |
776 | argv[9]->arg); | |
41675b4c RW |
777 | } |
778 | ||
779 | DEFUN (no_ipv6_route_pref_label, | |
780 | no_ipv6_route_pref_label_cmd, | |
e52702f2 | 781 | "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD", |
41675b4c RW |
782 | NO_STR |
783 | IP_STR | |
784 | "Establish static routes\n" | |
785 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
786 | "IPv6 gateway address\n" | |
787 | "IPv6 gateway interface name\n" | |
788 | "Distance value for this prefix\n" | |
6feb1a21 | 789 | MPLS_LABEL_HELPSTR) |
41675b4c | 790 | { |
d62a17ae | 791 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, |
792 | NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); | |
41675b4c RW |
793 | } |
794 | ||
795 | DEFUN (no_ipv6_route_pref_tag_label, | |
796 | no_ipv6_route_pref_tag_label_cmd, | |
e52702f2 | 797 | "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
798 | NO_STR |
799 | IP_STR | |
800 | "Establish static routes\n" | |
801 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
802 | "IPv6 gateway address\n" | |
803 | "IPv6 gateway interface name\n" | |
804 | "Set tag for this route\n" | |
805 | "Tag value\n" | |
806 | "Distance value for this prefix\n" | |
6feb1a21 | 807 | MPLS_LABEL_HELPSTR) |
41675b4c | 808 | { |
d62a17ae | 809 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, |
810 | NULL, argv[6]->arg, argv[7]->arg, NULL, | |
811 | argv[9]->arg); | |
41675b4c RW |
812 | } |
813 | ||
814 | DEFUN (no_ipv6_route_ifname_pref_label, | |
815 | no_ipv6_route_ifname_pref_label_cmd, | |
e52702f2 | 816 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD", |
41675b4c RW |
817 | NO_STR |
818 | IP_STR | |
819 | "Establish static routes\n" | |
820 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
821 | "IPv6 gateway address\n" | |
822 | "IPv6 gateway interface name\n" | |
823 | "Distance value for this prefix\n" | |
6feb1a21 | 824 | MPLS_LABEL_HELPSTR) |
41675b4c | 825 | { |
d62a17ae | 826 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, |
827 | argv[5]->arg, NULL, NULL, argv[6]->arg, NULL, | |
828 | argv[8]->arg); | |
41675b4c RW |
829 | } |
830 | ||
831 | DEFUN (no_ipv6_route_ifname_pref_tag_label, | |
832 | no_ipv6_route_ifname_pref_tag_label_cmd, | |
e52702f2 | 833 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD", |
41675b4c RW |
834 | NO_STR |
835 | IP_STR | |
836 | "Establish static routes\n" | |
837 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" | |
838 | "IPv6 gateway address\n" | |
839 | "IPv6 gateway interface name\n" | |
840 | "Set tag for this route\n" | |
841 | "Tag value\n" | |
842 | "Distance value for this prefix\n" | |
6feb1a21 | 843 | MPLS_LABEL_HELPSTR) |
41675b4c | 844 | { |
d62a17ae | 845 | return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, |
846 | argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, | |
847 | NULL, argv[10]->arg); | |
41675b4c RW |
848 | } |
849 | ||
850 | /* MPLS LSP configuration write function. */ | |
d62a17ae | 851 | static int zebra_mpls_config(struct vty *vty) |
41675b4c | 852 | { |
d62a17ae | 853 | int write = 0; |
854 | struct zebra_vrf *zvrf; | |
41675b4c | 855 | |
d62a17ae | 856 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
857 | if (!zvrf) | |
858 | return 0; | |
41675b4c | 859 | |
d62a17ae | 860 | write += zebra_mpls_write_lsp_config(vty, zvrf); |
861 | write += zebra_mpls_write_fec_config(vty, zvrf); | |
862 | write += zebra_mpls_write_label_block_config(vty, zvrf); | |
863 | return write; | |
41675b4c RW |
864 | } |
865 | ||
f31e084c DS |
866 | DEFUN (show_mpls_fec, |
867 | show_mpls_fec_cmd, | |
868 | "show mpls fec [<A.B.C.D/M|X:X::X:X/M>]", | |
869 | SHOW_STR | |
870 | MPLS_STR | |
871 | "MPLS FEC table\n" | |
872 | "FEC to display information about\n" | |
873 | "FEC to display information about\n") | |
874 | { | |
d62a17ae | 875 | struct zebra_vrf *zvrf; |
876 | struct prefix p; | |
877 | int ret; | |
878 | ||
879 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
880 | if (!zvrf) | |
881 | return 0; | |
882 | ||
883 | if (argc == 3) | |
884 | zebra_mpls_print_fec_table(vty, zvrf); | |
885 | else { | |
886 | memset(&p, 0, sizeof(struct prefix)); | |
887 | ret = str2prefix(argv[3]->arg, &p); | |
888 | if (ret <= 0) { | |
889 | vty_out(vty, "%% Malformed address\n"); | |
890 | return CMD_WARNING; | |
891 | } | |
892 | zebra_mpls_print_fec(vty, zvrf, &p); | |
893 | } | |
894 | ||
895 | return CMD_SUCCESS; | |
f31e084c DS |
896 | } |
897 | ||
41675b4c RW |
898 | DEFUN (show_mpls_table, |
899 | show_mpls_table_cmd, | |
e52702f2 | 900 | "show mpls table [json]", |
41675b4c RW |
901 | SHOW_STR |
902 | MPLS_STR | |
903 | "MPLS table\n" | |
9973d184 | 904 | JSON_STR) |
41675b4c | 905 | { |
d62a17ae | 906 | struct zebra_vrf *zvrf; |
907 | u_char uj = use_json(argc, argv); | |
41675b4c | 908 | |
d62a17ae | 909 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
910 | zebra_mpls_print_lsp_table(vty, zvrf, uj); | |
911 | return CMD_SUCCESS; | |
41675b4c RW |
912 | } |
913 | ||
914 | DEFUN (show_mpls_table_lsp, | |
915 | show_mpls_table_lsp_cmd, | |
e52702f2 | 916 | "show mpls table (16-1048575) [json]", |
41675b4c RW |
917 | SHOW_STR |
918 | MPLS_STR | |
919 | "MPLS table\n" | |
920 | "LSP to display information about\n" | |
9973d184 | 921 | JSON_STR) |
41675b4c | 922 | { |
d62a17ae | 923 | u_int32_t label; |
924 | struct zebra_vrf *zvrf; | |
925 | u_char uj = use_json(argc, argv); | |
926 | ||
927 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
928 | label = atoi(argv[3]->arg); | |
929 | zebra_mpls_print_lsp(vty, zvrf, label, uj); | |
930 | return CMD_SUCCESS; | |
41675b4c RW |
931 | } |
932 | ||
fe6c7157 RW |
933 | DEFUN (show_mpls_status, |
934 | show_mpls_status_cmd, | |
935 | "show mpls status", | |
936 | SHOW_STR | |
937 | "MPLS information\n" | |
938 | "MPLS status\n") | |
939 | { | |
d62a17ae | 940 | vty_out(vty, "MPLS support enabled: %s\n", |
941 | (mpls_enabled) ? "yes" | |
942 | : "no (mpls kernel extensions not detected)"); | |
943 | return CMD_SUCCESS; | |
fe6c7157 RW |
944 | } |
945 | ||
d62a17ae | 946 | static int zebra_mpls_global_block(struct vty *vty, int add_cmd, |
947 | const char *start_label_str, | |
948 | const char *end_label_str) | |
1b6d5c7e | 949 | { |
d62a17ae | 950 | int ret; |
951 | u_int32_t start_label; | |
952 | u_int32_t end_label; | |
953 | struct zebra_vrf *zvrf; | |
954 | ||
955 | zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); | |
956 | if (!zvrf) { | |
957 | vty_out(vty, "%% Default VRF does not exist\n"); | |
958 | return CMD_WARNING_CONFIG_FAILED; | |
959 | } | |
960 | ||
961 | if (add_cmd) { | |
962 | if (!start_label_str || !end_label_str) { | |
963 | vty_out(vty, "%% Labels not specified\n"); | |
964 | return CMD_WARNING_CONFIG_FAILED; | |
965 | } | |
966 | ||
967 | start_label = atoi(start_label_str); | |
968 | end_label = atoi(end_label_str); | |
969 | if (!IS_MPLS_UNRESERVED_LABEL(start_label) | |
970 | || !IS_MPLS_UNRESERVED_LABEL(end_label)) { | |
971 | vty_out(vty, "%% Invalid label\n"); | |
972 | return CMD_WARNING_CONFIG_FAILED; | |
973 | } | |
974 | if (end_label < start_label) { | |
975 | vty_out(vty, "%% End label is less than Start label\n"); | |
976 | return CMD_WARNING_CONFIG_FAILED; | |
977 | } | |
978 | ||
979 | ret = zebra_mpls_label_block_add(zvrf, start_label, end_label); | |
980 | } else | |
981 | ret = zebra_mpls_label_block_del(zvrf); | |
982 | ||
983 | if (ret) { | |
984 | vty_out(vty, "%% Global label block could not be %s\n", | |
985 | add_cmd ? "added" : "deleted"); | |
986 | return CMD_WARNING_CONFIG_FAILED; | |
987 | } | |
988 | ||
989 | return CMD_SUCCESS; | |
1b6d5c7e VV |
990 | } |
991 | ||
992 | DEFUN (mpls_label_global_block, | |
993 | mpls_label_global_block_cmd, | |
994 | "mpls label global-block (16-1048575) (16-1048575)", | |
995 | MPLS_STR | |
996 | "Label configuration\n" | |
997 | "Configure global label block\n" | |
998 | "Start label\n" | |
999 | "End label\n") | |
1000 | { | |
d62a17ae | 1001 | return zebra_mpls_global_block(vty, 1, argv[3]->arg, argv[4]->arg); |
1b6d5c7e VV |
1002 | } |
1003 | ||
1004 | DEFUN (no_mpls_label_global_block, | |
1005 | no_mpls_label_global_block_cmd, | |
1006 | "no mpls label global-block [(16-1048575) (16-1048575)]", | |
1007 | NO_STR | |
1008 | MPLS_STR | |
1009 | "Label configuration\n" | |
1010 | "Configure global label block\n" | |
1011 | "Start label\n" | |
1012 | "End label\n") | |
1013 | { | |
d62a17ae | 1014 | return zebra_mpls_global_block(vty, 0, NULL, NULL); |
1b6d5c7e VV |
1015 | } |
1016 | ||
41675b4c | 1017 | /* MPLS node for MPLS LSP. */ |
d62a17ae | 1018 | static struct cmd_node mpls_node = {MPLS_NODE, "", 1}; |
41675b4c RW |
1019 | |
1020 | /* MPLS VTY. */ | |
d62a17ae | 1021 | void zebra_mpls_vty_init(void) |
41675b4c | 1022 | { |
d62a17ae | 1023 | install_element(VIEW_NODE, &show_mpls_status_cmd); |
1024 | ||
1025 | install_node(&mpls_node, zebra_mpls_config); | |
1026 | ||
1027 | install_element(CONFIG_NODE, &ip_route_label_cmd); | |
1028 | install_element(CONFIG_NODE, &ip_route_tag_label_cmd); | |
1029 | install_element(CONFIG_NODE, &ip_route_mask_label_cmd); | |
1030 | install_element(CONFIG_NODE, &ip_route_mask_tag_label_cmd); | |
1031 | install_element(CONFIG_NODE, &no_ip_route_label_cmd); | |
1032 | install_element(CONFIG_NODE, &no_ip_route_tag_label_cmd); | |
1033 | install_element(CONFIG_NODE, &no_ip_route_mask_label_cmd); | |
1034 | install_element(CONFIG_NODE, &no_ip_route_mask_tag_label_cmd); | |
1035 | install_element(CONFIG_NODE, &ip_route_distance_label_cmd); | |
1036 | install_element(CONFIG_NODE, &ip_route_tag_distance_label_cmd); | |
1037 | install_element(CONFIG_NODE, &ip_route_mask_distance_label_cmd); | |
1038 | install_element(CONFIG_NODE, &ip_route_mask_tag_distance_label_cmd); | |
1039 | install_element(CONFIG_NODE, &no_ip_route_distance_label_cmd); | |
1040 | install_element(CONFIG_NODE, &no_ip_route_tag_distance_label_cmd); | |
1041 | install_element(CONFIG_NODE, &no_ip_route_mask_distance_label_cmd); | |
1042 | install_element(CONFIG_NODE, &no_ip_route_mask_tag_distance_label_cmd); | |
1043 | ||
1044 | install_element(CONFIG_NODE, &ipv6_route_label_cmd); | |
1045 | install_element(CONFIG_NODE, &ipv6_route_ifname_label_cmd); | |
1046 | install_element(CONFIG_NODE, &no_ipv6_route_label_cmd); | |
1047 | install_element(CONFIG_NODE, &no_ipv6_route_ifname_label_cmd); | |
1048 | install_element(CONFIG_NODE, &ipv6_route_pref_label_cmd); | |
1049 | install_element(CONFIG_NODE, &ipv6_route_ifname_pref_label_cmd); | |
1050 | install_element(CONFIG_NODE, &no_ipv6_route_pref_label_cmd); | |
1051 | install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_label_cmd); | |
1052 | install_element(CONFIG_NODE, &ipv6_route_tag_label_cmd); | |
1053 | install_element(CONFIG_NODE, &ipv6_route_ifname_tag_label_cmd); | |
1054 | install_element(CONFIG_NODE, &ipv6_route_pref_tag_label_cmd); | |
1055 | install_element(CONFIG_NODE, &ipv6_route_ifname_pref_tag_label_cmd); | |
1056 | install_element(CONFIG_NODE, &no_ipv6_route_tag_label_cmd); | |
1057 | install_element(CONFIG_NODE, &no_ipv6_route_ifname_tag_label_cmd); | |
1058 | install_element(CONFIG_NODE, &no_ipv6_route_pref_tag_label_cmd); | |
1059 | install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_label_cmd); | |
1060 | ||
1061 | install_element(CONFIG_NODE, &mpls_transit_lsp_cmd); | |
1062 | install_element(CONFIG_NODE, &no_mpls_transit_lsp_cmd); | |
1063 | install_element(CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd); | |
1064 | install_element(CONFIG_NODE, &no_mpls_transit_lsp_all_cmd); | |
1065 | install_element(CONFIG_NODE, &mpls_label_bind_cmd); | |
1066 | install_element(CONFIG_NODE, &no_mpls_label_bind_cmd); | |
1067 | ||
1068 | install_element(CONFIG_NODE, &mpls_label_global_block_cmd); | |
1069 | install_element(CONFIG_NODE, &no_mpls_label_global_block_cmd); | |
1070 | ||
1071 | install_element(VIEW_NODE, &show_mpls_table_cmd); | |
1072 | install_element(VIEW_NODE, &show_mpls_table_lsp_cmd); | |
1073 | install_element(VIEW_NODE, &show_mpls_fec_cmd); | |
41675b4c | 1074 | } |