2 * Copyright (C) 2002 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
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.
25 #include "zebra_memory.h"
36 #include "zebra/zserv.h"
37 #include "zebra/zebra_vrf.h"
38 #include "zebra/zebra_mpls.h"
39 #include "zebra/zebra_rnh.h"
40 #include "zebra/redistribute.h"
41 #include "zebra/zebra_routemap.h"
42 #include "zebra/zebra_static.h"
45 extern int allow_delete
;
47 static int do_show_ip_route(struct vty
*vty
, const char *vrf_name
,
48 safi_t safi
, u_char use_json
);
49 static void vty_show_ip_route_detail (struct vty
*vty
, struct route_node
*rn
,
52 #define ONE_DAY_SECOND 60*60*24
53 #define ONE_WEEK_SECOND 60*60*24*7
55 /* General function for static route. */
57 zebra_static_ipv4 (struct vty
*vty
, safi_t safi
, int add_cmd
,
58 const char *dest_str
, const char *mask_str
,
59 const char *gate_str
, const char *flag_str
,
60 const char *tag_str
, const char *distance_str
,
61 const char *vrf_id_str
, const char *label_str
)
70 struct zebra_vrf
*zvrf
= NULL
;
71 unsigned int ifindex
= 0;
72 const char *ifname
= NULL
;
73 u_char type
= STATIC_BLACKHOLE
;
74 struct static_nh_label snh_label
;
76 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
77 ret
= str2prefix (dest_str
, &p
);
80 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
84 /* Cisco like mask notation. */
87 ret
= inet_aton (mask_str
, &mask
);
90 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
93 p
.prefixlen
= ip_masklen (mask
);
96 /* Apply mask for given prefix. */
99 /* Administrative distance. */
101 distance
= atoi (distance_str
);
103 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
107 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
110 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
114 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
123 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
127 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
130 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
135 /* Null0 static route. */
136 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
140 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
144 static_add_route (AFI_IP
, safi
, type
, &p
, NULL
, ifindex
, ifname
,
145 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
147 static_delete_route (AFI_IP
, safi
, type
, &p
, NULL
, ifindex
, tag
,
148 distance
, zvrf
, &snh_label
);
154 switch(flag_str
[0]) {
157 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
161 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
164 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
169 if (gate_str
== NULL
)
172 static_add_route (AFI_IP
, safi
, type
, &p
, NULL
, ifindex
, ifname
, flag
,
173 tag
, distance
, zvrf
, &snh_label
);
175 static_delete_route (AFI_IP
, safi
, type
, &p
, NULL
, ifindex
, tag
, distance
,
181 /* When gateway is A.B.C.D format, gate is treated as nexthop
182 address other case gate is treated as interface name. */
183 ret
= inet_aton (gate_str
, &gate
);
186 struct interface
*ifp
= if_lookup_by_name_vrf (gate_str
, zvrf_id (zvrf
));
189 vty_out (vty
, "%% Unknown interface: %s%s", gate_str
, VTY_NEWLINE
);
190 ifindex
= IFINDEX_DELETED
;
193 ifindex
= ifp
->ifindex
;
195 type
= STATIC_IFINDEX
;
198 type
= STATIC_IPV4_GATEWAY
;
201 static_add_route (AFI_IP
, safi
, type
, &p
,
202 ifindex
? NULL
: (union g_addr
*)&gate
, ifindex
, ifname
,
203 flag
, tag
, distance
, zvrf
, &snh_label
);
205 static_delete_route (AFI_IP
, safi
, type
, &p
,
206 ifindex
? NULL
: (union g_addr
*)&gate
, ifindex
, tag
,
207 distance
, zvrf
, &snh_label
);
212 /* Static unicast routes for multicast RPF lookup. */
213 DEFUN (ip_mroute_dist
,
215 "ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
217 "Configure static unicast route into MRIB for multicast RPF lookup\n"
218 "IP destination prefix (e.g. 10.0.0.0/8)\n"
220 "Nexthop interface name\n"
223 char *destprefix
= argv
[2]->arg
;
224 char *nexthop
= argv
[3]->arg
;
225 char *distance
= (argc
== 5) ? argv
[4]->arg
: NULL
;
227 return zebra_static_ipv4 (vty
, SAFI_MULTICAST
, 1, destprefix
, NULL
, nexthop
, NULL
, NULL
, distance
, NULL
, NULL
);
230 DEFUN (no_ip_mroute_dist
,
231 no_ip_mroute_dist_cmd
,
232 "no ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
235 "Configure static unicast route into MRIB for multicast RPF lookup\n"
236 "IP destination prefix (e.g. 10.0.0.0/8)\n"
238 "Nexthop interface name\n"
241 char *destprefix
= argv
[3]->arg
;
242 char *nexthop
= argv
[4]->arg
;
243 char *distance
= (argc
== 6) ? argv
[5]->arg
: NULL
;
245 return zebra_static_ipv4 (vty
, SAFI_MULTICAST
, 0, destprefix
, NULL
, nexthop
, NULL
, NULL
, distance
, NULL
, NULL
);
248 DEFUN (ip_multicast_mode
,
249 ip_multicast_mode_cmd
,
250 "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>",
252 "Multicast options\n"
253 "RPF lookup behavior\n"
254 "Lookup in unicast RIB only\n"
255 "Lookup in multicast RIB only\n"
256 "Try multicast RIB first, fall back to unicast RIB\n"
257 "Lookup both, use entry with lower distance\n"
258 "Lookup both, use entry with longer prefix\n")
260 char *mode
= argv
[3]->text
;
262 if (strmatch (mode
, "urib-only"))
263 multicast_mode_ipv4_set (MCAST_URIB_ONLY
);
264 else if (strmatch (mode
, "mrib-only"))
265 multicast_mode_ipv4_set (MCAST_MRIB_ONLY
);
266 else if (strmatch (mode
, "mrib-then-urib"))
267 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST
);
268 else if (strmatch (mode
, "lower-distance"))
269 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE
);
270 else if (strmatch (mode
, "longer-prefix"))
271 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN
);
274 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
281 DEFUN (no_ip_multicast_mode
,
282 no_ip_multicast_mode_cmd
,
283 "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]",
286 "Multicast options\n"
287 "RPF lookup behavior\n"
288 "Lookup in unicast RIB only\n"
289 "Lookup in multicast RIB only\n"
290 "Try multicast RIB first, fall back to unicast RIB\n"
291 "Lookup both, use entry with lower distance\n"
292 "Lookup both, use entry with longer prefix\n")
294 multicast_mode_ipv4_set (MCAST_NO_CONFIG
);
304 "Display RPF information for multicast source\n")
306 return do_show_ip_route(vty
, VRF_DEFAULT_NAME
, SAFI_MULTICAST
, 0);
309 DEFUN (show_ip_rpf_addr
,
310 show_ip_rpf_addr_cmd
,
311 "show ip rpf A.B.C.D",
314 "Display RPF information for multicast source\n"
315 "IP multicast source address (e.g. 10.0.0.0)\n")
319 struct route_node
*rn
;
323 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &addr
);
326 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
330 rib
= rib_match_ipv4_multicast (VRF_DEFAULT
, addr
, &rn
);
333 vty_show_ip_route_detail (vty
, rn
, 1);
335 vty_out (vty
, "%% No match for RPF lookup%s", VTY_NEWLINE
);
341 zebra_vty_ip_route_tdv_helper (int argc
, struct cmd_token
*argv
[],
342 int idx_curr
, char **tag
,
343 char **distance
, char **vrf
, char **labels
)
346 while (idx_curr
< argc
)
348 if (strmatch (argv
[idx_curr
]->text
, "tag"))
351 *tag
= argv
[idx_curr
+1]->arg
;
354 else if (strmatch (argv
[idx_curr
]->text
, "vrf"))
357 *vrf
= argv
[idx_curr
+1]->arg
;
360 else if (strmatch (argv
[idx_curr
]->text
, "label"))
363 *labels
= argv
[idx_curr
+1]->arg
;
369 *distance
= argv
[idx_curr
]->arg
;
377 /* Static route configuration. */
380 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
382 "Establish static routes\n"
383 "IP destination prefix (e.g. 10.0.0.0/8)\n"
384 "IP gateway address\n"
385 "IP gateway interface name\n"
387 "Set tag for this route\n"
389 "Distance value for this route\n"
392 int idx_ipv4_prefixlen
= 2;
393 int idx_ipv4_ifname_null
= 3;
395 char *tag
, *distance
, *vrf
;
397 tag
= distance
= vrf
= NULL
;
398 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
400 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
401 argv
[idx_ipv4_prefixlen
]->arg
,
403 argv
[idx_ipv4_ifname_null
]->arg
,
405 tag
, distance
, vrf
, NULL
);
408 DEFUN (ip_route_flags
,
410 "ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
412 "Establish static routes\n"
413 "IP destination prefix (e.g. 10.0.0.0/8)\n"
414 "Emit an ICMP unreachable when matched\n"
415 "Silently discard pkts when matched\n"
416 "Set tag for this route\n"
418 "Distance value for this route\n"
420 "Specify labels for this route\n"
421 "One or more labels separated by '/'\n")
423 int idx_ipv4_prefixlen
= 2;
424 int idx_reject_blackhole
= 3;
426 char *tag
, *distance
, *vrf
;
428 tag
= distance
= vrf
= NULL
;
429 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
431 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
432 argv
[idx_ipv4_prefixlen
]->arg
,
435 argv
[idx_reject_blackhole
]->arg
,
436 tag
, distance
, vrf
, NULL
);
439 /* Mask as A.B.C.D format. */
440 DEFUN (ip_route_mask
,
442 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
444 "Establish static routes\n"
445 "IP destination prefix\n"
446 "IP destination prefix mask\n"
447 "IP gateway address\n"
448 "IP gateway interface name\n"
450 "Set tag for this route\n"
452 "Distance value for this route\n"
454 "Specify labels for this route\n"
455 "One or more labels separated by '/'\n")
459 int idx_ipv4_ifname_null
= 4;
461 char *tag
, *distance
, *vrf
;
463 tag
= distance
= vrf
= NULL
;
464 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
466 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
468 argv
[idx_ipv4_2
]->arg
,
469 argv
[idx_ipv4_ifname_null
]->arg
,
470 NULL
, tag
, distance
, vrf
, NULL
);
473 DEFUN (ip_route_mask_flags
,
474 ip_route_mask_flags_cmd
,
475 "ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
477 "Establish static routes\n"
478 "IP destination prefix\n"
479 "IP destination prefix mask\n"
480 "Emit an ICMP unreachable when matched\n"
481 "Silently discard pkts when matched\n"
482 "Set tag for this route\n"
484 "Distance value for this route\n"
486 "Specify labels for this route\n"
487 "One or more labels separated by '/'\n")
491 int idx_reject_blackhole
= 4;
493 char *tag
, *distance
, *vrf
;
495 tag
= distance
= vrf
= NULL
;
496 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
498 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
500 argv
[idx_ipv4_2
]->arg
,
502 argv
[idx_reject_blackhole
]->arg
,
503 tag
, distance
, vrf
, NULL
);
508 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
511 "Establish static routes\n"
512 "IP destination prefix (e.g. 10.0.0.0/8)\n"
513 "IP gateway address\n"
514 "IP gateway interface name\n"
516 "Tag of this route\n"
518 "Distance value for this route\n"
520 "Specify labels for this route\n"
521 "One or more labels separated by '/'\n")
523 int idx_ipv4_prefixlen
= 3;
524 int idx_ipv4_ifname_null
= 4;
526 char *tag
, *distance
, *vrf
;
528 tag
= distance
= vrf
= NULL
;
529 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
531 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
532 argv
[idx_ipv4_prefixlen
]->arg
,
534 argv
[idx_ipv4_ifname_null
]->arg
,
536 tag
, distance
, vrf
, NULL
);
539 DEFUN (no_ip_route_flags
,
540 no_ip_route_flags_cmd
,
541 "no ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
544 "Establish static routes\n"
545 "IP destination prefix (e.g. 10.0.0.0/8)\n"
546 "Emit an ICMP unreachable when matched\n"
547 "Silently discard pkts when matched\n"
548 "Tag of this route\n"
550 "Distance value for this route\n"
552 "Specify labels for this route\n"
553 "One or more labels separated by '/'\n")
555 int idx_ipv4_prefixlen
= 3;
557 char *tag
, *distance
, *vrf
;
559 tag
= distance
= vrf
= NULL
;
560 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
562 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
563 argv
[idx_ipv4_prefixlen
]->arg
,
565 tag
, distance
, vrf
, NULL
);
568 DEFUN (no_ip_route_mask
,
569 no_ip_route_mask_cmd
,
570 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
573 "Establish static routes\n"
574 "IP destination prefix\n"
575 "IP destination prefix mask\n"
576 "IP gateway address\n"
577 "IP gateway interface name\n"
579 "Tag of this route\n"
581 "Distance value for this route\n"
583 "Specify labels for this route\n"
584 "One or more labels separated by '/'\n")
588 int idx_ipv4_ifname_null
= 5;
590 char *tag
, *distance
, *vrf
;
592 tag
= distance
= vrf
= NULL
;
593 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
595 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
597 argv
[idx_ipv4_2
]->arg
,
598 argv
[idx_ipv4_ifname_null
]->arg
,
600 tag
, distance
, vrf
, NULL
);
603 DEFUN (no_ip_route_mask_flags
,
604 no_ip_route_mask_flags_cmd
,
605 "no ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
608 "Establish static routes\n"
609 "IP destination prefix\n"
610 "IP destination prefix mask\n"
611 "Emit an ICMP unreachable when matched\n"
612 "Silently discard pkts when matched\n"
613 "Tag of this route\n"
615 "Distance value for this route\n"
617 "Specify labels for this route\n"
618 "One or more labels separated by '/'\n")
623 char *tag
, *distance
, *vrf
;
625 tag
= distance
= vrf
= NULL
;
626 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
628 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
630 argv
[idx_ipv4_2
]->arg
,
632 tag
, distance
, vrf
, NULL
);
635 /* New RIB. Detailed information for IPv4 route. */
637 vty_show_ip_route_detail (struct vty
*vty
, struct route_node
*rn
, int mcast
)
640 struct nexthop
*nexthop
, *tnexthop
;
642 char buf
[PREFIX_STRLEN
];
643 struct zebra_vrf
*zvrf
;
645 RNODE_FOREACH_RIB (rn
, rib
)
647 const char *mcast_info
= "";
650 rib_table_info_t
*info
= rn
->table
->info
;
651 mcast_info
= (info
->safi
== SAFI_MULTICAST
)
652 ? " using Multicast RIB"
653 : " using Unicast RIB";
656 vty_out (vty
, "Routing entry for %s%s%s",
657 prefix2str (&rn
->p
, buf
, sizeof(buf
)), mcast_info
,
659 vty_out (vty
, " Known via \"%s", zebra_route_string (rib
->type
));
661 vty_out (vty
, "[%d]", rib
->instance
);
663 vty_out (vty
, ", distance %u, metric %u", rib
->distance
, rib
->metric
);
665 vty_out (vty
, ", tag %d", rib
->tag
);
667 vty_out (vty
, ", mtu %u", rib
->mtu
);
668 if (rib
->vrf_id
!= VRF_DEFAULT
)
670 zvrf
= vrf_info_lookup(rib
->vrf_id
);
671 vty_out (vty
, ", vrf %s", zvrf_name (zvrf
));
673 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
674 vty_out (vty
, ", best");
676 vty_out (vty
, ", refcnt %ld", rib
->refcnt
);
677 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
678 vty_out (vty
, ", blackhole");
679 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
680 vty_out (vty
, ", reject");
681 vty_out (vty
, "%s", VTY_NEWLINE
);
683 if (rib
->type
== ZEBRA_ROUTE_RIP
684 || rib
->type
== ZEBRA_ROUTE_OSPF
685 || rib
->type
== ZEBRA_ROUTE_ISIS
686 || rib
->type
== ZEBRA_ROUTE_TABLE
687 || rib
->type
== ZEBRA_ROUTE_BGP
)
692 uptime
= time (NULL
);
693 uptime
-= rib
->uptime
;
694 tm
= gmtime (&uptime
);
696 vty_out (vty
, " Last update ");
698 if (uptime
< ONE_DAY_SECOND
)
699 vty_out (vty
, "%02d:%02d:%02d",
700 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
701 else if (uptime
< ONE_WEEK_SECOND
)
702 vty_out (vty
, "%dd%02dh%02dm",
703 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
705 vty_out (vty
, "%02dw%dd%02dh",
707 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
708 vty_out (vty
, " ago%s", VTY_NEWLINE
);
711 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
715 vty_out (vty
, " %c%s",
716 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
) ? '*' : ' ',
717 recursing
? " " : "");
719 switch (nexthop
->type
)
721 case NEXTHOP_TYPE_IPV4
:
722 case NEXTHOP_TYPE_IPV4_IFINDEX
:
723 vty_out (vty
, " %s", inet_ntoa (nexthop
->gate
.ipv4
));
724 if (nexthop
->ifindex
)
725 vty_out (vty
, ", via %s",
726 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
728 case NEXTHOP_TYPE_IPV6
:
729 case NEXTHOP_TYPE_IPV6_IFINDEX
:
731 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
732 if (nexthop
->ifindex
)
733 vty_out (vty
, ", via %s",
734 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
736 case NEXTHOP_TYPE_IFINDEX
:
737 vty_out (vty
, " directly connected, %s",
738 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
740 case NEXTHOP_TYPE_BLACKHOLE
:
741 vty_out (vty
, " directly connected, Null0");
746 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
747 vty_out (vty
, " inactive");
749 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
750 vty_out (vty
, " onlink");
752 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
753 vty_out (vty
, " (recursive)");
755 switch (nexthop
->type
)
757 case NEXTHOP_TYPE_IPV4
:
758 case NEXTHOP_TYPE_IPV4_IFINDEX
:
759 if (nexthop
->src
.ipv4
.s_addr
)
761 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, addrstr
,
763 vty_out (vty
, ", src %s", addrstr
);
766 case NEXTHOP_TYPE_IPV6
:
767 case NEXTHOP_TYPE_IPV6_IFINDEX
:
768 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
770 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, addrstr
,
772 vty_out (vty
, ", src %s", addrstr
);
779 /* Label information */
780 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
782 vty_out (vty
, " label %s",
783 mpls_label2str (nexthop
->nh_label
->num_labels
,
784 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
787 vty_out (vty
, "%s", VTY_NEWLINE
);
789 vty_out (vty
, "%s", VTY_NEWLINE
);
794 vty_show_ip_route (struct vty
*vty
, struct route_node
*rn
, struct rib
*rib
,
797 struct nexthop
*nexthop
, *tnexthop
;
801 json_object
*json_nexthops
= NULL
;
802 json_object
*json_nexthop
= NULL
;
803 json_object
*json_route
= NULL
;
807 json_route
= json_object_new_object();
808 json_nexthops
= json_object_new_array();
810 json_object_string_add(json_route
, "prefix", prefix2str (&rn
->p
, buf
, sizeof buf
));
811 json_object_string_add(json_route
, "protocol", zebra_route_string(rib
->type
));
814 json_object_int_add(json_route
, "instance", rib
->instance
);
817 json_object_int_add(json_route
, "vrfId", rib
->vrf_id
);
819 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
820 json_object_boolean_true_add(json_route
, "selected");
822 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
&& rib
->type
!= ZEBRA_ROUTE_KERNEL
)
824 json_object_int_add(json_route
, "distance", rib
->distance
);
825 json_object_int_add(json_route
, "metric", rib
->metric
);
828 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
829 json_object_boolean_true_add(json_route
, "blackhole");
831 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
832 json_object_boolean_true_add(json_route
, "reject");
834 if (rib
->type
== ZEBRA_ROUTE_RIP
835 || rib
->type
== ZEBRA_ROUTE_OSPF
836 || rib
->type
== ZEBRA_ROUTE_ISIS
837 || rib
->type
== ZEBRA_ROUTE_TABLE
838 || rib
->type
== ZEBRA_ROUTE_BGP
)
843 uptime
= time (NULL
);
844 uptime
-= rib
->uptime
;
845 tm
= gmtime (&uptime
);
847 if (uptime
< ONE_DAY_SECOND
)
848 sprintf(buf
, "%02d:%02d:%02d", tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
849 else if (uptime
< ONE_WEEK_SECOND
)
850 sprintf(buf
, "%dd%02dh%02dm", tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
852 sprintf(buf
, "%02dw%dd%02dh", tm
->tm_yday
/7, tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
854 json_object_string_add(json_route
, "uptime", buf
);
857 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
859 json_nexthop
= json_object_new_object();
861 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
862 json_object_boolean_true_add(json_nexthop
, "fib");
864 switch (nexthop
->type
)
866 case NEXTHOP_TYPE_IPV4
:
867 case NEXTHOP_TYPE_IPV4_IFINDEX
:
868 json_object_string_add(json_nexthop
, "ip", inet_ntoa (nexthop
->gate
.ipv4
));
869 json_object_string_add(json_nexthop
, "afi", "ipv4");
871 if (nexthop
->ifindex
)
873 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
874 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
877 case NEXTHOP_TYPE_IPV6
:
878 case NEXTHOP_TYPE_IPV6_IFINDEX
:
879 json_object_string_add(json_nexthop
, "ip", inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
880 json_object_string_add(json_nexthop
, "afi", "ipv6");
882 if (nexthop
->ifindex
)
884 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
885 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
889 case NEXTHOP_TYPE_IFINDEX
:
890 json_object_boolean_true_add(json_nexthop
, "directlyConnected");
891 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
892 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
894 case NEXTHOP_TYPE_BLACKHOLE
:
895 json_object_boolean_true_add(json_nexthop
, "blackhole");
901 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
902 json_object_boolean_true_add(json_nexthop
, "active");
904 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
905 json_object_boolean_true_add(json_nexthop
, "onLink");
907 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
908 json_object_boolean_true_add(json_nexthop
, "recursive");
910 switch (nexthop
->type
)
912 case NEXTHOP_TYPE_IPV4
:
913 case NEXTHOP_TYPE_IPV4_IFINDEX
:
914 if (nexthop
->src
.ipv4
.s_addr
)
916 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
917 json_object_string_add(json_nexthop
, "source", buf
);
920 case NEXTHOP_TYPE_IPV6
:
921 case NEXTHOP_TYPE_IPV6_IFINDEX
:
922 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
924 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
925 json_object_string_add(json_nexthop
, "source", buf
);
932 json_object_array_add(json_nexthops
, json_nexthop
);
935 json_object_object_add(json_route
, "nexthops", json_nexthops
);
936 json_object_array_add(json
, json_route
);
940 /* Nexthop information. */
941 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
943 if (nexthop
== rib
->nexthop
)
945 /* Prefix information. */
946 len
= vty_out (vty
, "%c", zebra_route_char (rib
->type
));
948 len
+= vty_out (vty
, "[%d]", rib
->instance
);
949 len
+= vty_out (vty
, "%c%c %s",
950 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
)
952 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
954 prefix2str (&rn
->p
, buf
, sizeof buf
));
956 /* Distance and metric display. */
957 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
958 && rib
->type
!= ZEBRA_ROUTE_KERNEL
)
959 len
+= vty_out (vty
, " [%d/%d]", rib
->distance
,
963 vty_out (vty
, " %c%*c",
964 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
966 len
- 3 + (2 * recursing
), ' ');
968 switch (nexthop
->type
)
970 case NEXTHOP_TYPE_IPV4
:
971 case NEXTHOP_TYPE_IPV4_IFINDEX
:
972 vty_out (vty
, " via %s", inet_ntoa (nexthop
->gate
.ipv4
));
973 if (nexthop
->ifindex
)
974 vty_out (vty
, ", %s",
975 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
977 case NEXTHOP_TYPE_IPV6
:
978 case NEXTHOP_TYPE_IPV6_IFINDEX
:
979 vty_out (vty
, " via %s",
980 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
981 if (nexthop
->ifindex
)
982 vty_out (vty
, ", %s",
983 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
986 case NEXTHOP_TYPE_IFINDEX
:
987 vty_out (vty
, " is directly connected, %s",
988 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
990 case NEXTHOP_TYPE_BLACKHOLE
:
991 vty_out (vty
, " is directly connected, Null0");
996 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
997 vty_out (vty
, " inactive");
999 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1000 vty_out (vty
, " onlink");
1002 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1003 vty_out (vty
, " (recursive)");
1005 switch (nexthop
->type
)
1007 case NEXTHOP_TYPE_IPV4
:
1008 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1009 if (nexthop
->src
.ipv4
.s_addr
)
1011 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
1012 vty_out (vty
, ", src %s", buf
);
1015 case NEXTHOP_TYPE_IPV6
:
1016 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1017 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
1019 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
1020 vty_out (vty
, ", src %s", buf
);
1027 /* Label information */
1028 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
1030 vty_out (vty
, " label %s",
1031 mpls_label2str (nexthop
->nh_label
->num_labels
,
1032 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
1035 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
1036 vty_out (vty
, ", bh");
1037 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
1038 vty_out (vty
, ", rej");
1040 if (rib
->type
== ZEBRA_ROUTE_RIP
1041 || rib
->type
== ZEBRA_ROUTE_OSPF
1042 || rib
->type
== ZEBRA_ROUTE_ISIS
1043 || rib
->type
== ZEBRA_ROUTE_TABLE
1044 || rib
->type
== ZEBRA_ROUTE_BGP
)
1049 uptime
= time (NULL
);
1050 uptime
-= rib
->uptime
;
1051 tm
= gmtime (&uptime
);
1053 if (uptime
< ONE_DAY_SECOND
)
1054 vty_out (vty
, ", %02d:%02d:%02d",
1055 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
1056 else if (uptime
< ONE_WEEK_SECOND
)
1057 vty_out (vty
, ", %dd%02dh%02dm",
1058 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
1060 vty_out (vty
, ", %02dw%dd%02dh",
1062 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
1064 vty_out (vty
, "%s", VTY_NEWLINE
);
1068 DEFUN (show_ip_route
,
1070 "show ip route [json]",
1073 "IP routing table\n"
1076 return do_show_ip_route (vty
, VRF_DEFAULT_NAME
, SAFI_UNICAST
, use_json(argc
, argv
));
1080 do_show_ip_route (struct vty
*vty
, const char *vrf_name
, safi_t safi
,
1083 struct route_table
*table
;
1084 struct route_node
*rn
;
1087 struct zebra_vrf
*zvrf
= NULL
;
1089 json_object
*json
= NULL
;
1090 json_object
*json_prefix
= NULL
;
1092 if (!(zvrf
= zebra_vrf_lookup_by_name (vrf_name
)))
1095 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1097 vty_out (vty
, "vrf %s not defined%s", vrf_name
, VTY_NEWLINE
);
1101 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
1104 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1106 vty_out (vty
, "vrf %s inactive%s", vrf_name
, VTY_NEWLINE
);
1110 table
= zebra_vrf_table (AFI_IP
, safi
, zvrf_id (zvrf
));
1114 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1120 json
= json_object_new_object();
1122 /* Show all IPv4 routes. */
1123 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1125 RNODE_FOREACH_RIB (rn
, rib
)
1128 json_prefix
= json_object_new_array();
1129 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
1134 prefix2str (&rn
->p
, buf
, sizeof buf
);
1135 json_object_object_add(json
, buf
, json_prefix
);
1140 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
1141 json_object_free(json
);
1145 /* Show all IPv4 routes. */
1146 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1148 RNODE_FOREACH_RIB (rn
, rib
)
1152 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1155 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1163 DEFUN (show_ip_route_vrf
,
1164 show_ip_route_vrf_cmd
,
1165 "show ip route vrf NAME [json]",
1168 "IP routing table\n"
1173 u_char uj
= use_json(argc
, argv
);
1175 return do_show_ip_route (vty
, argv
[idx_vrf
]->arg
, SAFI_UNICAST
, uj
);
1180 "show ip nht [vrf NAME]",
1183 "IP nexthop tracking table\n"
1187 vrf_id_t vrf_id
= VRF_DEFAULT
;
1190 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1192 zebra_print_rnh_table(vrf_id
, AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1197 DEFUN (show_ip_nht_vrf_all
,
1198 show_ip_nht_vrf_all_cmd
,
1199 "show ip nht vrf all",
1202 "IP nexthop tracking table\n"
1203 VRF_ALL_CMD_HELP_STR
)
1206 struct zebra_vrf
*zvrf
;
1208 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1209 if ((zvrf
= vrf
->info
) != NULL
)
1211 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1212 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1218 DEFUN (show_ipv6_nht
,
1220 "show ipv6 nht [vrf NAME]",
1223 "IPv6 nexthop tracking table\n"
1227 vrf_id_t vrf_id
= VRF_DEFAULT
;
1230 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1232 zebra_print_rnh_table(vrf_id
, AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1237 DEFUN (show_ipv6_nht_vrf_all
,
1238 show_ipv6_nht_vrf_all_cmd
,
1239 "show ipv6 nht vrf all",
1242 "IPv6 nexthop tracking table\n"
1243 VRF_ALL_CMD_HELP_STR
)
1246 struct zebra_vrf
*zvrf
;
1248 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1249 if ((zvrf
= vrf
->info
) != NULL
)
1251 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1252 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1258 DEFUN (ip_nht_default_route
,
1259 ip_nht_default_route_cmd
,
1260 "ip nht resolve-via-default",
1262 "Filter Next Hop tracking route resolution\n"
1263 "Resolve via default route\n")
1265 if (zebra_rnh_ip_default_route
)
1268 zebra_rnh_ip_default_route
= 1;
1269 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1273 DEFUN (no_ip_nht_default_route
,
1274 no_ip_nht_default_route_cmd
,
1275 "no ip nht resolve-via-default",
1278 "Filter Next Hop tracking route resolution\n"
1279 "Resolve via default route\n")
1281 if (!zebra_rnh_ip_default_route
)
1284 zebra_rnh_ip_default_route
= 0;
1285 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1289 DEFUN (ipv6_nht_default_route
,
1290 ipv6_nht_default_route_cmd
,
1291 "ipv6 nht resolve-via-default",
1293 "Filter Next Hop tracking route resolution\n"
1294 "Resolve via default route\n")
1296 if (zebra_rnh_ipv6_default_route
)
1299 zebra_rnh_ipv6_default_route
= 1;
1300 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1304 DEFUN (no_ipv6_nht_default_route
,
1305 no_ipv6_nht_default_route_cmd
,
1306 "no ipv6 nht resolve-via-default",
1309 "Filter Next Hop tracking route resolution\n"
1310 "Resolve via default route\n")
1312 if (!zebra_rnh_ipv6_default_route
)
1315 zebra_rnh_ipv6_default_route
= 0;
1316 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1320 DEFUN (show_ip_route_tag
,
1321 show_ip_route_tag_cmd
,
1322 "show ip route [vrf NAME] tag (1-4294967295)",
1325 "IP routing table\n"
1327 "Show only routes with tag\n"
1333 struct route_table
*table
;
1334 struct route_node
*rn
;
1337 route_tag_t tag
= 0;
1338 vrf_id_t vrf_id
= VRF_DEFAULT
;
1340 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
1342 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
1343 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1348 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1351 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1355 /* Show all IPv4 routes with matching tag value. */
1356 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1357 RNODE_FOREACH_RIB (rn
, rib
)
1359 if (rib
->tag
!= tag
)
1364 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1367 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1372 DEFUN (show_ip_route_prefix_longer
,
1373 show_ip_route_prefix_longer_cmd
,
1374 "show ip route [vrf NAME] A.B.C.D/M longer-prefixes",
1377 "IP routing table\n"
1379 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1380 "Show route matching the specified Network/Mask pair only\n")
1382 struct route_table
*table
;
1383 struct route_node
*rn
;
1388 vrf_id_t vrf_id
= VRF_DEFAULT
;
1390 if (strmatch(argv
[3]->text
, "vrf"))
1392 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1393 ret
= str2prefix (argv
[5]->arg
, &p
);
1397 ret
= str2prefix (argv
[3]->arg
, &p
);
1402 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1406 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1410 /* Show matched type IPv4 routes. */
1411 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1412 RNODE_FOREACH_RIB (rn
, rib
)
1413 if (prefix_match (&p
, &rn
->p
))
1417 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1420 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1425 DEFUN (show_ip_route_supernets
,
1426 show_ip_route_supernets_cmd
,
1427 "show ip route [vrf NAME] supernets-only",
1430 "IP routing table\n"
1432 "Show supernet entries only\n")
1434 struct route_table
*table
;
1435 struct route_node
*rn
;
1439 vrf_id_t vrf_id
= VRF_DEFAULT
;
1441 if (strmatch(argv
[3]->text
, "vrf"))
1442 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1444 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1448 /* Show matched type IPv4 routes. */
1449 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1450 RNODE_FOREACH_RIB (rn
, rib
)
1452 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
1454 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
1455 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
1456 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
1460 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1463 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1469 DEFUN (show_ip_route_protocol
,
1470 show_ip_route_protocol_cmd
,
1471 "show ip route [vrf NAME] <kernel|connected|static|rip|ospf|isis|bgp|pim|table>",
1474 "IP routing table\n"
1476 FRR_IP_REDIST_HELP_STR_ZEBRA
)
1479 struct route_table
*table
;
1480 struct route_node
*rn
;
1483 vrf_id_t vrf_id
= VRF_DEFAULT
;
1486 if (argv_find (argv
, argc
, "NAME", &idx
))
1487 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
1489 char *proto
= argv
[argc
- 1]->text
;
1490 type
= proto_redistnum (AFI_IP
, proto
);
1494 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
1498 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1502 /* Show matched type IPv4 routes. */
1503 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1504 RNODE_FOREACH_RIB (rn
, rib
)
1505 if (rib
->type
== type
)
1509 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1512 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1518 DEFUN (show_ip_route_ospf_instance
,
1519 show_ip_route_ospf_instance_cmd
,
1520 "show ip route ospf (1-65535)",
1523 "IP routing table\n"
1524 "Open Shortest Path First (OSPFv2)\n"
1528 struct route_table
*table
;
1529 struct route_node
*rn
;
1532 u_short instance
= 0;
1534 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1536 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, VRF_DEFAULT
);
1540 /* Show matched type IPv4 routes. */
1541 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1542 RNODE_FOREACH_RIB (rn
, rib
)
1543 if (rib
->type
== ZEBRA_ROUTE_OSPF
&& rib
->instance
== instance
)
1547 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1550 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1555 DEFUN (show_ip_route_addr
,
1556 show_ip_route_addr_cmd
,
1557 "show ip route [vrf NAME] A.B.C.D",
1560 "IP routing table\n"
1562 "Network in the IP routing table to display\n")
1565 struct prefix_ipv4 p
;
1566 struct route_table
*table
;
1567 struct route_node
*rn
;
1568 vrf_id_t vrf_id
= VRF_DEFAULT
;
1570 if (strmatch(argv
[3]->text
, "vrf"))
1572 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1573 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1577 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1582 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1586 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1590 rn
= route_node_match (table
, (struct prefix
*) &p
);
1593 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1597 vty_show_ip_route_detail (vty
, rn
, 0);
1599 route_unlock_node (rn
);
1604 DEFUN (show_ip_route_prefix
,
1605 show_ip_route_prefix_cmd
,
1606 "show ip route [vrf NAME] A.B.C.D/M",
1609 "IP routing table\n"
1611 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1614 struct prefix_ipv4 p
;
1615 struct route_table
*table
;
1616 struct route_node
*rn
;
1617 vrf_id_t vrf_id
= VRF_DEFAULT
;
1619 if (strmatch(argv
[3]->text
, "vrf"))
1621 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1622 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1626 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1631 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1635 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1639 rn
= route_node_match (table
, (struct prefix
*) &p
);
1640 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
1642 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1646 vty_show_ip_route_detail (vty
, rn
, 0);
1648 route_unlock_node (rn
);
1655 vty_show_ip_route_summary (struct vty
*vty
, struct route_table
*table
)
1657 struct route_node
*rn
;
1659 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1660 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1661 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1662 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1666 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1667 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1668 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1669 RNODE_FOREACH_RIB (rn
, rib
)
1671 is_ibgp
= (rib
->type
== ZEBRA_ROUTE_BGP
&&
1672 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
));
1674 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1676 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1678 rib_cnt
[rib
->type
]++;
1680 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
1682 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1685 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1687 fib_cnt
[rib
->type
]++;
1691 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1692 "Route Source", "Routes", "FIB",
1693 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1696 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1698 if ((rib_cnt
[i
] > 0) ||
1699 (i
== ZEBRA_ROUTE_BGP
&& rib_cnt
[ZEBRA_ROUTE_IBGP
] > 0))
1701 if (i
== ZEBRA_ROUTE_BGP
)
1703 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1704 rib_cnt
[ZEBRA_ROUTE_BGP
], fib_cnt
[ZEBRA_ROUTE_BGP
],
1706 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1707 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1711 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1712 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1716 vty_out (vty
, "------%s", VTY_NEWLINE
);
1717 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1718 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1719 vty_out (vty
, "%s", VTY_NEWLINE
);
1723 * Implementation of the ip route summary prefix command.
1725 * This command prints the primary prefixes that have been installed by various
1726 * protocols on the box.
1730 vty_show_ip_route_summary_prefix (struct vty
*vty
, struct route_table
*table
)
1732 struct route_node
*rn
;
1734 struct nexthop
*nexthop
;
1735 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1736 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1737 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1738 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1742 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1743 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1744 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1745 RNODE_FOREACH_RIB (rn
, rib
)
1749 * In case of ECMP, count only once.
1752 for (nexthop
= rib
->nexthop
; (!cnt
&& nexthop
); nexthop
= nexthop
->next
)
1755 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1756 rib_cnt
[rib
->type
]++;
1757 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1759 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1760 fib_cnt
[rib
->type
]++;
1762 if (rib
->type
== ZEBRA_ROUTE_BGP
&&
1763 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
))
1765 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1766 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1767 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1772 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1773 "Route Source", "Prefix Routes", "FIB",
1774 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1777 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1781 if (i
== ZEBRA_ROUTE_BGP
)
1783 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1784 rib_cnt
[ZEBRA_ROUTE_BGP
] - rib_cnt
[ZEBRA_ROUTE_IBGP
],
1785 fib_cnt
[ZEBRA_ROUTE_BGP
] - fib_cnt
[ZEBRA_ROUTE_IBGP
],
1787 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1788 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1792 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1793 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1797 vty_out (vty
, "------%s", VTY_NEWLINE
);
1798 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1799 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1800 vty_out (vty
, "%s", VTY_NEWLINE
);
1803 /* Show route summary. */
1804 DEFUN (show_ip_route_summary
,
1805 show_ip_route_summary_cmd
,
1806 "show ip route [vrf NAME] summary",
1809 "IP routing table\n"
1811 "Summary of all routes\n")
1813 struct route_table
*table
;
1814 vrf_id_t vrf_id
= VRF_DEFAULT
;
1816 if (strmatch(argv
[3]->text
, "vrf"))
1817 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1819 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1823 vty_show_ip_route_summary (vty
, table
);
1828 /* Show route summary prefix. */
1829 DEFUN (show_ip_route_summary_prefix
,
1830 show_ip_route_summary_prefix_cmd
,
1831 "show ip route [vrf NAME] summary prefix",
1834 "IP routing table\n"
1836 "Summary of all routes\n"
1839 struct route_table
*table
;
1840 vrf_id_t vrf_id
= VRF_DEFAULT
;
1842 if (strmatch(argv
[3]->text
, "vrf"))
1843 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1845 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1849 vty_show_ip_route_summary_prefix (vty
, table
);
1855 DEFUN (show_ip_route_vrf_all
,
1856 show_ip_route_vrf_all_cmd
,
1857 "show ip route vrf all",
1860 "IP routing table\n"
1861 VRF_ALL_CMD_HELP_STR
)
1863 struct route_table
*table
;
1864 struct route_node
*rn
;
1867 struct zebra_vrf
*zvrf
;
1871 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1873 if ((zvrf
= vrf
->info
) == NULL
||
1874 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1877 /* Show all IPv4 routes. */
1878 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1879 RNODE_FOREACH_RIB (rn
, rib
)
1883 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1889 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1892 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1900 DEFUN (show_ip_route_vrf_all_tag
,
1901 show_ip_route_vrf_all_tag_cmd
,
1902 "show ip route vrf all tag (1-4294967295)",
1905 "IP routing table\n"
1906 VRF_ALL_CMD_HELP_STR
1907 "Show only routes with tag\n"
1911 struct route_table
*table
;
1912 struct route_node
*rn
;
1915 struct zebra_vrf
*zvrf
;
1918 route_tag_t tag
= 0;
1920 if (argv
[idx_number
]->arg
)
1921 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
1923 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1925 if ((zvrf
= vrf
->info
) == NULL
||
1926 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1929 /* Show all IPv4 routes with matching tag value. */
1930 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1931 RNODE_FOREACH_RIB (rn
, rib
)
1933 if (rib
->tag
!= tag
)
1938 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1944 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1947 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1954 DEFUN (show_ip_route_vrf_all_prefix_longer
,
1955 show_ip_route_vrf_all_prefix_longer_cmd
,
1956 "show ip route vrf all A.B.C.D/M longer-prefixes",
1959 "IP routing table\n"
1960 VRF_ALL_CMD_HELP_STR
1961 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1962 "Show route matching the specified Network/Mask pair only\n")
1964 int idx_ipv4_prefixlen
= 5;
1965 struct route_table
*table
;
1966 struct route_node
*rn
;
1970 struct zebra_vrf
*zvrf
;
1975 ret
= str2prefix (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
1978 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1982 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1984 if ((zvrf
= vrf
->info
) == NULL
||
1985 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1988 /* Show matched type IPv4 routes. */
1989 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1990 RNODE_FOREACH_RIB (rn
, rib
)
1991 if (prefix_match (&p
, &rn
->p
))
1995 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2001 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2004 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2012 DEFUN (show_ip_route_vrf_all_supernets
,
2013 show_ip_route_vrf_all_supernets_cmd
,
2014 "show ip route vrf all supernets-only",
2017 "IP routing table\n"
2018 VRF_ALL_CMD_HELP_STR
2019 "Show supernet entries only\n")
2021 struct route_table
*table
;
2022 struct route_node
*rn
;
2025 struct zebra_vrf
*zvrf
;
2030 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2032 if ((zvrf
= vrf
->info
) == NULL
||
2033 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2036 /* Show matched type IPv4 routes. */
2037 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2038 RNODE_FOREACH_RIB (rn
, rib
)
2040 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
2042 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
2043 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
2044 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
2048 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2053 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2056 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2065 DEFUN (show_ip_route_vrf_all_protocol
,
2066 show_ip_route_vrf_all_protocol_cmd
,
2067 "show ip route vrf all <kernel|connected|static|rip|ospf|isis|bgp|pim|table>",
2070 "IP routing table\n"
2071 VRF_ALL_CMD_HELP_STR
2072 FRR_IP_REDIST_HELP_STR_ZEBRA
"\n")
2075 struct route_table
*table
;
2076 struct route_node
*rn
;
2079 struct zebra_vrf
*zvrf
;
2083 char *proto
= argv
[argc
- 1]->text
;
2084 type
= proto_redistnum (AFI_IP
, proto
);
2088 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
2092 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2094 if ((zvrf
= vrf
->info
) == NULL
||
2095 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2098 /* Show matched type IPv4 routes. */
2099 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2100 RNODE_FOREACH_RIB (rn
, rib
)
2101 if (rib
->type
== type
)
2105 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2111 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2114 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2122 DEFUN (show_ip_route_vrf_all_addr
,
2123 show_ip_route_vrf_all_addr_cmd
,
2124 "show ip route vrf all A.B.C.D",
2127 "IP routing table\n"
2128 VRF_ALL_CMD_HELP_STR
2129 "Network in the IP routing table to display\n")
2133 struct prefix_ipv4 p
;
2134 struct route_table
*table
;
2135 struct route_node
*rn
;
2137 struct zebra_vrf
*zvrf
;
2139 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
2142 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2146 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2148 if ((zvrf
= vrf
->info
) == NULL
||
2149 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2152 rn
= route_node_match (table
, (struct prefix
*) &p
);
2156 vty_show_ip_route_detail (vty
, rn
, 0);
2158 route_unlock_node (rn
);
2164 DEFUN (show_ip_route_vrf_all_prefix
,
2165 show_ip_route_vrf_all_prefix_cmd
,
2166 "show ip route vrf all A.B.C.D/M",
2169 "IP routing table\n"
2170 VRF_ALL_CMD_HELP_STR
2171 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2173 int idx_ipv4_prefixlen
= 5;
2175 struct prefix_ipv4 p
;
2176 struct route_table
*table
;
2177 struct route_node
*rn
;
2179 struct zebra_vrf
*zvrf
;
2181 ret
= str2prefix_ipv4 (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
2184 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2188 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2190 if ((zvrf
= vrf
->info
) == NULL
||
2191 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2194 rn
= route_node_match (table
, (struct prefix
*) &p
);
2197 if (rn
->p
.prefixlen
!= p
.prefixlen
)
2199 route_unlock_node (rn
);
2203 vty_show_ip_route_detail (vty
, rn
, 0);
2205 route_unlock_node (rn
);
2211 DEFUN (show_ip_route_vrf_all_summary
,
2212 show_ip_route_vrf_all_summary_cmd
,
2213 "show ip route vrf all summary ",
2216 "IP routing table\n"
2217 VRF_ALL_CMD_HELP_STR
2218 "Summary of all routes\n")
2221 struct zebra_vrf
*zvrf
;
2223 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2224 if ((zvrf
= vrf
->info
) != NULL
)
2225 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2230 DEFUN (show_ip_route_vrf_all_summary_prefix
,
2231 show_ip_route_vrf_all_summary_prefix_cmd
,
2232 "show ip route vrf all summary prefix",
2235 "IP routing table\n"
2236 VRF_ALL_CMD_HELP_STR
2237 "Summary of all routes\n"
2241 struct zebra_vrf
*zvrf
;
2243 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2244 if ((zvrf
= vrf
->info
) != NULL
)
2245 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2250 /* Write IPv4 static route configuration. */
2252 static_config_ipv4 (struct vty
*vty
, safi_t safi
, const char *cmd
)
2254 struct route_node
*rn
;
2255 struct static_route
*si
;
2256 struct route_table
*stable
;
2258 struct zebra_vrf
*zvrf
;
2262 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2264 if (!(zvrf
= vrf
->info
))
2266 if ((stable
= zvrf
->stable
[AFI_IP
][safi
]) == NULL
)
2269 for (rn
= route_top (stable
); rn
; rn
= route_next (rn
))
2270 for (si
= rn
->info
; si
; si
= si
->next
)
2272 vty_out (vty
, "%s %s", cmd
, prefix2str (&rn
->p
, buf
, sizeof buf
));
2276 case STATIC_IPV4_GATEWAY
:
2277 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
2279 case STATIC_IFINDEX
:
2280 vty_out (vty
, " %s", si
->ifname
);
2282 case STATIC_BLACKHOLE
:
2283 vty_out (vty
, " Null0");
2285 case STATIC_IPV6_GATEWAY
:
2286 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
2288 case STATIC_IPV6_GATEWAY_IFINDEX
:
2289 vty_out (vty
, " %s %s",
2290 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
2291 ifindex2ifname_vrf (si
->ifindex
, si
->vrf_id
));
2295 /* flags are incompatible with STATIC_BLACKHOLE */
2296 if (si
->type
!= STATIC_BLACKHOLE
)
2298 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
2299 vty_out (vty
, " %s", "reject");
2301 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
2302 vty_out (vty
, " %s", "blackhole");
2306 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
2308 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
2309 vty_out (vty
, " %d", si
->distance
);
2311 if (si
->vrf_id
!= VRF_DEFAULT
)
2312 vty_out (vty
, " vrf %s", zvrf
? zvrf_name (zvrf
) : "");
2314 /* Label information */
2315 if (si
->snh_label
.num_labels
)
2316 vty_out (vty
, " label %s",
2317 mpls_label2str (si
->snh_label
.num_labels
,
2318 si
->snh_label
.label
, buf
, sizeof buf
));
2320 vty_out (vty
, "%s", VTY_NEWLINE
);
2328 /* General fucntion for IPv6 static route. */
2330 static_ipv6_func (struct vty
*vty
, int add_cmd
, const char *dest_str
,
2331 const char *gate_str
, const char *ifname
,
2332 const char *flag_str
, const char *tag_str
,
2333 const char *distance_str
, const char *vrf_id_str
,
2334 const char *label_str
)
2339 struct in6_addr
*gate
= NULL
;
2340 struct in6_addr gate_addr
;
2341 u_char type
= STATIC_BLACKHOLE
;
2343 route_tag_t tag
= 0;
2344 unsigned int ifindex
= 0;
2345 struct interface
*ifp
= NULL
;
2346 struct zebra_vrf
*zvrf
;
2347 struct static_nh_label snh_label
;
2349 ret
= str2prefix (dest_str
, &p
);
2352 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2356 /* Apply mask for given prefix. */
2359 /* Administrative distance. */
2361 distance
= atoi (distance_str
);
2363 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
2367 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
2369 /* When gateway is valid IPv6 addrees, then gate is treated as
2370 nexthop address other case gate is treated as interface name. */
2371 ret
= inet_pton (AF_INET6
, gate_str
, &gate_addr
);
2374 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
2378 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
2383 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
2388 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
2392 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
2395 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
2400 /* Null0 static route. */
2401 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
2405 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
2409 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, ifindex
, ifname
,
2410 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
2412 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, ifindex
, tag
,
2413 distance
, zvrf
, &snh_label
);
2419 switch(flag_str
[0]) {
2422 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
2426 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
2429 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
2436 /* When ifname is specified. It must be come with gateway
2440 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2443 type
= STATIC_IPV6_GATEWAY_IFINDEX
;
2445 ifp
= if_lookup_by_name_vrf (ifname
, zvrf_id (zvrf
));
2448 vty_out (vty
, "%% Malformed Interface name %s%s", ifname
, VTY_NEWLINE
);
2451 ifindex
= ifp
->ifindex
;
2457 type
= STATIC_IPV6_GATEWAY
;
2462 type
= STATIC_IFINDEX
;
2463 ifp
= if_lookup_by_name_vrf (gate_str
, zvrf_id (zvrf
));
2466 vty_out (vty
, "%% Malformed Interface name %s%s", gate_str
, VTY_NEWLINE
);
2467 ifindex
= IFINDEX_DELETED
;
2470 ifindex
= ifp
->ifindex
;
2476 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, (union g_addr
*)gate
,
2477 ifindex
, ifname
, flag
, tag
, distance
, zvrf
, &snh_label
);
2479 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, (union g_addr
*)gate
,
2480 ifindex
, tag
, distance
, zvrf
, &snh_label
);
2487 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2489 "Establish static routes\n"
2490 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2491 "IPv6 gateway address\n"
2492 "IPv6 gateway interface name\n"
2495 "Set tag for this route\n"
2497 "Distance value for this prefix\n"
2499 "Specify labels for this route\n"
2500 "One or more labels separated by '/'\n")
2502 int idx_ipv6_prefixlen
= 2;
2503 int idx_ipv6_ifname
= 3;
2505 char *tag
, *distance
, *vrf
;
2507 tag
= distance
= vrf
= NULL
;
2508 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2510 return static_ipv6_func (vty
, 1,
2511 argv
[idx_ipv6_prefixlen
]->arg
,
2512 argv
[idx_ipv6_ifname
]->arg
,
2514 tag
, distance
, vrf
, NULL
);
2517 DEFUN (ipv6_route_flags
,
2518 ipv6_route_flags_cmd
,
2519 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2521 "Establish static routes\n"
2522 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2523 "IPv6 gateway address\n"
2524 "IPv6 gateway interface name\n"
2525 "Emit an ICMP unreachable when matched\n"
2526 "Silently discard pkts when matched\n"
2527 "Silently discard pkts when matched\n"
2528 "Set tag for this route\n"
2530 "Distance value for this prefix\n"
2532 "Specify labels for this route\n"
2533 "One or more labels separated by '/'\n")
2535 int idx_ipv6_prefixlen
= 2;
2536 int idx_ipv6_ifname
= 3;
2537 int idx_reject_blackhole
= 4;
2539 char *tag
, *distance
, *vrf
;
2541 tag
= distance
= vrf
= NULL
;
2542 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2544 return static_ipv6_func (vty
, 1,
2545 argv
[idx_ipv6_prefixlen
]->arg
,
2546 argv
[idx_ipv6_ifname
]->arg
,
2548 argv
[idx_reject_blackhole
]->arg
,
2549 tag
, distance
, vrf
, NULL
);
2552 DEFUN (ipv6_route_ifname
,
2553 ipv6_route_ifname_cmd
,
2554 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2556 "Establish static routes\n"
2557 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2558 "IPv6 gateway address\n"
2559 "IPv6 gateway interface name\n"
2560 "Set tag for this route\n"
2562 "Distance value for this prefix\n"
2564 "Specify labels for this route\n"
2565 "One or more labels separated by '/'\n")
2567 int idx_ipv6_prefixlen
= 2;
2569 int idx_interface
= 4;
2571 char *tag
, *distance
, *vrf
;
2573 tag
= distance
= vrf
= NULL
;
2574 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2576 return static_ipv6_func (vty
, 1,
2577 argv
[idx_ipv6_prefixlen
]->arg
,
2578 argv
[idx_ipv6
]->arg
,
2579 argv
[idx_interface
]->arg
,
2581 tag
, distance
, vrf
, NULL
);
2584 DEFUN (ipv6_route_ifname_flags
,
2585 ipv6_route_ifname_flags_cmd
,
2586 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2588 "Establish static routes\n"
2589 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2590 "IPv6 gateway address\n"
2591 "IPv6 gateway interface name\n"
2592 "Emit an ICMP unreachable when matched\n"
2593 "Silently discard pkts when matched\n"
2594 "Set tag for this route\n"
2596 "Distance value for this prefix\n"
2598 "Specify labels for this route\n"
2599 "One or more labels separated by '/'\n")
2601 int idx_ipv6_prefixlen
= 2;
2603 int idx_interface
= 4;
2604 int idx_reject_blackhole
= 5;
2606 char *tag
, *distance
, *vrf
;
2608 tag
= distance
= vrf
= NULL
;
2609 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2611 return static_ipv6_func (vty
, 1,
2612 argv
[idx_ipv6_prefixlen
]->arg
,
2613 argv
[idx_ipv6
]->arg
,
2614 argv
[idx_interface
]->arg
,
2615 argv
[idx_reject_blackhole
]->arg
,
2616 tag
, distance
, vrf
, NULL
);
2619 DEFUN (no_ipv6_route
,
2621 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2624 "Establish static routes\n"
2625 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2626 "IPv6 gateway address\n"
2627 "IPv6 gateway interface name\n"
2629 "Set tag for this route\n"
2631 "Distance value for this prefix\n"
2633 "Specify labels for this route\n"
2634 "One or more labels separated by '/'\n")
2636 int idx_ipv6_prefixlen
= 3;
2637 int idx_ipv6_ifname
= 4;
2639 char *tag
, *distance
, *vrf
;
2641 tag
= distance
= vrf
= NULL
;
2642 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2644 return static_ipv6_func (vty
, 0,
2645 argv
[idx_ipv6_prefixlen
]->arg
,
2646 argv
[idx_ipv6_ifname
]->arg
,
2648 tag
, distance
, vrf
, NULL
);
2651 DEFUN (no_ipv6_route_flags
,
2652 no_ipv6_route_flags_cmd
,
2653 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2656 "Establish static routes\n"
2657 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2658 "IPv6 gateway address\n"
2659 "IPv6 gateway interface name\n"
2660 "Emit an ICMP unreachable when matched\n"
2661 "Silently discard pkts when matched\n"
2662 "Set tag for this route\n"
2664 "Distance value for this prefix\n"
2666 "Specify labels for this route\n"
2667 "One or more labels separated by '/'\n")
2669 int idx_ipv6_prefixlen
= 3;
2670 int idx_ipv6_ifname
= 4;
2671 int idx_reject_blackhole
= 5;
2673 char *tag
, *distance
, *vrf
;
2675 tag
= distance
= vrf
= NULL
;
2676 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2678 return static_ipv6_func (vty
, 0,
2679 argv
[idx_ipv6_prefixlen
]->arg
,
2680 argv
[idx_ipv6_ifname
]->arg
,
2682 argv
[idx_reject_blackhole
]->arg
,
2683 tag
, distance
, vrf
, NULL
);
2686 DEFUN (no_ipv6_route_ifname
,
2687 no_ipv6_route_ifname_cmd
,
2688 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2691 "Establish static routes\n"
2692 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2693 "IPv6 gateway address\n"
2694 "IPv6 gateway interface name\n"
2695 "Set tag for this route\n"
2697 "Distance value for this prefix\n"
2699 "Specify labels for this route\n"
2700 "One or more labels separated by '/'\n")
2702 int idx_ipv6_prefixlen
= 3;
2704 int idx_interface
= 5;
2706 char *tag
, *distance
, *vrf
;
2708 tag
= distance
= vrf
= NULL
;
2709 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2711 return static_ipv6_func (vty
, 0,
2712 argv
[idx_ipv6_prefixlen
]->arg
,
2713 argv
[idx_ipv6
]->arg
,
2714 argv
[idx_interface
]->arg
,
2716 tag
, distance
, vrf
, NULL
);
2719 DEFUN (no_ipv6_route_ifname_flags
,
2720 no_ipv6_route_ifname_flags_cmd
,
2721 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2724 "Establish static routes\n"
2725 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2726 "IPv6 gateway address\n"
2727 "IPv6 gateway interface name\n"
2728 "Emit an ICMP unreachable when matched\n"
2729 "Silently discard pkts when matched\n"
2730 "Set tag for this route\n"
2732 "Distance value for this prefix\n"
2734 "Specify labels for this route\n"
2735 "One or more labels separated by '/'\n")
2737 int idx_ipv6_prefixlen
= 3;
2739 int idx_interface
= 5;
2740 int idx_reject_blackhole
= 6;
2742 char *tag
, *distance
, *vrf
;
2744 tag
= distance
= vrf
= NULL
;
2745 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2747 return static_ipv6_func (vty
, 0,
2748 argv
[idx_ipv6_prefixlen
]->arg
,
2749 argv
[idx_ipv6
]->arg
,
2750 argv
[idx_interface
]->arg
,
2751 argv
[idx_reject_blackhole
]->arg
,
2752 tag
, distance
, vrf
, NULL
);
2755 DEFUN (show_ipv6_route
,
2756 show_ipv6_route_cmd
,
2757 "show ipv6 route [vrf NAME] [json]",
2760 "IPv6 routing table\n"
2764 struct route_table
*table
;
2765 struct route_node
*rn
;
2768 vrf_id_t vrf_id
= VRF_DEFAULT
;
2769 struct zebra_vrf
*zvrf
= NULL
;
2771 json_object
*json
= NULL
;
2772 json_object
*json_prefix
= NULL
;
2774 int vrf
= (argc
> 3 && strmatch (argv
[3]->text
, "vrf"));
2775 int uj
= vrf
? argc
== 6 : argc
== 4;
2776 char *vrfname
= vrf
? argv
[4]->arg
: NULL
;
2780 if (!(zvrf
= zebra_vrf_lookup_by_name (vrfname
)))
2783 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2785 vty_out (vty
, "vrf %s not defined%s", vrfname
, VTY_NEWLINE
);
2789 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
2792 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2794 vty_out (vty
, "vrf %s inactive%s", vrfname
, VTY_NEWLINE
);
2798 vrf_id
= zvrf_id (zvrf
);
2801 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2805 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2811 json
= json_object_new_object();
2813 /* Show all IPv6 route. */
2814 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2816 RNODE_FOREACH_RIB (rn
, rib
)
2819 json_prefix
= json_object_new_array();
2820 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
2825 prefix2str (&rn
->p
, buf
, sizeof buf
);
2826 json_object_object_add(json
, buf
, json_prefix
);
2831 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
2832 json_object_free(json
);
2836 /* Show all IPv6 route. */
2837 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2839 RNODE_FOREACH_RIB (rn
, rib
)
2843 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2846 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2854 DEFUN (show_ipv6_route_tag
,
2855 show_ipv6_route_tag_cmd
,
2856 "show ipv6 route [vrf NAME] tag (1-4294967295)",
2859 "IPv6 routing table\n"
2861 "Show only routes with tag\n"
2867 struct route_table
*table
;
2868 struct route_node
*rn
;
2871 route_tag_t tag
= 0;
2872 vrf_id_t vrf_id
= VRF_DEFAULT
;
2874 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
2876 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
2877 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
2882 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
2885 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2889 /* Show all IPv6 routes with matching tag value. */
2890 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2891 RNODE_FOREACH_RIB (rn
, rib
)
2893 if (rib
->tag
!= tag
)
2898 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2901 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2906 DEFUN (show_ipv6_route_prefix_longer
,
2907 show_ipv6_route_prefix_longer_cmd
,
2908 "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes",
2911 "IPv6 routing table\n"
2914 "Show route matching the specified Network/Mask pair only\n")
2916 struct route_table
*table
;
2917 struct route_node
*rn
;
2922 vrf_id_t vrf_id
= VRF_DEFAULT
;
2924 if (strmatch(argv
[3]->text
, "vrf"))
2926 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
2927 ret
= str2prefix (argv
[5]->arg
, &p
);
2931 ret
= str2prefix (argv
[3]->arg
, &p
);
2936 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
2940 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2944 /* Show matched type IPv6 routes. */
2945 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2946 RNODE_FOREACH_RIB (rn
, rib
)
2947 if (prefix_match (&p
, &rn
->p
))
2951 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2954 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2959 DEFUN (show_ipv6_route_protocol
,
2960 show_ipv6_route_protocol_cmd
,
2961 "show ipv6 route [vrf NAME] <kernel|connected|static|ripng|ospf6|isis|bgp|table>",
2964 "IP routing table\n"
2966 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
2969 struct route_table
*table
;
2970 struct route_node
*rn
;
2973 vrf_id_t vrf_id
= VRF_DEFAULT
;
2976 if (argv_find (argv
, argc
, "NAME", &idx
))
2977 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
2979 char *proto
= argv
[argc
- 1]->text
;
2980 type
= proto_redistnum (AFI_IP
, proto
);
2984 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
2988 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2992 /* Show matched type IPv6 routes. */
2993 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2994 RNODE_FOREACH_RIB (rn
, rib
)
2995 if (rib
->type
== type
)
2999 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3002 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3007 DEFUN (show_ipv6_route_addr
,
3008 show_ipv6_route_addr_cmd
,
3009 "show ipv6 route [vrf NAME] X:X::X:X",
3012 "IPv6 routing table\n"
3017 struct prefix_ipv6 p
;
3018 struct route_table
*table
;
3019 struct route_node
*rn
;
3020 vrf_id_t vrf_id
= VRF_DEFAULT
;
3022 if (strmatch(argv
[3]->text
, "vrf"))
3024 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3025 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3029 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3034 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3038 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3042 rn
= route_node_match (table
, (struct prefix
*) &p
);
3045 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3049 vty_show_ip_route_detail (vty
, rn
, 0);
3051 route_unlock_node (rn
);
3056 DEFUN (show_ipv6_route_prefix
,
3057 show_ipv6_route_prefix_cmd
,
3058 "show ipv6 route [vrf NAME] X:X::X:X/M",
3061 "IPv6 routing table\n"
3066 struct prefix_ipv6 p
;
3067 struct route_table
*table
;
3068 struct route_node
*rn
;
3069 vrf_id_t vrf_id
= VRF_DEFAULT
;
3071 if (strmatch(argv
[3]->text
, "vrf"))
3073 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3074 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3077 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3081 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3085 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3089 rn
= route_node_match (table
, (struct prefix
*) &p
);
3090 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
3092 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3096 vty_show_ip_route_detail (vty
, rn
, 0);
3098 route_unlock_node (rn
);
3104 /* Show route summary. */
3105 DEFUN (show_ipv6_route_summary
,
3106 show_ipv6_route_summary_cmd
,
3107 "show ipv6 route [vrf NAME] summary",
3110 "IPv6 routing table\n"
3112 "Summary of all IPv6 routes\n")
3114 struct route_table
*table
;
3115 vrf_id_t vrf_id
= VRF_DEFAULT
;
3117 if (strmatch(argv
[3]->text
, "vrf"))
3118 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3120 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3124 vty_show_ip_route_summary (vty
, table
);
3130 /* Show ipv6 route summary prefix. */
3131 DEFUN (show_ipv6_route_summary_prefix
,
3132 show_ipv6_route_summary_prefix_cmd
,
3133 "show ipv6 route [vrf NAME] summary prefix",
3136 "IPv6 routing table\n"
3138 "Summary of all IPv6 routes\n"
3141 struct route_table
*table
;
3142 vrf_id_t vrf_id
= VRF_DEFAULT
;
3144 if (strmatch(argv
[3]->text
, "vrf"))
3145 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3147 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3151 vty_show_ip_route_summary_prefix (vty
, table
);
3158 * Show IPv6 mroute command.Used to dump
3159 * the Multicast routing table.
3161 DEFUN (show_ipv6_mroute
,
3162 show_ipv6_mroute_cmd
,
3163 "show ipv6 mroute [vrf NAME]",
3166 "IPv6 Multicast routing table\n"
3169 struct route_table
*table
;
3170 struct route_node
*rn
;
3173 vrf_id_t vrf_id
= VRF_DEFAULT
;
3175 if (strmatch(argv
[3]->text
, "vrf"))
3176 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3178 table
= zebra_vrf_table (AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
3182 /* Show all IPv6 route. */
3183 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3184 RNODE_FOREACH_RIB (rn
, rib
)
3188 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3191 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3197 DEFUN (show_ipv6_route_vrf_all
,
3198 show_ipv6_route_vrf_all_cmd
,
3199 "show ipv6 route vrf all",
3202 "IPv6 routing table\n"
3203 VRF_ALL_CMD_HELP_STR
)
3205 struct route_table
*table
;
3206 struct route_node
*rn
;
3209 struct zebra_vrf
*zvrf
;
3213 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3215 if ((zvrf
= vrf
->info
) == NULL
||
3216 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3219 /* Show all IPv6 route. */
3220 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3221 RNODE_FOREACH_RIB (rn
, rib
)
3225 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3231 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3234 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3242 DEFUN (show_ipv6_route_vrf_all_tag
,
3243 show_ipv6_route_vrf_all_tag_cmd
,
3244 "show ipv6 route vrf all tag (1-4294967295)",
3247 "IPv6 routing table\n"
3248 VRF_ALL_CMD_HELP_STR
3249 "Show only routes with tag\n"
3253 struct route_table
*table
;
3254 struct route_node
*rn
;
3257 struct zebra_vrf
*zvrf
;
3260 route_tag_t tag
= 0;
3262 if (argv
[idx_number
]->arg
)
3263 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
3265 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3267 if ((zvrf
= vrf
->info
) == NULL
||
3268 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
3271 /* Show all IPv6 routes with matching tag value. */
3272 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3273 RNODE_FOREACH_RIB (rn
, rib
)
3275 if (rib
->tag
!= tag
)
3280 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3286 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3289 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3297 DEFUN (show_ipv6_route_vrf_all_prefix_longer
,
3298 show_ipv6_route_vrf_all_prefix_longer_cmd
,
3299 "show ipv6 route vrf all X:X::X:X/M longer-prefixes",
3302 "IPv6 routing table\n"
3303 VRF_ALL_CMD_HELP_STR
3305 "Show route matching the specified Network/Mask pair only\n")
3307 int idx_ipv6_prefixlen
= 5;
3308 struct route_table
*table
;
3309 struct route_node
*rn
;
3313 struct zebra_vrf
*zvrf
;
3318 ret
= str2prefix (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3321 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3325 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3327 if ((zvrf
= vrf
->info
) == NULL
||
3328 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3331 /* Show matched type IPv6 routes. */
3332 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3333 RNODE_FOREACH_RIB (rn
, rib
)
3334 if (prefix_match (&p
, &rn
->p
))
3338 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3344 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3347 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3355 DEFUN (show_ipv6_route_vrf_all_protocol
,
3356 show_ipv6_route_vrf_all_protocol_cmd
,
3357 "show ipv6 route vrf all <kernel|connected|static|ripng|ospf6|isis|bgp|table>",
3360 "IP routing table\n"
3361 VRF_ALL_CMD_HELP_STR
3362 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3365 struct route_table
*table
;
3366 struct route_node
*rn
;
3369 struct zebra_vrf
*zvrf
;
3373 char *proto
= argv
[argc
- 1]->text
;
3374 type
= proto_redistnum (AFI_IP
, proto
);
3378 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3382 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3384 if ((zvrf
= vrf
->info
) == NULL
||
3385 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3388 /* Show matched type IPv6 routes. */
3389 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3390 RNODE_FOREACH_RIB (rn
, rib
)
3391 if (rib
->type
== type
)
3395 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3401 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3404 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3412 DEFUN (show_ipv6_route_vrf_all_addr
,
3413 show_ipv6_route_vrf_all_addr_cmd
,
3414 "show ipv6 route vrf all X:X::X:X",
3417 "IPv6 routing table\n"
3418 VRF_ALL_CMD_HELP_STR
3423 struct prefix_ipv6 p
;
3424 struct route_table
*table
;
3425 struct route_node
*rn
;
3427 struct zebra_vrf
*zvrf
;
3429 ret
= str2prefix_ipv6 (argv
[idx_ipv6
]->arg
, &p
);
3432 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3436 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3438 if ((zvrf
= vrf
->info
) == NULL
||
3439 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3442 rn
= route_node_match (table
, (struct prefix
*) &p
);
3446 vty_show_ip_route_detail (vty
, rn
, 0);
3448 route_unlock_node (rn
);
3454 DEFUN (show_ipv6_route_vrf_all_prefix
,
3455 show_ipv6_route_vrf_all_prefix_cmd
,
3456 "show ipv6 route vrf all X:X::X:X/M",
3459 "IPv6 routing table\n"
3460 VRF_ALL_CMD_HELP_STR
3463 int idx_ipv6_prefixlen
= 5;
3465 struct prefix_ipv6 p
;
3466 struct route_table
*table
;
3467 struct route_node
*rn
;
3469 struct zebra_vrf
*zvrf
;
3471 ret
= str2prefix_ipv6 (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3474 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3478 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3480 if ((zvrf
= vrf
->info
) == NULL
||
3481 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3484 rn
= route_node_match (table
, (struct prefix
*) &p
);
3487 if (rn
->p
.prefixlen
!= p
.prefixlen
)
3489 route_unlock_node (rn
);
3493 vty_show_ip_route_detail (vty
, rn
, 0);
3495 route_unlock_node (rn
);
3501 DEFUN (show_ipv6_route_vrf_all_summary
,
3502 show_ipv6_route_vrf_all_summary_cmd
,
3503 "show ipv6 route vrf all summary",
3506 "IPv6 routing table\n"
3507 VRF_ALL_CMD_HELP_STR
3508 "Summary of all IPv6 routes\n")
3511 struct zebra_vrf
*zvrf
;
3513 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3514 if ((zvrf
= vrf
->info
) != NULL
)
3515 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3520 DEFUN (show_ipv6_mroute_vrf_all
,
3521 show_ipv6_mroute_vrf_all_cmd
,
3522 "show ipv6 mroute vrf all",
3525 "IPv6 Multicast routing table\n"
3526 VRF_ALL_CMD_HELP_STR
)
3528 struct route_table
*table
;
3529 struct route_node
*rn
;
3532 struct zebra_vrf
*zvrf
;
3535 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3537 if ((zvrf
= vrf
->info
) == NULL
||
3538 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3541 /* Show all IPv6 route. */
3542 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3543 RNODE_FOREACH_RIB (rn
, rib
)
3547 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3550 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3556 DEFUN (show_ipv6_route_vrf_all_summary_prefix
,
3557 show_ipv6_route_vrf_all_summary_prefix_cmd
,
3558 "show ipv6 route vrf all summary prefix",
3561 "IPv6 routing table\n"
3562 VRF_ALL_CMD_HELP_STR
3563 "Summary of all IPv6 routes\n"
3567 struct zebra_vrf
*zvrf
;
3569 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3570 if ((zvrf
= vrf
->info
) != NULL
)
3571 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3576 /* Write IPv6 static route configuration. */
3578 static_config_ipv6 (struct vty
*vty
)
3580 struct route_node
*rn
;
3581 struct static_route
*si
;
3583 char buf
[PREFIX_STRLEN
];
3584 struct route_table
*stable
;
3586 struct zebra_vrf
*zvrf
;
3588 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3590 if (!(zvrf
= vrf
->info
))
3592 if ((stable
= zvrf
->stable
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3595 for (rn
= route_top (stable
); rn
; rn
= route_next (rn
))
3596 for (si
= rn
->info
; si
; si
= si
->next
)
3598 vty_out (vty
, "ipv6 route %s", prefix2str (&rn
->p
, buf
, sizeof buf
));
3602 case STATIC_IPV4_GATEWAY
:
3603 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
3605 case STATIC_IPV6_GATEWAY
:
3606 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
3608 case STATIC_IFINDEX
:
3609 vty_out (vty
, " %s", si
->ifname
);
3611 case STATIC_BLACKHOLE
:
3612 vty_out (vty
, " Null0" );
3614 case STATIC_IPV6_GATEWAY_IFINDEX
:
3615 vty_out (vty
, " %s %s",
3616 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
3617 ifindex2ifname_vrf (si
->ifindex
, si
->vrf_id
));
3621 /* flags are incompatible with STATIC_BLACKHOLE */
3622 if (si
->type
!= STATIC_BLACKHOLE
)
3624 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
3625 vty_out (vty
, " %s", "reject");
3626 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
3627 vty_out (vty
, " %s", "blackhole");
3631 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
3633 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
3634 vty_out (vty
, " %d", si
->distance
);
3636 if (si
->vrf_id
!= VRF_DEFAULT
)
3638 vty_out (vty
, " vrf %s", zvrf_name (zvrf
));
3641 /* Label information */
3642 if (si
->snh_label
.num_labels
)
3643 vty_out (vty
, " label %s",
3644 mpls_label2str (si
->snh_label
.num_labels
,
3645 si
->snh_label
.label
, buf
, sizeof buf
));
3647 vty_out (vty
, "%s", VTY_NEWLINE
);
3655 DEFUN (allow_external_route_update
,
3656 allow_external_route_update_cmd
,
3657 "allow-external-route-update",
3658 "Allow Quagga routes to be overwritten by external processes")
3665 DEFUN (no_allow_external_route_update
,
3666 no_allow_external_route_update_cmd
,
3667 "no allow-external-route-update",
3668 "Allow Quagga routes to be overwritten by external processes")
3683 struct zebra_vrf
*zvrf
;
3685 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3687 if (!(zvrf
= vrf
->info
))
3689 if (!zvrf_id (zvrf
))
3692 vty_out (vty
, "vrf %s ", zvrf_name (zvrf
));
3693 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
3694 vty_out (vty
, "inactive");
3696 vty_out (vty
, "id %u table %u", zvrf_id (zvrf
), zvrf
->table_id
);
3697 vty_out (vty
, "%s", VTY_NEWLINE
);
3704 /* Static ip route configuration write function. */
3706 zebra_ip_config (struct vty
*vty
)
3710 write
+= static_config_ipv4 (vty
, SAFI_UNICAST
, "ip route");
3711 write
+= static_config_ipv4 (vty
, SAFI_MULTICAST
, "ip mroute");
3712 write
+= static_config_ipv6 (vty
);
3714 write
+= zebra_import_table_config (vty
);
3718 DEFUN (ip_zebra_import_table_distance
,
3719 ip_zebra_import_table_distance_cmd
,
3720 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
3722 "import routes from non-main kernel table\n"
3723 "kernel routing table id\n"
3724 "Distance for imported routes\n"
3725 "Default distance value\n"
3726 "route-map for filtering\n"
3729 u_int32_t table_id
= 0;
3731 VTY_GET_INTEGER("table", table_id
, argv
[2]->arg
);
3732 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
3733 char *rmap
= strmatch (argv
[argc
- 2]->text
, "route-map") ?
3734 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
) : NULL
;
3735 if (argc
== 7 || (argc
== 5 && !rmap
))
3736 VTY_GET_INTEGER_RANGE("distance", distance
, argv
[4]->arg
, 1, 255);
3738 if (!is_zebra_valid_kernel_table(table_id
))
3740 vty_out(vty
, "Invalid routing table ID, %d. Must be in range 1-252%s",
3741 table_id
, VTY_NEWLINE
);
3745 if (is_zebra_main_routing_table(table_id
))
3747 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3748 table_id
, VTY_NEWLINE
);
3752 return (zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1));
3755 DEFUN (no_ip_zebra_import_table
,
3756 no_ip_zebra_import_table_cmd
,
3757 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
3760 "import routes from non-main kernel table\n"
3761 "kernel routing table id\n"
3762 "Distance for imported routes\n"
3763 "Default distance value\n"
3764 "route-map for filtering\n"
3767 u_int32_t table_id
= 0;
3768 VTY_GET_INTEGER("table", table_id
, argv
[3]->arg
);
3770 if (!is_zebra_valid_kernel_table(table_id
))
3772 vty_out(vty
, "Invalid routing table ID. Must be in range 1-252%s",
3777 if (is_zebra_main_routing_table(table_id
))
3779 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3780 table_id
, VTY_NEWLINE
);
3784 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
3787 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
3791 config_write_protocol (struct vty
*vty
)
3794 vty_out(vty
, "allow-external-route-update%s", VTY_NEWLINE
);
3796 if (zebra_rnh_ip_default_route
)
3797 vty_out(vty
, "ip nht resolve-via-default%s", VTY_NEWLINE
);
3799 if (zebra_rnh_ipv6_default_route
)
3800 vty_out(vty
, "ipv6 nht resolve-via-default%s", VTY_NEWLINE
);
3802 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get ();
3804 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
3805 vty_out (vty
, "ip multicast rpf-lookup-mode %s%s",
3806 ipv4_multicast_mode
== MCAST_URIB_ONLY
? "urib-only" :
3807 ipv4_multicast_mode
== MCAST_MRIB_ONLY
? "mrib-only" :
3808 ipv4_multicast_mode
== MCAST_MIX_MRIB_FIRST
? "mrib-then-urib" :
3809 ipv4_multicast_mode
== MCAST_MIX_DISTANCE
? "lower-distance" :
3813 zebra_routemap_config_write_protocol(vty
);
3818 /* IP node for static routes. */
3819 static struct cmd_node ip_node
= { IP_NODE
, "", 1 };
3820 static struct cmd_node protocol_node
= { PROTOCOL_NODE
, "", 1 };
3824 zebra_vty_init (void)
3826 install_node (&ip_node
, zebra_ip_config
);
3827 install_node (&protocol_node
, config_write_protocol
);
3829 install_element (CONFIG_NODE
, &allow_external_route_update_cmd
);
3830 install_element (CONFIG_NODE
, &no_allow_external_route_update_cmd
);
3831 install_element (CONFIG_NODE
, &ip_mroute_dist_cmd
);
3832 install_element (CONFIG_NODE
, &no_ip_mroute_dist_cmd
);
3833 install_element (CONFIG_NODE
, &ip_multicast_mode_cmd
);
3834 install_element (CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
3835 install_element (CONFIG_NODE
, &ip_route_cmd
);
3836 install_element (CONFIG_NODE
, &ip_route_flags_cmd
);
3837 install_element (CONFIG_NODE
, &ip_route_mask_cmd
);
3838 install_element (CONFIG_NODE
, &ip_route_mask_flags_cmd
);
3839 install_element (CONFIG_NODE
, &no_ip_route_cmd
);
3840 install_element (CONFIG_NODE
, &no_ip_route_mask_cmd
);
3841 install_element (CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
3842 install_element (CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
3844 install_element (VIEW_NODE
, &show_vrf_cmd
);
3845 install_element (VIEW_NODE
, &show_ip_route_cmd
);
3846 install_element (VIEW_NODE
, &show_ip_route_ospf_instance_cmd
);
3847 install_element (VIEW_NODE
, &show_ip_route_tag_cmd
);
3848 install_element (VIEW_NODE
, &show_ip_nht_cmd
);
3849 install_element (VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
3850 install_element (VIEW_NODE
, &show_ipv6_nht_cmd
);
3851 install_element (VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
3852 install_element (VIEW_NODE
, &show_ip_route_addr_cmd
);
3853 install_element (VIEW_NODE
, &show_ip_route_prefix_cmd
);
3854 install_element (VIEW_NODE
, &show_ip_route_prefix_longer_cmd
);
3855 install_element (VIEW_NODE
, &show_ip_route_protocol_cmd
);
3856 install_element (VIEW_NODE
, &show_ip_route_supernets_cmd
);
3857 install_element (VIEW_NODE
, &show_ip_route_summary_cmd
);
3858 install_element (VIEW_NODE
, &show_ip_route_summary_prefix_cmd
);
3860 install_element (VIEW_NODE
, &show_ip_rpf_cmd
);
3861 install_element (VIEW_NODE
, &show_ip_rpf_addr_cmd
);
3863 /* Commands for VRF */
3865 install_element (CONFIG_NODE
, &no_ip_route_flags_cmd
);
3866 install_element (CONFIG_NODE
, &no_ip_route_mask_flags_cmd
);
3868 install_element (VIEW_NODE
, &show_ip_route_vrf_cmd
);
3870 install_element (VIEW_NODE
, &show_ip_route_vrf_all_cmd
);
3871 install_element (VIEW_NODE
, &show_ip_route_vrf_all_tag_cmd
);
3872 install_element (VIEW_NODE
, &show_ip_route_vrf_all_addr_cmd
);
3873 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_cmd
);
3874 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_longer_cmd
);
3875 install_element (VIEW_NODE
, &show_ip_route_vrf_all_protocol_cmd
);
3876 install_element (VIEW_NODE
, &show_ip_route_vrf_all_supernets_cmd
);
3877 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_cmd
);
3878 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_prefix_cmd
);
3880 install_element (CONFIG_NODE
, &ipv6_route_cmd
);
3881 install_element (CONFIG_NODE
, &ipv6_route_flags_cmd
);
3882 install_element (CONFIG_NODE
, &ipv6_route_ifname_cmd
);
3883 install_element (CONFIG_NODE
, &ipv6_route_ifname_flags_cmd
);
3884 install_element (CONFIG_NODE
, &no_ipv6_route_cmd
);
3885 install_element (CONFIG_NODE
, &no_ipv6_route_flags_cmd
);
3886 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_cmd
);
3887 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_flags_cmd
);
3888 install_element (CONFIG_NODE
, &ip_nht_default_route_cmd
);
3889 install_element (CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
3890 install_element (CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
3891 install_element (CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
3892 install_element (VIEW_NODE
, &show_ipv6_route_cmd
);
3893 install_element (VIEW_NODE
, &show_ipv6_route_tag_cmd
);
3894 install_element (VIEW_NODE
, &show_ipv6_route_summary_cmd
);
3895 install_element (VIEW_NODE
, &show_ipv6_route_summary_prefix_cmd
);
3896 install_element (VIEW_NODE
, &show_ipv6_route_protocol_cmd
);
3897 install_element (VIEW_NODE
, &show_ipv6_route_addr_cmd
);
3898 install_element (VIEW_NODE
, &show_ipv6_route_prefix_cmd
);
3899 install_element (VIEW_NODE
, &show_ipv6_route_prefix_longer_cmd
);
3901 install_element (VIEW_NODE
, &show_ipv6_mroute_cmd
);
3903 /* Commands for VRF */
3904 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_cmd
);
3905 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_tag_cmd
);
3906 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_cmd
);
3907 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_prefix_cmd
);
3908 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_protocol_cmd
);
3909 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_addr_cmd
);
3910 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_cmd
);
3911 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_longer_cmd
);
3913 install_element (VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);