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"
37 #include "zebra/zserv.h"
38 #include "zebra/zebra_vrf.h"
39 #include "zebra/zebra_mpls.h"
40 #include "zebra/zebra_rnh.h"
41 #include "zebra/redistribute.h"
42 #include "zebra/zebra_routemap.h"
43 #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");
2287 /* flags are incompatible with STATIC_BLACKHOLE */
2288 if (si
->type
!= STATIC_BLACKHOLE
)
2290 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
2291 vty_out (vty
, " %s", "reject");
2293 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
2294 vty_out (vty
, " %s", "blackhole");
2298 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
2300 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
2301 vty_out (vty
, " %d", si
->distance
);
2303 if (si
->vrf_id
!= VRF_DEFAULT
)
2304 vty_out (vty
, " vrf %s", zvrf
? zvrf_name (zvrf
) : "");
2306 /* Label information */
2307 if (si
->snh_label
.num_labels
)
2308 vty_out (vty
, " label %s",
2309 mpls_label2str (si
->snh_label
.num_labels
,
2310 si
->snh_label
.label
, buf
, sizeof buf
));
2312 vty_out (vty
, "%s", VTY_NEWLINE
);
2320 /* General fucntion for IPv6 static route. */
2322 static_ipv6_func (struct vty
*vty
, int add_cmd
, const char *dest_str
,
2323 const char *gate_str
, const char *ifname
,
2324 const char *flag_str
, const char *tag_str
,
2325 const char *distance_str
, const char *vrf_id_str
,
2326 const char *label_str
)
2331 struct in6_addr
*gate
= NULL
;
2332 struct in6_addr gate_addr
;
2333 u_char type
= STATIC_BLACKHOLE
;
2335 route_tag_t tag
= 0;
2336 unsigned int ifindex
= 0;
2337 struct interface
*ifp
= NULL
;
2338 struct zebra_vrf
*zvrf
;
2339 struct static_nh_label snh_label
;
2341 ret
= str2prefix (dest_str
, &p
);
2344 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2348 /* Apply mask for given prefix. */
2351 /* Administrative distance. */
2353 distance
= atoi (distance_str
);
2355 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
2359 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
2361 /* When gateway is valid IPv6 addrees, then gate is treated as
2362 nexthop address other case gate is treated as interface name. */
2363 ret
= inet_pton (AF_INET6
, gate_str
, &gate_addr
);
2366 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
2370 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
2375 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
2380 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
2384 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
2387 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
2392 /* Null0 static route. */
2393 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
2397 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
2401 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, ifindex
, ifname
,
2402 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
2404 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, ifindex
, tag
,
2405 distance
, zvrf
, &snh_label
);
2411 switch(flag_str
[0]) {
2414 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
2418 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
2421 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
2428 /* When ifname is specified. It must be come with gateway
2432 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2435 type
= STATIC_IPV6_GATEWAY_IFINDEX
;
2437 ifp
= if_lookup_by_name_vrf (ifname
, zvrf_id (zvrf
));
2440 vty_out (vty
, "%% Malformed Interface name %s%s", ifname
, VTY_NEWLINE
);
2443 ifindex
= ifp
->ifindex
;
2449 type
= STATIC_IPV6_GATEWAY
;
2454 type
= STATIC_IFINDEX
;
2455 ifp
= if_lookup_by_name_vrf (gate_str
, zvrf_id (zvrf
));
2458 vty_out (vty
, "%% Malformed Interface name %s%s", gate_str
, VTY_NEWLINE
);
2459 ifindex
= IFINDEX_DELETED
;
2462 ifindex
= ifp
->ifindex
;
2468 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, (union g_addr
*)gate
,
2469 ifindex
, ifname
, flag
, tag
, distance
, zvrf
, &snh_label
);
2471 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, (union g_addr
*)gate
,
2472 ifindex
, tag
, distance
, zvrf
, &snh_label
);
2479 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2481 "Establish static routes\n"
2482 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2483 "IPv6 gateway address\n"
2484 "IPv6 gateway interface name\n"
2487 "Set tag for this route\n"
2489 "Distance value for this prefix\n"
2491 "Specify labels for this route\n"
2492 "One or more labels separated by '/'\n")
2494 int idx_ipv6_prefixlen
= 2;
2495 int idx_ipv6_ifname
= 3;
2497 char *tag
, *distance
, *vrf
;
2499 tag
= distance
= vrf
= NULL
;
2500 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2502 return static_ipv6_func (vty
, 1,
2503 argv
[idx_ipv6_prefixlen
]->arg
,
2504 argv
[idx_ipv6_ifname
]->arg
,
2506 tag
, distance
, vrf
, NULL
);
2509 DEFUN (ipv6_route_flags
,
2510 ipv6_route_flags_cmd
,
2511 "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2513 "Establish static routes\n"
2514 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2515 "IPv6 gateway address\n"
2516 "IPv6 gateway interface name\n"
2517 "Emit an ICMP unreachable when matched\n"
2518 "Silently discard pkts when matched\n"
2519 "Silently discard pkts when matched\n"
2520 "Set tag for this route\n"
2522 "Distance value for this prefix\n"
2524 "Specify labels for this route\n"
2525 "One or more labels separated by '/'\n")
2527 int idx_ipv6_prefixlen
= 2;
2528 int idx_ipv6_ifname
= 3;
2529 int idx_reject_blackhole
= 4;
2531 char *tag
, *distance
, *vrf
;
2533 tag
= distance
= vrf
= NULL
;
2534 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2536 return static_ipv6_func (vty
, 1,
2537 argv
[idx_ipv6_prefixlen
]->arg
,
2538 argv
[idx_ipv6_ifname
]->arg
,
2540 argv
[idx_reject_blackhole
]->arg
,
2541 tag
, distance
, vrf
, NULL
);
2544 DEFUN (ipv6_route_ifname
,
2545 ipv6_route_ifname_cmd
,
2546 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2548 "Establish static routes\n"
2549 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2550 "IPv6 gateway address\n"
2551 "IPv6 gateway interface name\n"
2552 "Set tag for this route\n"
2554 "Distance value for this prefix\n"
2556 "Specify labels for this route\n"
2557 "One or more labels separated by '/'\n")
2559 int idx_ipv6_prefixlen
= 2;
2561 int idx_interface
= 4;
2563 char *tag
, *distance
, *vrf
;
2565 tag
= distance
= vrf
= NULL
;
2566 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2568 return static_ipv6_func (vty
, 1,
2569 argv
[idx_ipv6_prefixlen
]->arg
,
2570 argv
[idx_ipv6
]->arg
,
2571 argv
[idx_interface
]->arg
,
2573 tag
, distance
, vrf
, NULL
);
2576 DEFUN (ipv6_route_ifname_flags
,
2577 ipv6_route_ifname_flags_cmd
,
2578 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2580 "Establish static routes\n"
2581 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2582 "IPv6 gateway address\n"
2583 "IPv6 gateway interface name\n"
2584 "Emit an ICMP unreachable when matched\n"
2585 "Silently discard pkts when matched\n"
2586 "Set tag for this route\n"
2588 "Distance value for this prefix\n"
2590 "Specify labels for this route\n"
2591 "One or more labels separated by '/'\n")
2593 int idx_ipv6_prefixlen
= 2;
2595 int idx_interface
= 4;
2596 int idx_reject_blackhole
= 5;
2598 char *tag
, *distance
, *vrf
;
2600 tag
= distance
= vrf
= NULL
;
2601 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2603 return static_ipv6_func (vty
, 1,
2604 argv
[idx_ipv6_prefixlen
]->arg
,
2605 argv
[idx_ipv6
]->arg
,
2606 argv
[idx_interface
]->arg
,
2607 argv
[idx_reject_blackhole
]->arg
,
2608 tag
, distance
, vrf
, NULL
);
2611 DEFUN (no_ipv6_route
,
2613 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2616 "Establish static routes\n"
2617 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2618 "IPv6 gateway address\n"
2619 "IPv6 gateway interface name\n"
2621 "Set tag for this route\n"
2623 "Distance value for this prefix\n"
2625 "Specify labels for this route\n"
2626 "One or more labels separated by '/'\n")
2628 int idx_ipv6_prefixlen
= 3;
2629 int idx_ipv6_ifname
= 4;
2631 char *tag
, *distance
, *vrf
;
2633 tag
= distance
= vrf
= NULL
;
2634 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2636 return static_ipv6_func (vty
, 0,
2637 argv
[idx_ipv6_prefixlen
]->arg
,
2638 argv
[idx_ipv6_ifname
]->arg
,
2640 tag
, distance
, vrf
, NULL
);
2643 DEFUN (no_ipv6_route_flags
,
2644 no_ipv6_route_flags_cmd
,
2645 "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2648 "Establish static routes\n"
2649 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2650 "IPv6 gateway address\n"
2651 "IPv6 gateway interface name\n"
2652 "Emit an ICMP unreachable when matched\n"
2653 "Silently discard pkts when matched\n"
2654 "Set tag for this route\n"
2656 "Distance value for this prefix\n"
2658 "Specify labels for this route\n"
2659 "One or more labels separated by '/'\n")
2661 int idx_ipv6_prefixlen
= 3;
2662 int idx_ipv6_ifname
= 4;
2663 int idx_reject_blackhole
= 5;
2665 char *tag
, *distance
, *vrf
;
2667 tag
= distance
= vrf
= NULL
;
2668 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2670 return static_ipv6_func (vty
, 0,
2671 argv
[idx_ipv6_prefixlen
]->arg
,
2672 argv
[idx_ipv6_ifname
]->arg
,
2674 argv
[idx_reject_blackhole
]->arg
,
2675 tag
, distance
, vrf
, NULL
);
2678 DEFUN (no_ipv6_route_ifname
,
2679 no_ipv6_route_ifname_cmd
,
2680 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2683 "Establish static routes\n"
2684 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2685 "IPv6 gateway address\n"
2686 "IPv6 gateway interface name\n"
2687 "Set tag for this route\n"
2689 "Distance value for this prefix\n"
2691 "Specify labels for this route\n"
2692 "One or more labels separated by '/'\n")
2694 int idx_ipv6_prefixlen
= 3;
2696 int idx_interface
= 5;
2698 char *tag
, *distance
, *vrf
;
2700 tag
= distance
= vrf
= NULL
;
2701 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2703 return static_ipv6_func (vty
, 0,
2704 argv
[idx_ipv6_prefixlen
]->arg
,
2705 argv
[idx_ipv6
]->arg
,
2706 argv
[idx_interface
]->arg
,
2708 tag
, distance
, vrf
, NULL
);
2711 DEFUN (no_ipv6_route_ifname_flags
,
2712 no_ipv6_route_ifname_flags_cmd
,
2713 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2716 "Establish static routes\n"
2717 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2718 "IPv6 gateway address\n"
2719 "IPv6 gateway interface name\n"
2720 "Emit an ICMP unreachable when matched\n"
2721 "Silently discard pkts when matched\n"
2722 "Set tag for this route\n"
2724 "Distance value for this prefix\n"
2726 "Specify labels for this route\n"
2727 "One or more labels separated by '/'\n")
2729 int idx_ipv6_prefixlen
= 3;
2731 int idx_interface
= 5;
2732 int idx_reject_blackhole
= 6;
2734 char *tag
, *distance
, *vrf
;
2736 tag
= distance
= vrf
= NULL
;
2737 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2739 return static_ipv6_func (vty
, 0,
2740 argv
[idx_ipv6_prefixlen
]->arg
,
2741 argv
[idx_ipv6
]->arg
,
2742 argv
[idx_interface
]->arg
,
2743 argv
[idx_reject_blackhole
]->arg
,
2744 tag
, distance
, vrf
, NULL
);
2747 DEFUN (show_ipv6_route
,
2748 show_ipv6_route_cmd
,
2749 "show ipv6 route [vrf NAME] [json]",
2752 "IPv6 routing table\n"
2756 struct route_table
*table
;
2757 struct route_node
*rn
;
2760 vrf_id_t vrf_id
= VRF_DEFAULT
;
2761 struct zebra_vrf
*zvrf
= NULL
;
2763 json_object
*json
= NULL
;
2764 json_object
*json_prefix
= NULL
;
2766 int vrf
= (argc
> 3 && strmatch (argv
[3]->text
, "vrf"));
2767 int uj
= vrf
? argc
== 6 : argc
== 4;
2768 char *vrfname
= vrf
? argv
[4]->arg
: NULL
;
2772 if (!(zvrf
= zebra_vrf_lookup_by_name (vrfname
)))
2775 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2777 vty_out (vty
, "vrf %s not defined%s", vrfname
, VTY_NEWLINE
);
2781 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
2784 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2786 vty_out (vty
, "vrf %s inactive%s", vrfname
, VTY_NEWLINE
);
2790 vrf_id
= zvrf_id (zvrf
);
2793 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2797 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2803 json
= json_object_new_object();
2805 /* Show all IPv6 route. */
2806 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2808 RNODE_FOREACH_RIB (rn
, rib
)
2811 json_prefix
= json_object_new_array();
2812 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
2817 prefix2str (&rn
->p
, buf
, sizeof buf
);
2818 json_object_object_add(json
, buf
, json_prefix
);
2823 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
2824 json_object_free(json
);
2828 /* Show all IPv6 route. */
2829 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2831 RNODE_FOREACH_RIB (rn
, rib
)
2835 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2838 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2846 DEFUN (show_ipv6_route_tag
,
2847 show_ipv6_route_tag_cmd
,
2848 "show ipv6 route [vrf NAME] tag (1-4294967295)",
2851 "IPv6 routing table\n"
2853 "Show only routes with tag\n"
2859 struct route_table
*table
;
2860 struct route_node
*rn
;
2863 route_tag_t tag
= 0;
2864 vrf_id_t vrf_id
= VRF_DEFAULT
;
2866 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
2868 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
2869 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
2874 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
2877 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2881 /* Show all IPv6 routes with matching tag value. */
2882 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2883 RNODE_FOREACH_RIB (rn
, rib
)
2885 if (rib
->tag
!= tag
)
2890 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2893 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2898 DEFUN (show_ipv6_route_prefix_longer
,
2899 show_ipv6_route_prefix_longer_cmd
,
2900 "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes",
2903 "IPv6 routing table\n"
2906 "Show route matching the specified Network/Mask pair only\n")
2908 struct route_table
*table
;
2909 struct route_node
*rn
;
2914 vrf_id_t vrf_id
= VRF_DEFAULT
;
2916 if (strmatch(argv
[3]->text
, "vrf"))
2918 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
2919 ret
= str2prefix (argv
[5]->arg
, &p
);
2923 ret
= str2prefix (argv
[3]->arg
, &p
);
2928 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
2932 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2936 /* Show matched type IPv6 routes. */
2937 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2938 RNODE_FOREACH_RIB (rn
, rib
)
2939 if (prefix_match (&p
, &rn
->p
))
2943 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2946 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2951 DEFUN (show_ipv6_route_protocol
,
2952 show_ipv6_route_protocol_cmd
,
2953 "show ipv6 route [vrf NAME] <kernel|connected|static|ripng|ospf6|isis|bgp|table>",
2956 "IP routing table\n"
2958 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
2961 struct route_table
*table
;
2962 struct route_node
*rn
;
2965 vrf_id_t vrf_id
= VRF_DEFAULT
;
2968 if (argv_find (argv
, argc
, "NAME", &idx
))
2969 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
2971 char *proto
= argv
[argc
- 1]->text
;
2972 type
= proto_redistnum (AFI_IP
, proto
);
2976 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
2980 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2984 /* Show matched type IPv6 routes. */
2985 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2986 RNODE_FOREACH_RIB (rn
, rib
)
2987 if (rib
->type
== type
)
2991 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
2994 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2999 DEFUN (show_ipv6_route_addr
,
3000 show_ipv6_route_addr_cmd
,
3001 "show ipv6 route [vrf NAME] X:X::X:X",
3004 "IPv6 routing table\n"
3009 struct prefix_ipv6 p
;
3010 struct route_table
*table
;
3011 struct route_node
*rn
;
3012 vrf_id_t vrf_id
= VRF_DEFAULT
;
3014 if (strmatch(argv
[3]->text
, "vrf"))
3016 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3017 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3021 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3026 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3030 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3034 rn
= route_node_match (table
, (struct prefix
*) &p
);
3037 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3041 vty_show_ip_route_detail (vty
, rn
, 0);
3043 route_unlock_node (rn
);
3048 DEFUN (show_ipv6_route_prefix
,
3049 show_ipv6_route_prefix_cmd
,
3050 "show ipv6 route [vrf NAME] X:X::X:X/M",
3053 "IPv6 routing table\n"
3058 struct prefix_ipv6 p
;
3059 struct route_table
*table
;
3060 struct route_node
*rn
;
3061 vrf_id_t vrf_id
= VRF_DEFAULT
;
3063 if (strmatch(argv
[3]->text
, "vrf"))
3065 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3066 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3069 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3073 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3077 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3081 rn
= route_node_match (table
, (struct prefix
*) &p
);
3082 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
3084 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3088 vty_show_ip_route_detail (vty
, rn
, 0);
3090 route_unlock_node (rn
);
3096 /* Show route summary. */
3097 DEFUN (show_ipv6_route_summary
,
3098 show_ipv6_route_summary_cmd
,
3099 "show ipv6 route [vrf NAME] summary",
3102 "IPv6 routing table\n"
3104 "Summary of all IPv6 routes\n")
3106 struct route_table
*table
;
3107 vrf_id_t vrf_id
= VRF_DEFAULT
;
3109 if (strmatch(argv
[3]->text
, "vrf"))
3110 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3112 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3116 vty_show_ip_route_summary (vty
, table
);
3122 /* Show ipv6 route summary prefix. */
3123 DEFUN (show_ipv6_route_summary_prefix
,
3124 show_ipv6_route_summary_prefix_cmd
,
3125 "show ipv6 route [vrf NAME] summary prefix",
3128 "IPv6 routing table\n"
3130 "Summary of all IPv6 routes\n"
3133 struct route_table
*table
;
3134 vrf_id_t vrf_id
= VRF_DEFAULT
;
3136 if (strmatch(argv
[3]->text
, "vrf"))
3137 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3139 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3143 vty_show_ip_route_summary_prefix (vty
, table
);
3150 * Show IPv6 mroute command.Used to dump
3151 * the Multicast routing table.
3153 DEFUN (show_ipv6_mroute
,
3154 show_ipv6_mroute_cmd
,
3155 "show ipv6 mroute [vrf NAME]",
3158 "IPv6 Multicast routing table\n"
3161 struct route_table
*table
;
3162 struct route_node
*rn
;
3165 vrf_id_t vrf_id
= VRF_DEFAULT
;
3167 if (strmatch(argv
[3]->text
, "vrf"))
3168 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3170 table
= zebra_vrf_table (AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
3174 /* Show all IPv6 route. */
3175 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3176 RNODE_FOREACH_RIB (rn
, rib
)
3180 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3183 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3189 DEFUN (show_ipv6_route_vrf_all
,
3190 show_ipv6_route_vrf_all_cmd
,
3191 "show ipv6 route vrf all",
3194 "IPv6 routing table\n"
3195 VRF_ALL_CMD_HELP_STR
)
3197 struct route_table
*table
;
3198 struct route_node
*rn
;
3201 struct zebra_vrf
*zvrf
;
3205 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3207 if ((zvrf
= vrf
->info
) == NULL
||
3208 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3211 /* Show all IPv6 route. */
3212 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3213 RNODE_FOREACH_RIB (rn
, rib
)
3217 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3223 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3226 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3234 DEFUN (show_ipv6_route_vrf_all_tag
,
3235 show_ipv6_route_vrf_all_tag_cmd
,
3236 "show ipv6 route vrf all tag (1-4294967295)",
3239 "IPv6 routing table\n"
3240 VRF_ALL_CMD_HELP_STR
3241 "Show only routes with tag\n"
3245 struct route_table
*table
;
3246 struct route_node
*rn
;
3249 struct zebra_vrf
*zvrf
;
3252 route_tag_t tag
= 0;
3254 if (argv
[idx_number
]->arg
)
3255 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
3257 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3259 if ((zvrf
= vrf
->info
) == NULL
||
3260 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
3263 /* Show all IPv6 routes with matching tag value. */
3264 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3265 RNODE_FOREACH_RIB (rn
, rib
)
3267 if (rib
->tag
!= tag
)
3272 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3278 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3281 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3289 DEFUN (show_ipv6_route_vrf_all_prefix_longer
,
3290 show_ipv6_route_vrf_all_prefix_longer_cmd
,
3291 "show ipv6 route vrf all X:X::X:X/M longer-prefixes",
3294 "IPv6 routing table\n"
3295 VRF_ALL_CMD_HELP_STR
3297 "Show route matching the specified Network/Mask pair only\n")
3299 int idx_ipv6_prefixlen
= 5;
3300 struct route_table
*table
;
3301 struct route_node
*rn
;
3305 struct zebra_vrf
*zvrf
;
3310 ret
= str2prefix (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3313 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3317 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3319 if ((zvrf
= vrf
->info
) == NULL
||
3320 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3323 /* Show matched type IPv6 routes. */
3324 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3325 RNODE_FOREACH_RIB (rn
, rib
)
3326 if (prefix_match (&p
, &rn
->p
))
3330 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3336 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3339 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3347 DEFUN (show_ipv6_route_vrf_all_protocol
,
3348 show_ipv6_route_vrf_all_protocol_cmd
,
3349 "show ipv6 route vrf all <kernel|connected|static|ripng|ospf6|isis|bgp|table>",
3352 "IP routing table\n"
3353 VRF_ALL_CMD_HELP_STR
3354 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3357 struct route_table
*table
;
3358 struct route_node
*rn
;
3361 struct zebra_vrf
*zvrf
;
3365 char *proto
= argv
[argc
- 1]->text
;
3366 type
= proto_redistnum (AFI_IP
, proto
);
3370 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3374 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3376 if ((zvrf
= vrf
->info
) == NULL
||
3377 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3380 /* Show matched type IPv6 routes. */
3381 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3382 RNODE_FOREACH_RIB (rn
, rib
)
3383 if (rib
->type
== type
)
3387 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3393 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3396 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3404 DEFUN (show_ipv6_route_vrf_all_addr
,
3405 show_ipv6_route_vrf_all_addr_cmd
,
3406 "show ipv6 route vrf all X:X::X:X",
3409 "IPv6 routing table\n"
3410 VRF_ALL_CMD_HELP_STR
3415 struct prefix_ipv6 p
;
3416 struct route_table
*table
;
3417 struct route_node
*rn
;
3419 struct zebra_vrf
*zvrf
;
3421 ret
= str2prefix_ipv6 (argv
[idx_ipv6
]->arg
, &p
);
3424 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3428 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3430 if ((zvrf
= vrf
->info
) == NULL
||
3431 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3434 rn
= route_node_match (table
, (struct prefix
*) &p
);
3438 vty_show_ip_route_detail (vty
, rn
, 0);
3440 route_unlock_node (rn
);
3446 DEFUN (show_ipv6_route_vrf_all_prefix
,
3447 show_ipv6_route_vrf_all_prefix_cmd
,
3448 "show ipv6 route vrf all X:X::X:X/M",
3451 "IPv6 routing table\n"
3452 VRF_ALL_CMD_HELP_STR
3455 int idx_ipv6_prefixlen
= 5;
3457 struct prefix_ipv6 p
;
3458 struct route_table
*table
;
3459 struct route_node
*rn
;
3461 struct zebra_vrf
*zvrf
;
3463 ret
= str2prefix_ipv6 (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3466 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3470 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3472 if ((zvrf
= vrf
->info
) == NULL
||
3473 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3476 rn
= route_node_match (table
, (struct prefix
*) &p
);
3479 if (rn
->p
.prefixlen
!= p
.prefixlen
)
3481 route_unlock_node (rn
);
3485 vty_show_ip_route_detail (vty
, rn
, 0);
3487 route_unlock_node (rn
);
3493 DEFUN (show_ipv6_route_vrf_all_summary
,
3494 show_ipv6_route_vrf_all_summary_cmd
,
3495 "show ipv6 route vrf all summary",
3498 "IPv6 routing table\n"
3499 VRF_ALL_CMD_HELP_STR
3500 "Summary of all IPv6 routes\n")
3503 struct zebra_vrf
*zvrf
;
3505 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3506 if ((zvrf
= vrf
->info
) != NULL
)
3507 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3512 DEFUN (show_ipv6_mroute_vrf_all
,
3513 show_ipv6_mroute_vrf_all_cmd
,
3514 "show ipv6 mroute vrf all",
3517 "IPv6 Multicast routing table\n"
3518 VRF_ALL_CMD_HELP_STR
)
3520 struct route_table
*table
;
3521 struct route_node
*rn
;
3524 struct zebra_vrf
*zvrf
;
3527 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3529 if ((zvrf
= vrf
->info
) == NULL
||
3530 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3533 /* Show all IPv6 route. */
3534 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3535 RNODE_FOREACH_RIB (rn
, rib
)
3539 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3542 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3548 DEFUN (show_ipv6_route_vrf_all_summary_prefix
,
3549 show_ipv6_route_vrf_all_summary_prefix_cmd
,
3550 "show ipv6 route vrf all summary prefix",
3553 "IPv6 routing table\n"
3554 VRF_ALL_CMD_HELP_STR
3555 "Summary of all IPv6 routes\n"
3559 struct zebra_vrf
*zvrf
;
3561 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3562 if ((zvrf
= vrf
->info
) != NULL
)
3563 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3568 /* Write IPv6 static route configuration. */
3570 static_config_ipv6 (struct vty
*vty
)
3572 struct route_node
*rn
;
3573 struct static_route
*si
;
3575 char buf
[PREFIX_STRLEN
];
3576 struct route_table
*stable
;
3578 struct zebra_vrf
*zvrf
;
3580 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3582 if (!(zvrf
= vrf
->info
))
3584 if ((stable
= zvrf
->stable
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3587 for (rn
= route_top (stable
); rn
; rn
= route_next (rn
))
3588 for (si
= rn
->info
; si
; si
= si
->next
)
3590 vty_out (vty
, "ipv6 route %s", prefix2str (&rn
->p
, buf
, sizeof buf
));
3594 case STATIC_IPV6_GATEWAY
:
3595 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
3597 case STATIC_IFINDEX
:
3598 vty_out (vty
, " %s", si
->ifname
);
3600 case STATIC_BLACKHOLE
:
3601 vty_out (vty
, " Null0" );
3603 case STATIC_IPV6_GATEWAY_IFINDEX
:
3604 vty_out (vty
, " %s %s",
3605 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
3606 ifindex2ifname_vrf (si
->ifindex
, si
->vrf_id
));
3610 /* flags are incompatible with STATIC_BLACKHOLE */
3611 if (si
->type
!= STATIC_BLACKHOLE
)
3613 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
3614 vty_out (vty
, " %s", "reject");
3615 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
3616 vty_out (vty
, " %s", "blackhole");
3620 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
3622 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
3623 vty_out (vty
, " %d", si
->distance
);
3625 if (si
->vrf_id
!= VRF_DEFAULT
)
3627 vty_out (vty
, " vrf %s", zvrf_name (zvrf
));
3630 /* Label information */
3631 if (si
->snh_label
.num_labels
)
3632 vty_out (vty
, " label %s",
3633 mpls_label2str (si
->snh_label
.num_labels
,
3634 si
->snh_label
.label
, buf
, sizeof buf
));
3636 vty_out (vty
, "%s", VTY_NEWLINE
);
3644 DEFUN (allow_external_route_update
,
3645 allow_external_route_update_cmd
,
3646 "allow-external-route-update",
3647 "Allow Quagga routes to be overwritten by external processes")
3654 DEFUN (no_allow_external_route_update
,
3655 no_allow_external_route_update_cmd
,
3656 "no allow-external-route-update",
3657 "Allow Quagga routes to be overwritten by external processes")
3672 struct zebra_vrf
*zvrf
;
3674 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3676 if (!(zvrf
= vrf
->info
))
3678 if (!zvrf_id (zvrf
))
3681 vty_out (vty
, "vrf %s ", zvrf_name (zvrf
));
3682 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
3683 vty_out (vty
, "inactive");
3685 vty_out (vty
, "id %u table %u", zvrf_id (zvrf
), zvrf
->table_id
);
3686 vty_out (vty
, "%s", VTY_NEWLINE
);
3693 /* Static ip route configuration write function. */
3695 zebra_ip_config (struct vty
*vty
)
3699 write
+= static_config_ipv4 (vty
, SAFI_UNICAST
, "ip route");
3700 write
+= static_config_ipv4 (vty
, SAFI_MULTICAST
, "ip mroute");
3701 write
+= static_config_ipv6 (vty
);
3703 write
+= zebra_import_table_config (vty
);
3707 DEFUN (ip_zebra_import_table_distance
,
3708 ip_zebra_import_table_distance_cmd
,
3709 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
3711 "import routes from non-main kernel table\n"
3712 "kernel routing table id\n"
3713 "Distance for imported routes\n"
3714 "Default distance value\n"
3715 "route-map for filtering\n"
3718 u_int32_t table_id
= 0;
3720 VTY_GET_INTEGER("table", table_id
, argv
[2]->arg
);
3721 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
3722 char *rmap
= strmatch (argv
[argc
- 2]->text
, "route-map") ?
3723 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
) : NULL
;
3724 if (argc
== 7 || (argc
== 5 && !rmap
))
3725 VTY_GET_INTEGER_RANGE("distance", distance
, argv
[4]->arg
, 1, 255);
3727 if (!is_zebra_valid_kernel_table(table_id
))
3729 vty_out(vty
, "Invalid routing table ID, %d. Must be in range 1-252%s",
3730 table_id
, VTY_NEWLINE
);
3734 if (is_zebra_main_routing_table(table_id
))
3736 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3737 table_id
, VTY_NEWLINE
);
3741 return (zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1));
3744 DEFUN (no_ip_zebra_import_table
,
3745 no_ip_zebra_import_table_cmd
,
3746 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
3749 "import routes from non-main kernel table\n"
3750 "kernel routing table id\n"
3751 "Distance for imported routes\n"
3752 "Default distance value\n"
3753 "route-map for filtering\n"
3756 u_int32_t table_id
= 0;
3757 VTY_GET_INTEGER("table", table_id
, argv
[3]->arg
);
3759 if (!is_zebra_valid_kernel_table(table_id
))
3761 vty_out(vty
, "Invalid routing table ID. Must be in range 1-252%s",
3766 if (is_zebra_main_routing_table(table_id
))
3768 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3769 table_id
, VTY_NEWLINE
);
3773 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
3776 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
3780 config_write_protocol (struct vty
*vty
)
3783 vty_out(vty
, "allow-external-route-update%s", VTY_NEWLINE
);
3785 if (zebra_rnh_ip_default_route
)
3786 vty_out(vty
, "ip nht resolve-via-default%s", VTY_NEWLINE
);
3788 if (zebra_rnh_ipv6_default_route
)
3789 vty_out(vty
, "ipv6 nht resolve-via-default%s", VTY_NEWLINE
);
3791 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get ();
3793 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
3794 vty_out (vty
, "ip multicast rpf-lookup-mode %s%s",
3795 ipv4_multicast_mode
== MCAST_URIB_ONLY
? "urib-only" :
3796 ipv4_multicast_mode
== MCAST_MRIB_ONLY
? "mrib-only" :
3797 ipv4_multicast_mode
== MCAST_MIX_MRIB_FIRST
? "mrib-then-urib" :
3798 ipv4_multicast_mode
== MCAST_MIX_DISTANCE
? "lower-distance" :
3802 zebra_routemap_config_write_protocol(vty
);
3807 /* IP node for static routes. */
3808 static struct cmd_node ip_node
= { IP_NODE
, "", 1 };
3809 static struct cmd_node protocol_node
= { PROTOCOL_NODE
, "", 1 };
3813 zebra_vty_init (void)
3815 install_node (&ip_node
, zebra_ip_config
);
3816 install_node (&protocol_node
, config_write_protocol
);
3818 install_element (CONFIG_NODE
, &allow_external_route_update_cmd
);
3819 install_element (CONFIG_NODE
, &no_allow_external_route_update_cmd
);
3820 install_element (CONFIG_NODE
, &ip_mroute_dist_cmd
);
3821 install_element (CONFIG_NODE
, &no_ip_mroute_dist_cmd
);
3822 install_element (CONFIG_NODE
, &ip_multicast_mode_cmd
);
3823 install_element (CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
3824 install_element (CONFIG_NODE
, &ip_route_cmd
);
3825 install_element (CONFIG_NODE
, &ip_route_flags_cmd
);
3826 install_element (CONFIG_NODE
, &ip_route_mask_cmd
);
3827 install_element (CONFIG_NODE
, &ip_route_mask_flags_cmd
);
3828 install_element (CONFIG_NODE
, &no_ip_route_cmd
);
3829 install_element (CONFIG_NODE
, &no_ip_route_mask_cmd
);
3830 install_element (CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
3831 install_element (CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
3833 install_element (VIEW_NODE
, &show_vrf_cmd
);
3834 install_element (VIEW_NODE
, &show_ip_route_cmd
);
3835 install_element (VIEW_NODE
, &show_ip_route_ospf_instance_cmd
);
3836 install_element (VIEW_NODE
, &show_ip_route_tag_cmd
);
3837 install_element (VIEW_NODE
, &show_ip_nht_cmd
);
3838 install_element (VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
3839 install_element (VIEW_NODE
, &show_ipv6_nht_cmd
);
3840 install_element (VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
3841 install_element (VIEW_NODE
, &show_ip_route_addr_cmd
);
3842 install_element (VIEW_NODE
, &show_ip_route_prefix_cmd
);
3843 install_element (VIEW_NODE
, &show_ip_route_prefix_longer_cmd
);
3844 install_element (VIEW_NODE
, &show_ip_route_protocol_cmd
);
3845 install_element (VIEW_NODE
, &show_ip_route_supernets_cmd
);
3846 install_element (VIEW_NODE
, &show_ip_route_summary_cmd
);
3847 install_element (VIEW_NODE
, &show_ip_route_summary_prefix_cmd
);
3849 install_element (VIEW_NODE
, &show_ip_rpf_cmd
);
3850 install_element (VIEW_NODE
, &show_ip_rpf_addr_cmd
);
3852 /* Commands for VRF */
3854 install_element (CONFIG_NODE
, &no_ip_route_flags_cmd
);
3855 install_element (CONFIG_NODE
, &no_ip_route_mask_flags_cmd
);
3857 install_element (VIEW_NODE
, &show_ip_route_vrf_cmd
);
3859 install_element (VIEW_NODE
, &show_ip_route_vrf_all_cmd
);
3860 install_element (VIEW_NODE
, &show_ip_route_vrf_all_tag_cmd
);
3861 install_element (VIEW_NODE
, &show_ip_route_vrf_all_addr_cmd
);
3862 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_cmd
);
3863 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_longer_cmd
);
3864 install_element (VIEW_NODE
, &show_ip_route_vrf_all_protocol_cmd
);
3865 install_element (VIEW_NODE
, &show_ip_route_vrf_all_supernets_cmd
);
3866 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_cmd
);
3867 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_prefix_cmd
);
3869 install_element (CONFIG_NODE
, &ipv6_route_cmd
);
3870 install_element (CONFIG_NODE
, &ipv6_route_flags_cmd
);
3871 install_element (CONFIG_NODE
, &ipv6_route_ifname_cmd
);
3872 install_element (CONFIG_NODE
, &ipv6_route_ifname_flags_cmd
);
3873 install_element (CONFIG_NODE
, &no_ipv6_route_cmd
);
3874 install_element (CONFIG_NODE
, &no_ipv6_route_flags_cmd
);
3875 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_cmd
);
3876 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_flags_cmd
);
3877 install_element (CONFIG_NODE
, &ip_nht_default_route_cmd
);
3878 install_element (CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
3879 install_element (CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
3880 install_element (CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
3881 install_element (VIEW_NODE
, &show_ipv6_route_cmd
);
3882 install_element (VIEW_NODE
, &show_ipv6_route_tag_cmd
);
3883 install_element (VIEW_NODE
, &show_ipv6_route_summary_cmd
);
3884 install_element (VIEW_NODE
, &show_ipv6_route_summary_prefix_cmd
);
3885 install_element (VIEW_NODE
, &show_ipv6_route_protocol_cmd
);
3886 install_element (VIEW_NODE
, &show_ipv6_route_addr_cmd
);
3887 install_element (VIEW_NODE
, &show_ipv6_route_prefix_cmd
);
3888 install_element (VIEW_NODE
, &show_ipv6_route_prefix_longer_cmd
);
3890 install_element (VIEW_NODE
, &show_ipv6_mroute_cmd
);
3892 /* Commands for VRF */
3893 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_cmd
);
3894 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_tag_cmd
);
3895 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_cmd
);
3896 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_prefix_cmd
);
3897 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_protocol_cmd
);
3898 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_addr_cmd
);
3899 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_cmd
);
3900 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_longer_cmd
);
3902 install_element (VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);