]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vty.c
*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
[mirror_frr.git] / zebra / zebra_vty.c
1 /* Zebra 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 "zebra_memory.h"
26 #include "if.h"
27 #include "prefix.h"
28 #include "command.h"
29 #include "table.h"
30 #include "rib.h"
31 #include "nexthop.h"
32 #include "vrf.h"
33 #include "lib/json.h"
34 #include "routemap.h"
35
36 #include "zebra/zserv.h"
37 #include "zebra/zebra_vrf.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 extern int allow_delete;
44
45 static int do_show_ip_route(struct vty *vty, const char *vrf_name,
46 safi_t safi, u_char use_json);
47 static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
48 int mcast);
49
50 #define ONE_DAY_SECOND 60*60*24
51 #define ONE_WEEK_SECOND 60*60*24*7
52
53 /* General function for static route. */
54 static int
55 zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd,
56 const char *dest_str, const char *mask_str,
57 const char *gate_str, const char *flag_str,
58 const char *tag_str, const char *distance_str,
59 const char *vrf_id_str)
60 {
61 int ret;
62 u_char distance;
63 struct prefix p;
64 struct in_addr gate;
65 struct in_addr mask;
66 u_char flag = 0;
67 u_short tag = 0;
68 struct zebra_vrf *zvrf = NULL;
69 unsigned int ifindex = 0;
70 const char *ifname = NULL;
71 u_char type = STATIC_IPV4_BLACKHOLE;
72
73 ret = str2prefix (dest_str, &p);
74 if (ret <= 0)
75 {
76 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
77 return CMD_WARNING;
78 }
79
80 /* Cisco like mask notation. */
81 if (mask_str)
82 {
83 ret = inet_aton (mask_str, &mask);
84 if (ret == 0)
85 {
86 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
87 return CMD_WARNING;
88 }
89 p.prefixlen = ip_masklen (mask);
90 }
91
92 /* Apply mask for given prefix. */
93 apply_mask (&p);
94
95 /* Administrative distance. */
96 if (distance_str)
97 distance = atoi (distance_str);
98 else
99 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
100
101 /* tag */
102 if (tag_str)
103 tag = atoi(tag_str);
104
105 /* VRF id */
106 zvrf = zebra_vrf_list_lookup_by_name (vrf_id_str);
107
108 if (!zvrf)
109 {
110 vty_out (vty, "%% vrf %s is not defined%s", vrf_id_str, VTY_NEWLINE);
111 return CMD_WARNING;
112 }
113
114 /* Null0 static route. */
115 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
116 {
117 if (flag_str)
118 {
119 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
120 return CMD_WARNING;
121 }
122 if (add_cmd)
123 static_add_route (AFI_IP, safi, type, &p, NULL, ifindex, ifname, ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf);
124 else
125 static_delete_route (AFI_IP, safi, type, &p, NULL, ifindex, tag, distance, zvrf);
126 return CMD_SUCCESS;
127 }
128
129 /* Route flags */
130 if (flag_str) {
131 switch(flag_str[0]) {
132 case 'r':
133 case 'R': /* XXX */
134 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
135 break;
136 case 'b':
137 case 'B': /* XXX */
138 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
139 break;
140 default:
141 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
142 return CMD_WARNING;
143 }
144 }
145
146 if (gate_str == NULL)
147 {
148 if (add_cmd)
149 static_add_route (AFI_IP, safi, type, &p, NULL, ifindex, ifname, flag, tag, distance, zvrf);
150 else
151 static_delete_route (AFI_IP, safi, type, &p, NULL, ifindex, tag, distance, zvrf);
152
153 return CMD_SUCCESS;
154 }
155
156 /* When gateway is A.B.C.D format, gate is treated as nexthop
157 address other case gate is treated as interface name. */
158 ret = inet_aton (gate_str, &gate);
159 if (!ret)
160 {
161 struct interface *ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id);
162 if (!ifp)
163 {
164 vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE);
165 ifindex = IFINDEX_DELETED;
166 }
167 else
168 ifindex = ifp->ifindex;
169 ifname = gate_str;
170 type = STATIC_IFINDEX;
171 }
172 else
173 type = STATIC_IPV4_GATEWAY;
174
175 if (add_cmd)
176 static_add_route (AFI_IP, safi, type, &p, ifindex ? NULL : (union g_addr *)&gate, ifindex, ifname, flag, tag, distance, zvrf);
177 else
178 static_delete_route (AFI_IP, safi, type, &p, ifindex ? NULL : (union g_addr *)&gate, ifindex, tag, distance, zvrf);
179
180 return CMD_SUCCESS;
181 }
182
183 /* Static unicast routes for multicast RPF lookup. */
184 DEFUN (ip_mroute_dist,
185 ip_mroute_dist_cmd,
186 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
187 IP_STR
188 "Configure static unicast route into MRIB for multicast RPF lookup\n"
189 "IP destination prefix (e.g. 10.0.0.0/8)\n"
190 "Nexthop address\n"
191 "Nexthop interface name\n"
192 "Distance\n")
193 {
194 return zebra_static_ipv4 (vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
195 }
196
197 ALIAS (ip_mroute_dist,
198 ip_mroute_cmd,
199 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
200 IP_STR
201 "Configure static unicast route into MRIB for multicast RPF lookup\n"
202 "IP destination prefix (e.g. 10.0.0.0/8)\n"
203 "Nexthop address\n"
204 "Nexthop interface name\n")
205
206 DEFUN (no_ip_mroute_dist,
207 no_ip_mroute_dist_cmd,
208 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
209 IP_STR
210 "Configure static unicast route into MRIB for multicast RPF lookup\n"
211 "IP destination prefix (e.g. 10.0.0.0/8)\n"
212 "Nexthop address\n"
213 "Nexthop interface name\n"
214 "Distance\n")
215 {
216 return zebra_static_ipv4 (vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
217 }
218
219 ALIAS (no_ip_mroute_dist,
220 no_ip_mroute_cmd,
221 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
222 NO_STR
223 IP_STR
224 "Configure static unicast route into MRIB for multicast RPF lookup\n"
225 "IP destination prefix (e.g. 10.0.0.0/8)\n"
226 "Nexthop address\n"
227 "Nexthop interface name\n")
228
229 DEFUN (ip_multicast_mode,
230 ip_multicast_mode_cmd,
231 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
232 IP_STR
233 "Multicast options\n"
234 "RPF lookup behavior\n"
235 "Lookup in unicast RIB only\n"
236 "Lookup in multicast RIB only\n"
237 "Try multicast RIB first, fall back to unicast RIB\n"
238 "Lookup both, use entry with lower distance\n"
239 "Lookup both, use entry with longer prefix\n")
240 {
241
242 if (!strncmp (argv[0], "u", 1))
243 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
244 else if (!strncmp (argv[0], "mrib-o", 6))
245 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
246 else if (!strncmp (argv[0], "mrib-t", 6))
247 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
248 else if (!strncmp (argv[0], "low", 3))
249 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
250 else if (!strncmp (argv[0], "lon", 3))
251 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
252 else
253 {
254 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
255 return CMD_WARNING;
256 }
257
258 return CMD_SUCCESS;
259 }
260
261 DEFUN (no_ip_multicast_mode,
262 no_ip_multicast_mode_cmd,
263 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
264 NO_STR
265 IP_STR
266 "Multicast options\n"
267 "RPF lookup behavior\n"
268 "Lookup in unicast RIB only\n"
269 "Lookup in multicast RIB only\n"
270 "Try multicast RIB first, fall back to unicast RIB\n"
271 "Lookup both, use entry with lower distance\n"
272 "Lookup both, use entry with longer prefix\n")
273 {
274 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
275 return CMD_SUCCESS;
276 }
277
278 ALIAS (no_ip_multicast_mode,
279 no_ip_multicast_mode_noarg_cmd,
280 "no ip multicast rpf-lookup-mode",
281 NO_STR
282 IP_STR
283 "Multicast options\n"
284 "RPF lookup behavior\n")
285
286 DEFUN (show_ip_rpf,
287 show_ip_rpf_cmd,
288 "show ip rpf",
289 SHOW_STR
290 IP_STR
291 "Display RPF information for multicast source\n")
292 {
293 return do_show_ip_route(vty, VRF_DEFAULT_NAME, SAFI_MULTICAST, 0);
294 }
295
296 DEFUN (show_ip_rpf_addr,
297 show_ip_rpf_addr_cmd,
298 "show ip rpf A.B.C.D",
299 SHOW_STR
300 IP_STR
301 "Display RPF information for multicast source\n"
302 "IP multicast source address (e.g. 10.0.0.0)\n")
303 {
304 struct in_addr addr;
305 struct route_node *rn;
306 struct rib *rib;
307 int ret;
308
309 ret = inet_aton (argv[0], &addr);
310 if (ret == 0)
311 {
312 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
313 return CMD_WARNING;
314 }
315
316 rib = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
317
318 if (rib)
319 vty_show_ip_route_detail (vty, rn, 1);
320 else
321 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
322
323 return CMD_SUCCESS;
324 }
325
326 /* Static route configuration. */
327 DEFUN (ip_route,
328 ip_route_cmd,
329 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
330 IP_STR
331 "Establish static routes\n"
332 "IP destination prefix (e.g. 10.0.0.0/8)\n"
333 "IP gateway address\n"
334 "IP gateway interface name\n"
335 "Null interface\n")
336 {
337 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL,
338 NULL, NULL);
339 }
340
341 DEFUN (ip_route_tag,
342 ip_route_tag_cmd,
343 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535>",
344 IP_STR
345 "Establish static routes\n"
346 "IP destination prefix (e.g. 10.0.0.0/8)\n"
347 "IP gateway address\n"
348 "IP gateway interface name\n"
349 "Null interface\n"
350 "Set tag for this route\n"
351 "Tag value\n")
352 {
353 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2],
354 NULL, NULL);
355 }
356
357 DEFUN (ip_route_flags,
358 ip_route_flags_cmd,
359 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
360 IP_STR
361 "Establish static routes\n"
362 "IP destination prefix (e.g. 10.0.0.0/8)\n"
363 "IP gateway address\n"
364 "IP gateway interface name\n"
365 "Emit an ICMP unreachable when matched\n"
366 "Silently discard pkts when matched\n")
367 {
368 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL,
369 NULL, NULL);
370 }
371
372 DEFUN (ip_route_flags_tag,
373 ip_route_flags_tag_cmd,
374 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535>",
375 IP_STR
376 "Establish static routes\n"
377 "IP destination prefix (e.g. 10.0.0.0/8)\n"
378 "IP gateway address\n"
379 "IP gateway interface name\n"
380 "Emit an ICMP unreachable when matched\n"
381 "Silently discard pkts when matched\n"
382 "Set tag for this route\n"
383 "Tag value\n")
384
385 {
386 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3],
387 NULL, NULL);
388 }
389
390 DEFUN (ip_route_flags2,
391 ip_route_flags2_cmd,
392 "ip route A.B.C.D/M (reject|blackhole)",
393 IP_STR
394 "Establish static routes\n"
395 "IP destination prefix (e.g. 10.0.0.0/8)\n"
396 "Emit an ICMP unreachable when matched\n"
397 "Silently discard pkts when matched\n")
398 {
399 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL,
400 NULL, NULL);
401 }
402
403 DEFUN (ip_route_flags2_tag,
404 ip_route_flags2_tag_cmd,
405 "ip route A.B.C.D/M (reject|blackhole) tag <1-65535>",
406 IP_STR
407 "Establish static routes\n"
408 "IP destination prefix (e.g. 10.0.0.0/8)\n"
409 "Emit an ICMP unreachable when matched\n"
410 "Silently discard pkts when matched\n"
411 "Set tag for this route\n"
412 "Tag value\n")
413
414 {
415 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2],
416 NULL, NULL);
417 }
418
419 /* Mask as A.B.C.D format. */
420 DEFUN (ip_route_mask,
421 ip_route_mask_cmd,
422 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
423 IP_STR
424 "Establish static routes\n"
425 "IP destination prefix\n"
426 "IP destination prefix mask\n"
427 "IP gateway address\n"
428 "IP gateway interface name\n"
429 "Null interface\n")
430 {
431 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL,
432 NULL, NULL);
433 }
434
435 DEFUN (ip_route_mask_tag,
436 ip_route_mask_tag_cmd,
437 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535>",
438 IP_STR
439 "Establish static routes\n"
440 "IP destination prefix\n"
441 "IP destination prefix mask\n"
442 "IP gateway address\n"
443 "IP gateway interface name\n"
444 "Null interface\n"
445 "Set tag for this route\n"
446 "Tag value\n")
447
448 {
449 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3],
450 NULL, NULL);
451 }
452
453 DEFUN (ip_route_mask_flags,
454 ip_route_mask_flags_cmd,
455 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
456 IP_STR
457 "Establish static routes\n"
458 "IP destination prefix\n"
459 "IP destination prefix mask\n"
460 "IP gateway address\n"
461 "IP gateway interface name\n"
462 "Emit an ICMP unreachable when matched\n"
463 "Silently discard pkts when matched\n")
464 {
465 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL,
466 NULL, NULL);
467 }
468
469 DEFUN (ip_route_mask_flags_tag,
470 ip_route_mask_flags_tag_cmd,
471 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535>",
472 IP_STR
473 "Establish static routes\n"
474 "IP destination prefix\n"
475 "IP destination prefix mask\n"
476 "IP gateway address\n"
477 "IP gateway interface name\n"
478 "Emit an ICMP unreachable when matched\n"
479 "Silently discard pkts when matched\n"
480 "Set tag for this route\n"
481 "Tag value\n")
482
483 {
484 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
485 NULL, NULL);
486 }
487
488 DEFUN (ip_route_mask_flags2,
489 ip_route_mask_flags2_cmd,
490 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
491 IP_STR
492 "Establish static routes\n"
493 "IP destination prefix\n"
494 "IP destination prefix mask\n"
495 "Emit an ICMP unreachable when matched\n"
496 "Silently discard pkts when matched\n")
497 {
498 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL,
499 NULL, NULL);
500 }
501
502 DEFUN (ip_route_mask_flags2_tag,
503 ip_route_mask_flags2_tag_cmd,
504 "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535>",
505 IP_STR
506 "Establish static routes\n"
507 "IP destination prefix\n"
508 "IP destination prefix mask\n"
509 "Emit an ICMP unreachable when matched\n"
510 "Silently discard pkts when matched\n"
511 "Set tag for this route\n"
512 "Tag value\n")
513 {
514 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3],
515 NULL, NULL);
516 }
517
518 /* Distance option value. */
519 DEFUN (ip_route_distance,
520 ip_route_distance_cmd,
521 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
522 IP_STR
523 "Establish static routes\n"
524 "IP destination prefix (e.g. 10.0.0.0/8)\n"
525 "IP gateway address\n"
526 "IP gateway interface name\n"
527 "Null interface\n"
528 "Distance value for this route\n")
529 {
530 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL,
531 argv[2], NULL);
532 }
533
534 DEFUN (ip_route_tag_distance,
535 ip_route_tag_distance_cmd,
536 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255>",
537 IP_STR
538 "Establish static routes\n"
539 "IP destination prefix (e.g. 10.0.0.0/8)\n"
540 "IP gateway address\n"
541 "IP gateway interface name\n"
542 "Null interface\n"
543 "Set tag for this route\n"
544 "Tag value\n"
545 "Distance value for this route\n")
546
547 {
548 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2],
549 argv[3], NULL);
550 }
551
552 DEFUN (ip_route_flags_distance,
553 ip_route_flags_distance_cmd,
554 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
555 IP_STR
556 "Establish static routes\n"
557 "IP destination prefix (e.g. 10.0.0.0/8)\n"
558 "IP gateway address\n"
559 "IP gateway interface name\n"
560 "Emit an ICMP unreachable when matched\n"
561 "Silently discard pkts when matched\n"
562 "Distance value for this route\n")
563 {
564 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL,
565 argv[3], NULL);
566 }
567
568 DEFUN (ip_route_flags_tag_distance,
569 ip_route_flags_tag_distance_cmd,
570 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
571 IP_STR
572 "Establish static routes\n"
573 "IP destination prefix (e.g. 10.0.0.0/8)\n"
574 "IP gateway address\n"
575 "IP gateway interface name\n"
576 "Emit an ICMP unreachable when matched\n"
577 "Silently discard pkts when matched\n"
578 "Set tag for this route\n"
579 "Tag value\n"
580 "Distance value for this route\n")
581 {
582 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3],
583 argv[4], NULL);
584 }
585
586 DEFUN (ip_route_flags_distance2,
587 ip_route_flags_distance2_cmd,
588 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
589 IP_STR
590 "Establish static routes\n"
591 "IP destination prefix (e.g. 10.0.0.0/8)\n"
592 "Emit an ICMP unreachable when matched\n"
593 "Silently discard pkts when matched\n"
594 "Distance value for this route\n")
595 {
596 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL,
597 argv[2], NULL);
598 }
599
600 DEFUN (ip_route_flags_tag_distance2,
601 ip_route_flags_tag_distance2_cmd,
602 "ip route A.B.C.D/M (reject|blackhole) tag <1-65535> <1-255>",
603 IP_STR
604 "Establish static routes\n"
605 "IP destination prefix (e.g. 10.0.0.0/8)\n"
606 "Emit an ICMP unreachable when matched\n"
607 "Silently discard pkts when matched\n"
608 "Set tag for this route\n"
609 "Tag value\n"
610 "Distance value for this route\n")
611 {
612 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2],
613 argv[3], NULL);
614 }
615
616 DEFUN (ip_route_mask_distance,
617 ip_route_mask_distance_cmd,
618 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
619 IP_STR
620 "Establish static routes\n"
621 "IP destination prefix\n"
622 "IP destination prefix mask\n"
623 "IP gateway address\n"
624 "IP gateway interface name\n"
625 "Null interface\n"
626 "Distance value for this route\n")
627 {
628 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL,
629 argv[3], NULL);
630 }
631
632 DEFUN (ip_route_mask_tag_distance,
633 ip_route_mask_tag_distance_cmd,
634 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255>",
635 IP_STR
636 "Establish static routes\n"
637 "IP destination prefix\n"
638 "IP destination prefix mask\n"
639 "IP gateway address\n"
640 "IP gateway interface name\n"
641 "Null interface\n"
642 "Set tag for this route\n"
643 "Tag value\n"
644 "Distance value for this route\n")
645 {
646 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3],
647 argv[4], NULL);
648 }
649
650 DEFUN (ip_route_mask_flags_tag_distance,
651 ip_route_mask_flags_tag_distance_cmd,
652 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
653 IP_STR
654 "Establish static routes\n"
655 "IP destination prefix\n"
656 "IP destination prefix mask\n"
657 "IP gateway address\n"
658 "IP gateway interface name\n"
659 "Set tag for this route\n"
660 "Tag value\n"
661 "Distance value for this route\n"
662 "Emit an ICMP unreachable when matched\n"
663 "Silently discard pkts when matched\n")
664 {
665 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
666 argv[5], NULL);
667 }
668
669
670 DEFUN (ip_route_mask_flags_distance,
671 ip_route_mask_flags_distance_cmd,
672 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
673 IP_STR
674 "Establish static routes\n"
675 "IP destination prefix\n"
676 "IP destination prefix mask\n"
677 "IP gateway address\n"
678 "IP gateway interface name\n"
679 "Emit an ICMP unreachable when matched\n"
680 "Silently discard pkts when matched\n"
681 "Distance value for this route\n")
682 {
683 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL,
684 argv[4], NULL);
685 }
686
687 DEFUN (ip_route_mask_flags_distance2,
688 ip_route_mask_flags_distance2_cmd,
689 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
690 IP_STR
691 "Establish static routes\n"
692 "IP destination prefix\n"
693 "IP destination prefix mask\n"
694 "Emit an ICMP unreachable when matched\n"
695 "Silently discard pkts when matched\n"
696 "Distance value for this route\n")
697 {
698 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL,
699 argv[3], NULL);
700 }
701
702 DEFUN (ip_route_mask_flags_tag_distance2,
703 ip_route_mask_flags_tag_distance2_cmd,
704 "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> <1-255>",
705 IP_STR
706 "Establish static routes\n"
707 "IP destination prefix\n"
708 "IP destination prefix mask\n"
709 "Set tag for this route\n"
710 "Tag value\n"
711 "Distance value for this route\n"
712 "Emit an ICMP unreachable when matched\n"
713 "Silently discard pkts when matched\n")
714 {
715 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3],
716 argv[4], NULL);
717 }
718
719 DEFUN (no_ip_route,
720 no_ip_route_cmd,
721 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
722 NO_STR
723 IP_STR
724 "Establish static routes\n"
725 "IP destination prefix (e.g. 10.0.0.0/8)\n"
726 "IP gateway address\n"
727 "IP gateway interface name\n"
728 "Null interface\n")
729 {
730 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL,
731 NULL, NULL);
732 }
733
734 DEFUN (no_ip_route_tag,
735 no_ip_route_tag_cmd,
736 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535>",
737 NO_STR
738 IP_STR
739 "Establish static routes\n"
740 "IP destination prefix (e.g. 10.0.0.0/8)\n"
741 "IP gateway address\n"
742 "IP gateway interface name\n"
743 "Null interface\n"
744 "Tag of this route\n"
745 "Tag value\n")
746 {
747 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2],
748 NULL, NULL);
749 }
750
751 ALIAS (no_ip_route,
752 no_ip_route_flags_cmd,
753 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
754 NO_STR
755 IP_STR
756 "Establish static routes\n"
757 "IP destination prefix (e.g. 10.0.0.0/8)\n"
758 "IP gateway address\n"
759 "IP gateway interface name\n"
760 "Emit an ICMP unreachable when matched\n"
761 "Silently discard pkts when matched\n")
762
763 ALIAS (no_ip_route_tag,
764 no_ip_route_flags_tag_cmd,
765 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535>",
766 NO_STR
767 IP_STR
768 "Establish static routes\n"
769 "IP destination prefix (e.g. 10.0.0.0/8)\n"
770 "IP gateway address\n"
771 "IP gateway interface name\n"
772 "Emit an ICMP unreachable when matched\n"
773 "Silently discard pkts when matched\n"
774 "Tag of this route\n"
775 "Tag value\n")
776
777 DEFUN (no_ip_route_flags2,
778 no_ip_route_flags2_cmd,
779 "no ip route A.B.C.D/M (reject|blackhole)",
780 NO_STR
781 IP_STR
782 "Establish static routes\n"
783 "IP destination prefix (e.g. 10.0.0.0/8)\n"
784 "Emit an ICMP unreachable when matched\n"
785 "Silently discard pkts when matched\n")
786 {
787 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, NULL, NULL,
788 NULL, NULL);
789 }
790
791 DEFUN (no_ip_route_flags2_tag,
792 no_ip_route_flags2_tag_cmd,
793 "no ip route A.B.C.D/M (reject|blackhole) tag <1-65535>",
794 NO_STR
795 IP_STR
796 "Establish static routes\n"
797 "IP destination prefix (e.g. 10.0.0.0/8)\n"
798 "Emit an ICMP unreachable when matched\n"
799 "Silently discard pkts when matched\n"
800 "Tag of this route\n"
801 "Tag value\n")
802 {
803 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, NULL, argv[1],
804 NULL, NULL);
805 }
806
807 DEFUN (no_ip_route_mask,
808 no_ip_route_mask_cmd,
809 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
810 NO_STR
811 IP_STR
812 "Establish static routes\n"
813 "IP destination prefix\n"
814 "IP destination prefix mask\n"
815 "IP gateway address\n"
816 "IP gateway interface name\n"
817 "Null interface\n")
818 {
819 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL,
820 NULL, NULL);
821 }
822
823 DEFUN (no_ip_route_mask_tag,
824 no_ip_route_mask_tag_cmd,
825 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535>",
826 NO_STR
827 IP_STR
828 "Establish static routes\n"
829 "IP destination prefix\n"
830 "IP destination prefix mask\n"
831 "IP gateway address\n"
832 "IP gateway interface name\n"
833 "Null interface\n"
834 "Tag of this route\n"
835 "Tag value\n")
836 {
837 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3],
838 NULL, NULL);
839 }
840
841 ALIAS (no_ip_route_mask,
842 no_ip_route_mask_flags_cmd,
843 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
844 NO_STR
845 IP_STR
846 "Establish static routes\n"
847 "IP destination prefix\n"
848 "IP destination prefix mask\n"
849 "IP gateway address\n"
850 "IP gateway interface name\n"
851 "Emit an ICMP unreachable when matched\n"
852 "Silently discard pkts when matched\n")
853
854 ALIAS (no_ip_route_mask_tag,
855 no_ip_route_mask_flags_tag_cmd,
856 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535>",
857 NO_STR
858 IP_STR
859 "Establish static routes\n"
860 "IP destination prefix\n"
861 "IP destination prefix mask\n"
862 "IP gateway address\n"
863 "IP gateway interface name\n"
864 "Emit an ICMP unreachable when matched\n"
865 "Silently discard pkts when matched\n"
866 "Tag of this route\n"
867 "Tag value\n")
868
869 DEFUN (no_ip_route_mask_flags2,
870 no_ip_route_mask_flags2_cmd,
871 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
872 NO_STR
873 IP_STR
874 "Establish static routes\n"
875 "IP destination prefix\n"
876 "IP destination prefix mask\n"
877 "Emit an ICMP unreachable when matched\n"
878 "Silently discard pkts when matched\n")
879 {
880 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, NULL, NULL,
881 NULL, NULL);
882 }
883
884 DEFUN (no_ip_route_mask_flags2_tag,
885 no_ip_route_mask_flags2_tag_cmd,
886 "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535>",
887 NO_STR
888 IP_STR
889 "Establish static routes\n"
890 "IP destination prefix\n"
891 "IP destination prefix mask\n"
892 "Emit an ICMP unreachable when matched\n"
893 "Silently discard pkts when matched\n"
894 "Tag of this route\n"
895 "Tag value\n")
896 {
897 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, NULL, argv[2],
898 NULL, NULL);
899 }
900
901 DEFUN (no_ip_route_distance,
902 no_ip_route_distance_cmd,
903 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
904 NO_STR
905 IP_STR
906 "Establish static routes\n"
907 "IP destination prefix (e.g. 10.0.0.0/8)\n"
908 "IP gateway address\n"
909 "IP gateway interface name\n"
910 "Null interface\n"
911 "Distance value for this route\n")
912 {
913 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL,
914 argv[2], NULL);
915 }
916
917 DEFUN (no_ip_route_tag_distance,
918 no_ip_route_tag_distance_cmd,
919 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255>",
920 NO_STR
921 IP_STR
922 "Establish static routes\n"
923 "IP destination prefix (e.g. 10.0.0.0/8)\n"
924 "IP gateway address\n"
925 "IP gateway interface name\n"
926 "Null interface\n"
927 "Tag of this route\n"
928 "Tag value\n"
929 "Distance value for this route\n")
930 {
931 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2],
932 argv[3], NULL);
933 }
934
935 DEFUN (no_ip_route_flags_distance,
936 no_ip_route_flags_distance_cmd,
937 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
938 NO_STR
939 IP_STR
940 "Establish static routes\n"
941 "IP destination prefix (e.g. 10.0.0.0/8)\n"
942 "IP gateway address\n"
943 "IP gateway interface name\n"
944 "Emit an ICMP unreachable when matched\n"
945 "Silently discard pkts when matched\n"
946 "Distance value for this route\n")
947 {
948 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], NULL,
949 argv[3], NULL);
950 }
951
952 DEFUN (no_ip_route_flags_tag_distance,
953 no_ip_route_flags_tag_distance_cmd,
954 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
955 NO_STR
956 IP_STR
957 "Establish static routes\n"
958 "IP destination prefix (e.g. 10.0.0.0/8)\n"
959 "IP gateway address\n"
960 "IP gateway interface name\n"
961 "Emit an ICMP unreachable when matched\n"
962 "Silently discard pkts when matched\n"
963 "Tag of this route\n"
964 "Tag value\n"
965 "Distance value for this route\n")
966 {
967 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], argv[3],
968 argv[4], NULL);
969 }
970
971 DEFUN (no_ip_route_flags_distance2,
972 no_ip_route_flags_distance2_cmd,
973 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
974 NO_STR
975 IP_STR
976 "Establish static routes\n"
977 "IP destination prefix (e.g. 10.0.0.0/8)\n"
978 "Emit an ICMP unreachable when matched\n"
979 "Silently discard pkts when matched\n"
980 "Distance value for this route\n")
981 {
982 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], NULL,
983 argv[2], NULL);
984 }
985
986 DEFUN (no_ip_route_flags_tag_distance2,
987 no_ip_route_flags_tag_distance2_cmd,
988 "no ip route A.B.C.D/M (reject|blackhole) tag <1-65535> <1-255>",
989 NO_STR
990 IP_STR
991 "Establish static routes\n"
992 "IP destination prefix (e.g. 10.0.0.0/8)\n"
993 "Emit an ICMP unreachable when matched\n"
994 "Silently discard pkts when matched\n"
995 "Tag of this route\n"
996 "Tag value\n"
997 "Distance value for this route\n")
998 {
999 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], argv[2],
1000 argv[3], NULL);
1001 }
1002
1003 DEFUN (no_ip_route_mask_distance,
1004 no_ip_route_mask_distance_cmd,
1005 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
1006 NO_STR
1007 IP_STR
1008 "Establish static routes\n"
1009 "IP destination prefix\n"
1010 "IP destination prefix mask\n"
1011 "IP gateway address\n"
1012 "IP gateway interface name\n"
1013 "Null interface\n"
1014 "Distance value for this route\n")
1015 {
1016 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL,
1017 argv[3], NULL);
1018 }
1019
1020 DEFUN (no_ip_route_mask_tag_distance,
1021 no_ip_route_mask_tag_distance_cmd,
1022 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255>",
1023 NO_STR
1024 IP_STR
1025 "Establish static routes\n"
1026 "IP destination prefix\n"
1027 "IP destination prefix mask\n"
1028 "IP gateway address\n"
1029 "IP gateway interface name\n"
1030 "Null interface\n"
1031 "Tag of this route\n"
1032 "Tag value\n"
1033 "Distance value for this route\n")
1034 {
1035 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3],
1036 argv[4], NULL);
1037 }
1038
1039 DEFUN (no_ip_route_mask_flags_distance,
1040 no_ip_route_mask_flags_distance_cmd,
1041 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
1042 NO_STR
1043 IP_STR
1044 "Establish static routes\n"
1045 "IP destination prefix\n"
1046 "IP destination prefix mask\n"
1047 "IP gateway address\n"
1048 "IP gateway interface name\n"
1049 "Emit an ICMP unreachable when matched\n"
1050 "Silently discard pkts when matched\n"
1051 "Distance value for this route\n")
1052 {
1053 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], NULL,
1054 argv[4], NULL);
1055 }
1056
1057 DEFUN (no_ip_route_mask_flags_tag_distance,
1058 no_ip_route_mask_flags_tag_distance_cmd,
1059 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
1060 NO_STR
1061 IP_STR
1062 "Establish static routes\n"
1063 "IP destination prefix\n"
1064 "IP destination prefix mask\n"
1065 "IP gateway address\n"
1066 "IP gateway interface name\n"
1067 "Emit an ICMP unreachable when matched\n"
1068 "Silently discard pkts when matched\n"
1069 "Tag of this route\n"
1070 "Tag value\n"
1071 "Distance value for this route\n")
1072 {
1073 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
1074 argv[5], NULL);
1075 }
1076
1077 DEFUN (no_ip_route_mask_flags_distance2,
1078 no_ip_route_mask_flags_distance2_cmd,
1079 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
1080 NO_STR
1081 IP_STR
1082 "Establish static routes\n"
1083 "IP destination prefix\n"
1084 "IP destination prefix mask\n"
1085 "Emit an ICMP unreachable when matched\n"
1086 "Silently discard pkts when matched\n"
1087 "Distance value for this route\n")
1088 {
1089 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], NULL,
1090 argv[3], NULL);
1091 }
1092
1093 DEFUN (no_ip_route_mask_flags_tag_distance2,
1094 no_ip_route_mask_flags_tag_distance2_cmd,
1095 "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> <1-255>",
1096 NO_STR
1097 IP_STR
1098 "Establish static routes\n"
1099 "IP destination prefix\n"
1100 "IP destination prefix mask\n"
1101 "Emit an ICMP unreachable when matched\n"
1102 "Silently discard pkts when matched\n"
1103 "Tag of this route\n"
1104 "Tag value\n"
1105 "Distance value for this route\n")
1106 {
1107 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], argv[3],
1108 argv[4], NULL);
1109 }
1110
1111 /* Static route configuration. */
1112 DEFUN (ip_route_vrf,
1113 ip_route_vrf_cmd,
1114 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1115 IP_STR
1116 "Establish static routes\n"
1117 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1118 "IP gateway address\n"
1119 "IP gateway interface name\n"
1120 "Null interface\n"
1121 VRF_CMD_HELP_STR)
1122 {
1123 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, NULL, argv[2]);
1124 }
1125
1126 DEFUN (ip_route_tag_vrf,
1127 ip_route_tag_vrf_cmd,
1128 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> " VRF_CMD_STR,
1129 IP_STR
1130 "Establish static routes\n"
1131 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1132 "IP gateway address\n"
1133 "IP gateway interface name\n"
1134 "Null interface\n"
1135 "Set tag for this route\n"
1136 "Tag value\n"
1137 VRF_CMD_HELP_STR)
1138 {
1139 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], NULL, argv[3]);
1140 }
1141
1142 DEFUN (ip_route_flags_vrf,
1143 ip_route_flags_vrf_cmd,
1144 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1145 IP_STR
1146 "Establish static routes\n"
1147 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1148 "IP gateway address\n"
1149 "IP gateway interface name\n"
1150 "Emit an ICMP unreachable when matched\n"
1151 "Silently discard pkts when matched\n"
1152 VRF_CMD_HELP_STR)
1153 {
1154 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL, NULL, argv[3]);
1155 }
1156
1157 DEFUN (ip_route_flags_tag_vrf,
1158 ip_route_flags_tag_vrf_cmd,
1159 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1160 IP_STR
1161 "Establish static routes\n"
1162 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1163 "IP gateway address\n"
1164 "IP gateway interface name\n"
1165 "Emit an ICMP unreachable when matched\n"
1166 "Silently discard pkts when matched\n"
1167 "Set tag for this route\n"
1168 "Tag value\n"
1169 VRF_CMD_HELP_STR)
1170
1171 {
1172 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3], NULL, argv[4]);
1173 }
1174
1175 DEFUN (ip_route_flags2_vrf,
1176 ip_route_flags2_vrf_cmd,
1177 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1178 IP_STR
1179 "Establish static routes\n"
1180 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1181 "Emit an ICMP unreachable when matched\n"
1182 "Silently discard pkts when matched\n"
1183 VRF_CMD_HELP_STR)
1184 {
1185 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL, NULL, argv[2]);
1186 }
1187
1188 DEFUN (ip_route_flags2_tag_vrf,
1189 ip_route_flags2_tag_vrf_cmd,
1190 "ip route A.B.C.D/M (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1191 IP_STR
1192 "Establish static routes\n"
1193 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1194 "Emit an ICMP unreachable when matched\n"
1195 "Silently discard pkts when matched\n"
1196 "Set tag for this route\n"
1197 "Tag value\n"
1198 VRF_CMD_HELP_STR)
1199
1200 {
1201 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2], NULL, argv[3]);
1202 }
1203
1204 /* Mask as A.B.C.D format. */
1205 DEFUN (ip_route_mask_vrf,
1206 ip_route_mask_vrf_cmd,
1207 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1208 IP_STR
1209 "Establish static routes\n"
1210 "IP destination prefix\n"
1211 "IP destination prefix mask\n"
1212 "IP gateway address\n"
1213 "IP gateway interface name\n"
1214 "Null interface\n"
1215 VRF_CMD_HELP_STR)
1216 {
1217 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3]);
1218 }
1219
1220 DEFUN (ip_route_mask_tag_vrf,
1221 ip_route_mask_tag_vrf_cmd,
1222 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> " VRF_CMD_STR,
1223 IP_STR
1224 "Establish static routes\n"
1225 "IP destination prefix\n"
1226 "IP destination prefix mask\n"
1227 "IP gateway address\n"
1228 "IP gateway interface name\n"
1229 "Null interface\n"
1230 "Set tag for this route\n"
1231 "Tag value\n"
1232 VRF_CMD_HELP_STR)
1233
1234 {
1235 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
1236 }
1237
1238 DEFUN (ip_route_mask_flags_vrf,
1239 ip_route_mask_flags_vrf_cmd,
1240 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1241 IP_STR
1242 "Establish static routes\n"
1243 "IP destination prefix\n"
1244 "IP destination prefix mask\n"
1245 "IP gateway address\n"
1246 "IP gateway interface name\n"
1247 "Emit an ICMP unreachable when matched\n"
1248 "Silently discard pkts when matched\n"
1249 VRF_CMD_HELP_STR)
1250 {
1251 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4]);
1252 }
1253
1254 DEFUN (ip_route_mask_flags_tag_vrf,
1255 ip_route_mask_flags_tag_vrf_cmd,
1256 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1257 IP_STR
1258 "Establish static routes\n"
1259 "IP destination prefix\n"
1260 "IP destination prefix mask\n"
1261 "IP gateway address\n"
1262 "IP gateway interface name\n"
1263 "Emit an ICMP unreachable when matched\n"
1264 "Silently discard pkts when matched\n"
1265 "Set tag for this route\n"
1266 "Tag value\n"
1267 VRF_CMD_HELP_STR)
1268
1269 {
1270 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5]);
1271 }
1272
1273 DEFUN (ip_route_mask_flags2_vrf,
1274 ip_route_mask_flags2_vrf_cmd,
1275 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1276 IP_STR
1277 "Establish static routes\n"
1278 "IP destination prefix\n"
1279 "IP destination prefix mask\n"
1280 "Emit an ICMP unreachable when matched\n"
1281 "Silently discard pkts when matched\n"
1282 VRF_CMD_HELP_STR)
1283 {
1284 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3]);
1285 }
1286
1287 DEFUN (ip_route_mask_flags2_tag_vrf,
1288 ip_route_mask_flags2_tag_vrf_cmd,
1289 "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1290 IP_STR
1291 "Establish static routes\n"
1292 "IP destination prefix\n"
1293 "IP destination prefix mask\n"
1294 "Emit an ICMP unreachable when matched\n"
1295 "Silently discard pkts when matched\n"
1296 "Set tag for this route\n"
1297 "Tag value\n"
1298 VRF_CMD_HELP_STR)
1299 {
1300 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4]);
1301 }
1302
1303 /* Distance option value. */
1304 DEFUN (ip_route_distance_vrf,
1305 ip_route_distance_vrf_cmd,
1306 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1307 IP_STR
1308 "Establish static routes\n"
1309 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1310 "IP gateway address\n"
1311 "IP gateway interface name\n"
1312 "Null interface\n"
1313 "Distance value for this route\n"
1314 VRF_CMD_HELP_STR)
1315 {
1316 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL, argv[2], argv[3]);
1317 }
1318
1319 DEFUN (ip_route_tag_distance_vrf,
1320 ip_route_tag_distance_vrf_cmd,
1321 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255> " VRF_CMD_STR,
1322 IP_STR
1323 "Establish static routes\n"
1324 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1325 "IP gateway address\n"
1326 "IP gateway interface name\n"
1327 "Null interface\n"
1328 "Set tag for this route\n"
1329 "Tag value\n"
1330 "Distance value for this route\n"
1331 VRF_CMD_HELP_STR)
1332
1333 {
1334 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2], argv[3], argv[4]);
1335 }
1336
1337 DEFUN (ip_route_flags_distance_vrf,
1338 ip_route_flags_distance_vrf_cmd,
1339 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1340 IP_STR
1341 "Establish static routes\n"
1342 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1343 "IP gateway address\n"
1344 "IP gateway interface name\n"
1345 "Emit an ICMP unreachable when matched\n"
1346 "Silently discard pkts when matched\n"
1347 "Distance value for this route\n"
1348 VRF_CMD_HELP_STR)
1349 {
1350 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], NULL, argv[3], argv[4]);
1351 }
1352
1353 DEFUN (ip_route_flags_tag_distance_vrf,
1354 ip_route_flags_tag_distance_vrf_cmd,
1355 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1356 IP_STR
1357 "Establish static routes\n"
1358 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1359 "IP gateway address\n"
1360 "IP gateway interface name\n"
1361 "Emit an ICMP unreachable when matched\n"
1362 "Silently discard pkts when matched\n"
1363 "Set tag for this route\n"
1364 "Tag value\n"
1365 "Distance value for this route\n"
1366 VRF_CMD_HELP_STR)
1367 {
1368 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], argv[2], argv[3], argv[4],argv[5]);
1369 }
1370
1371 DEFUN (ip_route_flags_distance2_vrf,
1372 ip_route_flags_distance2_vrf_cmd,
1373 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1374 IP_STR
1375 "Establish static routes\n"
1376 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1377 "Emit an ICMP unreachable when matched\n"
1378 "Silently discard pkts when matched\n"
1379 "Distance value for this route\n"
1380 VRF_CMD_HELP_STR)
1381 {
1382 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], NULL, argv[2], argv[3]);
1383 }
1384
1385 DEFUN (ip_route_flags_tag_distance2_vrf,
1386 ip_route_flags_tag_distance2_vrf_cmd,
1387 "ip route A.B.C.D/M (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1388 IP_STR
1389 "Establish static routes\n"
1390 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1391 "Emit an ICMP unreachable when matched\n"
1392 "Silently discard pkts when matched\n"
1393 "Set tag for this route\n"
1394 "Tag value\n"
1395 "Distance value for this route\n"
1396 VRF_CMD_HELP_STR)
1397 {
1398 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, NULL, argv[1], argv[2], argv[3], argv[4]);
1399 }
1400
1401 DEFUN (ip_route_mask_distance_vrf,
1402 ip_route_mask_distance_vrf_cmd,
1403 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1404 IP_STR
1405 "Establish static routes\n"
1406 "IP destination prefix\n"
1407 "IP destination prefix mask\n"
1408 "IP gateway address\n"
1409 "IP gateway interface name\n"
1410 "Null interface\n"
1411 "Distance value for this route\n"
1412 VRF_CMD_HELP_STR)
1413 {
1414 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]);
1415 }
1416
1417 DEFUN (ip_route_mask_tag_distance_vrf,
1418 ip_route_mask_tag_distance_vrf_cmd,
1419 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255> " VRF_CMD_STR,
1420 IP_STR
1421 "Establish static routes\n"
1422 "IP destination prefix\n"
1423 "IP destination prefix mask\n"
1424 "IP gateway address\n"
1425 "IP gateway interface name\n"
1426 "Null interface\n"
1427 "Set tag for this route\n"
1428 "Tag value\n"
1429 "Distance value for this route\n"
1430 VRF_CMD_HELP_STR)
1431 {
1432 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
1433 }
1434
1435 DEFUN (ip_route_mask_flags_tag_distance_vrf,
1436 ip_route_mask_flags_tag_distance_vrf_cmd,
1437 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1438 IP_STR
1439 "Establish static routes\n"
1440 "IP destination prefix\n"
1441 "IP destination prefix mask\n"
1442 "IP gateway address\n"
1443 "IP gateway interface name\n"
1444 "Set tag for this route\n"
1445 "Tag value\n"
1446 "Distance value for this route\n"
1447 "Emit an ICMP unreachable when matched\n"
1448 "Silently discard pkts when matched\n"
1449 VRF_CMD_HELP_STR)
1450 {
1451 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
1452 }
1453
1454
1455 DEFUN (ip_route_mask_flags_distance_vrf,
1456 ip_route_mask_flags_distance_vrf_cmd,
1457 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1458 IP_STR
1459 "Establish static routes\n"
1460 "IP destination prefix\n"
1461 "IP destination prefix mask\n"
1462 "IP gateway address\n"
1463 "IP gateway interface name\n"
1464 "Emit an ICMP unreachable when matched\n"
1465 "Silently discard pkts when matched\n"
1466 "Distance value for this route\n"
1467 VRF_CMD_HELP_STR)
1468 {
1469 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]);
1470 }
1471
1472 DEFUN (ip_route_mask_flags_distance2_vrf,
1473 ip_route_mask_flags_distance2_vrf_cmd,
1474 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1475 IP_STR
1476 "Establish static routes\n"
1477 "IP destination prefix\n"
1478 "IP destination prefix mask\n"
1479 "Emit an ICMP unreachable when matched\n"
1480 "Silently discard pkts when matched\n"
1481 "Distance value for this route\n"
1482 VRF_CMD_HELP_STR)
1483 {
1484 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]);
1485 }
1486
1487 DEFUN (ip_route_mask_flags_tag_distance2_vrf,
1488 ip_route_mask_flags_tag_distance2_vrf_cmd,
1489 "ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1490 IP_STR
1491 "Establish static routes\n"
1492 "IP destination prefix\n"
1493 "IP destination prefix mask\n"
1494 "Set tag for this route\n"
1495 "Tag value\n"
1496 "Distance value for this route\n"
1497 "Emit an ICMP unreachable when matched\n"
1498 "Silently discard pkts when matched\n"
1499 VRF_CMD_HELP_STR)
1500 {
1501 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
1502 }
1503
1504 DEFUN (no_ip_route_vrf,
1505 no_ip_route_vrf_cmd,
1506 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1507 NO_STR
1508 IP_STR
1509 "Establish static routes\n"
1510 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1511 "IP gateway address\n"
1512 "IP gateway interface name\n"
1513 "Null interface\n"
1514 VRF_CMD_HELP_STR)
1515 {
1516 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, NULL, argv[2]);
1517 }
1518
1519 DEFUN (no_ip_route_flags_vrf,
1520 no_ip_route_flags_vrf_cmd,
1521 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1522 NO_STR
1523 IP_STR
1524 "Establish static routes\n"
1525 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1526 "IP gateway address\n"
1527 "IP gateway interface name\n"
1528 "Emit an ICMP unreachable when matched\n"
1529 "Silently discard pkts when matched\n"
1530 VRF_CMD_HELP_STR)
1531 {
1532 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], NULL, NULL, argv[3]);
1533 }
1534
1535 DEFUN (no_ip_route_tag_vrf,
1536 no_ip_route_tag_vrf_cmd,
1537 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> " VRF_CMD_STR,
1538 NO_STR
1539 IP_STR
1540 "Establish static routes\n"
1541 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1542 "IP gateway address\n"
1543 "IP gateway interface name\n"
1544 "Null interface\n"
1545 "Tag of this route\n"
1546 "Tag value\n"
1547 VRF_CMD_HELP_STR)
1548 {
1549 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], NULL, argv[3]);
1550 }
1551
1552 DEFUN (no_ip_route_flags_tag_vrf,
1553 no_ip_route_flags_tag_vrf_cmd,
1554 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1555 NO_STR
1556 IP_STR
1557 "Establish static routes\n"
1558 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1559 "IP gateway address\n"
1560 "IP gateway interface name\n"
1561 "Emit an ICMP unreachable when matched\n"
1562 "Silently discard pkts when matched\n"
1563 "Tag of this route\n"
1564 "Tag value\n"
1565 VRF_CMD_HELP_STR)
1566 {
1567 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], argv[3], NULL, argv[4]);
1568 }
1569
1570 DEFUN (no_ip_route_flags2_vrf,
1571 no_ip_route_flags2_vrf_cmd,
1572 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1573 NO_STR
1574 IP_STR
1575 "Establish static routes\n"
1576 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1577 "Emit an ICMP unreachable when matched\n"
1578 "Silently discard pkts when matched\n"
1579 VRF_CMD_HELP_STR)
1580 {
1581 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], NULL, NULL, argv[2]);
1582 }
1583
1584 DEFUN (no_ip_route_flags2_tag_vrf,
1585 no_ip_route_flags2_tag_vrf_cmd,
1586 "no ip route A.B.C.D/M (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1587 NO_STR
1588 IP_STR
1589 "Establish static routes\n"
1590 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1591 "Emit an ICMP unreachable when matched\n"
1592 "Silently discard pkts when matched\n"
1593 "Tag of this route\n"
1594 "Tag value\n"
1595 VRF_CMD_HELP_STR)
1596 {
1597 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], argv[2], NULL, argv[3]);
1598 }
1599
1600 DEFUN (no_ip_route_mask_vrf,
1601 no_ip_route_mask_vrf_cmd,
1602 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1603 NO_STR
1604 IP_STR
1605 "Establish static routes\n"
1606 "IP destination prefix\n"
1607 "IP destination prefix mask\n"
1608 "IP gateway address\n"
1609 "IP gateway interface name\n"
1610 "Null interface\n"
1611 VRF_CMD_HELP_STR)
1612 {
1613 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3]);
1614 }
1615
1616 DEFUN (no_ip_route_mask_flags_vrf,
1617 no_ip_route_mask_flags_vrf_cmd,
1618 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1619 NO_STR
1620 IP_STR
1621 "Establish static routes\n"
1622 "IP destination prefix\n"
1623 "IP destination prefix mask\n"
1624 "IP gateway address\n"
1625 "IP gateway interface name\n"
1626 "Emit an ICMP unreachable when matched\n"
1627 "Silently discard pkts when matched\n"
1628 VRF_CMD_HELP_STR)
1629 {
1630 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4]);
1631 }
1632
1633 DEFUN (no_ip_route_mask_tag_vrf,
1634 no_ip_route_mask_tag_vrf_cmd,
1635 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> " VRF_CMD_STR,
1636 NO_STR
1637 IP_STR
1638 "Establish static routes\n"
1639 "IP destination prefix\n"
1640 "IP destination prefix mask\n"
1641 "IP gateway address\n"
1642 "IP gateway interface name\n"
1643 "Null interface\n"
1644 "Tag of this route\n"
1645 "Tag value\n"
1646 VRF_CMD_HELP_STR)
1647 {
1648 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
1649 }
1650
1651 DEFUN (no_ip_route_mask_flags_tag_vrf,
1652 no_ip_route_mask_flags_tag_vrf_cmd,
1653 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1654 NO_STR
1655 IP_STR
1656 "Establish static routes\n"
1657 "IP destination prefix\n"
1658 "IP destination prefix mask\n"
1659 "IP gateway address\n"
1660 "IP gateway interface name\n"
1661 "Emit an ICMP unreachable when matched\n"
1662 "Silently discard pkts when matched\n"
1663 "Tag of this route\n"
1664 "Tag value\n"
1665 VRF_CMD_HELP_STR)
1666 {
1667 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5]);
1668 }
1669
1670 DEFUN (no_ip_route_mask_flags2_vrf,
1671 no_ip_route_mask_flags2_vrf_cmd,
1672 "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1673 NO_STR
1674 IP_STR
1675 "Establish static routes\n"
1676 "IP destination prefix\n"
1677 "IP destination prefix mask\n"
1678 "Emit an ICMP unreachable when matched\n"
1679 "Silently discard pkts when matched\n"
1680 VRF_CMD_HELP_STR)
1681 {
1682 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3]);
1683 }
1684
1685 DEFUN (no_ip_route_mask_flags2_tag_vrf,
1686 no_ip_route_mask_flags2_tag_vrf_cmd,
1687 "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
1688 NO_STR
1689 IP_STR
1690 "Establish static routes\n"
1691 "IP destination prefix\n"
1692 "IP destination prefix mask\n"
1693 "Emit an ICMP unreachable when matched\n"
1694 "Silently discard pkts when matched\n"
1695 "Tag of this route\n"
1696 "Tag value\n"
1697 VRF_CMD_HELP_STR)
1698 {
1699 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4]);
1700 }
1701
1702
1703 DEFUN (no_ip_route_distance_vrf,
1704 no_ip_route_distance_vrf_cmd,
1705 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1706 NO_STR
1707 IP_STR
1708 "Establish static routes\n"
1709 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1710 "IP gateway address\n"
1711 "IP gateway interface name\n"
1712 "Null interface\n"
1713 "Distance value for this route\n"
1714 VRF_CMD_HELP_STR)
1715 {
1716 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL, argv[2], argv[3]);
1717 }
1718
1719 DEFUN (no_ip_route_tag_distance_vrf,
1720 no_ip_route_tag_distance_vrf_cmd,
1721 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255> " VRF_CMD_STR,
1722 NO_STR
1723 IP_STR
1724 "Establish static routes\n"
1725 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1726 "IP gateway address\n"
1727 "IP gateway interface name\n"
1728 "Null interface\n"
1729 "Tag of this route\n"
1730 "Tag value\n"
1731 "Distance value for this route\n"
1732 VRF_CMD_HELP_STR)
1733 {
1734 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2], argv[3], argv[4]);
1735 }
1736
1737 DEFUN (no_ip_route_flags_distance_vrf,
1738 no_ip_route_flags_distance_vrf_cmd,
1739 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1740 NO_STR
1741 IP_STR
1742 "Establish static routes\n"
1743 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1744 "IP gateway address\n"
1745 "IP gateway interface name\n"
1746 "Emit an ICMP unreachable when matched\n"
1747 "Silently discard pkts when matched\n"
1748 "Distance value for this route\n"
1749 VRF_CMD_HELP_STR)
1750 {
1751 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], NULL, argv[3], argv[4]);
1752 }
1753
1754 DEFUN (no_ip_route_flags_tag_distance_vrf,
1755 no_ip_route_flags_tag_distance_vrf_cmd,
1756 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1757 NO_STR
1758 IP_STR
1759 "Establish static routes\n"
1760 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1761 "IP gateway address\n"
1762 "IP gateway interface name\n"
1763 "Emit an ICMP unreachable when matched\n"
1764 "Silently discard pkts when matched\n"
1765 "Tag of this route\n"
1766 "Tag value\n"
1767 "Distance value for this route\n"
1768 VRF_CMD_HELP_STR)
1769 {
1770 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], argv[2], argv[3], argv[4],argv[5]);
1771 }
1772
1773 DEFUN (no_ip_route_flags_distance2_vrf,
1774 no_ip_route_flags_distance2_vrf_cmd,
1775 "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1776 NO_STR
1777 IP_STR
1778 "Establish static routes\n"
1779 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1780 "Emit an ICMP unreachable when matched\n"
1781 "Silently discard pkts when matched\n"
1782 "Distance value for this route\n"
1783 VRF_CMD_HELP_STR)
1784 {
1785 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], NULL, argv[2], argv[3]);
1786 }
1787
1788 DEFUN (no_ip_route_flags_tag_distance2_vrf,
1789 no_ip_route_flags_tag_distance2_vrf_cmd,
1790 "no ip route A.B.C.D/M (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1791 NO_STR
1792 IP_STR
1793 "Establish static routes\n"
1794 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1795 "Emit an ICMP unreachable when matched\n"
1796 "Silently discard pkts when matched\n"
1797 "Tag of this route\n"
1798 "Tag value\n"
1799 "Distance value for this route\n"
1800 VRF_CMD_HELP_STR)
1801 {
1802 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, argv[1], argv[2] , argv[3], argv[4]);
1803 }
1804
1805 DEFUN (no_ip_route_mask_distance_vrf,
1806 no_ip_route_mask_distance_vrf_cmd,
1807 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1808 NO_STR
1809 IP_STR
1810 "Establish static routes\n"
1811 "IP destination prefix\n"
1812 "IP destination prefix mask\n"
1813 "IP gateway address\n"
1814 "IP gateway interface name\n"
1815 "Null interface\n"
1816 "Distance value for this route\n"
1817 VRF_CMD_HELP_STR)
1818 {
1819 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]);
1820 }
1821
1822 DEFUN (no_ip_route_mask_tag_distance_vrf,
1823 no_ip_route_mask_tag_distance_vrf_cmd,
1824 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-65535> <1-255> " VRF_CMD_STR,
1825 NO_STR
1826 IP_STR
1827 "Establish static routes\n"
1828 "IP destination prefix\n"
1829 "IP destination prefix mask\n"
1830 "IP gateway address\n"
1831 "IP gateway interface name\n"
1832 "Null interface\n"
1833 "Tag of this route\n"
1834 "Tag value\n"
1835 "Distance value for this route\n"
1836 VRF_CMD_HELP_STR)
1837 {
1838 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
1839 }
1840
1841 DEFUN (no_ip_route_mask_flags_distance_vrf,
1842 no_ip_route_mask_flags_distance_vrf_cmd,
1843 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1844 NO_STR
1845 IP_STR
1846 "Establish static routes\n"
1847 "IP destination prefix\n"
1848 "IP destination prefix mask\n"
1849 "IP gateway address\n"
1850 "IP gateway interface name\n"
1851 "Emit an ICMP unreachable when matched\n"
1852 "Silently discard pkts when matched\n"
1853 "Distance value for this route\n"
1854 VRF_CMD_HELP_STR)
1855 {
1856 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]);
1857 }
1858
1859 DEFUN (no_ip_route_mask_flags_tag_distance_vrf,
1860 no_ip_route_mask_flags_tag_distance_vrf_cmd,
1861 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1862 NO_STR
1863 IP_STR
1864 "Establish static routes\n"
1865 "IP destination prefix\n"
1866 "IP destination prefix mask\n"
1867 "IP gateway address\n"
1868 "IP gateway interface name\n"
1869 "Emit an ICMP unreachable when matched\n"
1870 "Silently discard pkts when matched\n"
1871 "Tag of this route\n"
1872 "Tag value\n"
1873 "Distance value for this route\n"
1874 VRF_CMD_HELP_STR)
1875 {
1876 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
1877 }
1878
1879 DEFUN (no_ip_route_mask_flags_distance2_vrf,
1880 no_ip_route_mask_flags_distance2_vrf_cmd,
1881 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1882 NO_STR
1883 IP_STR
1884 "Establish static routes\n"
1885 "IP destination prefix\n"
1886 "IP destination prefix mask\n"
1887 "Emit an ICMP unreachable when matched\n"
1888 "Silently discard pkts when matched\n"
1889 "Distance value for this route\n"
1890 VRF_CMD_HELP_STR)
1891 {
1892 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]);
1893 }
1894
1895 DEFUN (no_ip_route_mask_flags_tag_distance2_vrf,
1896 no_ip_route_mask_flags_tag_distance2_vrf_cmd,
1897 "no ip route A.B.C.D A.B.C.D (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
1898 NO_STR
1899 IP_STR
1900 "Establish static routes\n"
1901 "IP destination prefix\n"
1902 "IP destination prefix mask\n"
1903 "Emit an ICMP unreachable when matched\n"
1904 "Silently discard pkts when matched\n"
1905 "Tag of this route\n"
1906 "Tag value\n"
1907 "Distance value for this route\n"
1908 VRF_CMD_HELP_STR)
1909 {
1910 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
1911 }
1912
1913 /* New RIB. Detailed information for IPv4 route. */
1914 static void
1915 vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
1916 {
1917 struct rib *rib;
1918 struct nexthop *nexthop, *tnexthop;
1919 int recursing;
1920 char buf[PREFIX_STRLEN];
1921 struct zebra_vrf *zvrf;
1922
1923 RNODE_FOREACH_RIB (rn, rib)
1924 {
1925 const char *mcast_info = "";
1926 if (mcast)
1927 {
1928 rib_table_info_t *info = rn->table->info;
1929 mcast_info = (info->safi == SAFI_MULTICAST)
1930 ? " using Multicast RIB"
1931 : " using Unicast RIB";
1932 }
1933
1934 vty_out (vty, "Routing entry for %s%s%s",
1935 prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
1936 VTY_NEWLINE);
1937 vty_out (vty, " Known via \"%s", zebra_route_string (rib->type));
1938 if (rib->instance)
1939 vty_out (vty, "[%d]", rib->instance);
1940 vty_out (vty, "\"");
1941 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
1942 if (rib->tag)
1943 vty_out (vty, ", tag %d", rib->tag);
1944 if (rib->mtu)
1945 vty_out (vty, ", mtu %u", rib->mtu);
1946 if (rib->vrf_id != VRF_DEFAULT)
1947 {
1948 zvrf = vrf_info_lookup(rib->vrf_id);
1949 vty_out (vty, ", vrf %s", zvrf->name);
1950 }
1951 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
1952 vty_out (vty, ", best");
1953 if (rib->refcnt)
1954 vty_out (vty, ", refcnt %ld", rib->refcnt);
1955 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1956 vty_out (vty, ", blackhole");
1957 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1958 vty_out (vty, ", reject");
1959 vty_out (vty, "%s", VTY_NEWLINE);
1960
1961 if (rib->type == ZEBRA_ROUTE_RIP
1962 || rib->type == ZEBRA_ROUTE_OSPF
1963 || rib->type == ZEBRA_ROUTE_ISIS
1964 || rib->type == ZEBRA_ROUTE_TABLE
1965 || rib->type == ZEBRA_ROUTE_BGP)
1966 {
1967 time_t uptime;
1968 struct tm *tm;
1969
1970 uptime = time (NULL);
1971 uptime -= rib->uptime;
1972 tm = gmtime (&uptime);
1973
1974 vty_out (vty, " Last update ");
1975
1976 if (uptime < ONE_DAY_SECOND)
1977 vty_out (vty, "%02d:%02d:%02d",
1978 tm->tm_hour, tm->tm_min, tm->tm_sec);
1979 else if (uptime < ONE_WEEK_SECOND)
1980 vty_out (vty, "%dd%02dh%02dm",
1981 tm->tm_yday, tm->tm_hour, tm->tm_min);
1982 else
1983 vty_out (vty, "%02dw%dd%02dh",
1984 tm->tm_yday/7,
1985 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1986 vty_out (vty, " ago%s", VTY_NEWLINE);
1987 }
1988
1989 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
1990 {
1991 char addrstr[32];
1992
1993 vty_out (vty, " %c%s",
1994 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1995 recursing ? " " : "");
1996
1997 switch (nexthop->type)
1998 {
1999 case NEXTHOP_TYPE_IPV4:
2000 case NEXTHOP_TYPE_IPV4_IFINDEX:
2001 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
2002 if (nexthop->ifindex)
2003 vty_out (vty, ", via %s",
2004 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2005 break;
2006 case NEXTHOP_TYPE_IPV6:
2007 case NEXTHOP_TYPE_IPV6_IFINDEX:
2008 vty_out (vty, " %s",
2009 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
2010 if (nexthop->ifindex)
2011 vty_out (vty, ", via %s",
2012 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2013 break;
2014 case NEXTHOP_TYPE_IFINDEX:
2015 vty_out (vty, " directly connected, %s",
2016 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2017 break;
2018 case NEXTHOP_TYPE_BLACKHOLE:
2019 vty_out (vty, " directly connected, Null0");
2020 break;
2021 default:
2022 break;
2023 }
2024 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2025 vty_out (vty, " inactive");
2026
2027 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
2028 vty_out (vty, " onlink");
2029
2030 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
2031 vty_out (vty, " (recursive)");
2032
2033 switch (nexthop->type)
2034 {
2035 case NEXTHOP_TYPE_IPV4:
2036 case NEXTHOP_TYPE_IPV4_IFINDEX:
2037 if (nexthop->src.ipv4.s_addr)
2038 {
2039 if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
2040 sizeof addrstr))
2041 vty_out (vty, ", src %s", addrstr);
2042 }
2043 break;
2044 case NEXTHOP_TYPE_IPV6:
2045 case NEXTHOP_TYPE_IPV6_IFINDEX:
2046 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
2047 {
2048 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
2049 sizeof addrstr))
2050 vty_out (vty, ", src %s", addrstr);
2051 }
2052 break;
2053 default:
2054 break;
2055 }
2056 vty_out (vty, "%s", VTY_NEWLINE);
2057 }
2058 vty_out (vty, "%s", VTY_NEWLINE);
2059 }
2060 }
2061
2062 static void
2063 vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
2064 json_object *json)
2065 {
2066 struct nexthop *nexthop, *tnexthop;
2067 int recursing;
2068 int len = 0;
2069 char buf[BUFSIZ];
2070 json_object *json_nexthops = NULL;
2071 json_object *json_nexthop = NULL;
2072 json_object *json_route = NULL;
2073
2074 if (json)
2075 {
2076 json_route = json_object_new_object();
2077 json_nexthops = json_object_new_array();
2078
2079 json_object_string_add(json_route, "prefix", prefix2str (&rn->p, buf, sizeof buf));
2080 json_object_string_add(json_route, "protocol", zebra_route_string(rib->type));
2081
2082 if (rib->instance)
2083 json_object_int_add(json_route, "instance", rib->instance);
2084
2085 if (rib->vrf_id)
2086 json_object_int_add(json_route, "vrfId", rib->vrf_id);
2087
2088 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
2089 json_object_boolean_true_add(json_route, "selected");
2090
2091 if (rib->type != ZEBRA_ROUTE_CONNECT && rib->type != ZEBRA_ROUTE_KERNEL)
2092 {
2093 json_object_int_add(json_route, "distance", rib->distance);
2094 json_object_int_add(json_route, "metric", rib->metric);
2095 }
2096
2097 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
2098 json_object_boolean_true_add(json_route, "blackhole");
2099
2100 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
2101 json_object_boolean_true_add(json_route, "reject");
2102
2103 if (rib->type == ZEBRA_ROUTE_RIP
2104 || rib->type == ZEBRA_ROUTE_OSPF
2105 || rib->type == ZEBRA_ROUTE_ISIS
2106 || rib->type == ZEBRA_ROUTE_TABLE
2107 || rib->type == ZEBRA_ROUTE_BGP)
2108 {
2109 time_t uptime;
2110 struct tm *tm;
2111
2112 uptime = time (NULL);
2113 uptime -= rib->uptime;
2114 tm = gmtime (&uptime);
2115
2116 if (uptime < ONE_DAY_SECOND)
2117 sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
2118 else if (uptime < ONE_WEEK_SECOND)
2119 sprintf(buf, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, tm->tm_min);
2120 else
2121 sprintf(buf, "%02dw%dd%02dh", tm->tm_yday/7, tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
2122
2123 json_object_string_add(json_route, "uptime", buf);
2124 }
2125
2126 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
2127 {
2128 json_nexthop = json_object_new_object();
2129
2130 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2131 json_object_boolean_true_add(json_nexthop, "fib");
2132
2133 switch (nexthop->type)
2134 {
2135 case NEXTHOP_TYPE_IPV4:
2136 case NEXTHOP_TYPE_IPV4_IFINDEX:
2137 json_object_string_add(json_nexthop, "ip", inet_ntoa (nexthop->gate.ipv4));
2138 json_object_string_add(json_nexthop, "afi", "ipv4");
2139
2140 if (nexthop->ifindex)
2141 {
2142 json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
2143 json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2144 }
2145 break;
2146 case NEXTHOP_TYPE_IPV6:
2147 case NEXTHOP_TYPE_IPV6_IFINDEX:
2148 json_object_string_add(json_nexthop, "ip", inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
2149 json_object_string_add(json_nexthop, "afi", "ipv6");
2150
2151 if (nexthop->ifindex)
2152 {
2153 json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
2154 json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2155 }
2156 break;
2157
2158 case NEXTHOP_TYPE_IFINDEX:
2159 json_object_boolean_true_add(json_nexthop, "directlyConnected");
2160 json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex);
2161 json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2162 break;
2163 case NEXTHOP_TYPE_BLACKHOLE:
2164 json_object_boolean_true_add(json_nexthop, "blackhole");
2165 break;
2166 default:
2167 break;
2168 }
2169
2170 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2171 json_object_boolean_true_add(json_nexthop, "active");
2172
2173 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
2174 json_object_boolean_true_add(json_nexthop, "onLink");
2175
2176 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
2177 json_object_boolean_true_add(json_nexthop, "recursive");
2178
2179 switch (nexthop->type)
2180 {
2181 case NEXTHOP_TYPE_IPV4:
2182 case NEXTHOP_TYPE_IPV4_IFINDEX:
2183 if (nexthop->src.ipv4.s_addr)
2184 {
2185 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
2186 json_object_string_add(json_nexthop, "source", buf);
2187 }
2188 break;
2189 case NEXTHOP_TYPE_IPV6:
2190 case NEXTHOP_TYPE_IPV6_IFINDEX:
2191 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
2192 {
2193 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
2194 json_object_string_add(json_nexthop, "source", buf);
2195 }
2196 break;
2197 default:
2198 break;
2199 }
2200
2201 json_object_array_add(json_nexthops, json_nexthop);
2202 }
2203
2204 json_object_object_add(json_route, "nexthops", json_nexthops);
2205 json_object_array_add(json, json_route);
2206 return;
2207 }
2208
2209 /* Nexthop information. */
2210 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
2211 {
2212 if (nexthop == rib->nexthop)
2213 {
2214 /* Prefix information. */
2215 len = vty_out (vty, "%c", zebra_route_char (rib->type));
2216 if (rib->instance)
2217 len += vty_out (vty, "[%d]", rib->instance);
2218 len += vty_out (vty, "%c%c %s",
2219 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
2220 ? '>' : ' ',
2221 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2222 ? '*' : ' ',
2223 prefix2str (&rn->p, buf, sizeof buf));
2224
2225 /* Distance and metric display. */
2226 if (rib->type != ZEBRA_ROUTE_CONNECT
2227 && rib->type != ZEBRA_ROUTE_KERNEL)
2228 len += vty_out (vty, " [%d/%d]", rib->distance,
2229 rib->metric);
2230 }
2231 else
2232 vty_out (vty, " %c%*c",
2233 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
2234 ? '*' : ' ',
2235 len - 3 + (2 * recursing), ' ');
2236
2237 switch (nexthop->type)
2238 {
2239 case NEXTHOP_TYPE_IPV4:
2240 case NEXTHOP_TYPE_IPV4_IFINDEX:
2241 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
2242 if (nexthop->ifindex)
2243 vty_out (vty, ", %s",
2244 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2245 break;
2246 case NEXTHOP_TYPE_IPV6:
2247 case NEXTHOP_TYPE_IPV6_IFINDEX:
2248 vty_out (vty, " via %s",
2249 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
2250 if (nexthop->ifindex)
2251 vty_out (vty, ", %s",
2252 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2253 break;
2254
2255 case NEXTHOP_TYPE_IFINDEX:
2256 vty_out (vty, " is directly connected, %s",
2257 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
2258 break;
2259 case NEXTHOP_TYPE_BLACKHOLE:
2260 vty_out (vty, " is directly connected, Null0");
2261 break;
2262 default:
2263 break;
2264 }
2265 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
2266 vty_out (vty, " inactive");
2267
2268 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
2269 vty_out (vty, " onlink");
2270
2271 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
2272 vty_out (vty, " (recursive)");
2273
2274 switch (nexthop->type)
2275 {
2276 case NEXTHOP_TYPE_IPV4:
2277 case NEXTHOP_TYPE_IPV4_IFINDEX:
2278 if (nexthop->src.ipv4.s_addr)
2279 {
2280 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
2281 vty_out (vty, ", src %s", buf);
2282 }
2283 break;
2284 case NEXTHOP_TYPE_IPV6:
2285 case NEXTHOP_TYPE_IPV6_IFINDEX:
2286 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
2287 {
2288 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
2289 vty_out (vty, ", src %s", buf);
2290 }
2291 break;
2292 default:
2293 break;
2294 }
2295
2296 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
2297 vty_out (vty, ", bh");
2298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
2299 vty_out (vty, ", rej");
2300
2301 if (rib->type == ZEBRA_ROUTE_RIP
2302 || rib->type == ZEBRA_ROUTE_OSPF
2303 || rib->type == ZEBRA_ROUTE_ISIS
2304 || rib->type == ZEBRA_ROUTE_TABLE
2305 || rib->type == ZEBRA_ROUTE_BGP)
2306 {
2307 time_t uptime;
2308 struct tm *tm;
2309
2310 uptime = time (NULL);
2311 uptime -= rib->uptime;
2312 tm = gmtime (&uptime);
2313
2314 if (uptime < ONE_DAY_SECOND)
2315 vty_out (vty, ", %02d:%02d:%02d",
2316 tm->tm_hour, tm->tm_min, tm->tm_sec);
2317 else if (uptime < ONE_WEEK_SECOND)
2318 vty_out (vty, ", %dd%02dh%02dm",
2319 tm->tm_yday, tm->tm_hour, tm->tm_min);
2320 else
2321 vty_out (vty, ", %02dw%dd%02dh",
2322 tm->tm_yday/7,
2323 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
2324 }
2325 vty_out (vty, "%s", VTY_NEWLINE);
2326 }
2327 }
2328
2329 DEFUN (show_ip_route,
2330 show_ip_route_cmd,
2331 "show ip route {json}",
2332 SHOW_STR
2333 IP_STR
2334 "IP routing table\n")
2335 {
2336 return do_show_ip_route (vty, VRF_DEFAULT_NAME, SAFI_UNICAST, use_json(argc, argv));
2337 }
2338
2339 static int
2340 do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi,
2341 u_char use_json)
2342 {
2343 struct route_table *table;
2344 struct route_node *rn;
2345 struct rib *rib;
2346 int first = 1;
2347 struct zebra_vrf *zvrf = NULL;
2348 char buf[BUFSIZ];
2349 json_object *json = NULL;
2350 json_object *json_prefix = NULL;
2351
2352 if (!(zvrf = zebra_vrf_list_lookup_by_name (vrf_name)))
2353 {
2354 if (use_json)
2355 vty_out (vty, "{}%s", VTY_NEWLINE);
2356 else
2357 vty_out (vty, "vrf %s not defined%s", vrf_name, VTY_NEWLINE);
2358 return CMD_SUCCESS;
2359 }
2360
2361 if (zvrf->vrf_id == VRF_UNKNOWN)
2362 {
2363 if (use_json)
2364 vty_out (vty, "{}%s", VTY_NEWLINE);
2365 else
2366 vty_out (vty, "vrf %s inactive%s", vrf_name, VTY_NEWLINE);
2367 return CMD_SUCCESS;
2368 }
2369
2370 table = zebra_vrf_table (AFI_IP, safi, zvrf->vrf_id);
2371 if (! table)
2372 {
2373 if (use_json)
2374 vty_out (vty, "{}%s", VTY_NEWLINE);
2375 return CMD_SUCCESS;
2376 }
2377
2378 if (use_json)
2379 {
2380 json = json_object_new_object();
2381
2382 /* Show all IPv4 routes. */
2383 for (rn = route_top (table); rn; rn = route_next (rn))
2384 {
2385 RNODE_FOREACH_RIB (rn, rib)
2386 {
2387 if (!json_prefix)
2388 json_prefix = json_object_new_array();
2389 vty_show_ip_route (vty, rn, rib, json_prefix);
2390 }
2391
2392 if (json_prefix)
2393 {
2394 prefix2str (&rn->p, buf, sizeof buf);
2395 json_object_object_add(json, buf, json_prefix);
2396 json_prefix = NULL;
2397 }
2398 }
2399
2400 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
2401 json_object_free(json);
2402 }
2403 else
2404 {
2405 /* Show all IPv4 routes. */
2406 for (rn = route_top (table); rn; rn = route_next (rn))
2407 {
2408 RNODE_FOREACH_RIB (rn, rib)
2409 {
2410 if (first)
2411 {
2412 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2413 first = 0;
2414 }
2415 vty_show_ip_route (vty, rn, rib, NULL);
2416 }
2417 }
2418 }
2419
2420 return CMD_SUCCESS;
2421 }
2422
2423 DEFUN (show_ip_route_vrf,
2424 show_ip_route_vrf_cmd,
2425 "show ip route " VRF_CMD_STR " {json}",
2426 SHOW_STR
2427 IP_STR
2428 "IP routing table\n"
2429 VRF_CMD_HELP_STR)
2430 {
2431 u_char uj = use_json(argc, argv);
2432
2433 if (argc == 1 && uj)
2434 return do_show_ip_route (vty, NULL, SAFI_UNICAST, uj);
2435 else
2436 return do_show_ip_route (vty, argv[0], SAFI_UNICAST, uj);
2437 }
2438
2439 DEFUN (show_ip_nht,
2440 show_ip_nht_cmd,
2441 "show ip nht",
2442 SHOW_STR
2443 IP_STR
2444 "IP nexthop tracking table\n")
2445 {
2446 vrf_id_t vrf_id = VRF_DEFAULT;
2447
2448 if (argc)
2449 VRF_GET_ID (vrf_id, argv[0]);
2450
2451 zebra_print_rnh_table(vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE);
2452 return CMD_SUCCESS;
2453 }
2454
2455 ALIAS (show_ip_nht,
2456 show_ip_nht_vrf_cmd,
2457 "show ip nht " VRF_CMD_STR,
2458 SHOW_STR
2459 IP_STR
2460 "IP nexthop tracking table\n"
2461 VRF_CMD_HELP_STR)
2462
2463 DEFUN (show_ip_nht_vrf_all,
2464 show_ip_nht_vrf_all_cmd,
2465 "show ip nht " VRF_ALL_CMD_STR,
2466 SHOW_STR
2467 IP_STR
2468 "IP nexthop tracking table\n"
2469 VRF_ALL_CMD_HELP_STR)
2470 {
2471 struct zebra_vrf *zvrf;
2472 vrf_iter_t iter;
2473
2474 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2475 if ((zvrf = vrf_iter2info (iter)) != NULL)
2476 {
2477 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
2478 zebra_print_rnh_table(zvrf->vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE);
2479 }
2480
2481 return CMD_SUCCESS;
2482 }
2483
2484 DEFUN (show_ipv6_nht,
2485 show_ipv6_nht_cmd,
2486 "show ipv6 nht",
2487 SHOW_STR
2488 IPV6_STR
2489 "IPv6 nexthop tracking table\n")
2490 {
2491 vrf_id_t vrf_id = VRF_DEFAULT;
2492
2493 if (argc)
2494 VRF_GET_ID (vrf_id, argv[0]);
2495
2496 zebra_print_rnh_table(vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE);
2497 return CMD_SUCCESS;
2498 }
2499
2500 ALIAS (show_ipv6_nht,
2501 show_ipv6_nht_vrf_cmd,
2502 "show ipv6 nht " VRF_CMD_STR,
2503 SHOW_STR
2504 IPV6_STR
2505 "IPv6 nexthop tracking table\n"
2506 VRF_CMD_HELP_STR)
2507
2508 DEFUN (show_ipv6_nht_vrf_all,
2509 show_ipv6_nht_vrf_all_cmd,
2510 "show ipv6 nht " VRF_ALL_CMD_STR,
2511 SHOW_STR
2512 IP_STR
2513 "IPv6 nexthop tracking table\n"
2514 VRF_ALL_CMD_HELP_STR)
2515 {
2516 struct zebra_vrf *zvrf;
2517 vrf_iter_t iter;
2518
2519 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2520 if ((zvrf = vrf_iter2info (iter)) != NULL)
2521 {
2522 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
2523 zebra_print_rnh_table(zvrf->vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE);
2524 }
2525
2526 return CMD_SUCCESS;
2527 }
2528
2529 DEFUN (ip_nht_default_route,
2530 ip_nht_default_route_cmd,
2531 "ip nht resolve-via-default",
2532 IP_STR
2533 "Filter Next Hop tracking route resolution\n"
2534 "Resolve via default route\n")
2535 {
2536 if (zebra_rnh_ip_default_route)
2537 return CMD_SUCCESS;
2538
2539 zebra_rnh_ip_default_route = 1;
2540 zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
2541 return CMD_SUCCESS;
2542 }
2543
2544 DEFUN (no_ip_nht_default_route,
2545 no_ip_nht_default_route_cmd,
2546 "no ip nht resolve-via-default",
2547 NO_STR
2548 IP_STR
2549 "Filter Next Hop tracking route resolution\n"
2550 "Resolve via default route\n")
2551 {
2552 if (!zebra_rnh_ip_default_route)
2553 return CMD_SUCCESS;
2554
2555 zebra_rnh_ip_default_route = 0;
2556 zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
2557 return CMD_SUCCESS;
2558 }
2559
2560 DEFUN (ipv6_nht_default_route,
2561 ipv6_nht_default_route_cmd,
2562 "ipv6 nht resolve-via-default",
2563 IP6_STR
2564 "Filter Next Hop tracking route resolution\n"
2565 "Resolve via default route\n")
2566 {
2567 if (zebra_rnh_ipv6_default_route)
2568 return CMD_SUCCESS;
2569
2570 zebra_rnh_ipv6_default_route = 1;
2571 zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
2572 return CMD_SUCCESS;
2573 }
2574
2575 DEFUN (no_ipv6_nht_default_route,
2576 no_ipv6_nht_default_route_cmd,
2577 "no ipv6 nht resolve-via-default",
2578 NO_STR
2579 IP6_STR
2580 "Filter Next Hop tracking route resolution\n"
2581 "Resolve via default route\n")
2582 {
2583 if (!zebra_rnh_ipv6_default_route)
2584 return CMD_SUCCESS;
2585
2586 zebra_rnh_ipv6_default_route = 0;
2587 zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
2588 return CMD_SUCCESS;
2589 }
2590
2591 DEFUN (show_ip_route_tag,
2592 show_ip_route_tag_cmd,
2593 "show ip route tag <1-65535>",
2594 SHOW_STR
2595 IP_STR
2596 "IP routing table\n"
2597 "Show only routes with tag\n"
2598 "Tag value\n")
2599 {
2600 struct route_table *table;
2601 struct route_node *rn;
2602 struct rib *rib;
2603 int first = 1;
2604 u_short tag = 0;
2605 vrf_id_t vrf_id = VRF_DEFAULT;
2606
2607 if (argc > 1)
2608 {
2609 tag = atoi(argv[1]);
2610 VRF_GET_ID (vrf_id, argv[0]);
2611 }
2612 else
2613 tag = atoi(argv[0]);
2614
2615 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2616 if (! table)
2617 return CMD_SUCCESS;
2618
2619 /* Show all IPv4 routes with matching tag value. */
2620 for (rn = route_top (table); rn; rn = route_next (rn))
2621 RNODE_FOREACH_RIB (rn, rib)
2622 {
2623 if (rib->tag != tag)
2624 continue;
2625
2626 if (first)
2627 {
2628 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2629 first = 0;
2630 }
2631 vty_show_ip_route (vty, rn, rib, NULL);
2632 }
2633 return CMD_SUCCESS;
2634 }
2635
2636 ALIAS (show_ip_route_tag,
2637 show_ip_route_vrf_tag_cmd,
2638 "show ip route " VRF_CMD_STR " tag <1-65535>",
2639 SHOW_STR
2640 IP_STR
2641 "IP routing table\n"
2642 VRF_CMD_HELP_STR
2643 "Show only routes with tag\n"
2644 "Tag value\n")
2645
2646 DEFUN (show_ip_route_prefix_longer,
2647 show_ip_route_prefix_longer_cmd,
2648 "show ip route A.B.C.D/M longer-prefixes",
2649 SHOW_STR
2650 IP_STR
2651 "IP routing table\n"
2652 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2653 "Show route matching the specified Network/Mask pair only\n")
2654 {
2655 struct route_table *table;
2656 struct route_node *rn;
2657 struct rib *rib;
2658 struct prefix p;
2659 int ret;
2660 int first = 1;
2661 vrf_id_t vrf_id = VRF_DEFAULT;
2662
2663 if (argc > 1)
2664 {
2665 ret = str2prefix (argv[1], &p);
2666 VRF_GET_ID (vrf_id, argv[0]);
2667 }
2668 else
2669 ret = str2prefix (argv[0], &p);
2670
2671 if (! ret)
2672 {
2673 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2674 return CMD_WARNING;
2675 }
2676
2677 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2678 if (! table)
2679 return CMD_SUCCESS;
2680
2681 /* Show matched type IPv4 routes. */
2682 for (rn = route_top (table); rn; rn = route_next (rn))
2683 RNODE_FOREACH_RIB (rn, rib)
2684 if (prefix_match (&p, &rn->p))
2685 {
2686 if (first)
2687 {
2688 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2689 first = 0;
2690 }
2691 vty_show_ip_route (vty, rn, rib, NULL);
2692 }
2693 return CMD_SUCCESS;
2694 }
2695
2696 ALIAS (show_ip_route_prefix_longer,
2697 show_ip_route_vrf_prefix_longer_cmd,
2698 "show ip route " VRF_CMD_STR " A.B.C.D/M longer-prefixes",
2699 SHOW_STR
2700 IP_STR
2701 "IP routing table\n"
2702 VRF_CMD_HELP_STR
2703 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2704 "Show route matching the specified Network/Mask pair only\n")
2705
2706 DEFUN (show_ip_route_supernets,
2707 show_ip_route_supernets_cmd,
2708 "show ip route supernets-only",
2709 SHOW_STR
2710 IP_STR
2711 "IP routing table\n"
2712 "Show supernet entries only\n")
2713 {
2714 struct route_table *table;
2715 struct route_node *rn;
2716 struct rib *rib;
2717 u_int32_t addr;
2718 int first = 1;
2719 vrf_id_t vrf_id = VRF_DEFAULT;
2720
2721 if (argc > 0)
2722 VRF_GET_ID (vrf_id, argv[0]);
2723
2724 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2725 if (! table)
2726 return CMD_SUCCESS;
2727
2728 /* Show matched type IPv4 routes. */
2729 for (rn = route_top (table); rn; rn = route_next (rn))
2730 RNODE_FOREACH_RIB (rn, rib)
2731 {
2732 addr = ntohl (rn->p.u.prefix4.s_addr);
2733
2734 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2735 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2736 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2737 {
2738 if (first)
2739 {
2740 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2741 first = 0;
2742 }
2743 vty_show_ip_route (vty, rn, rib, NULL);
2744 }
2745 }
2746 return CMD_SUCCESS;
2747 }
2748
2749 ALIAS (show_ip_route_supernets,
2750 show_ip_route_vrf_supernets_cmd,
2751 "show ip route " VRF_CMD_STR " supernets-only",
2752 SHOW_STR
2753 IP_STR
2754 "IP routing table\n"
2755 VRF_CMD_HELP_STR
2756 "Show supernet entries only\n")
2757
2758 DEFUN (show_ip_route_protocol,
2759 show_ip_route_protocol_cmd,
2760 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
2761 SHOW_STR
2762 IP_STR
2763 "IP routing table\n"
2764 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
2765 {
2766 int type;
2767 struct route_table *table;
2768 struct route_node *rn;
2769 struct rib *rib;
2770 int first = 1;
2771 vrf_id_t vrf_id = VRF_DEFAULT;
2772
2773 if (argc > 1)
2774 {
2775 type = proto_redistnum (AFI_IP, argv[1]);
2776 VRF_GET_ID (vrf_id, argv[0]);
2777 }
2778 else
2779 type = proto_redistnum (AFI_IP, argv[0]);
2780
2781 if (type < 0)
2782 {
2783 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2784 return CMD_WARNING;
2785 }
2786
2787 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2788 if (! table)
2789 return CMD_SUCCESS;
2790
2791 /* Show matched type IPv4 routes. */
2792 for (rn = route_top (table); rn; rn = route_next (rn))
2793 RNODE_FOREACH_RIB (rn, rib)
2794 if (rib->type == type)
2795 {
2796 if (first)
2797 {
2798 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2799 first = 0;
2800 }
2801 vty_show_ip_route (vty, rn, rib, NULL);
2802 }
2803 return CMD_SUCCESS;
2804 }
2805
2806 ALIAS (show_ip_route_protocol,
2807 show_ip_route_vrf_protocol_cmd,
2808 "show ip route " VRF_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA,
2809 SHOW_STR
2810 IP_STR
2811 "IP routing table\n"
2812 VRF_CMD_HELP_STR
2813 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
2814
2815 DEFUN (show_ip_route_ospf_instance,
2816 show_ip_route_ospf_instance_cmd,
2817 "show ip route ospf <1-65535>",
2818 SHOW_STR
2819 IP_STR
2820 "IP routing table\n"
2821 "Open Shortest Path First (OSPFv2)\n"
2822 "Instance ID\n")
2823 {
2824 struct route_table *table;
2825 struct route_node *rn;
2826 struct rib *rib;
2827 int first = 1;
2828 u_short instance = 0;
2829
2830 VTY_GET_INTEGER ("Instance", instance, argv[0]);
2831
2832 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT);
2833 if (! table)
2834 return CMD_SUCCESS;
2835
2836 /* Show matched type IPv4 routes. */
2837 for (rn = route_top (table); rn; rn = route_next (rn))
2838 RNODE_FOREACH_RIB (rn, rib)
2839 if (rib->type == ZEBRA_ROUTE_OSPF && rib->instance == instance)
2840 {
2841 if (first)
2842 {
2843 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2844 first = 0;
2845 }
2846 vty_show_ip_route (vty, rn, rib, NULL);
2847 }
2848 return CMD_SUCCESS;
2849 }
2850
2851 DEFUN (show_ip_route_addr,
2852 show_ip_route_addr_cmd,
2853 "show ip route A.B.C.D",
2854 SHOW_STR
2855 IP_STR
2856 "IP routing table\n"
2857 "Network in the IP routing table to display\n")
2858 {
2859 int ret;
2860 struct prefix_ipv4 p;
2861 struct route_table *table;
2862 struct route_node *rn;
2863 vrf_id_t vrf_id = VRF_DEFAULT;
2864
2865 if (argc > 1)
2866 {
2867 VRF_GET_ID (vrf_id, argv[0]);
2868 ret = str2prefix_ipv4 (argv[1], &p);
2869 }
2870 else
2871 ret = str2prefix_ipv4 (argv[0], &p);
2872
2873 if (ret <= 0)
2874 {
2875 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2876 return CMD_WARNING;
2877 }
2878
2879 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2880 if (! table)
2881 return CMD_SUCCESS;
2882
2883 rn = route_node_match (table, (struct prefix *) &p);
2884 if (! rn)
2885 {
2886 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2887 return CMD_WARNING;
2888 }
2889
2890 vty_show_ip_route_detail (vty, rn, 0);
2891
2892 route_unlock_node (rn);
2893
2894 return CMD_SUCCESS;
2895 }
2896
2897 ALIAS (show_ip_route_addr,
2898 show_ip_route_vrf_addr_cmd,
2899 "show ip route " VRF_CMD_STR " A.B.C.D",
2900 SHOW_STR
2901 IP_STR
2902 "IP routing table\n"
2903 VRF_CMD_HELP_STR
2904 "Network in the IP routing table to display\n")
2905
2906 DEFUN (show_ip_route_prefix,
2907 show_ip_route_prefix_cmd,
2908 "show ip route A.B.C.D/M",
2909 SHOW_STR
2910 IP_STR
2911 "IP routing table\n"
2912 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2913 {
2914 int ret;
2915 struct prefix_ipv4 p;
2916 struct route_table *table;
2917 struct route_node *rn;
2918 vrf_id_t vrf_id = VRF_DEFAULT;
2919
2920 if (argc > 1)
2921 {
2922 VRF_GET_ID (vrf_id, argv[0]);
2923 ret = str2prefix_ipv4 (argv[1], &p);
2924 }
2925 else
2926 ret = str2prefix_ipv4 (argv[0], &p);
2927
2928 if (ret <= 0)
2929 {
2930 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2931 return CMD_WARNING;
2932 }
2933
2934 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
2935 if (! table)
2936 return CMD_SUCCESS;
2937
2938 rn = route_node_match (table, (struct prefix *) &p);
2939 if (! rn || rn->p.prefixlen != p.prefixlen)
2940 {
2941 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2942 return CMD_WARNING;
2943 }
2944
2945 vty_show_ip_route_detail (vty, rn, 0);
2946
2947 route_unlock_node (rn);
2948
2949 return CMD_SUCCESS;
2950 }
2951
2952 ALIAS (show_ip_route_prefix,
2953 show_ip_route_vrf_prefix_cmd,
2954 "show ip route " VRF_CMD_STR " A.B.C.D/M",
2955 SHOW_STR
2956 IP_STR
2957 "IP routing table\n"
2958 VRF_CMD_HELP_STR
2959 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2960
2961 static void
2962 vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
2963 {
2964 struct route_node *rn;
2965 struct rib *rib;
2966 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
2967 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
2968 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2969 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
2970 u_int32_t i;
2971 u_int32_t is_ibgp;
2972
2973 memset (&rib_cnt, 0, sizeof(rib_cnt));
2974 memset (&fib_cnt, 0, sizeof(fib_cnt));
2975 for (rn = route_top (table); rn; rn = route_next (rn))
2976 RNODE_FOREACH_RIB (rn, rib)
2977 {
2978 is_ibgp = (rib->type == ZEBRA_ROUTE_BGP &&
2979 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP));
2980
2981 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
2982 if (is_ibgp)
2983 rib_cnt[ZEBRA_ROUTE_IBGP]++;
2984 else
2985 rib_cnt[rib->type]++;
2986
2987 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
2988 {
2989 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
2990
2991 if (is_ibgp)
2992 fib_cnt[ZEBRA_ROUTE_IBGP]++;
2993 else
2994 fib_cnt[rib->type]++;
2995 }
2996 }
2997
2998 vty_out (vty, "%-20s %-20s %s (vrf %s)%s",
2999 "Route Source", "Routes", "FIB",
3000 ((rib_table_info_t *)table->info)->zvrf->name,
3001 VTY_NEWLINE);
3002
3003 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
3004 {
3005 if ((rib_cnt[i] > 0) ||
3006 (i == ZEBRA_ROUTE_BGP && rib_cnt[ZEBRA_ROUTE_IBGP] > 0))
3007 {
3008 if (i == ZEBRA_ROUTE_BGP)
3009 {
3010 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
3011 rib_cnt[ZEBRA_ROUTE_BGP], fib_cnt[ZEBRA_ROUTE_BGP],
3012 VTY_NEWLINE);
3013 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
3014 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
3015 VTY_NEWLINE);
3016 }
3017 else
3018 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
3019 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
3020 }
3021 }
3022
3023 vty_out (vty, "------%s", VTY_NEWLINE);
3024 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
3025 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
3026 vty_out (vty, "%s", VTY_NEWLINE);
3027 }
3028
3029 /*
3030 * Implementation of the ip route summary prefix command.
3031 *
3032 * This command prints the primary prefixes that have been installed by various
3033 * protocols on the box.
3034 *
3035 */
3036 static void
3037 vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
3038 {
3039 struct route_node *rn;
3040 struct rib *rib;
3041 struct nexthop *nexthop;
3042 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
3043 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
3044 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
3045 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
3046 u_int32_t i;
3047 int cnt;
3048
3049 memset (&rib_cnt, 0, sizeof(rib_cnt));
3050 memset (&fib_cnt, 0, sizeof(fib_cnt));
3051 for (rn = route_top (table); rn; rn = route_next (rn))
3052 RNODE_FOREACH_RIB (rn, rib)
3053 {
3054
3055 /*
3056 * In case of ECMP, count only once.
3057 */
3058 cnt = 0;
3059 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
3060 {
3061 cnt++;
3062 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
3063 rib_cnt[rib->type]++;
3064 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
3065 {
3066 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
3067 fib_cnt[rib->type]++;
3068 }
3069 if (rib->type == ZEBRA_ROUTE_BGP &&
3070 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
3071 {
3072 rib_cnt[ZEBRA_ROUTE_IBGP]++;
3073 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
3074 fib_cnt[ZEBRA_ROUTE_IBGP]++;
3075 }
3076 }
3077 }
3078
3079 vty_out (vty, "%-20s %-20s %s (vrf %s)%s",
3080 "Route Source", "Prefix Routes", "FIB",
3081 ((rib_table_info_t *)table->info)->zvrf->name,
3082 VTY_NEWLINE);
3083
3084 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
3085 {
3086 if (rib_cnt[i] > 0)
3087 {
3088 if (i == ZEBRA_ROUTE_BGP)
3089 {
3090 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
3091 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
3092 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
3093 VTY_NEWLINE);
3094 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
3095 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
3096 VTY_NEWLINE);
3097 }
3098 else
3099 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
3100 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
3101 }
3102 }
3103
3104 vty_out (vty, "------%s", VTY_NEWLINE);
3105 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
3106 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
3107 vty_out (vty, "%s", VTY_NEWLINE);
3108 }
3109
3110 /* Show route summary. */
3111 DEFUN (show_ip_route_summary,
3112 show_ip_route_summary_cmd,
3113 "show ip route summary",
3114 SHOW_STR
3115 IP_STR
3116 "IP routing table\n"
3117 "Summary of all routes\n")
3118 {
3119 struct route_table *table;
3120 vrf_id_t vrf_id = VRF_DEFAULT;
3121
3122 if (argc > 0)
3123 VRF_GET_ID (vrf_id, argv[0]);
3124
3125 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
3126 if (! table)
3127 return CMD_SUCCESS;
3128
3129 vty_show_ip_route_summary (vty, table);
3130
3131 return CMD_SUCCESS;
3132 }
3133
3134 ALIAS (show_ip_route_summary,
3135 show_ip_route_vrf_summary_cmd,
3136 "show ip route " VRF_CMD_STR " summary",
3137 SHOW_STR
3138 IP_STR
3139 "IP routing table\n"
3140 VRF_CMD_HELP_STR
3141 "Summary of all routes\n")
3142
3143 /* Show route summary prefix. */
3144 DEFUN (show_ip_route_summary_prefix,
3145 show_ip_route_summary_prefix_cmd,
3146 "show ip route summary prefix",
3147 SHOW_STR
3148 IP_STR
3149 "IP routing table\n"
3150 "Summary of all routes\n"
3151 "Prefix routes\n")
3152 {
3153 struct route_table *table;
3154 vrf_id_t vrf_id = VRF_DEFAULT;
3155
3156 if (argc > 0)
3157 VRF_GET_ID (vrf_id, argv[0]);
3158
3159 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
3160 if (! table)
3161 return CMD_SUCCESS;
3162
3163 vty_show_ip_route_summary_prefix (vty, table);
3164
3165 return CMD_SUCCESS;
3166 }
3167
3168 ALIAS (show_ip_route_summary_prefix,
3169 show_ip_route_vrf_summary_prefix_cmd,
3170 "show ip route " VRF_CMD_STR " summary prefix",
3171 SHOW_STR
3172 IP_STR
3173 "IP routing table\n"
3174 VRF_CMD_HELP_STR
3175 "Summary of all routes\n"
3176 "Prefix routes\n")
3177
3178 DEFUN (show_ip_route_vrf_all,
3179 show_ip_route_vrf_all_cmd,
3180 "show ip route " VRF_ALL_CMD_STR,
3181 SHOW_STR
3182 IP_STR
3183 "IP routing table\n"
3184 VRF_ALL_CMD_HELP_STR)
3185 {
3186 struct route_table *table;
3187 struct route_node *rn;
3188 struct rib *rib;
3189 struct zebra_vrf *zvrf;
3190 vrf_iter_t iter;
3191 int first = 1;
3192 int vrf_header = 1;
3193
3194 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3195 {
3196 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3197 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3198 continue;
3199
3200 /* Show all IPv4 routes. */
3201 for (rn = route_top (table); rn; rn = route_next (rn))
3202 RNODE_FOREACH_RIB (rn, rib)
3203 {
3204 if (first)
3205 {
3206 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3207 first = 0;
3208 }
3209
3210 if (vrf_header)
3211 {
3212 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
3213 vrf_header = 0;
3214 }
3215 vty_show_ip_route (vty, rn, rib, NULL);
3216 }
3217 vrf_header = 1;
3218 }
3219
3220 return CMD_SUCCESS;
3221 }
3222
3223 DEFUN (show_ip_route_vrf_all_tag,
3224 show_ip_route_vrf_all_tag_cmd,
3225 "show ip route " VRF_ALL_CMD_STR " tag <1-65535>",
3226 SHOW_STR
3227 IP_STR
3228 "IP routing table\n"
3229 VRF_ALL_CMD_HELP_STR
3230 "Show only routes with tag\n"
3231 "Tag value\n")
3232 {
3233 struct route_table *table;
3234 struct route_node *rn;
3235 struct rib *rib;
3236 struct zebra_vrf *zvrf;
3237 vrf_iter_t iter;
3238 int first = 1;
3239 int vrf_header = 1;
3240 u_short tag = 0;
3241
3242 if (argv[0])
3243 tag = atoi(argv[0]);
3244
3245 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3246 {
3247 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3248 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3249 continue;
3250
3251 /* Show all IPv4 routes with matching tag value. */
3252 for (rn = route_top (table); rn; rn = route_next (rn))
3253 RNODE_FOREACH_RIB (rn, rib)
3254 {
3255 if (rib->tag != tag)
3256 continue;
3257
3258 if (first)
3259 {
3260 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3261 first = 0;
3262 }
3263
3264 if (vrf_header)
3265 {
3266 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
3267 vrf_header = 0;
3268 }
3269 vty_show_ip_route (vty, rn, rib, NULL);
3270 }
3271 vrf_header = 1;
3272 }
3273 return CMD_SUCCESS;
3274 }
3275
3276 DEFUN (show_ip_route_vrf_all_prefix_longer,
3277 show_ip_route_vrf_all_prefix_longer_cmd,
3278 "show ip route " VRF_ALL_CMD_STR " A.B.C.D/M longer-prefixes",
3279 SHOW_STR
3280 IP_STR
3281 "IP routing table\n"
3282 VRF_ALL_CMD_HELP_STR
3283 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3284 "Show route matching the specified Network/Mask pair only\n")
3285 {
3286 struct route_table *table;
3287 struct route_node *rn;
3288 struct rib *rib;
3289 struct prefix p;
3290 struct zebra_vrf *zvrf;
3291 vrf_iter_t iter;
3292 int ret;
3293 int first = 1;
3294 int vrf_header = 1;
3295
3296 ret = str2prefix (argv[0], &p);
3297 if (! ret)
3298 {
3299 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3300 return CMD_WARNING;
3301 }
3302
3303 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3304 {
3305 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3306 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3307 continue;
3308
3309 /* Show matched type IPv4 routes. */
3310 for (rn = route_top (table); rn; rn = route_next (rn))
3311 RNODE_FOREACH_RIB (rn, rib)
3312 if (prefix_match (&p, &rn->p))
3313 {
3314 if (first)
3315 {
3316 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3317 first = 0;
3318 }
3319
3320 if (vrf_header)
3321 {
3322 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
3323 vrf_header = 0;
3324 }
3325 vty_show_ip_route (vty, rn, rib, NULL);
3326 }
3327 vrf_header = 1;
3328 }
3329
3330 return CMD_SUCCESS;
3331 }
3332
3333 DEFUN (show_ip_route_vrf_all_supernets,
3334 show_ip_route_vrf_all_supernets_cmd,
3335 "show ip route " VRF_ALL_CMD_STR " supernets-only",
3336 SHOW_STR
3337 IP_STR
3338 "IP routing table\n"
3339 VRF_ALL_CMD_HELP_STR
3340 "Show supernet entries only\n")
3341 {
3342 struct route_table *table;
3343 struct route_node *rn;
3344 struct rib *rib;
3345 struct zebra_vrf *zvrf;
3346 vrf_iter_t iter;
3347 u_int32_t addr;
3348 int first = 1;
3349 int vrf_header = 1;
3350
3351 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3352 {
3353 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3354 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3355 continue;
3356
3357 /* Show matched type IPv4 routes. */
3358 for (rn = route_top (table); rn; rn = route_next (rn))
3359 RNODE_FOREACH_RIB (rn, rib)
3360 {
3361 addr = ntohl (rn->p.u.prefix4.s_addr);
3362
3363 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
3364 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
3365 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
3366 {
3367 if (first)
3368 {
3369 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3370 first = 0;
3371 }
3372
3373 if (vrf_header)
3374 {
3375 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
3376 vrf_header = 0;
3377 }
3378 vty_show_ip_route (vty, rn, rib, NULL);
3379 }
3380 }
3381 vrf_header = 1;
3382 }
3383
3384 return CMD_SUCCESS;
3385 }
3386
3387 DEFUN (show_ip_route_vrf_all_protocol,
3388 show_ip_route_vrf_all_protocol_cmd,
3389 "show ip route " VRF_ALL_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA,
3390 SHOW_STR
3391 IP_STR
3392 "IP routing table\n"
3393 VRF_ALL_CMD_HELP_STR
3394 QUAGGA_IP_REDIST_HELP_STR_ZEBRA"\n")
3395 {
3396 int type;
3397 struct route_table *table;
3398 struct route_node *rn;
3399 struct rib *rib;
3400 struct zebra_vrf *zvrf;
3401 vrf_iter_t iter;
3402 int first = 1;
3403 int vrf_header = 1;
3404
3405 type = proto_redistnum (AFI_IP, argv[0]);
3406 if (type < 0)
3407 {
3408 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3409 return CMD_WARNING;
3410 }
3411
3412 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3413 {
3414 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3415 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3416 continue;
3417
3418 /* Show matched type IPv4 routes. */
3419 for (rn = route_top (table); rn; rn = route_next (rn))
3420 RNODE_FOREACH_RIB (rn, rib)
3421 if (rib->type == type)
3422 {
3423 if (first)
3424 {
3425 vty_out (vty, SHOW_ROUTE_V4_HEADER);
3426 first = 0;
3427 }
3428
3429 if (vrf_header)
3430 {
3431 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
3432 vrf_header = 0;
3433 }
3434 vty_show_ip_route (vty, rn, rib, NULL);
3435 }
3436 vrf_header = 1;
3437 }
3438
3439 return CMD_SUCCESS;
3440 }
3441
3442 DEFUN (show_ip_route_vrf_all_addr,
3443 show_ip_route_vrf_all_addr_cmd,
3444 "show ip route " VRF_ALL_CMD_STR " A.B.C.D",
3445 SHOW_STR
3446 IP_STR
3447 "IP routing table\n"
3448 VRF_ALL_CMD_HELP_STR
3449 "Network in the IP routing table to display\n")
3450 {
3451 int ret;
3452 struct prefix_ipv4 p;
3453 struct route_table *table;
3454 struct route_node *rn;
3455 struct zebra_vrf *zvrf;
3456 vrf_iter_t iter;
3457
3458 ret = str2prefix_ipv4 (argv[0], &p);
3459 if (ret <= 0)
3460 {
3461 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
3462 return CMD_WARNING;
3463 }
3464
3465 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3466 {
3467 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3468 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3469 continue;
3470
3471 rn = route_node_match (table, (struct prefix *) &p);
3472 if (! rn)
3473 continue;
3474
3475 vty_show_ip_route_detail (vty, rn, 0);
3476
3477 route_unlock_node (rn);
3478 }
3479
3480 return CMD_SUCCESS;
3481 }
3482
3483 DEFUN (show_ip_route_vrf_all_prefix,
3484 show_ip_route_vrf_all_prefix_cmd,
3485 "show ip route " VRF_ALL_CMD_STR " A.B.C.D/M",
3486 SHOW_STR
3487 IP_STR
3488 "IP routing table\n"
3489 VRF_ALL_CMD_HELP_STR
3490 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3491 {
3492 int ret;
3493 struct prefix_ipv4 p;
3494 struct route_table *table;
3495 struct route_node *rn;
3496 struct zebra_vrf *zvrf;
3497 vrf_iter_t iter;
3498
3499 ret = str2prefix_ipv4 (argv[0], &p);
3500 if (ret <= 0)
3501 {
3502 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
3503 return CMD_WARNING;
3504 }
3505
3506 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3507 {
3508 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3509 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
3510 continue;
3511
3512 rn = route_node_match (table, (struct prefix *) &p);
3513 if (! rn)
3514 continue;
3515 if (rn->p.prefixlen != p.prefixlen)
3516 {
3517 route_unlock_node (rn);
3518 continue;
3519 }
3520
3521 vty_show_ip_route_detail (vty, rn, 0);
3522
3523 route_unlock_node (rn);
3524 }
3525
3526 return CMD_SUCCESS;
3527 }
3528
3529 DEFUN (show_ip_route_vrf_all_summary,
3530 show_ip_route_vrf_all_summary_cmd,
3531 "show ip route " VRF_ALL_CMD_STR " summary ",
3532 SHOW_STR
3533 IP_STR
3534 "IP routing table\n"
3535 VRF_ALL_CMD_HELP_STR
3536 "Summary of all routes\n")
3537 {
3538 struct zebra_vrf *zvrf;
3539 vrf_iter_t iter;
3540
3541 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3542 if ((zvrf = vrf_iter2info (iter)) != NULL)
3543 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
3544
3545 return CMD_SUCCESS;
3546 }
3547
3548 DEFUN (show_ip_route_vrf_all_summary_prefix,
3549 show_ip_route_vrf_all_summary_prefix_cmd,
3550 "show ip route " VRF_ALL_CMD_STR " summary prefix",
3551 SHOW_STR
3552 IP_STR
3553 "IP routing table\n"
3554 VRF_ALL_CMD_HELP_STR
3555 "Summary of all routes\n"
3556 "Prefix routes\n")
3557 {
3558 struct zebra_vrf *zvrf;
3559 vrf_iter_t iter;
3560
3561 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3562 if ((zvrf = vrf_iter2info (iter)) != NULL)
3563 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
3564
3565 return CMD_SUCCESS;
3566 }
3567
3568 /* Write IPv4 static route configuration. */
3569 static int
3570 static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
3571 {
3572 struct route_node *rn;
3573 struct static_route *si;
3574 struct route_table *stable;
3575 struct zebra_vrf *zvrf;
3576 char buf[PREFIX_STRLEN];
3577 int write =0;
3578 struct listnode *node;
3579
3580 for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf))
3581 {
3582 if ((stable = zvrf->stable[AFI_IP][safi]) == NULL)
3583 continue;
3584
3585 for (rn = route_top (stable); rn; rn = route_next (rn))
3586 for (si = rn->info; si; si = si->next)
3587 {
3588 vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf));
3589
3590 switch (si->type)
3591 {
3592 case STATIC_IPV4_GATEWAY:
3593 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
3594 break;
3595 case STATIC_IFINDEX:
3596 vty_out (vty, " %s", si->ifname);
3597 break;
3598 case STATIC_IPV4_BLACKHOLE:
3599 vty_out (vty, " Null0");
3600 break;
3601 }
3602
3603 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
3604 if (si->type != STATIC_IPV4_BLACKHOLE)
3605 {
3606 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3607 vty_out (vty, " %s", "reject");
3608
3609 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3610 vty_out (vty, " %s", "blackhole");
3611 }
3612
3613 if (si->tag)
3614 vty_out (vty, " tag %d", si->tag);
3615
3616 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3617 vty_out (vty, " %d", si->distance);
3618
3619 if (si->vrf_id != VRF_DEFAULT)
3620 vty_out (vty, " vrf %s", zvrf ? zvrf->name : "");
3621
3622 vty_out (vty, "%s", VTY_NEWLINE);
3623
3624 write = 1;
3625 }
3626 }
3627 return write;
3628 }
3629
3630 #ifdef HAVE_IPV6
3631 /* General fucntion for IPv6 static route. */
3632 static int
3633 static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
3634 const char *gate_str, const char *ifname,
3635 const char *flag_str, const char *tag_str,
3636 const char *distance_str, const char *vrf_id_str)
3637 {
3638 int ret;
3639 u_char distance;
3640 struct prefix p;
3641 struct in6_addr *gate = NULL;
3642 struct in6_addr gate_addr;
3643 u_char type = 0;
3644 u_char flag = 0;
3645 u_short tag = 0;
3646 unsigned int ifindex = 0;
3647 struct interface *ifp = NULL;
3648 struct zebra_vrf *zvrf;
3649
3650 ret = str2prefix (dest_str, &p);
3651 if (ret <= 0)
3652 {
3653 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
3654 return CMD_WARNING;
3655 }
3656
3657 /* Apply mask for given prefix. */
3658 apply_mask (&p);
3659
3660 /* Route flags */
3661 if (flag_str) {
3662 switch(flag_str[0]) {
3663 case 'r':
3664 case 'R': /* XXX */
3665 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
3666 break;
3667 case 'b':
3668 case 'B': /* XXX */
3669 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
3670 break;
3671 default:
3672 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
3673 return CMD_WARNING;
3674 }
3675 }
3676
3677 /* Administrative distance. */
3678 if (distance_str)
3679 distance = atoi (distance_str);
3680 else
3681 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
3682
3683 /* tag */
3684 if (tag_str)
3685 tag = atoi(tag_str);
3686
3687 /* When gateway is valid IPv6 addrees, then gate is treated as
3688 nexthop address other case gate is treated as interface name. */
3689 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
3690
3691 /* VRF id */
3692 zvrf = zebra_vrf_list_lookup_by_name (vrf_id_str);
3693
3694 if (!zvrf)
3695 {
3696 vty_out (vty, "%% vrf %s is not defined%s", vrf_id_str, VTY_NEWLINE);
3697 return CMD_WARNING;
3698 }
3699
3700 if (ifname)
3701 {
3702 /* When ifname is specified. It must be come with gateway
3703 address. */
3704 if (ret != 1)
3705 {
3706 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
3707 return CMD_WARNING;
3708 }
3709 type = STATIC_IPV6_GATEWAY_IFINDEX;
3710 gate = &gate_addr;
3711 ifp = if_lookup_by_name_vrf (ifname, zvrf->vrf_id);
3712 if (!ifp)
3713 {
3714 vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE);
3715 return CMD_WARNING;
3716 }
3717 ifindex = ifp->ifindex;
3718 }
3719 else
3720 {
3721 if (ret == 1)
3722 {
3723 type = STATIC_IPV6_GATEWAY;
3724 gate = &gate_addr;
3725 }
3726 else
3727 {
3728 type = STATIC_IFINDEX;
3729 ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id);
3730 if (!ifp)
3731 {
3732 vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE);
3733 ifindex = IFINDEX_DELETED;
3734 }
3735 else
3736 ifindex = ifp->ifindex;
3737 ifname = gate_str;
3738 }
3739 }
3740
3741 if (add_cmd)
3742 static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, (union g_addr *)gate, ifindex, ifname, flag, tag, distance, zvrf);
3743 else
3744 static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, (union g_addr *)gate, ifindex, tag, distance, zvrf);
3745
3746 return CMD_SUCCESS;
3747 }
3748
3749 DEFUN (ipv6_route,
3750 ipv6_route_cmd,
3751 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
3752 IP_STR
3753 "Establish static routes\n"
3754 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3755 "IPv6 gateway address\n"
3756 "IPv6 gateway interface name\n")
3757 {
3758 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL);
3759 }
3760
3761 DEFUN (ipv6_route_tag,
3762 ipv6_route_tag_cmd,
3763 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535>",
3764 IP_STR
3765 "Establish static routes\n"
3766 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3767 "IPv6 gateway address\n"
3768 "IPv6 gateway interface name\n"
3769 "Set tag for this route\n"
3770 "Tag value\n")
3771 {
3772 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL);
3773 }
3774
3775 DEFUN (ipv6_route_flags,
3776 ipv6_route_flags_cmd,
3777 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
3778 IP_STR
3779 "Establish static routes\n"
3780 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3781 "IPv6 gateway address\n"
3782 "IPv6 gateway interface name\n"
3783 "Emit an ICMP unreachable when matched\n"
3784 "Silently discard pkts when matched\n")
3785 {
3786 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, NULL);
3787 }
3788
3789 DEFUN (ipv6_route_flags_tag,
3790 ipv6_route_flags_tag_cmd,
3791 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535>",
3792 IP_STR
3793 "Establish static routes\n"
3794 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3795 "IPv6 gateway address\n"
3796 "IPv6 gateway interface name\n"
3797 "Emit an ICMP unreachable when matched\n"
3798 "Silently discard pkts when matched\n"
3799 "Set tag for this route\n"
3800 "Tag value\n")
3801 {
3802 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, NULL);
3803 }
3804
3805 DEFUN (ipv6_route_ifname,
3806 ipv6_route_ifname_cmd,
3807 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
3808 IP_STR
3809 "Establish static routes\n"
3810 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3811 "IPv6 gateway address\n"
3812 "IPv6 gateway interface name\n")
3813 {
3814 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL);
3815 }
3816 DEFUN (ipv6_route_ifname_tag,
3817 ipv6_route_ifname_tag_cmd,
3818 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535>",
3819 IP_STR
3820 "Establish static routes\n"
3821 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3822 "IPv6 gateway address\n"
3823 "IPv6 gateway interface name\n"
3824 "Set tag for this route\n"
3825 "Tag value\n")
3826 {
3827 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL);
3828 }
3829
3830 DEFUN (ipv6_route_ifname_flags,
3831 ipv6_route_ifname_flags_cmd,
3832 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
3833 IP_STR
3834 "Establish static routes\n"
3835 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3836 "IPv6 gateway address\n"
3837 "IPv6 gateway interface name\n"
3838 "Emit an ICMP unreachable when matched\n"
3839 "Silently discard pkts when matched\n")
3840 {
3841 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, NULL);
3842 }
3843
3844 DEFUN (ipv6_route_ifname_flags_tag,
3845 ipv6_route_ifname_flags_tag_cmd,
3846 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535>",
3847 IP_STR
3848 "Establish static routes\n"
3849 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3850 "IPv6 gateway address\n"
3851 "IPv6 gateway interface name\n"
3852 "Emit an ICMP unreachable when matched\n"
3853 "Silently discard pkts when matched\n"
3854 "Set tag for this route\n"
3855 "Tag value\n")
3856 {
3857 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, NULL);
3858 }
3859
3860 DEFUN (ipv6_route_pref,
3861 ipv6_route_pref_cmd,
3862 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
3863 IP_STR
3864 "Establish static routes\n"
3865 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3866 "IPv6 gateway address\n"
3867 "IPv6 gateway interface name\n"
3868 "Distance value for this prefix\n")
3869 {
3870 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL);
3871 }
3872
3873 DEFUN (ipv6_route_pref_tag,
3874 ipv6_route_pref_tag_cmd,
3875 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> <1-255>",
3876 IP_STR
3877 "Establish static routes\n"
3878 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3879 "IPv6 gateway address\n"
3880 "IPv6 gateway interface name\n"
3881 "Set tag for this route\n"
3882 "Tag value\n"
3883 "Distance value for this prefix\n")
3884 {
3885 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL);
3886 }
3887
3888 DEFUN (ipv6_route_flags_pref,
3889 ipv6_route_flags_pref_cmd,
3890 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
3891 IP_STR
3892 "Establish static routes\n"
3893 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3894 "IPv6 gateway address\n"
3895 "IPv6 gateway interface name\n"
3896 "Emit an ICMP unreachable when matched\n"
3897 "Silently discard pkts when matched\n"
3898 "Distance value for this prefix\n")
3899 {
3900 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL);
3901 }
3902
3903 DEFUN (ipv6_route_flags_pref_tag,
3904 ipv6_route_flags_pref_tag_cmd,
3905 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
3906 IP_STR
3907 "Establish static routes\n"
3908 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3909 "IPv6 gateway address\n"
3910 "IPv6 gateway interface name\n"
3911 "Emit an ICMP unreachable when matched\n"
3912 "Silently discard pkts when matched\n"
3913 "Set tag for this route\n"
3914 "Tag value\n"
3915 "Distance value for this prefix\n")
3916 {
3917 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL);
3918 }
3919
3920 DEFUN (ipv6_route_ifname_pref,
3921 ipv6_route_ifname_pref_cmd,
3922 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
3923 IP_STR
3924 "Establish static routes\n"
3925 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3926 "IPv6 gateway address\n"
3927 "IPv6 gateway interface name\n"
3928 "Distance value for this prefix\n")
3929 {
3930 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL);
3931 }
3932
3933 DEFUN (ipv6_route_ifname_pref_tag,
3934 ipv6_route_ifname_pref_tag_cmd,
3935 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> <1-255>",
3936 IP_STR
3937 "Establish static routes\n"
3938 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3939 "IPv6 gateway address\n"
3940 "IPv6 gateway interface name\n"
3941 "Set tag for this route\n"
3942 "Tag value\n"
3943 "Distance value for this prefix\n")
3944 {
3945 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL);
3946 }
3947
3948 DEFUN (ipv6_route_ifname_flags_pref,
3949 ipv6_route_ifname_flags_pref_cmd,
3950 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
3951 IP_STR
3952 "Establish static routes\n"
3953 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3954 "IPv6 gateway address\n"
3955 "IPv6 gateway interface name\n"
3956 "Emit an ICMP unreachable when matched\n"
3957 "Silently discard pkts when matched\n"
3958 "Distance value for this prefix\n")
3959 {
3960 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL);
3961 }
3962
3963 DEFUN (ipv6_route_ifname_flags_pref_tag,
3964 ipv6_route_ifname_flags_pref_tag_cmd,
3965 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> <1-255>",
3966 IP_STR
3967 "Establish static routes\n"
3968 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3969 "IPv6 gateway address\n"
3970 "IPv6 gateway interface name\n"
3971 "Emit an ICMP unreachable when matched\n"
3972 "Silently discard pkts when matched\n"
3973 "Set tag for this route\n"
3974 "Tag value\n"
3975 "Distance value for this prefix\n")
3976 {
3977 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL);
3978 }
3979
3980 DEFUN (no_ipv6_route,
3981 no_ipv6_route_cmd,
3982 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
3983 NO_STR
3984 IP_STR
3985 "Establish static routes\n"
3986 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3987 "IPv6 gateway address\n"
3988 "IPv6 gateway interface name\n")
3989 {
3990 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL);
3991 }
3992
3993 DEFUN (no_ipv6_route_tag,
3994 no_ipv6_route_tag_cmd,
3995 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535>",
3996 NO_STR
3997 IP_STR
3998 "Establish static routes\n"
3999 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4000 "IPv6 gateway address\n"
4001 "IPv6 gateway interface name\n"
4002 "Set tag for this route\n"
4003 "Tag value\n")
4004 {
4005 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL);
4006 }
4007
4008 DEFUN (no_ipv6_route_flags,
4009 no_ipv6_route_flags_cmd,
4010 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
4011 NO_STR
4012 IP_STR
4013 "Establish static routes\n"
4014 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4015 "IPv6 gateway address\n"
4016 "IPv6 gateway interface name\n"
4017 "Emit an ICMP unreachable when matched\n"
4018 "Silently discard pkts when matched\n")
4019 {
4020 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, NULL, NULL);
4021 }
4022
4023 DEFUN (no_ipv6_route_flags_tag,
4024 no_ipv6_route_flags_tag_cmd,
4025 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535>",
4026 NO_STR
4027 IP_STR
4028 "Establish static routes\n"
4029 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4030 "IPv6 gateway address\n"
4031 "IPv6 gateway interface name\n"
4032 "Emit an ICMP unreachable when matched\n"
4033 "Silently discard pkts when matched\n"
4034 "Set tag for this route\n"
4035 "Tag value\n")
4036 {
4037 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL, NULL);
4038 }
4039
4040 DEFUN (no_ipv6_route_ifname,
4041 no_ipv6_route_ifname_cmd,
4042 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
4043 NO_STR
4044 IP_STR
4045 "Establish static routes\n"
4046 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4047 "IPv6 gateway address\n"
4048 "IPv6 gateway interface name\n")
4049 {
4050 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL);
4051 }
4052
4053 DEFUN (no_ipv6_route_ifname_tag,
4054 no_ipv6_route_ifname_tag_cmd,
4055 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535>",
4056 NO_STR
4057 IP_STR
4058 "Establish static routes\n"
4059 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4060 "IPv6 gateway address\n"
4061 "IPv6 gateway interface name\n"
4062 "Set tag for this route\n"
4063 "Tag value\n")
4064 {
4065 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL);
4066 }
4067
4068 DEFUN (no_ipv6_route_ifname_flags,
4069 no_ipv6_route_ifname_flags_cmd,
4070 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
4071 NO_STR
4072 IP_STR
4073 "Establish static routes\n"
4074 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4075 "IPv6 gateway address\n"
4076 "IPv6 gateway interface name\n"
4077 "Emit an ICMP unreachable when matched\n"
4078 "Silently discard pkts when matched\n")
4079 {
4080 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, NULL, NULL);
4081 }
4082
4083 DEFUN (no_ipv6_route_ifname_flags_tag,
4084 no_ipv6_route_ifname_flags_tag_cmd,
4085 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535>",
4086 NO_STR
4087 IP_STR
4088 "Establish static routes\n"
4089 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4090 "IPv6 gateway address\n"
4091 "IPv6 gateway interface name\n"
4092 "Emit an ICMP unreachable when matched\n"
4093 "Silently discard pkts when matched\n"
4094 "Set tag for this route\n"
4095 "Tag value\n")
4096 {
4097 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, NULL);
4098 }
4099
4100 DEFUN (no_ipv6_route_pref,
4101 no_ipv6_route_pref_cmd,
4102 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
4103 NO_STR
4104 IP_STR
4105 "Establish static routes\n"
4106 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4107 "IPv6 gateway address\n"
4108 "IPv6 gateway interface name\n"
4109 "Distance value for this prefix\n")
4110 {
4111 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL);
4112 }
4113
4114 DEFUN (no_ipv6_route_pref_tag,
4115 no_ipv6_route_pref_tag_cmd,
4116 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> <1-255>",
4117 NO_STR
4118 IP_STR
4119 "Establish static routes\n"
4120 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4121 "IPv6 gateway address\n"
4122 "IPv6 gateway interface name\n"
4123 "Set tag for this route\n"
4124 "Tag value\n"
4125 "Distance value for this prefix\n")
4126 {
4127 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL);
4128 }
4129
4130 DEFUN (no_ipv6_route_flags_pref,
4131 no_ipv6_route_flags_pref_cmd,
4132 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
4133 NO_STR
4134 IP_STR
4135 "Establish static routes\n"
4136 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4137 "IPv6 gateway address\n"
4138 "IPv6 gateway interface name\n"
4139 "Emit an ICMP unreachable when matched\n"
4140 "Silently discard pkts when matched\n"
4141 "Distance value for this prefix\n")
4142 {
4143 /* We do not care about argv[2] */
4144 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL);
4145 }
4146
4147 DEFUN (no_ipv6_route_flags_pref_tag,
4148 no_ipv6_route_flags_pref_tag_cmd,
4149 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> <1-255>",
4150 NO_STR
4151 IP_STR
4152 "Establish static routes\n"
4153 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4154 "IPv6 gateway address\n"
4155 "IPv6 gateway interface name\n"
4156 "Emit an ICMP unreachable when matched\n"
4157 "Silently discard pkts when matched\n"
4158 "Set tag for this route\n"
4159 "Tag value\n"
4160 "Distance value for this prefix\n")
4161 {
4162 /* We do not care about argv[2] */
4163 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], NULL);
4164 }
4165
4166 DEFUN (no_ipv6_route_ifname_pref,
4167 no_ipv6_route_ifname_pref_cmd,
4168 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
4169 NO_STR
4170 IP_STR
4171 "Establish static routes\n"
4172 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4173 "IPv6 gateway address\n"
4174 "IPv6 gateway interface name\n"
4175 "Distance value for this prefix\n")
4176 {
4177 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL);
4178 }
4179
4180 DEFUN (no_ipv6_route_ifname_pref_tag,
4181 no_ipv6_route_ifname_pref_tag_cmd,
4182 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> <1-255>",
4183 NO_STR
4184 IP_STR
4185 "Establish static routes\n"
4186 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4187 "IPv6 gateway address\n"
4188 "IPv6 gateway interface name\n"
4189 "Set tag for this route\n"
4190 "Tag value\n"
4191 "Distance value for this prefix\n")
4192 {
4193 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL);
4194 }
4195
4196 DEFUN (no_ipv6_route_ifname_flags_pref,
4197 no_ipv6_route_ifname_flags_pref_cmd,
4198 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
4199 NO_STR
4200 IP_STR
4201 "Establish static routes\n"
4202 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4203 "IPv6 gateway address\n"
4204 "IPv6 gateway interface name\n"
4205 "Emit an ICMP unreachable when matched\n"
4206 "Silently discard pkts when matched\n"
4207 "Distance value for this prefix\n")
4208 {
4209 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL);
4210 }
4211
4212 DEFUN (no_ipv6_route_ifname_flags_pref_tag,
4213 no_ipv6_route_ifname_flags_pref_tag_cmd,
4214 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> <1-255>",
4215 NO_STR
4216 IP_STR
4217 "Establish static routes\n"
4218 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4219 "IPv6 gateway address\n"
4220 "IPv6 gateway interface name\n"
4221 "Emit an ICMP unreachable when matched\n"
4222 "Silently discard pkts when matched\n"
4223 "Set tag for this route\n"
4224 "Tag value\n"
4225 "Distance value for this prefix\n")
4226 {
4227 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL);
4228 }
4229
4230 DEFUN (ipv6_route_vrf,
4231 ipv6_route_vrf_cmd,
4232 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
4233 IP_STR
4234 "Establish static routes\n"
4235 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4236 "IPv6 gateway address\n"
4237 "IPv6 gateway interface name\n"
4238 VRF_CMD_HELP_STR)
4239 {
4240 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2]);
4241 }
4242
4243 DEFUN (ipv6_route_tag_vrf,
4244 ipv6_route_tag_vrf_cmd,
4245 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> " VRF_CMD_STR,
4246 IP_STR
4247 "Establish static routes\n"
4248 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4249 "IPv6 gateway address\n"
4250 "IPv6 gateway interface name\n"
4251 "Set tag for this route\n"
4252 "Tag value\n"
4253 VRF_CMD_HELP_STR)
4254 {
4255 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3]);
4256 }
4257
4258 DEFUN (ipv6_route_flags_vrf,
4259 ipv6_route_flags_vrf_cmd,
4260 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
4261 IP_STR
4262 "Establish static routes\n"
4263 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4264 "IPv6 gateway address\n"
4265 "IPv6 gateway interface name\n"
4266 "Emit an ICMP unreachable when matched\n"
4267 "Silently discard pkts when matched\n"
4268 VRF_CMD_HELP_STR)
4269 {
4270 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3]);
4271 }
4272
4273 DEFUN (ipv6_route_flags_tag_vrf,
4274 ipv6_route_flags_tag_vrf_cmd,
4275 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
4276 IP_STR
4277 "Establish static routes\n"
4278 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4279 "IPv6 gateway address\n"
4280 "IPv6 gateway interface name\n"
4281 "Emit an ICMP unreachable when matched\n"
4282 "Silently discard pkts when matched\n"
4283 "Set tag for this route\n"
4284 "Tag value\n"
4285 VRF_CMD_HELP_STR)
4286 {
4287 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4]);
4288 }
4289
4290 DEFUN (ipv6_route_ifname_vrf,
4291 ipv6_route_ifname_vrf_cmd,
4292 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
4293 IP_STR
4294 "Establish static routes\n"
4295 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4296 "IPv6 gateway address\n"
4297 "IPv6 gateway interface name\n"
4298 VRF_CMD_HELP_STR)
4299 {
4300 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3]);
4301 }
4302 DEFUN (ipv6_route_ifname_tag_vrf,
4303 ipv6_route_ifname_tag_vrf_cmd,
4304 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> " VRF_CMD_STR,
4305 IP_STR
4306 "Establish static routes\n"
4307 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4308 "IPv6 gateway address\n"
4309 "IPv6 gateway interface name\n"
4310 "Set tag for this route\n"
4311 "Tag value\n"
4312 VRF_CMD_HELP_STR)
4313 {
4314 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
4315 }
4316
4317 DEFUN (ipv6_route_ifname_flags_vrf,
4318 ipv6_route_ifname_flags_vrf_cmd,
4319 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
4320 IP_STR
4321 "Establish static routes\n"
4322 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4323 "IPv6 gateway address\n"
4324 "IPv6 gateway interface name\n"
4325 "Emit an ICMP unreachable when matched\n"
4326 "Silently discard pkts when matched\n"
4327 VRF_CMD_HELP_STR)
4328 {
4329 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4]);
4330 }
4331
4332 DEFUN (ipv6_route_ifname_flags_tag_vrf,
4333 ipv6_route_ifname_flags_tag_vrf_cmd,
4334 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
4335 IP_STR
4336 "Establish static routes\n"
4337 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4338 "IPv6 gateway address\n"
4339 "IPv6 gateway interface name\n"
4340 "Emit an ICMP unreachable when matched\n"
4341 "Silently discard pkts when matched\n"
4342 "Set tag for this route\n"
4343 "Tag value\n"
4344 VRF_CMD_HELP_STR)
4345 {
4346 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5]);
4347 }
4348
4349 DEFUN (ipv6_route_pref_vrf,
4350 ipv6_route_pref_vrf_cmd,
4351 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
4352 IP_STR
4353 "Establish static routes\n"
4354 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4355 "IPv6 gateway address\n"
4356 "IPv6 gateway interface name\n"
4357 "Distance value for this prefix\n"
4358 VRF_CMD_HELP_STR)
4359 {
4360 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3]);
4361 }
4362
4363 DEFUN (ipv6_route_pref_tag_vrf,
4364 ipv6_route_pref_tag_vrf_cmd,
4365 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> <1-255> " VRF_CMD_STR,
4366 IP_STR
4367 "Establish static routes\n"
4368 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4369 "IPv6 gateway address\n"
4370 "IPv6 gateway interface name\n"
4371 "Set tag for this route\n"
4372 "Tag value\n"
4373 "Distance value for this prefix\n"
4374 VRF_CMD_HELP_STR)
4375 {
4376 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4]);
4377 }
4378
4379 DEFUN (ipv6_route_flags_pref_vrf,
4380 ipv6_route_flags_pref_vrf_cmd,
4381 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
4382 IP_STR
4383 "Establish static routes\n"
4384 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4385 "IPv6 gateway address\n"
4386 "IPv6 gateway interface name\n"
4387 "Emit an ICMP unreachable when matched\n"
4388 "Silently discard pkts when matched\n"
4389 "Distance value for this prefix\n"
4390 VRF_CMD_HELP_STR)
4391 {
4392 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]);
4393 }
4394
4395 DEFUN (ipv6_route_flags_pref_tag_vrf,
4396 ipv6_route_flags_pref_tag_vrf_cmd,
4397 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
4398 IP_STR
4399 "Establish static routes\n"
4400 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4401 "IPv6 gateway address\n"
4402 "IPv6 gateway interface name\n"
4403 "Emit an ICMP unreachable when matched\n"
4404 "Silently discard pkts when matched\n"
4405 "Set tag for this route\n"
4406 "Tag value\n"
4407 "Distance value for this prefix\n"
4408 VRF_CMD_HELP_STR)
4409 {
4410 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
4411 }
4412
4413 DEFUN (ipv6_route_ifname_pref_vrf,
4414 ipv6_route_ifname_pref_vrf_cmd,
4415 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
4416 IP_STR
4417 "Establish static routes\n"
4418 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4419 "IPv6 gateway address\n"
4420 "IPv6 gateway interface name\n"
4421 "Distance value for this prefix\n"
4422 VRF_CMD_HELP_STR)
4423 {
4424 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]);
4425 }
4426
4427 DEFUN (ipv6_route_ifname_pref_tag_vrf,
4428 ipv6_route_ifname_pref_tag_vrf_cmd,
4429 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> <1-255> " VRF_CMD_STR,
4430 IP_STR
4431 "Establish static routes\n"
4432 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4433 "IPv6 gateway address\n"
4434 "IPv6 gateway interface name\n"
4435 "Set tag for this route\n"
4436 "Tag value\n"
4437 "Distance value for this prefix\n"
4438 VRF_CMD_HELP_STR)
4439 {
4440 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
4441 }
4442
4443 DEFUN (ipv6_route_ifname_flags_pref_vrf,
4444 ipv6_route_ifname_flags_pref_vrf_cmd,
4445 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
4446 IP_STR
4447 "Establish static routes\n"
4448 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4449 "IPv6 gateway address\n"
4450 "IPv6 gateway interface name\n"
4451 "Emit an ICMP unreachable when matched\n"
4452 "Silently discard pkts when matched\n"
4453 "Distance value for this prefix\n"
4454 VRF_CMD_HELP_STR)
4455 {
4456 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]);
4457 }
4458
4459 DEFUN (ipv6_route_ifname_flags_pref_tag_vrf,
4460 ipv6_route_ifname_flags_pref_tag_vrf_cmd,
4461 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
4462 IP_STR
4463 "Establish static routes\n"
4464 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4465 "IPv6 gateway address\n"
4466 "IPv6 gateway interface name\n"
4467 "Emit an ICMP unreachable when matched\n"
4468 "Silently discard pkts when matched\n"
4469 "Set tag for this route\n"
4470 "Tag value\n"
4471 "Distance value for this prefix\n"
4472 VRF_CMD_HELP_STR)
4473 {
4474 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
4475 }
4476
4477 DEFUN (no_ipv6_route_vrf,
4478 no_ipv6_route_vrf_cmd,
4479 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
4480 NO_STR
4481 IP_STR
4482 "Establish static routes\n"
4483 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4484 "IPv6 gateway address\n"
4485 "IPv6 gateway interface name\n"
4486 VRF_CMD_HELP_STR)
4487 {
4488 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2]);
4489 }
4490
4491 DEFUN (no_ipv6_route_tag_vrf,
4492 no_ipv6_route_tag_vrf_cmd,
4493 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> " VRF_CMD_STR,
4494 NO_STR
4495 IP_STR
4496 "Establish static routes\n"
4497 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4498 "IPv6 gateway address\n"
4499 "IPv6 gateway interface name\n"
4500 "Set tag for this route\n"
4501 "Tag value\n"
4502 VRF_CMD_HELP_STR)
4503 {
4504 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, argv[3]);
4505 }
4506
4507 DEFUN (no_ipv6_route_flags_vrf,
4508 no_ipv6_route_flags_vrf_cmd,
4509 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
4510 NO_STR
4511 IP_STR
4512 "Establish static routes\n"
4513 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4514 "IPv6 gateway address\n"
4515 "IPv6 gateway interface name\n"
4516 "Emit an ICMP unreachable when matched\n"
4517 "Silently discard pkts when matched\n"
4518 VRF_CMD_HELP_STR)
4519 {
4520 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3]);
4521 }
4522
4523 DEFUN (no_ipv6_route_flags_tag_vrf,
4524 no_ipv6_route_flags_tag_vrf_cmd,
4525 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
4526 NO_STR
4527 IP_STR
4528 "Establish static routes\n"
4529 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4530 "IPv6 gateway address\n"
4531 "IPv6 gateway interface name\n"
4532 "Emit an ICMP unreachable when matched\n"
4533 "Silently discard pkts when matched\n"
4534 "Set tag for this route\n"
4535 "Tag value\n"
4536 VRF_CMD_HELP_STR)
4537 {
4538 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL, argv[4]);
4539 }
4540
4541 DEFUN (no_ipv6_route_ifname_vrf,
4542 no_ipv6_route_ifname_vrf_cmd,
4543 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
4544 NO_STR
4545 IP_STR
4546 "Establish static routes\n"
4547 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4548 "IPv6 gateway address\n"
4549 "IPv6 gateway interface name\n"
4550 VRF_CMD_HELP_STR)
4551 {
4552 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3]);
4553 }
4554
4555 DEFUN (no_ipv6_route_ifname_tag_vrf,
4556 no_ipv6_route_ifname_tag_vrf_cmd,
4557 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> " VRF_CMD_STR,
4558 NO_STR
4559 IP_STR
4560 "Establish static routes\n"
4561 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4562 "IPv6 gateway address\n"
4563 "IPv6 gateway interface name\n"
4564 "Set tag for this route\n"
4565 "Tag value\n"
4566 VRF_CMD_HELP_STR)
4567 {
4568 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, argv[4]);
4569 }
4570
4571 DEFUN (no_ipv6_route_ifname_flags_vrf,
4572 no_ipv6_route_ifname_flags_vrf_cmd,
4573 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
4574 NO_STR
4575 IP_STR
4576 "Establish static routes\n"
4577 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4578 "IPv6 gateway address\n"
4579 "IPv6 gateway interface name\n"
4580 "Emit an ICMP unreachable when matched\n"
4581 "Silently discard pkts when matched\n"
4582 VRF_CMD_HELP_STR)
4583 {
4584 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4]);
4585 }
4586
4587 DEFUN (no_ipv6_route_ifname_flags_tag_vrf,
4588 no_ipv6_route_ifname_flags_tag_vrf_cmd,
4589 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> " VRF_CMD_STR,
4590 NO_STR
4591 IP_STR
4592 "Establish static routes\n"
4593 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4594 "IPv6 gateway address\n"
4595 "IPv6 gateway interface name\n"
4596 "Emit an ICMP unreachable when matched\n"
4597 "Silently discard pkts when matched\n"
4598 "Set tag for this route\n"
4599 "Tag value\n"
4600 VRF_CMD_HELP_STR)
4601 {
4602 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL, argv[5]);
4603 }
4604
4605 DEFUN (no_ipv6_route_pref_vrf,
4606 no_ipv6_route_pref_vrf_cmd,
4607 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
4608 NO_STR
4609 IP_STR
4610 "Establish static routes\n"
4611 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4612 "IPv6 gateway address\n"
4613 "IPv6 gateway interface name\n"
4614 "Distance value for this prefix\n"
4615 VRF_CMD_HELP_STR)
4616 {
4617 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3]);
4618 }
4619
4620 DEFUN (no_ipv6_route_pref_tag_vrf,
4621 no_ipv6_route_pref_tag_vrf_cmd,
4622 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-65535> <1-255> " VRF_CMD_STR,
4623 NO_STR
4624 IP_STR
4625 "Establish static routes\n"
4626 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4627 "IPv6 gateway address\n"
4628 "IPv6 gateway interface name\n"
4629 "Set tag for this route\n"
4630 "Tag value\n"
4631 "Distance value for this prefix\n"
4632 VRF_CMD_HELP_STR)
4633 {
4634 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], argv[4]);
4635 }
4636
4637 DEFUN (no_ipv6_route_flags_pref_vrf,
4638 no_ipv6_route_flags_pref_vrf_cmd,
4639 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
4640 NO_STR
4641 IP_STR
4642 "Establish static routes\n"
4643 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4644 "IPv6 gateway address\n"
4645 "IPv6 gateway interface name\n"
4646 "Emit an ICMP unreachable when matched\n"
4647 "Silently discard pkts when matched\n"
4648 "Distance value for this prefix\n"
4649 VRF_CMD_HELP_STR)
4650 {
4651 /* We do not care about argv[2] */
4652 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]);
4653 }
4654
4655 DEFUN (no_ipv6_route_flags_pref_tag_vrf,
4656 no_ipv6_route_flags_pref_tag_vrf_cmd,
4657 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
4658 NO_STR
4659 IP_STR
4660 "Establish static routes\n"
4661 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4662 "IPv6 gateway address\n"
4663 "IPv6 gateway interface name\n"
4664 "Emit an ICMP unreachable when matched\n"
4665 "Silently discard pkts when matched\n"
4666 "Set tag for this route\n"
4667 "Tag value\n"
4668 "Distance value for this prefix\n"
4669 VRF_CMD_HELP_STR)
4670 {
4671 /* We do not care about argv[2] */
4672 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], argv[4], argv[5]);
4673 }
4674
4675 DEFUN (no_ipv6_route_ifname_pref_vrf,
4676 no_ipv6_route_ifname_pref_vrf_cmd,
4677 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
4678 NO_STR
4679 IP_STR
4680 "Establish static routes\n"
4681 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4682 "IPv6 gateway address\n"
4683 "IPv6 gateway interface name\n"
4684 "Distance value for this prefix\n"
4685 VRF_CMD_HELP_STR)
4686 {
4687 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]);
4688 }
4689
4690 DEFUN (no_ipv6_route_ifname_pref_tag_vrf,
4691 no_ipv6_route_ifname_pref_tag_vrf_cmd,
4692 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-65535> <1-255> " VRF_CMD_STR,
4693 NO_STR
4694 IP_STR
4695 "Establish static routes\n"
4696 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4697 "IPv6 gateway address\n"
4698 "IPv6 gateway interface name\n"
4699 "Set tag for this route\n"
4700 "Tag value\n"
4701 "Distance value for this prefix\n"
4702 VRF_CMD_HELP_STR)
4703 {
4704 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], argv[5]);
4705 }
4706
4707 DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
4708 no_ipv6_route_ifname_flags_pref_vrf_cmd,
4709 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
4710 NO_STR
4711 IP_STR
4712 "Establish static routes\n"
4713 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4714 "IPv6 gateway address\n"
4715 "IPv6 gateway interface name\n"
4716 "Emit an ICMP unreachable when matched\n"
4717 "Silently discard pkts when matched\n"
4718 "Distance value for this prefix\n"
4719 VRF_CMD_HELP_STR)
4720 {
4721 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]);
4722 }
4723
4724 DEFUN (no_ipv6_route_ifname_flags_pref_tag_vrf,
4725 no_ipv6_route_ifname_flags_pref_tag_vrf_cmd,
4726 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) tag <1-65535> <1-255> " VRF_CMD_STR,
4727 NO_STR
4728 IP_STR
4729 "Establish static routes\n"
4730 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
4731 "IPv6 gateway address\n"
4732 "IPv6 gateway interface name\n"
4733 "Emit an ICMP unreachable when matched\n"
4734 "Silently discard pkts when matched\n"
4735 "Set tag for this route\n"
4736 "Tag value\n"
4737 "Distance value for this prefix\n"
4738 VRF_CMD_HELP_STR)
4739 {
4740 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
4741 }
4742
4743 DEFUN (show_ipv6_route,
4744 show_ipv6_route_cmd,
4745 "show ipv6 route {json}",
4746 SHOW_STR
4747 IP_STR
4748 "IPv6 routing table\n")
4749 {
4750 struct route_table *table;
4751 struct route_node *rn;
4752 struct rib *rib;
4753 int first = 1;
4754 vrf_id_t vrf_id = VRF_DEFAULT;
4755 struct zebra_vrf *zvrf = NULL;
4756 char buf[BUFSIZ];
4757 json_object *json = NULL;
4758 json_object *json_prefix = NULL;
4759 u_char uj = use_json(argc, argv);
4760
4761 if (argc > 0 && argv[0] && strcmp(argv[0], "json") != 0)
4762 {
4763 if (!(zvrf = zebra_vrf_list_lookup_by_name (argv[0])))
4764 {
4765 if (uj)
4766 vty_out (vty, "{}%s", VTY_NEWLINE);
4767 else
4768 vty_out (vty, "vrf %s not defined%s", argv[0], VTY_NEWLINE);
4769 return CMD_SUCCESS;
4770 }
4771
4772 if (zvrf->vrf_id == VRF_UNKNOWN)
4773 {
4774 if (uj)
4775 vty_out (vty, "{}%s", VTY_NEWLINE);
4776 else
4777 vty_out (vty, "vrf %s inactive%s", argv[0], VTY_NEWLINE);
4778 return CMD_SUCCESS;
4779 }
4780 else
4781 vrf_id = zvrf->vrf_id;
4782 }
4783
4784 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4785 if (! table)
4786 {
4787 if (uj)
4788 vty_out (vty, "{}%s", VTY_NEWLINE);
4789 return CMD_SUCCESS;
4790 }
4791
4792 if (uj)
4793 {
4794 json = json_object_new_object();
4795
4796 /* Show all IPv6 route. */
4797 for (rn = route_top (table); rn; rn = route_next (rn))
4798 {
4799 RNODE_FOREACH_RIB (rn, rib)
4800 {
4801 if (!json_prefix)
4802 json_prefix = json_object_new_array();
4803 vty_show_ip_route (vty, rn, rib, json_prefix);
4804 }
4805
4806 if (json_prefix)
4807 {
4808 prefix2str (&rn->p, buf, sizeof buf);
4809 json_object_object_add(json, buf, json_prefix);
4810 json_prefix = NULL;
4811 }
4812 }
4813
4814 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
4815 json_object_free(json);
4816 }
4817 else
4818 {
4819 /* Show all IPv6 route. */
4820 for (rn = route_top (table); rn; rn = route_next (rn))
4821 {
4822 RNODE_FOREACH_RIB (rn, rib)
4823 {
4824 if (first)
4825 {
4826 vty_out (vty, SHOW_ROUTE_V6_HEADER);
4827 first = 0;
4828 }
4829 vty_show_ip_route (vty, rn, rib, NULL);
4830 }
4831 }
4832 }
4833
4834 return CMD_SUCCESS;
4835 }
4836
4837 ALIAS (show_ipv6_route,
4838 show_ipv6_route_vrf_cmd,
4839 "show ipv6 route " VRF_CMD_STR " {json}",
4840 SHOW_STR
4841 IP_STR
4842 "IPv6 routing table\n"
4843 VRF_CMD_HELP_STR)
4844
4845 DEFUN (show_ipv6_route_tag,
4846 show_ipv6_route_tag_cmd,
4847 "show ipv6 route tag <1-65535>",
4848 SHOW_STR
4849 IP_STR
4850 "IPv6 routing table\n"
4851 "Show only routes with tag\n"
4852 "Tag value\n")
4853 {
4854 struct route_table *table;
4855 struct route_node *rn;
4856 struct rib *rib;
4857 int first = 1;
4858 u_short tag = 0;
4859 vrf_id_t vrf_id = VRF_DEFAULT;
4860
4861 if (argc > 1)
4862 {
4863 VRF_GET_ID (vrf_id, argv[0]);
4864 tag = atoi(argv[1]);
4865 }
4866 else
4867 tag = atoi(argv[0]);
4868
4869 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4870 if (! table)
4871 return CMD_SUCCESS;
4872
4873 /* Show all IPv6 routes with matching tag value. */
4874 for (rn = route_top (table); rn; rn = route_next (rn))
4875 RNODE_FOREACH_RIB (rn, rib)
4876 {
4877 if (rib->tag != tag)
4878 continue;
4879
4880 if (first)
4881 {
4882 vty_out (vty, SHOW_ROUTE_V6_HEADER);
4883 first = 0;
4884 }
4885 vty_show_ip_route (vty, rn, rib, NULL);
4886 }
4887 return CMD_SUCCESS;
4888 }
4889
4890 ALIAS (show_ipv6_route_tag,
4891 show_ipv6_route_vrf_tag_cmd,
4892 "show ipv6 route " VRF_CMD_STR " tag <1-65535>",
4893 SHOW_STR
4894 IP_STR
4895 "IPv6 routing table\n"
4896 VRF_CMD_HELP_STR
4897 "Show only routes with tag\n"
4898 "Tag value\n")
4899
4900 DEFUN (show_ipv6_route_prefix_longer,
4901 show_ipv6_route_prefix_longer_cmd,
4902 "show ipv6 route X:X::X:X/M longer-prefixes",
4903 SHOW_STR
4904 IP_STR
4905 "IPv6 routing table\n"
4906 "IPv6 prefix\n"
4907 "Show route matching the specified Network/Mask pair only\n")
4908 {
4909 struct route_table *table;
4910 struct route_node *rn;
4911 struct rib *rib;
4912 struct prefix p;
4913 int ret;
4914 int first = 1;
4915 vrf_id_t vrf_id = VRF_DEFAULT;
4916
4917 if (argc > 1)
4918 {
4919 VRF_GET_ID (vrf_id, argv[0]);
4920 ret = str2prefix (argv[1], &p);
4921 }
4922 else
4923 ret = str2prefix (argv[0], &p);
4924
4925 if (! ret)
4926 {
4927 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
4928 return CMD_WARNING;
4929 }
4930
4931 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4932 if (! table)
4933 return CMD_SUCCESS;
4934
4935 /* Show matched type IPv6 routes. */
4936 for (rn = route_top (table); rn; rn = route_next (rn))
4937 RNODE_FOREACH_RIB (rn, rib)
4938 if (prefix_match (&p, &rn->p))
4939 {
4940 if (first)
4941 {
4942 vty_out (vty, SHOW_ROUTE_V6_HEADER);
4943 first = 0;
4944 }
4945 vty_show_ip_route (vty, rn, rib, NULL);
4946 }
4947 return CMD_SUCCESS;
4948 }
4949
4950 ALIAS (show_ipv6_route_prefix_longer,
4951 show_ipv6_route_vrf_prefix_longer_cmd,
4952 "show ipv6 route " VRF_CMD_STR " X:X::X:X/M longer-prefixes",
4953 SHOW_STR
4954 IP_STR
4955 "IPv6 routing table\n"
4956 VRF_CMD_HELP_STR
4957 "IPv6 prefix\n"
4958 "Show route matching the specified Network/Mask pair only\n")
4959
4960 DEFUN (show_ipv6_route_protocol,
4961 show_ipv6_route_protocol_cmd,
4962 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
4963 SHOW_STR
4964 IP_STR
4965 "IP routing table\n"
4966 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
4967 {
4968 int type;
4969 struct route_table *table;
4970 struct route_node *rn;
4971 struct rib *rib;
4972 int first = 1;
4973 vrf_id_t vrf_id = VRF_DEFAULT;
4974
4975 if ( argc >1 )
4976 {
4977 VRF_GET_ID (vrf_id, argv[0]);
4978 type = proto_redistnum (AFI_IP6, argv[1]);
4979 }
4980 else
4981 type = proto_redistnum (AFI_IP6, argv[0]);
4982
4983 if (type < 0)
4984 {
4985 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
4986 return CMD_WARNING;
4987 }
4988
4989 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
4990 if (! table)
4991 return CMD_SUCCESS;
4992
4993 /* Show matched type IPv6 routes. */
4994 for (rn = route_top (table); rn; rn = route_next (rn))
4995 RNODE_FOREACH_RIB (rn, rib)
4996 if (rib->type == type)
4997 {
4998 if (first)
4999 {
5000 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5001 first = 0;
5002 }
5003 vty_show_ip_route (vty, rn, rib, NULL);
5004 }
5005 return CMD_SUCCESS;
5006 }
5007
5008 ALIAS (show_ipv6_route_protocol,
5009 show_ipv6_route_vrf_protocol_cmd,
5010 "show ipv6 route " VRF_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA,
5011 SHOW_STR
5012 IP_STR
5013 "IP routing table\n"
5014 VRF_CMD_HELP_STR
5015 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
5016
5017 DEFUN (show_ipv6_route_addr,
5018 show_ipv6_route_addr_cmd,
5019 "show ipv6 route X:X::X:X",
5020 SHOW_STR
5021 IP_STR
5022 "IPv6 routing table\n"
5023 "IPv6 Address\n")
5024 {
5025 int ret;
5026 struct prefix_ipv6 p;
5027 struct route_table *table;
5028 struct route_node *rn;
5029 vrf_id_t vrf_id = VRF_DEFAULT;
5030
5031 if (argc > 1 )
5032 {
5033 VRF_GET_ID (vrf_id, argv[0]);
5034 ret = str2prefix_ipv6 (argv[1], &p);
5035 }
5036 else
5037 ret = str2prefix_ipv6 (argv[0], &p);
5038
5039 if (ret <= 0)
5040 {
5041 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
5042 return CMD_WARNING;
5043 }
5044
5045 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
5046 if (! table)
5047 return CMD_SUCCESS;
5048
5049 rn = route_node_match (table, (struct prefix *) &p);
5050 if (! rn)
5051 {
5052 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5053 return CMD_WARNING;
5054 }
5055
5056 vty_show_ip_route_detail (vty, rn, 0);
5057
5058 route_unlock_node (rn);
5059
5060 return CMD_SUCCESS;
5061 }
5062
5063 ALIAS (show_ipv6_route_addr,
5064 show_ipv6_route_vrf_addr_cmd,
5065 "show ipv6 route " VRF_CMD_STR " X:X::X:X",
5066 SHOW_STR
5067 IP_STR
5068 "IPv6 routing table\n"
5069 VRF_CMD_HELP_STR
5070 "IPv6 Address\n")
5071
5072 DEFUN (show_ipv6_route_prefix,
5073 show_ipv6_route_prefix_cmd,
5074 "show ipv6 route X:X::X:X/M",
5075 SHOW_STR
5076 IP_STR
5077 "IPv6 routing table\n"
5078 "IPv6 prefix\n")
5079 {
5080 int ret;
5081 struct prefix_ipv6 p;
5082 struct route_table *table;
5083 struct route_node *rn;
5084 vrf_id_t vrf_id = VRF_DEFAULT;
5085
5086 if (argc > 1)
5087 {
5088 VRF_GET_ID (vrf_id, argv[0]);
5089 ret = str2prefix_ipv6 (argv[1], &p);
5090 }
5091 else
5092 ret = str2prefix_ipv6 (argv[0], &p);
5093
5094 if (ret <= 0)
5095 {
5096 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
5097 return CMD_WARNING;
5098 }
5099
5100 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
5101 if (! table)
5102 return CMD_SUCCESS;
5103
5104 rn = route_node_match (table, (struct prefix *) &p);
5105 if (! rn || rn->p.prefixlen != p.prefixlen)
5106 {
5107 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5108 return CMD_WARNING;
5109 }
5110
5111 vty_show_ip_route_detail (vty, rn, 0);
5112
5113 route_unlock_node (rn);
5114
5115 return CMD_SUCCESS;
5116 }
5117
5118 ALIAS (show_ipv6_route_prefix,
5119 show_ipv6_route_vrf_prefix_cmd,
5120 "show ipv6 route " VRF_CMD_STR " X:X::X:X/M ",
5121 SHOW_STR
5122 IP_STR
5123 "IPv6 routing table\n"
5124 VRF_CMD_HELP_STR
5125 "IPv6 prefix\n")
5126
5127 /* Show route summary. */
5128 DEFUN (show_ipv6_route_summary,
5129 show_ipv6_route_summary_cmd,
5130 "show ipv6 route summary",
5131 SHOW_STR
5132 IP_STR
5133 "IPv6 routing table\n"
5134 "Summary of all IPv6 routes\n")
5135 {
5136 struct route_table *table;
5137 vrf_id_t vrf_id = VRF_DEFAULT;
5138
5139 if (argc > 0)
5140 VRF_GET_ID (vrf_id, argv[0]);
5141
5142 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
5143 if (! table)
5144 return CMD_SUCCESS;
5145
5146 vty_show_ip_route_summary (vty, table);
5147
5148 return CMD_SUCCESS;
5149 }
5150
5151 ALIAS (show_ipv6_route_summary,
5152 show_ipv6_route_vrf_summary_cmd,
5153 "show ipv6 route " VRF_CMD_STR " summary",
5154 SHOW_STR
5155 IP_STR
5156 "IPv6 routing table\n"
5157 VRF_CMD_HELP_STR
5158 "Summary of all IPv6 routes\n")
5159
5160 /* Show ipv6 route summary prefix. */
5161 DEFUN (show_ipv6_route_summary_prefix,
5162 show_ipv6_route_summary_prefix_cmd,
5163 "show ipv6 route summary prefix",
5164 SHOW_STR
5165 IP_STR
5166 "IPv6 routing table\n"
5167 "Summary of all IPv6 routes\n"
5168 "Prefix routes\n")
5169 {
5170 struct route_table *table;
5171 vrf_id_t vrf_id = VRF_DEFAULT;
5172
5173 if (argc > 0)
5174 VRF_GET_ID (vrf_id, argv[0]);
5175
5176 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
5177 if (! table)
5178 return CMD_SUCCESS;
5179
5180 vty_show_ip_route_summary_prefix (vty, table);
5181
5182 return CMD_SUCCESS;
5183 }
5184
5185 ALIAS (show_ipv6_route_summary_prefix,
5186 show_ipv6_route_vrf_summary_prefix_cmd,
5187 "show ipv6 route " VRF_CMD_STR " summary prefix",
5188 SHOW_STR
5189 IP_STR
5190 "IPv6 routing table\n"
5191 VRF_CMD_HELP_STR
5192 "Summary of all IPv6 routes\n"
5193 "Prefix routes\n")
5194
5195 /*
5196 * Show IPv6 mroute command.Used to dump
5197 * the Multicast routing table.
5198 */
5199
5200 DEFUN (show_ipv6_mroute,
5201 show_ipv6_mroute_cmd,
5202 "show ipv6 mroute",
5203 SHOW_STR
5204 IP_STR
5205 "IPv6 Multicast routing table\n")
5206 {
5207 struct route_table *table;
5208 struct route_node *rn;
5209 struct rib *rib;
5210 int first = 1;
5211 vrf_id_t vrf_id = VRF_DEFAULT;
5212
5213 if (argc > 0)
5214 VRF_GET_ID (vrf_id, argv[0]);
5215
5216 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
5217 if (! table)
5218 return CMD_SUCCESS;
5219
5220 /* Show all IPv6 route. */
5221 for (rn = route_top (table); rn; rn = route_next (rn))
5222 RNODE_FOREACH_RIB (rn, rib)
5223 {
5224 if (first)
5225 {
5226 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5227 first = 0;
5228 }
5229 vty_show_ip_route (vty, rn, rib, NULL);
5230 }
5231 return CMD_SUCCESS;
5232 }
5233
5234 ALIAS (show_ipv6_mroute,
5235 show_ipv6_mroute_vrf_cmd,
5236 "show ipv6 mroute " VRF_CMD_STR,
5237 SHOW_STR
5238 IP_STR
5239 "IPv6 Multicast routing table\n"
5240 VRF_CMD_HELP_STR)
5241
5242 DEFUN (show_ipv6_route_vrf_all,
5243 show_ipv6_route_vrf_all_cmd,
5244 "show ipv6 route " VRF_ALL_CMD_STR,
5245 SHOW_STR
5246 IP_STR
5247 "IPv6 routing table\n"
5248 VRF_ALL_CMD_HELP_STR)
5249 {
5250 struct route_table *table;
5251 struct route_node *rn;
5252 struct rib *rib;
5253 struct zebra_vrf *zvrf;
5254 vrf_iter_t iter;
5255 int first = 1;
5256 int vrf_header = 1;
5257
5258 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5259 {
5260 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5261 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5262 continue;
5263
5264 /* Show all IPv6 route. */
5265 for (rn = route_top (table); rn; rn = route_next (rn))
5266 RNODE_FOREACH_RIB (rn, rib)
5267 {
5268 if (first)
5269 {
5270 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5271 first = 0;
5272 }
5273
5274 if (vrf_header)
5275 {
5276 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
5277 vrf_header = 0;
5278 }
5279 vty_show_ip_route (vty, rn, rib, NULL);
5280 }
5281 vrf_header = 1;
5282 }
5283
5284 return CMD_SUCCESS;
5285 }
5286
5287 DEFUN (show_ipv6_route_vrf_all_tag,
5288 show_ipv6_route_vrf_all_tag_cmd,
5289 "show ipv6 route " VRF_ALL_CMD_STR " tag <1-65535>",
5290 SHOW_STR
5291 IP_STR
5292 "IPv6 routing table\n"
5293 VRF_ALL_CMD_HELP_STR
5294 "Show only routes with tag\n"
5295 "Tag value\n")
5296 {
5297 struct route_table *table;
5298 struct route_node *rn;
5299 struct rib *rib;
5300 struct zebra_vrf *zvrf;
5301 vrf_iter_t iter;
5302 int first = 1;
5303 int vrf_header = 1;
5304 u_short tag = 0;
5305
5306 if (argv[0])
5307 tag = atoi(argv[0]);
5308
5309 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5310 {
5311 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5312 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
5313 continue;
5314
5315 /* Show all IPv6 routes with matching tag value. */
5316 for (rn = route_top (table); rn; rn = route_next (rn))
5317 RNODE_FOREACH_RIB (rn, rib)
5318 {
5319 if (rib->tag != tag)
5320 continue;
5321
5322 if (first)
5323 {
5324 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5325 first = 0;
5326 }
5327
5328 if (vrf_header)
5329 {
5330 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
5331 vrf_header = 0;
5332 }
5333 vty_show_ip_route (vty, rn, rib, NULL);
5334 }
5335 vrf_header = 1;
5336 }
5337
5338 return CMD_SUCCESS;
5339 }
5340
5341 DEFUN (show_ipv6_route_vrf_all_prefix_longer,
5342 show_ipv6_route_vrf_all_prefix_longer_cmd,
5343 "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X/M longer-prefixes",
5344 SHOW_STR
5345 IP_STR
5346 "IPv6 routing table\n"
5347 VRF_ALL_CMD_HELP_STR
5348 "IPv6 prefix\n"
5349 "Show route matching the specified Network/Mask pair only\n")
5350 {
5351 struct route_table *table;
5352 struct route_node *rn;
5353 struct rib *rib;
5354 struct prefix p;
5355 struct zebra_vrf *zvrf;
5356 vrf_iter_t iter;
5357 int ret;
5358 int first = 1;
5359 int vrf_header = 1;
5360
5361 ret = str2prefix (argv[0], &p);
5362 if (! ret)
5363 {
5364 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
5365 return CMD_WARNING;
5366 }
5367
5368 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5369 {
5370 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5371 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5372 continue;
5373
5374 /* Show matched type IPv6 routes. */
5375 for (rn = route_top (table); rn; rn = route_next (rn))
5376 RNODE_FOREACH_RIB (rn, rib)
5377 if (prefix_match (&p, &rn->p))
5378 {
5379 if (first)
5380 {
5381 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5382 first = 0;
5383 }
5384
5385 if (vrf_header)
5386 {
5387 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
5388 vrf_header = 0;
5389 }
5390 vty_show_ip_route (vty, rn, rib, NULL);
5391 }
5392 vrf_header = 1;
5393 }
5394
5395 return CMD_SUCCESS;
5396 }
5397
5398 DEFUN (show_ipv6_route_vrf_all_protocol,
5399 show_ipv6_route_vrf_all_protocol_cmd,
5400 "show ipv6 route " VRF_ALL_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA,
5401 SHOW_STR
5402 IP_STR
5403 "IP routing table\n"
5404 VRF_ALL_CMD_HELP_STR
5405 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
5406 {
5407 int type;
5408 struct route_table *table;
5409 struct route_node *rn;
5410 struct rib *rib;
5411 struct zebra_vrf *zvrf;
5412 vrf_iter_t iter;
5413 int first = 1;
5414 int vrf_header = 1;
5415
5416 type = proto_redistnum (AFI_IP6, argv[0]);
5417 if (type < 0)
5418 {
5419 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
5420 return CMD_WARNING;
5421 }
5422
5423 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5424 {
5425 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5426 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5427 continue;
5428
5429 /* Show matched type IPv6 routes. */
5430 for (rn = route_top (table); rn; rn = route_next (rn))
5431 RNODE_FOREACH_RIB (rn, rib)
5432 if (rib->type == type)
5433 {
5434 if (first)
5435 {
5436 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5437 first = 0;
5438 }
5439
5440 if (vrf_header)
5441 {
5442 vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE);
5443 vrf_header = 0;
5444 }
5445 vty_show_ip_route (vty, rn, rib, NULL);
5446 }
5447 vrf_header = 1;
5448 }
5449
5450 return CMD_SUCCESS;
5451 }
5452
5453 DEFUN (show_ipv6_route_vrf_all_addr,
5454 show_ipv6_route_vrf_all_addr_cmd,
5455 "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X",
5456 SHOW_STR
5457 IP_STR
5458 "IPv6 routing table\n"
5459 VRF_ALL_CMD_HELP_STR
5460 "IPv6 Address\n")
5461 {
5462 int ret;
5463 struct prefix_ipv6 p;
5464 struct route_table *table;
5465 struct route_node *rn;
5466 struct zebra_vrf *zvrf;
5467 vrf_iter_t iter;
5468
5469 ret = str2prefix_ipv6 (argv[0], &p);
5470 if (ret <= 0)
5471 {
5472 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
5473 return CMD_WARNING;
5474 }
5475
5476 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5477 {
5478 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5479 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5480 continue;
5481
5482 rn = route_node_match (table, (struct prefix *) &p);
5483 if (! rn)
5484 continue;
5485
5486 vty_show_ip_route_detail (vty, rn, 0);
5487
5488 route_unlock_node (rn);
5489 }
5490
5491 return CMD_SUCCESS;
5492 }
5493
5494 DEFUN (show_ipv6_route_vrf_all_prefix,
5495 show_ipv6_route_vrf_all_prefix_cmd,
5496 "show ipv6 route " VRF_ALL_CMD_STR " X:X::X:X/M",
5497 SHOW_STR
5498 IP_STR
5499 "IPv6 routing table\n"
5500 VRF_ALL_CMD_HELP_STR
5501 "IPv6 prefix\n")
5502 {
5503 int ret;
5504 struct prefix_ipv6 p;
5505 struct route_table *table;
5506 struct route_node *rn;
5507 struct zebra_vrf *zvrf;
5508 vrf_iter_t iter;
5509
5510 ret = str2prefix_ipv6 (argv[0], &p);
5511 if (ret <= 0)
5512 {
5513 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
5514 return CMD_WARNING;
5515 }
5516
5517 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5518 {
5519 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5520 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5521 continue;
5522
5523 rn = route_node_match (table, (struct prefix *) &p);
5524 if (! rn)
5525 continue;
5526 if (rn->p.prefixlen != p.prefixlen)
5527 {
5528 route_unlock_node (rn);
5529 continue;
5530 }
5531
5532 vty_show_ip_route_detail (vty, rn, 0);
5533
5534 route_unlock_node (rn);
5535 }
5536
5537 return CMD_SUCCESS;
5538 }
5539
5540 DEFUN (show_ipv6_route_vrf_all_summary,
5541 show_ipv6_route_vrf_all_summary_cmd,
5542 "show ipv6 route " VRF_ALL_CMD_STR " summary",
5543 SHOW_STR
5544 IP_STR
5545 "IPv6 routing table\n"
5546 VRF_ALL_CMD_HELP_STR
5547 "Summary of all IPv6 routes\n")
5548 {
5549 struct zebra_vrf *zvrf;
5550 vrf_iter_t iter;
5551
5552 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5553 if ((zvrf = vrf_iter2info (iter)) != NULL)
5554 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
5555
5556 return CMD_SUCCESS;
5557 }
5558
5559 DEFUN (show_ipv6_mroute_vrf_all,
5560 show_ipv6_mroute_vrf_all_cmd,
5561 "show ipv6 mroute " VRF_ALL_CMD_STR,
5562 SHOW_STR
5563 IP_STR
5564 "IPv6 Multicast routing table\n"
5565 VRF_ALL_CMD_HELP_STR)
5566 {
5567 struct route_table *table;
5568 struct route_node *rn;
5569 struct rib *rib;
5570 struct zebra_vrf *zvrf;
5571 vrf_iter_t iter;
5572 int first = 1;
5573
5574 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5575 {
5576 if ((zvrf = vrf_iter2info (iter)) == NULL ||
5577 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
5578 continue;
5579
5580 /* Show all IPv6 route. */
5581 for (rn = route_top (table); rn; rn = route_next (rn))
5582 RNODE_FOREACH_RIB (rn, rib)
5583 {
5584 if (first)
5585 {
5586 vty_out (vty, SHOW_ROUTE_V6_HEADER);
5587 first = 0;
5588 }
5589 vty_show_ip_route (vty, rn, rib, NULL);
5590 }
5591 }
5592 return CMD_SUCCESS;
5593 }
5594
5595 DEFUN (show_ipv6_route_vrf_all_summary_prefix,
5596 show_ipv6_route_vrf_all_summary_prefix_cmd,
5597 "show ipv6 route " VRF_ALL_CMD_STR " summary prefix",
5598 SHOW_STR
5599 IP_STR
5600 "IPv6 routing table\n"
5601 VRF_ALL_CMD_HELP_STR
5602 "Summary of all IPv6 routes\n"
5603 "Prefix routes\n")
5604 {
5605 struct zebra_vrf *zvrf;
5606 vrf_iter_t iter;
5607
5608 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
5609 if ((zvrf = vrf_iter2info (iter)) != NULL)
5610 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
5611
5612 return CMD_SUCCESS;
5613 }
5614
5615 /* Write IPv6 static route configuration. */
5616 static int
5617 static_config_ipv6 (struct vty *vty)
5618 {
5619 struct route_node *rn;
5620 struct static_route *si;
5621 int write = 0;
5622 char buf[PREFIX_STRLEN];
5623 struct route_table *stable;
5624 struct zebra_vrf *zvrf;
5625 struct listnode *node;
5626
5627 for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf))
5628 {
5629 if ((stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
5630 continue;
5631
5632 for (rn = route_top (stable); rn; rn = route_next (rn))
5633 for (si = rn->info; si; si = si->next)
5634 {
5635 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
5636
5637 switch (si->type)
5638 {
5639 case STATIC_IPV6_GATEWAY:
5640 vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
5641 break;
5642 case STATIC_IFINDEX:
5643 vty_out (vty, " %s", si->ifname);
5644 break;
5645 case STATIC_IPV6_GATEWAY_IFINDEX:
5646 vty_out (vty, " %s %s",
5647 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
5648 ifindex2ifname_vrf (si->ifindex, si->vrf_id));
5649 break;
5650 }
5651
5652 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
5653 vty_out (vty, " %s", "reject");
5654
5655 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
5656 vty_out (vty, " %s", "blackhole");
5657
5658 if (si->tag)
5659 vty_out (vty, " tag %d", si->tag);
5660
5661 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
5662 vty_out (vty, " %d", si->distance);
5663
5664 if (si->vrf_id != VRF_DEFAULT)
5665 {
5666 vty_out (vty, " vrf %s", zvrf->name);
5667 }
5668
5669 vty_out (vty, "%s", VTY_NEWLINE);
5670
5671 write = 1;
5672 }
5673 }
5674 return write;
5675 }
5676 #endif /* HAVE_IPV6 */
5677
5678 DEFUN (allow_external_route_update,
5679 allow_external_route_update_cmd,
5680 "allow-external-route-update",
5681 "Allow Quagga routes to be overwritten by external processes")
5682 {
5683 allow_delete = 1;
5684
5685 return CMD_SUCCESS;
5686 }
5687
5688 DEFUN (no_allow_external_route_update,
5689 no_allow_external_route_update_cmd,
5690 "no allow-external-route-update",
5691 "Allow Quagga routes to be overwritten by external processes")
5692 {
5693 allow_delete = 0;
5694
5695 return CMD_SUCCESS;
5696 }
5697
5698 /* show vrf */
5699 DEFUN (show_vrf,
5700 show_vrf_cmd,
5701 "show vrf",
5702 SHOW_STR
5703 "VRF\n")
5704 {
5705 struct zebra_vrf *zvrf;
5706 struct listnode *node;
5707
5708 for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf))
5709 {
5710 if (!zvrf->vrf_id)
5711 continue;
5712
5713 vty_out (vty, "vrf %s ", zvrf->name);
5714 if (zvrf->vrf_id == VRF_UNKNOWN)
5715 vty_out (vty, "inactive");
5716 else
5717 vty_out (vty, "id %u table %u", zvrf->vrf_id, zvrf->table_id);
5718 vty_out (vty, "%s", VTY_NEWLINE);
5719
5720 }
5721
5722 return CMD_SUCCESS;
5723 }
5724
5725 /* Static ip route configuration write function. */
5726 static int
5727 zebra_ip_config (struct vty *vty)
5728 {
5729 int write = 0;
5730
5731 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
5732 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
5733 #ifdef HAVE_IPV6
5734 write += static_config_ipv6 (vty);
5735 #endif /* HAVE_IPV6 */
5736
5737 write += zebra_import_table_config (vty);
5738 return write;
5739 }
5740
5741 DEFUN (ip_zebra_import_table_distance,
5742 ip_zebra_import_table_distance_cmd,
5743 "ip import-table <1-252> distance <1-255>",
5744 IP_STR
5745 "import routes from non-main kernel table\n"
5746 "kernel routing table id\n"
5747 "Distance for imported routes\n"
5748 "Default distance value\n")
5749 {
5750 u_int32_t table_id = 0;
5751 int distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
5752
5753 if (argc)
5754 VTY_GET_INTEGER("table", table_id, argv[0]);
5755
5756 if (!is_zebra_valid_kernel_table(table_id))
5757 {
5758 vty_out(vty, "Invalid routing table ID, %d. Must be in range 1-252%s",
5759 table_id, VTY_NEWLINE);
5760 return CMD_WARNING;
5761 }
5762
5763 if (is_zebra_main_routing_table(table_id))
5764 {
5765 vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s",
5766 table_id, VTY_NEWLINE);
5767 return CMD_WARNING;
5768 }
5769
5770 if (argc > 1)
5771 VTY_GET_INTEGER_RANGE("distance", distance, argv[1], 1, 255);
5772 return (zebra_import_table(AFI_IP, table_id, distance, NULL, 1));
5773
5774 }
5775
5776 ALIAS (ip_zebra_import_table_distance,
5777 ip_zebra_import_table_cmd,
5778 "ip import-table <1-252>",
5779 IP_STR
5780 "import routes from non-main kernel table\n"
5781 "kernel routing table id\n")
5782
5783 DEFUN (ip_zebra_import_table_distance_routemap,
5784 ip_zebra_import_table_distance_routemap_cmd,
5785 "ip import-table <1-252> distance <1-255> route-map WORD",
5786 IP_STR
5787 "import routes from non-main kernel table\n"
5788 "kernel routing table id\n"
5789 "Distance for imported routes\n"
5790 "Default distance value\n"
5791 "route-map for filtering\n"
5792 "route-map name\n")
5793 {
5794 u_int32_t table_id = 0;
5795 int distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
5796 const char *rmap_name;
5797
5798 if (argc)
5799 VTY_GET_INTEGER("table", table_id, argv[0]);
5800
5801 if (!is_zebra_valid_kernel_table(table_id))
5802 {
5803 vty_out(vty, "Invalid routing table ID, %d. Must be in range 1-252%s",
5804 table_id, VTY_NEWLINE);
5805 return CMD_WARNING;
5806 }
5807
5808 if (is_zebra_main_routing_table(table_id))
5809 {
5810 vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s",
5811 table_id, VTY_NEWLINE);
5812 return CMD_WARNING;
5813 }
5814
5815 if (argc > 2)
5816 {
5817 VTY_GET_INTEGER_RANGE("distance", distance, argv[1], 1, 255);
5818 rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[2]);
5819 }
5820 else
5821 rmap_name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
5822
5823 return (zebra_import_table(AFI_IP, table_id, distance, rmap_name, 1));
5824 }
5825
5826 ALIAS (ip_zebra_import_table_distance_routemap,
5827 ip_zebra_import_table_routemap_cmd,
5828 "ip import-table <1-252> route-map WORD",
5829 IP_STR
5830 "import routes from non-main kernel table\n"
5831 "kernel routing table id\n"
5832 "route-map for filtering\n"
5833 "route-map name\n")
5834
5835 DEFUN (no_ip_zebra_import_table,
5836 no_ip_zebra_import_table_cmd,
5837 "no ip import-table <1-252> {route-map NAME}",
5838 NO_STR
5839 IP_STR
5840 "import routes from non-main kernel table\n"
5841 "kernel routing table id\n")
5842 {
5843 u_int32_t table_id = 0;
5844
5845 if (argc)
5846 VTY_GET_INTEGER("table", table_id, argv[0]);
5847
5848 if (!is_zebra_valid_kernel_table(table_id))
5849 {
5850 vty_out(vty, "Invalid routing table ID. Must be in range 1-252%s",
5851 VTY_NEWLINE);
5852 return CMD_WARNING;
5853 }
5854
5855 if (is_zebra_main_routing_table(table_id))
5856 {
5857 vty_out(vty, "Invalid routing table ID, %d. Must be non-default table%s",
5858 table_id, VTY_NEWLINE);
5859 return CMD_WARNING;
5860 }
5861
5862 if (!is_zebra_import_table_enabled(AFI_IP, table_id))
5863 return CMD_SUCCESS;
5864
5865 return (zebra_import_table(AFI_IP, table_id, 0, NULL, 0));
5866 }
5867
5868 ALIAS (no_ip_zebra_import_table,
5869 no_ip_zebra_import_table_distance_cmd,
5870 "no ip import-table <1-252> distance <1-255> {route-map NAME}",
5871 IP_STR
5872 "import routes from non-main kernel table to main table"
5873 "kernel routing table id\n"
5874 "distance to be used\n")
5875
5876 static int
5877 config_write_protocol (struct vty *vty)
5878 {
5879 if (allow_delete)
5880 vty_out(vty, "allow-external-route-update%s", VTY_NEWLINE);
5881
5882 if (zebra_rnh_ip_default_route)
5883 vty_out(vty, "ip nht resolve-via-default%s", VTY_NEWLINE);
5884
5885 if (zebra_rnh_ipv6_default_route)
5886 vty_out(vty, "ipv6 nht resolve-via-default%s", VTY_NEWLINE);
5887
5888 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
5889
5890 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
5891 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
5892 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
5893 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
5894 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
5895 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
5896 "longer-prefix",
5897 VTY_NEWLINE);
5898
5899 zebra_routemap_config_write_protocol(vty);
5900
5901 return 1;
5902 }
5903
5904 /* IP node for static routes. */
5905 static struct cmd_node ip_node = { IP_NODE, "", 1 };
5906 static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
5907
5908 /* Route VTY. */
5909 void
5910 zebra_vty_init (void)
5911 {
5912 install_node (&ip_node, zebra_ip_config);
5913 install_node (&protocol_node, config_write_protocol);
5914
5915 install_element (CONFIG_NODE, &allow_external_route_update_cmd);
5916 install_element (CONFIG_NODE, &no_allow_external_route_update_cmd);
5917 install_element (CONFIG_NODE, &ip_mroute_cmd);
5918 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
5919 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
5920 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
5921 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
5922 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
5923 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
5924 install_element (CONFIG_NODE, &ip_route_cmd);
5925 install_element (CONFIG_NODE, &ip_route_tag_cmd);
5926 install_element (CONFIG_NODE, &ip_route_flags_cmd);
5927 install_element (CONFIG_NODE, &ip_route_flags_tag_cmd);
5928 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
5929 install_element (CONFIG_NODE, &ip_route_flags2_tag_cmd);
5930 install_element (CONFIG_NODE, &ip_route_mask_cmd);
5931 install_element (CONFIG_NODE, &ip_route_mask_tag_cmd);
5932 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
5933 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_cmd);
5934 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
5935 install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_cmd);
5936 install_element (CONFIG_NODE, &no_ip_route_cmd);
5937 install_element (CONFIG_NODE, &no_ip_route_tag_cmd);
5938 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
5939 install_element (CONFIG_NODE, &no_ip_route_flags_tag_cmd);
5940 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
5941 install_element (CONFIG_NODE, &no_ip_route_flags2_tag_cmd);
5942 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
5943 install_element (CONFIG_NODE, &no_ip_route_mask_tag_cmd);
5944 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
5945 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_cmd);
5946 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
5947 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_cmd);
5948 install_element (CONFIG_NODE, &ip_route_distance_cmd);
5949 install_element (CONFIG_NODE, &ip_route_tag_distance_cmd);
5950 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
5951 install_element (CONFIG_NODE, &ip_route_flags_tag_distance_cmd);
5952 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
5953 install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_cmd);
5954 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
5955 install_element (CONFIG_NODE, &ip_route_mask_tag_distance_cmd);
5956 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
5957 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_cmd);
5958 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
5959 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_cmd);
5960 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
5961 install_element (CONFIG_NODE, &no_ip_route_tag_distance_cmd);
5962 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
5963 install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_cmd);
5964 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
5965 install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_cmd);
5966 install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd);
5967 install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_cmd);
5968 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
5969 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_cmd);
5970 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
5971 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_cmd);
5972 install_element (CONFIG_NODE, &ip_zebra_import_table_cmd);
5973 install_element (CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
5974 install_element (CONFIG_NODE, &ip_zebra_import_table_routemap_cmd);
5975 install_element (CONFIG_NODE, &ip_zebra_import_table_distance_routemap_cmd);
5976 install_element (CONFIG_NODE, &no_ip_zebra_import_table_cmd);
5977 install_element (CONFIG_NODE, &no_ip_zebra_import_table_distance_cmd);
5978
5979 install_element (VIEW_NODE, &show_vrf_cmd);
5980 install_element (VIEW_NODE, &show_ip_route_cmd);
5981 install_element (VIEW_NODE, &show_ip_route_ospf_instance_cmd);
5982 install_element (VIEW_NODE, &show_ip_route_tag_cmd);
5983 install_element (VIEW_NODE, &show_ip_nht_cmd);
5984 install_element (VIEW_NODE, &show_ip_nht_vrf_cmd);
5985 install_element (VIEW_NODE, &show_ip_nht_vrf_all_cmd);
5986 install_element (VIEW_NODE, &show_ipv6_nht_cmd);
5987 install_element (VIEW_NODE, &show_ipv6_nht_vrf_cmd);
5988 install_element (VIEW_NODE, &show_ipv6_nht_vrf_all_cmd);
5989 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
5990 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
5991 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
5992 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
5993 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
5994 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
5995 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
5996 install_element (ENABLE_NODE, &show_vrf_cmd);
5997 install_element (ENABLE_NODE, &show_ip_route_cmd);
5998 install_element (ENABLE_NODE, &show_ip_route_ospf_instance_cmd);
5999 install_element (ENABLE_NODE, &show_ip_route_tag_cmd);
6000 install_element (ENABLE_NODE, &show_ip_nht_cmd);
6001 install_element (ENABLE_NODE, &show_ip_nht_vrf_cmd);
6002 install_element (ENABLE_NODE, &show_ip_nht_vrf_all_cmd);
6003 install_element (ENABLE_NODE, &show_ipv6_nht_cmd);
6004 install_element (ENABLE_NODE, &show_ipv6_nht_vrf_cmd);
6005 install_element (ENABLE_NODE, &show_ipv6_nht_vrf_all_cmd);
6006 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
6007 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
6008 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
6009 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
6010 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
6011 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
6012 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
6013
6014 install_element (VIEW_NODE, &show_ip_rpf_cmd);
6015 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
6016 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
6017 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
6018
6019 /* Commands for VRF */
6020
6021 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
6022 install_element (CONFIG_NODE, &ip_route_tag_vrf_cmd);
6023 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
6024 install_element (CONFIG_NODE, &ip_route_flags_tag_vrf_cmd);
6025 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
6026 install_element (CONFIG_NODE, &ip_route_flags2_tag_vrf_cmd);
6027 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
6028 install_element (CONFIG_NODE, &ip_route_mask_tag_vrf_cmd);
6029 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
6030 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_vrf_cmd);
6031 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
6032 install_element (CONFIG_NODE, &ip_route_mask_flags2_tag_vrf_cmd);
6033 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
6034 install_element (CONFIG_NODE, &no_ip_route_tag_vrf_cmd);
6035 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
6036 install_element (CONFIG_NODE, &no_ip_route_flags_tag_vrf_cmd);
6037 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
6038 install_element (CONFIG_NODE, &no_ip_route_flags2_tag_vrf_cmd);
6039 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
6040 install_element (CONFIG_NODE, &no_ip_route_mask_tag_vrf_cmd);
6041 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
6042 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_vrf_cmd);
6043 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
6044 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_tag_vrf_cmd);
6045 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
6046 install_element (CONFIG_NODE, &ip_route_tag_distance_vrf_cmd);
6047 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
6048 install_element (CONFIG_NODE, &ip_route_flags_tag_distance_vrf_cmd);
6049 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
6050 install_element (CONFIG_NODE, &ip_route_flags_tag_distance2_vrf_cmd);
6051 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
6052 install_element (CONFIG_NODE, &ip_route_mask_tag_distance_vrf_cmd);
6053 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
6054 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance_vrf_cmd);
6055 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
6056 install_element (CONFIG_NODE, &ip_route_mask_flags_tag_distance2_vrf_cmd);
6057 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
6058 install_element (CONFIG_NODE, &no_ip_route_tag_distance_vrf_cmd);
6059 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
6060 install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance_vrf_cmd);
6061 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
6062 install_element (CONFIG_NODE, &no_ip_route_flags_tag_distance2_vrf_cmd);
6063 install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd);
6064 install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_vrf_cmd);
6065 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
6066 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance_vrf_cmd);
6067 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
6068 install_element (CONFIG_NODE, &no_ip_route_mask_flags_tag_distance2_vrf_cmd);
6069
6070 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
6071 install_element (VIEW_NODE, &show_ip_route_vrf_addr_cmd);
6072 install_element (VIEW_NODE, &show_ip_route_vrf_tag_cmd);
6073 install_element (VIEW_NODE, &show_ip_route_vrf_prefix_cmd);
6074 install_element (VIEW_NODE, &show_ip_route_vrf_prefix_longer_cmd);
6075 install_element (VIEW_NODE, &show_ip_route_vrf_protocol_cmd);
6076 install_element (VIEW_NODE, &show_ip_route_vrf_supernets_cmd);
6077 install_element (VIEW_NODE, &show_ip_route_vrf_summary_cmd);
6078 install_element (VIEW_NODE, &show_ip_route_vrf_summary_prefix_cmd);
6079 install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
6080 install_element (ENABLE_NODE, &show_ip_route_vrf_addr_cmd);
6081 install_element (ENABLE_NODE, &show_ip_route_vrf_tag_cmd);
6082 install_element (ENABLE_NODE, &show_ip_route_vrf_prefix_cmd);
6083 install_element (ENABLE_NODE, &show_ip_route_vrf_prefix_longer_cmd);
6084 install_element (ENABLE_NODE, &show_ip_route_vrf_protocol_cmd);
6085 install_element (ENABLE_NODE, &show_ip_route_vrf_supernets_cmd);
6086 install_element (ENABLE_NODE, &show_ip_route_vrf_summary_cmd);
6087 install_element (ENABLE_NODE, &show_ip_route_vrf_summary_prefix_cmd);
6088
6089 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
6090 install_element (VIEW_NODE, &show_ip_route_vrf_all_tag_cmd);
6091 install_element (VIEW_NODE, &show_ip_route_vrf_all_addr_cmd);
6092 install_element (VIEW_NODE, &show_ip_route_vrf_all_prefix_cmd);
6093 install_element (VIEW_NODE, &show_ip_route_vrf_all_prefix_longer_cmd);
6094 install_element (VIEW_NODE, &show_ip_route_vrf_all_protocol_cmd);
6095 install_element (VIEW_NODE, &show_ip_route_vrf_all_supernets_cmd);
6096 install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_cmd);
6097 install_element (VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
6098 install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
6099 install_element (ENABLE_NODE, &show_ip_route_vrf_all_tag_cmd);
6100 install_element (ENABLE_NODE, &show_ip_route_vrf_all_addr_cmd);
6101 install_element (ENABLE_NODE, &show_ip_route_vrf_all_prefix_cmd);
6102 install_element (ENABLE_NODE, &show_ip_route_vrf_all_prefix_longer_cmd);
6103 install_element (ENABLE_NODE, &show_ip_route_vrf_all_protocol_cmd);
6104 install_element (ENABLE_NODE, &show_ip_route_vrf_all_supernets_cmd);
6105 install_element (ENABLE_NODE, &show_ip_route_vrf_all_summary_cmd);
6106 install_element (ENABLE_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
6107
6108 #ifdef HAVE_IPV6
6109 install_element (CONFIG_NODE, &ipv6_route_cmd);
6110 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
6111 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
6112 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
6113 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
6114 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
6115 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
6116 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
6117 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
6118 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
6119 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
6120 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
6121 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
6122 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
6123 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
6124 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
6125 install_element (CONFIG_NODE, &ipv6_route_tag_cmd);
6126 install_element (CONFIG_NODE, &ipv6_route_flags_tag_cmd);
6127 install_element (CONFIG_NODE, &ipv6_route_ifname_tag_cmd);
6128 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_cmd);
6129 install_element (CONFIG_NODE, &ipv6_route_pref_tag_cmd);
6130 install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_cmd);
6131 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_cmd);
6132 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_cmd);
6133 install_element (CONFIG_NODE, &no_ipv6_route_tag_cmd);
6134 install_element (CONFIG_NODE, &no_ipv6_route_flags_tag_cmd);
6135 install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_cmd);
6136 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_tag_cmd);
6137 install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_cmd);
6138 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_cmd);
6139 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_cmd);
6140 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_cmd);
6141 install_element (CONFIG_NODE, &ip_nht_default_route_cmd);
6142 install_element (CONFIG_NODE, &no_ip_nht_default_route_cmd);
6143 install_element (CONFIG_NODE, &ipv6_nht_default_route_cmd);
6144 install_element (CONFIG_NODE, &no_ipv6_nht_default_route_cmd);
6145 install_element (VIEW_NODE, &show_ipv6_route_cmd);
6146 install_element (VIEW_NODE, &show_ipv6_route_tag_cmd);
6147 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
6148 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
6149 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
6150 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
6151 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
6152 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
6153 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
6154 install_element (ENABLE_NODE, &show_ipv6_route_tag_cmd);
6155 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
6156 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
6157 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
6158 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
6159 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
6160 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
6161
6162 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
6163 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
6164
6165 /* Commands for VRF */
6166
6167 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
6168 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
6169 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
6170 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
6171 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
6172 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
6173 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
6174 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
6175 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
6176 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
6177 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
6178 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
6179 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
6180 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
6181 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
6182 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
6183 install_element (CONFIG_NODE, &ipv6_route_tag_vrf_cmd);
6184 install_element (CONFIG_NODE, &ipv6_route_flags_tag_vrf_cmd);
6185 install_element (CONFIG_NODE, &ipv6_route_ifname_tag_vrf_cmd);
6186 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_tag_vrf_cmd);
6187 install_element (CONFIG_NODE, &ipv6_route_pref_tag_vrf_cmd);
6188 install_element (CONFIG_NODE, &ipv6_route_flags_pref_tag_vrf_cmd);
6189 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_vrf_cmd);
6190 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_tag_vrf_cmd);
6191 install_element (CONFIG_NODE, &no_ipv6_route_tag_vrf_cmd);
6192 install_element (CONFIG_NODE, &no_ipv6_route_flags_tag_vrf_cmd);
6193 install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_vrf_cmd);
6194 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_tag_vrf_cmd);
6195 install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_vrf_cmd);
6196 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_tag_vrf_cmd);
6197 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_vrf_cmd);
6198 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_tag_vrf_cmd);
6199
6200
6201 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
6202 install_element (VIEW_NODE, &show_ipv6_route_vrf_tag_cmd);
6203 install_element (VIEW_NODE, &show_ipv6_route_vrf_summary_cmd);
6204 install_element (VIEW_NODE, &show_ipv6_route_vrf_summary_prefix_cmd);
6205 install_element (VIEW_NODE, &show_ipv6_route_vrf_protocol_cmd);
6206 install_element (VIEW_NODE, &show_ipv6_route_vrf_addr_cmd);
6207 install_element (VIEW_NODE, &show_ipv6_route_vrf_prefix_cmd);
6208 install_element (VIEW_NODE, &show_ipv6_route_vrf_prefix_longer_cmd);
6209 install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
6210 install_element (ENABLE_NODE, &show_ipv6_route_vrf_tag_cmd);
6211 install_element (ENABLE_NODE, &show_ipv6_route_vrf_protocol_cmd);
6212 install_element (ENABLE_NODE, &show_ipv6_route_vrf_addr_cmd);
6213 install_element (ENABLE_NODE, &show_ipv6_route_vrf_prefix_cmd);
6214 install_element (ENABLE_NODE, &show_ipv6_route_vrf_prefix_longer_cmd);
6215 install_element (ENABLE_NODE, &show_ipv6_route_vrf_summary_cmd);
6216 install_element (ENABLE_NODE, &show_ipv6_route_vrf_summary_prefix_cmd);
6217
6218 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
6219 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_tag_cmd);
6220 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_summary_cmd);
6221 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_summary_prefix_cmd);
6222 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_protocol_cmd);
6223 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_addr_cmd);
6224 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_cmd);
6225 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_prefix_longer_cmd);
6226 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
6227 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_tag_cmd);
6228 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_protocol_cmd);
6229 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_addr_cmd);
6230 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_prefix_cmd);
6231 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_prefix_longer_cmd);
6232 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_summary_cmd);
6233 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_summary_prefix_cmd);
6234
6235 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
6236 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
6237
6238 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
6239 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
6240 #endif /* HAVE_IPV6 */
6241 }