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"
35 #include "srcdest_table.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"
46 extern int allow_delete
;
48 static int do_show_ip_route(struct vty
*vty
, const char *vrf_name
,
49 safi_t safi
, u_char use_json
);
50 static void vty_show_ip_route_detail (struct vty
*vty
, struct route_node
*rn
,
53 #define ONE_DAY_SECOND 60*60*24
54 #define ONE_WEEK_SECOND 60*60*24*7
56 /* General function for static route. */
58 zebra_static_ipv4 (struct vty
*vty
, safi_t safi
, int add_cmd
,
59 const char *dest_str
, const char *mask_str
,
60 const char *gate_str
, const char *flag_str
,
61 const char *tag_str
, const char *distance_str
,
62 const char *vrf_id_str
, const char *label_str
)
71 struct zebra_vrf
*zvrf
= NULL
;
72 unsigned int ifindex
= 0;
73 const char *ifname
= NULL
;
74 u_char type
= STATIC_BLACKHOLE
;
75 struct static_nh_label snh_label
;
77 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
78 ret
= str2prefix (dest_str
, &p
);
81 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
85 /* Cisco like mask notation. */
88 ret
= inet_aton (mask_str
, &mask
);
91 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
94 p
.prefixlen
= ip_masklen (mask
);
97 /* Apply mask for given prefix. */
100 /* Administrative distance. */
102 distance
= atoi (distance_str
);
104 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
108 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
111 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
115 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
124 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
128 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
131 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
136 /* Null0 static route. */
137 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
141 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
145 static_add_route (AFI_IP
, safi
, type
, &p
, NULL
, NULL
, ifindex
, ifname
,
146 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
148 static_delete_route (AFI_IP
, safi
, type
, &p
, NULL
, NULL
, ifindex
, tag
,
149 distance
, zvrf
, &snh_label
);
155 switch(flag_str
[0]) {
158 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
162 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
165 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
170 if (gate_str
== NULL
)
173 static_add_route (AFI_IP
, safi
, type
, &p
, NULL
, NULL
, ifindex
, ifname
, flag
,
174 tag
, distance
, zvrf
, &snh_label
);
176 static_delete_route (AFI_IP
, safi
, type
, &p
, NULL
, NULL
, ifindex
, tag
, distance
,
182 /* When gateway is A.B.C.D format, gate is treated as nexthop
183 address other case gate is treated as interface name. */
184 ret
= inet_aton (gate_str
, &gate
);
187 struct interface
*ifp
= if_lookup_by_name_vrf (gate_str
, zvrf_id (zvrf
));
190 vty_out (vty
, "%% Unknown interface: %s%s", gate_str
, VTY_NEWLINE
);
191 ifindex
= IFINDEX_DELETED
;
194 ifindex
= ifp
->ifindex
;
196 type
= STATIC_IFINDEX
;
199 type
= STATIC_IPV4_GATEWAY
;
202 static_add_route (AFI_IP
, safi
, type
, &p
, NULL
,
203 ifindex
? NULL
: (union g_addr
*)&gate
, ifindex
, ifname
,
204 flag
, tag
, distance
, zvrf
, &snh_label
);
206 static_delete_route (AFI_IP
, safi
, type
, &p
, NULL
,
207 ifindex
? NULL
: (union g_addr
*)&gate
, ifindex
, tag
,
208 distance
, zvrf
, &snh_label
);
213 /* Static unicast routes for multicast RPF lookup. */
214 DEFUN (ip_mroute_dist
,
216 "ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
218 "Configure static unicast route into MRIB for multicast RPF lookup\n"
219 "IP destination prefix (e.g. 10.0.0.0/8)\n"
221 "Nexthop interface name\n"
224 char *destprefix
= argv
[2]->arg
;
225 char *nexthop
= argv
[3]->arg
;
226 char *distance
= (argc
== 5) ? argv
[4]->arg
: NULL
;
228 return zebra_static_ipv4 (vty
, SAFI_MULTICAST
, 1, destprefix
, NULL
, nexthop
, NULL
, NULL
, distance
, NULL
, NULL
);
231 DEFUN (no_ip_mroute_dist
,
232 no_ip_mroute_dist_cmd
,
233 "no ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
236 "Configure static unicast route into MRIB for multicast RPF lookup\n"
237 "IP destination prefix (e.g. 10.0.0.0/8)\n"
239 "Nexthop interface name\n"
242 char *destprefix
= argv
[3]->arg
;
243 char *nexthop
= argv
[4]->arg
;
244 char *distance
= (argc
== 6) ? argv
[5]->arg
: NULL
;
246 return zebra_static_ipv4 (vty
, SAFI_MULTICAST
, 0, destprefix
, NULL
, nexthop
, NULL
, NULL
, distance
, NULL
, NULL
);
249 DEFUN (ip_multicast_mode
,
250 ip_multicast_mode_cmd
,
251 "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>",
253 "Multicast options\n"
254 "RPF lookup behavior\n"
255 "Lookup in unicast RIB only\n"
256 "Lookup in multicast RIB only\n"
257 "Try multicast RIB first, fall back to unicast RIB\n"
258 "Lookup both, use entry with lower distance\n"
259 "Lookup both, use entry with longer prefix\n")
261 char *mode
= argv
[3]->text
;
263 if (strmatch (mode
, "urib-only"))
264 multicast_mode_ipv4_set (MCAST_URIB_ONLY
);
265 else if (strmatch (mode
, "mrib-only"))
266 multicast_mode_ipv4_set (MCAST_MRIB_ONLY
);
267 else if (strmatch (mode
, "mrib-then-urib"))
268 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST
);
269 else if (strmatch (mode
, "lower-distance"))
270 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE
);
271 else if (strmatch (mode
, "longer-prefix"))
272 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN
);
275 vty_out (vty
, "Invalid mode specified%s", VTY_NEWLINE
);
282 DEFUN (no_ip_multicast_mode
,
283 no_ip_multicast_mode_cmd
,
284 "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]",
287 "Multicast options\n"
288 "RPF lookup behavior\n"
289 "Lookup in unicast RIB only\n"
290 "Lookup in multicast RIB only\n"
291 "Try multicast RIB first, fall back to unicast RIB\n"
292 "Lookup both, use entry with lower distance\n"
293 "Lookup both, use entry with longer prefix\n")
295 multicast_mode_ipv4_set (MCAST_NO_CONFIG
);
305 "Display RPF information for multicast source\n")
307 return do_show_ip_route(vty
, VRF_DEFAULT_NAME
, SAFI_MULTICAST
, 0);
310 DEFUN (show_ip_rpf_addr
,
311 show_ip_rpf_addr_cmd
,
312 "show ip rpf A.B.C.D",
315 "Display RPF information for multicast source\n"
316 "IP multicast source address (e.g. 10.0.0.0)\n")
320 struct route_node
*rn
;
324 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &addr
);
327 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
331 rib
= rib_match_ipv4_multicast (VRF_DEFAULT
, addr
, &rn
);
334 vty_show_ip_route_detail (vty
, rn
, 1);
336 vty_out (vty
, "%% No match for RPF lookup%s", VTY_NEWLINE
);
342 zebra_vty_ip_route_tdv_helper (int argc
, struct cmd_token
*argv
[],
343 int idx_curr
, char **tag
,
344 char **distance
, char **vrf
, char **labels
)
347 while (idx_curr
< argc
)
349 if (strmatch (argv
[idx_curr
]->text
, "tag"))
352 *tag
= argv
[idx_curr
+1]->arg
;
355 else if (strmatch (argv
[idx_curr
]->text
, "vrf"))
358 *vrf
= argv
[idx_curr
+1]->arg
;
361 else if (strmatch (argv
[idx_curr
]->text
, "label"))
364 *labels
= argv
[idx_curr
+1]->arg
;
370 *distance
= argv
[idx_curr
]->arg
;
378 /* Static route configuration. */
381 "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
383 "Establish static routes\n"
384 "IP destination prefix (e.g. 10.0.0.0/8)\n"
385 "IP gateway address\n"
386 "IP gateway interface name\n"
388 "Set tag for this route\n"
390 "Distance value for this route\n"
393 int idx_ipv4_prefixlen
= 2;
394 int idx_ipv4_ifname_null
= 3;
396 char *tag
, *distance
, *vrf
;
398 tag
= distance
= vrf
= NULL
;
399 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
401 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
402 argv
[idx_ipv4_prefixlen
]->arg
,
404 argv
[idx_ipv4_ifname_null
]->arg
,
406 tag
, distance
, vrf
, NULL
);
409 DEFUN (ip_route_flags
,
411 "ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
413 "Establish static routes\n"
414 "IP destination prefix (e.g. 10.0.0.0/8)\n"
415 "Emit an ICMP unreachable when matched\n"
416 "Silently discard pkts when matched\n"
417 "Set tag for this route\n"
419 "Distance value for this route\n"
421 "Specify labels for this route\n"
422 "One or more labels separated by '/'\n")
424 int idx_ipv4_prefixlen
= 2;
425 int idx_reject_blackhole
= 3;
427 char *tag
, *distance
, *vrf
;
429 tag
= distance
= vrf
= NULL
;
430 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
432 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
433 argv
[idx_ipv4_prefixlen
]->arg
,
436 argv
[idx_reject_blackhole
]->arg
,
437 tag
, distance
, vrf
, NULL
);
440 /* Mask as A.B.C.D format. */
441 DEFUN (ip_route_mask
,
443 "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
445 "Establish static routes\n"
446 "IP destination prefix\n"
447 "IP destination prefix mask\n"
448 "IP gateway address\n"
449 "IP gateway interface name\n"
451 "Set tag for this route\n"
453 "Distance value for this route\n"
455 "Specify labels for this route\n"
456 "One or more labels separated by '/'\n")
460 int idx_ipv4_ifname_null
= 4;
462 char *tag
, *distance
, *vrf
;
464 tag
= distance
= vrf
= NULL
;
465 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
467 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
469 argv
[idx_ipv4_2
]->arg
,
470 argv
[idx_ipv4_ifname_null
]->arg
,
471 NULL
, tag
, distance
, vrf
, NULL
);
474 DEFUN (ip_route_mask_flags
,
475 ip_route_mask_flags_cmd
,
476 "ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
478 "Establish static routes\n"
479 "IP destination prefix\n"
480 "IP destination prefix mask\n"
481 "Emit an ICMP unreachable when matched\n"
482 "Silently discard pkts when matched\n"
483 "Set tag for this route\n"
485 "Distance value for this route\n"
487 "Specify labels for this route\n"
488 "One or more labels separated by '/'\n")
492 int idx_reject_blackhole
= 4;
494 char *tag
, *distance
, *vrf
;
496 tag
= distance
= vrf
= NULL
;
497 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
499 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 1,
501 argv
[idx_ipv4_2
]->arg
,
503 argv
[idx_reject_blackhole
]->arg
,
504 tag
, distance
, vrf
, NULL
);
509 "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
512 "Establish static routes\n"
513 "IP destination prefix (e.g. 10.0.0.0/8)\n"
514 "IP gateway address\n"
515 "IP gateway interface name\n"
517 "Tag of this route\n"
519 "Distance value for this route\n"
521 "Specify labels for this route\n"
522 "One or more labels separated by '/'\n")
524 int idx_ipv4_prefixlen
= 3;
525 int idx_ipv4_ifname_null
= 4;
527 char *tag
, *distance
, *vrf
;
529 tag
= distance
= vrf
= NULL
;
530 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
532 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
533 argv
[idx_ipv4_prefixlen
]->arg
,
535 argv
[idx_ipv4_ifname_null
]->arg
,
537 tag
, distance
, vrf
, NULL
);
540 DEFUN (no_ip_route_flags
,
541 no_ip_route_flags_cmd
,
542 "no ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
545 "Establish static routes\n"
546 "IP destination prefix (e.g. 10.0.0.0/8)\n"
547 "Emit an ICMP unreachable when matched\n"
548 "Silently discard pkts when matched\n"
549 "Tag of this route\n"
551 "Distance value for this route\n"
553 "Specify labels for this route\n"
554 "One or more labels separated by '/'\n")
556 int idx_ipv4_prefixlen
= 3;
558 char *tag
, *distance
, *vrf
;
560 tag
= distance
= vrf
= NULL
;
561 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
563 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
564 argv
[idx_ipv4_prefixlen
]->arg
,
566 tag
, distance
, vrf
, NULL
);
569 DEFUN (no_ip_route_mask
,
570 no_ip_route_mask_cmd
,
571 "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
574 "Establish static routes\n"
575 "IP destination prefix\n"
576 "IP destination prefix mask\n"
577 "IP gateway address\n"
578 "IP gateway interface name\n"
580 "Tag of this route\n"
582 "Distance value for this route\n"
584 "Specify labels for this route\n"
585 "One or more labels separated by '/'\n")
589 int idx_ipv4_ifname_null
= 5;
591 char *tag
, *distance
, *vrf
;
593 tag
= distance
= vrf
= NULL
;
594 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
596 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
598 argv
[idx_ipv4_2
]->arg
,
599 argv
[idx_ipv4_ifname_null
]->arg
,
601 tag
, distance
, vrf
, NULL
);
604 DEFUN (no_ip_route_mask_flags
,
605 no_ip_route_mask_flags_cmd
,
606 "no ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
609 "Establish static routes\n"
610 "IP destination prefix\n"
611 "IP destination prefix mask\n"
612 "Emit an ICMP unreachable when matched\n"
613 "Silently discard pkts when matched\n"
614 "Tag of this route\n"
616 "Distance value for this route\n"
618 "Specify labels for this route\n"
619 "One or more labels separated by '/'\n")
624 char *tag
, *distance
, *vrf
;
626 tag
= distance
= vrf
= NULL
;
627 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
629 return zebra_static_ipv4 (vty
, SAFI_UNICAST
, 0,
631 argv
[idx_ipv4_2
]->arg
,
633 tag
, distance
, vrf
, NULL
);
636 /* New RIB. Detailed information for IPv4 route. */
638 vty_show_ip_route_detail (struct vty
*vty
, struct route_node
*rn
, int mcast
)
641 struct nexthop
*nexthop
, *tnexthop
;
643 char buf
[SRCDEST2STR_BUFFER
];
644 struct zebra_vrf
*zvrf
;
646 RNODE_FOREACH_RIB (rn
, rib
)
648 const char *mcast_info
= "";
651 rib_table_info_t
*info
= srcdest_rnode_table_info(rn
);
652 mcast_info
= (info
->safi
== SAFI_MULTICAST
)
653 ? " using Multicast RIB"
654 : " using Unicast RIB";
657 vty_out (vty
, "Routing entry for %s%s%s",
658 srcdest_rnode2str(rn
, buf
, sizeof(buf
)), mcast_info
,
660 vty_out (vty
, " Known via \"%s", zebra_route_string (rib
->type
));
662 vty_out (vty
, "[%d]", rib
->instance
);
664 vty_out (vty
, ", distance %u, metric %u", rib
->distance
, rib
->metric
);
666 vty_out (vty
, ", tag %d", rib
->tag
);
668 vty_out (vty
, ", mtu %u", rib
->mtu
);
669 if (rib
->vrf_id
!= VRF_DEFAULT
)
671 zvrf
= vrf_info_lookup(rib
->vrf_id
);
672 vty_out (vty
, ", vrf %s", zvrf_name (zvrf
));
674 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
675 vty_out (vty
, ", best");
677 vty_out (vty
, ", refcnt %ld", rib
->refcnt
);
678 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
679 vty_out (vty
, ", blackhole");
680 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
681 vty_out (vty
, ", reject");
682 vty_out (vty
, "%s", VTY_NEWLINE
);
684 if (rib
->type
== ZEBRA_ROUTE_RIP
685 || rib
->type
== ZEBRA_ROUTE_OSPF
686 || rib
->type
== ZEBRA_ROUTE_ISIS
687 || rib
->type
== ZEBRA_ROUTE_TABLE
688 || rib
->type
== ZEBRA_ROUTE_BGP
)
693 uptime
= time (NULL
);
694 uptime
-= rib
->uptime
;
695 tm
= gmtime (&uptime
);
697 vty_out (vty
, " Last update ");
699 if (uptime
< ONE_DAY_SECOND
)
700 vty_out (vty
, "%02d:%02d:%02d",
701 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
702 else if (uptime
< ONE_WEEK_SECOND
)
703 vty_out (vty
, "%dd%02dh%02dm",
704 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
706 vty_out (vty
, "%02dw%dd%02dh",
708 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
709 vty_out (vty
, " ago%s", VTY_NEWLINE
);
712 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
716 vty_out (vty
, " %c%s",
717 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
) ? '*' : ' ',
718 recursing
? " " : "");
720 switch (nexthop
->type
)
722 case NEXTHOP_TYPE_IPV4
:
723 case NEXTHOP_TYPE_IPV4_IFINDEX
:
724 vty_out (vty
, " %s", inet_ntoa (nexthop
->gate
.ipv4
));
725 if (nexthop
->ifindex
)
726 vty_out (vty
, ", via %s",
727 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
729 case NEXTHOP_TYPE_IPV6
:
730 case NEXTHOP_TYPE_IPV6_IFINDEX
:
732 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
733 if (nexthop
->ifindex
)
734 vty_out (vty
, ", via %s",
735 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
737 case NEXTHOP_TYPE_IFINDEX
:
738 vty_out (vty
, " directly connected, %s",
739 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
741 case NEXTHOP_TYPE_BLACKHOLE
:
742 vty_out (vty
, " directly connected, Null0");
747 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
748 vty_out (vty
, " inactive");
750 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
751 vty_out (vty
, " onlink");
753 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
754 vty_out (vty
, " (recursive)");
756 switch (nexthop
->type
)
758 case NEXTHOP_TYPE_IPV4
:
759 case NEXTHOP_TYPE_IPV4_IFINDEX
:
760 if (nexthop
->src
.ipv4
.s_addr
)
762 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, addrstr
,
764 vty_out (vty
, ", src %s", addrstr
);
767 case NEXTHOP_TYPE_IPV6
:
768 case NEXTHOP_TYPE_IPV6_IFINDEX
:
769 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
771 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, addrstr
,
773 vty_out (vty
, ", src %s", addrstr
);
780 /* Label information */
781 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
783 vty_out (vty
, " label %s",
784 mpls_label2str (nexthop
->nh_label
->num_labels
,
785 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
788 vty_out (vty
, "%s", VTY_NEWLINE
);
790 vty_out (vty
, "%s", VTY_NEWLINE
);
795 vty_show_ip_route (struct vty
*vty
, struct route_node
*rn
, struct rib
*rib
,
798 struct nexthop
*nexthop
, *tnexthop
;
801 char buf
[SRCDEST2STR_BUFFER
];
802 json_object
*json_nexthops
= NULL
;
803 json_object
*json_nexthop
= NULL
;
804 json_object
*json_route
= NULL
;
808 json_route
= json_object_new_object();
809 json_nexthops
= json_object_new_array();
811 json_object_string_add(json_route
, "prefix", srcdest_rnode2str (rn
, buf
, sizeof buf
));
812 json_object_string_add(json_route
, "protocol", zebra_route_string(rib
->type
));
815 json_object_int_add(json_route
, "instance", rib
->instance
);
818 json_object_int_add(json_route
, "vrfId", rib
->vrf_id
);
820 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
821 json_object_boolean_true_add(json_route
, "selected");
823 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
&& rib
->type
!= ZEBRA_ROUTE_KERNEL
)
825 json_object_int_add(json_route
, "distance", rib
->distance
);
826 json_object_int_add(json_route
, "metric", rib
->metric
);
829 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
830 json_object_boolean_true_add(json_route
, "blackhole");
832 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
833 json_object_boolean_true_add(json_route
, "reject");
835 if (rib
->type
== ZEBRA_ROUTE_RIP
836 || rib
->type
== ZEBRA_ROUTE_OSPF
837 || rib
->type
== ZEBRA_ROUTE_ISIS
838 || rib
->type
== ZEBRA_ROUTE_TABLE
839 || rib
->type
== ZEBRA_ROUTE_BGP
)
844 uptime
= time (NULL
);
845 uptime
-= rib
->uptime
;
846 tm
= gmtime (&uptime
);
848 if (uptime
< ONE_DAY_SECOND
)
849 sprintf(buf
, "%02d:%02d:%02d", tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
850 else if (uptime
< ONE_WEEK_SECOND
)
851 sprintf(buf
, "%dd%02dh%02dm", tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
853 sprintf(buf
, "%02dw%dd%02dh", tm
->tm_yday
/7, tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
855 json_object_string_add(json_route
, "uptime", buf
);
858 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
860 json_nexthop
= json_object_new_object();
862 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
863 json_object_boolean_true_add(json_nexthop
, "fib");
865 switch (nexthop
->type
)
867 case NEXTHOP_TYPE_IPV4
:
868 case NEXTHOP_TYPE_IPV4_IFINDEX
:
869 json_object_string_add(json_nexthop
, "ip", inet_ntoa (nexthop
->gate
.ipv4
));
870 json_object_string_add(json_nexthop
, "afi", "ipv4");
872 if (nexthop
->ifindex
)
874 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
875 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
878 case NEXTHOP_TYPE_IPV6
:
879 case NEXTHOP_TYPE_IPV6_IFINDEX
:
880 json_object_string_add(json_nexthop
, "ip", inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
881 json_object_string_add(json_nexthop
, "afi", "ipv6");
883 if (nexthop
->ifindex
)
885 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
886 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
890 case NEXTHOP_TYPE_IFINDEX
:
891 json_object_boolean_true_add(json_nexthop
, "directlyConnected");
892 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
893 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
895 case NEXTHOP_TYPE_BLACKHOLE
:
896 json_object_boolean_true_add(json_nexthop
, "blackhole");
902 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
903 json_object_boolean_true_add(json_nexthop
, "active");
905 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
906 json_object_boolean_true_add(json_nexthop
, "onLink");
908 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
909 json_object_boolean_true_add(json_nexthop
, "recursive");
911 switch (nexthop
->type
)
913 case NEXTHOP_TYPE_IPV4
:
914 case NEXTHOP_TYPE_IPV4_IFINDEX
:
915 if (nexthop
->src
.ipv4
.s_addr
)
917 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
918 json_object_string_add(json_nexthop
, "source", buf
);
921 case NEXTHOP_TYPE_IPV6
:
922 case NEXTHOP_TYPE_IPV6_IFINDEX
:
923 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
925 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
926 json_object_string_add(json_nexthop
, "source", buf
);
933 json_object_array_add(json_nexthops
, json_nexthop
);
936 json_object_object_add(json_route
, "nexthops", json_nexthops
);
937 json_object_array_add(json
, json_route
);
941 /* Nexthop information. */
942 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
944 if (nexthop
== rib
->nexthop
)
946 /* Prefix information. */
947 len
= vty_out (vty
, "%c", zebra_route_char (rib
->type
));
949 len
+= vty_out (vty
, "[%d]", rib
->instance
);
950 len
+= vty_out (vty
, "%c%c %s",
951 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
)
953 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
955 srcdest_rnode2str (rn
, buf
, sizeof buf
));
957 /* Distance and metric display. */
958 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
959 && rib
->type
!= ZEBRA_ROUTE_KERNEL
)
960 len
+= vty_out (vty
, " [%d/%d]", rib
->distance
,
964 vty_out (vty
, " %c%*c",
965 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
967 len
- 3 + (2 * recursing
), ' ');
969 switch (nexthop
->type
)
971 case NEXTHOP_TYPE_IPV4
:
972 case NEXTHOP_TYPE_IPV4_IFINDEX
:
973 vty_out (vty
, " via %s", inet_ntoa (nexthop
->gate
.ipv4
));
974 if (nexthop
->ifindex
)
975 vty_out (vty
, ", %s",
976 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
978 case NEXTHOP_TYPE_IPV6
:
979 case NEXTHOP_TYPE_IPV6_IFINDEX
:
980 vty_out (vty
, " via %s",
981 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
982 if (nexthop
->ifindex
)
983 vty_out (vty
, ", %s",
984 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
987 case NEXTHOP_TYPE_IFINDEX
:
988 vty_out (vty
, " is directly connected, %s",
989 ifindex2ifname_vrf (nexthop
->ifindex
, rib
->vrf_id
));
991 case NEXTHOP_TYPE_BLACKHOLE
:
992 vty_out (vty
, " is directly connected, Null0");
997 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
998 vty_out (vty
, " inactive");
1000 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1001 vty_out (vty
, " onlink");
1003 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1004 vty_out (vty
, " (recursive)");
1006 switch (nexthop
->type
)
1008 case NEXTHOP_TYPE_IPV4
:
1009 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1010 if (nexthop
->src
.ipv4
.s_addr
)
1012 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
1013 vty_out (vty
, ", src %s", buf
);
1016 case NEXTHOP_TYPE_IPV6
:
1017 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1018 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
1020 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
1021 vty_out (vty
, ", src %s", buf
);
1028 /* Label information */
1029 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
1031 vty_out (vty
, " label %s",
1032 mpls_label2str (nexthop
->nh_label
->num_labels
,
1033 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
1036 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
1037 vty_out (vty
, ", bh");
1038 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
1039 vty_out (vty
, ", rej");
1041 if (rib
->type
== ZEBRA_ROUTE_RIP
1042 || rib
->type
== ZEBRA_ROUTE_OSPF
1043 || rib
->type
== ZEBRA_ROUTE_ISIS
1044 || rib
->type
== ZEBRA_ROUTE_TABLE
1045 || rib
->type
== ZEBRA_ROUTE_BGP
)
1050 uptime
= time (NULL
);
1051 uptime
-= rib
->uptime
;
1052 tm
= gmtime (&uptime
);
1054 if (uptime
< ONE_DAY_SECOND
)
1055 vty_out (vty
, ", %02d:%02d:%02d",
1056 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
1057 else if (uptime
< ONE_WEEK_SECOND
)
1058 vty_out (vty
, ", %dd%02dh%02dm",
1059 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
1061 vty_out (vty
, ", %02dw%dd%02dh",
1063 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
1065 vty_out (vty
, "%s", VTY_NEWLINE
);
1069 DEFUN (show_ip_route
,
1071 "show ip route [json]",
1074 "IP routing table\n"
1077 return do_show_ip_route (vty
, VRF_DEFAULT_NAME
, SAFI_UNICAST
, use_json(argc
, argv
));
1081 do_show_ip_route (struct vty
*vty
, const char *vrf_name
, safi_t safi
,
1084 struct route_table
*table
;
1085 struct route_node
*rn
;
1088 struct zebra_vrf
*zvrf
= NULL
;
1090 json_object
*json
= NULL
;
1091 json_object
*json_prefix
= NULL
;
1093 if (!(zvrf
= zebra_vrf_lookup_by_name (vrf_name
)))
1096 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1098 vty_out (vty
, "vrf %s not defined%s", vrf_name
, VTY_NEWLINE
);
1102 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
1105 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1107 vty_out (vty
, "vrf %s inactive%s", vrf_name
, VTY_NEWLINE
);
1111 table
= zebra_vrf_table (AFI_IP
, safi
, zvrf_id (zvrf
));
1115 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1121 json
= json_object_new_object();
1123 /* Show all IPv4 routes. */
1124 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1126 RNODE_FOREACH_RIB (rn
, rib
)
1129 json_prefix
= json_object_new_array();
1130 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
1135 prefix2str (&rn
->p
, buf
, sizeof buf
);
1136 json_object_object_add(json
, buf
, json_prefix
);
1141 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
1142 json_object_free(json
);
1146 /* Show all IPv4 routes. */
1147 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1149 RNODE_FOREACH_RIB (rn
, rib
)
1153 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1156 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1164 DEFUN (show_ip_route_vrf
,
1165 show_ip_route_vrf_cmd
,
1166 "show ip route vrf NAME [json]",
1169 "IP routing table\n"
1174 u_char uj
= use_json(argc
, argv
);
1176 return do_show_ip_route (vty
, argv
[idx_vrf
]->arg
, SAFI_UNICAST
, uj
);
1181 "show ip nht [vrf NAME]",
1184 "IP nexthop tracking table\n"
1188 vrf_id_t vrf_id
= VRF_DEFAULT
;
1191 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1193 zebra_print_rnh_table(vrf_id
, AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1198 DEFUN (show_ip_nht_vrf_all
,
1199 show_ip_nht_vrf_all_cmd
,
1200 "show ip nht vrf all",
1203 "IP nexthop tracking table\n"
1204 VRF_ALL_CMD_HELP_STR
)
1207 struct zebra_vrf
*zvrf
;
1209 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1210 if ((zvrf
= vrf
->info
) != NULL
)
1212 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1213 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1219 DEFUN (show_ipv6_nht
,
1221 "show ipv6 nht [vrf NAME]",
1224 "IPv6 nexthop tracking table\n"
1228 vrf_id_t vrf_id
= VRF_DEFAULT
;
1231 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1233 zebra_print_rnh_table(vrf_id
, AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1238 DEFUN (show_ipv6_nht_vrf_all
,
1239 show_ipv6_nht_vrf_all_cmd
,
1240 "show ipv6 nht vrf all",
1243 "IPv6 nexthop tracking table\n"
1244 VRF_ALL_CMD_HELP_STR
)
1247 struct zebra_vrf
*zvrf
;
1249 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1250 if ((zvrf
= vrf
->info
) != NULL
)
1252 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1253 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1259 DEFUN (ip_nht_default_route
,
1260 ip_nht_default_route_cmd
,
1261 "ip nht resolve-via-default",
1263 "Filter Next Hop tracking route resolution\n"
1264 "Resolve via default route\n")
1266 if (zebra_rnh_ip_default_route
)
1269 zebra_rnh_ip_default_route
= 1;
1270 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1274 DEFUN (no_ip_nht_default_route
,
1275 no_ip_nht_default_route_cmd
,
1276 "no ip nht resolve-via-default",
1279 "Filter Next Hop tracking route resolution\n"
1280 "Resolve via default route\n")
1282 if (!zebra_rnh_ip_default_route
)
1285 zebra_rnh_ip_default_route
= 0;
1286 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1290 DEFUN (ipv6_nht_default_route
,
1291 ipv6_nht_default_route_cmd
,
1292 "ipv6 nht resolve-via-default",
1294 "Filter Next Hop tracking route resolution\n"
1295 "Resolve via default route\n")
1297 if (zebra_rnh_ipv6_default_route
)
1300 zebra_rnh_ipv6_default_route
= 1;
1301 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1305 DEFUN (no_ipv6_nht_default_route
,
1306 no_ipv6_nht_default_route_cmd
,
1307 "no ipv6 nht resolve-via-default",
1310 "Filter Next Hop tracking route resolution\n"
1311 "Resolve via default route\n")
1313 if (!zebra_rnh_ipv6_default_route
)
1316 zebra_rnh_ipv6_default_route
= 0;
1317 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1321 DEFUN (show_ip_route_tag
,
1322 show_ip_route_tag_cmd
,
1323 "show ip route [vrf NAME] tag (1-4294967295)",
1326 "IP routing table\n"
1328 "Show only routes with tag\n"
1334 struct route_table
*table
;
1335 struct route_node
*rn
;
1338 route_tag_t tag
= 0;
1339 vrf_id_t vrf_id
= VRF_DEFAULT
;
1341 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
1343 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
1344 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1349 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1352 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1356 /* Show all IPv4 routes with matching tag value. */
1357 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1358 RNODE_FOREACH_RIB (rn
, rib
)
1360 if (rib
->tag
!= tag
)
1365 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1368 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1373 DEFUN (show_ip_route_prefix_longer
,
1374 show_ip_route_prefix_longer_cmd
,
1375 "show ip route [vrf NAME] A.B.C.D/M longer-prefixes",
1378 "IP routing table\n"
1380 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1381 "Show route matching the specified Network/Mask pair only\n")
1383 struct route_table
*table
;
1384 struct route_node
*rn
;
1389 vrf_id_t vrf_id
= VRF_DEFAULT
;
1391 if (strmatch(argv
[3]->text
, "vrf"))
1393 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1394 ret
= str2prefix (argv
[5]->arg
, &p
);
1398 ret
= str2prefix (argv
[3]->arg
, &p
);
1403 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1407 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1411 /* Show matched type IPv4 routes. */
1412 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1413 RNODE_FOREACH_RIB (rn
, rib
)
1414 if (prefix_match (&p
, &rn
->p
))
1418 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1421 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1426 DEFUN (show_ip_route_supernets
,
1427 show_ip_route_supernets_cmd
,
1428 "show ip route [vrf NAME] supernets-only",
1431 "IP routing table\n"
1433 "Show supernet entries only\n")
1435 struct route_table
*table
;
1436 struct route_node
*rn
;
1440 vrf_id_t vrf_id
= VRF_DEFAULT
;
1442 if (strmatch(argv
[3]->text
, "vrf"))
1443 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1445 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1449 /* Show matched type IPv4 routes. */
1450 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1451 RNODE_FOREACH_RIB (rn
, rib
)
1453 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
1455 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
1456 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
1457 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
1461 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1464 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1470 DEFUN (show_ip_route_protocol
,
1471 show_ip_route_protocol_cmd
,
1472 "show ip route [vrf NAME] " FRR_IP_REDIST_STR_ZEBRA
,
1475 "IP routing table\n"
1477 FRR_IP_REDIST_HELP_STR_ZEBRA
)
1480 struct route_table
*table
;
1481 struct route_node
*rn
;
1484 vrf_id_t vrf_id
= VRF_DEFAULT
;
1487 if (argv_find (argv
, argc
, "NAME", &idx
))
1488 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
1490 char *proto
= argv
[argc
- 1]->text
;
1491 type
= proto_redistnum (AFI_IP
, proto
);
1495 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
1499 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1503 /* Show matched type IPv4 routes. */
1504 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1505 RNODE_FOREACH_RIB (rn
, rib
)
1506 if (rib
->type
== type
)
1510 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1513 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1519 DEFUN (show_ip_route_ospf_instance
,
1520 show_ip_route_ospf_instance_cmd
,
1521 "show ip route ospf (1-65535)",
1524 "IP routing table\n"
1525 "Open Shortest Path First (OSPFv2)\n"
1529 struct route_table
*table
;
1530 struct route_node
*rn
;
1533 u_short instance
= 0;
1535 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1537 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, VRF_DEFAULT
);
1541 /* Show matched type IPv4 routes. */
1542 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1543 RNODE_FOREACH_RIB (rn
, rib
)
1544 if (rib
->type
== ZEBRA_ROUTE_OSPF
&& rib
->instance
== instance
)
1548 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1551 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1556 DEFUN (show_ip_route_addr
,
1557 show_ip_route_addr_cmd
,
1558 "show ip route [vrf NAME] A.B.C.D",
1561 "IP routing table\n"
1563 "Network in the IP routing table to display\n")
1566 struct prefix_ipv4 p
;
1567 struct route_table
*table
;
1568 struct route_node
*rn
;
1569 vrf_id_t vrf_id
= VRF_DEFAULT
;
1571 if (strmatch(argv
[3]->text
, "vrf"))
1573 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1574 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1578 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1583 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1587 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1591 rn
= route_node_match (table
, (struct prefix
*) &p
);
1594 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1598 vty_show_ip_route_detail (vty
, rn
, 0);
1600 route_unlock_node (rn
);
1605 DEFUN (show_ip_route_prefix
,
1606 show_ip_route_prefix_cmd
,
1607 "show ip route [vrf NAME] A.B.C.D/M",
1610 "IP routing table\n"
1612 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1615 struct prefix_ipv4 p
;
1616 struct route_table
*table
;
1617 struct route_node
*rn
;
1618 vrf_id_t vrf_id
= VRF_DEFAULT
;
1620 if (strmatch(argv
[3]->text
, "vrf"))
1622 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1623 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1627 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1632 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1636 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1640 rn
= route_node_match (table
, (struct prefix
*) &p
);
1641 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
1643 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1647 vty_show_ip_route_detail (vty
, rn
, 0);
1649 route_unlock_node (rn
);
1656 vty_show_ip_route_summary (struct vty
*vty
, struct route_table
*table
)
1658 struct route_node
*rn
;
1660 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1661 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1662 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1663 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1667 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1668 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1669 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
1670 RNODE_FOREACH_RIB (rn
, rib
)
1672 is_ibgp
= (rib
->type
== ZEBRA_ROUTE_BGP
&&
1673 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
));
1675 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1677 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1679 rib_cnt
[rib
->type
]++;
1681 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
1683 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1686 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1688 fib_cnt
[rib
->type
]++;
1692 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1693 "Route Source", "Routes", "FIB",
1694 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1697 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1699 if ((rib_cnt
[i
] > 0) ||
1700 (i
== ZEBRA_ROUTE_BGP
&& rib_cnt
[ZEBRA_ROUTE_IBGP
] > 0))
1702 if (i
== ZEBRA_ROUTE_BGP
)
1704 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1705 rib_cnt
[ZEBRA_ROUTE_BGP
], fib_cnt
[ZEBRA_ROUTE_BGP
],
1707 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1708 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1712 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1713 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1717 vty_out (vty
, "------%s", VTY_NEWLINE
);
1718 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1719 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1720 vty_out (vty
, "%s", VTY_NEWLINE
);
1724 * Implementation of the ip route summary prefix command.
1726 * This command prints the primary prefixes that have been installed by various
1727 * protocols on the box.
1731 vty_show_ip_route_summary_prefix (struct vty
*vty
, struct route_table
*table
)
1733 struct route_node
*rn
;
1735 struct nexthop
*nexthop
;
1736 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1737 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1738 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1739 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1743 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1744 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1745 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
1746 RNODE_FOREACH_RIB (rn
, rib
)
1750 * In case of ECMP, count only once.
1753 for (nexthop
= rib
->nexthop
; (!cnt
&& nexthop
); nexthop
= nexthop
->next
)
1756 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1757 rib_cnt
[rib
->type
]++;
1758 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1760 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1761 fib_cnt
[rib
->type
]++;
1763 if (rib
->type
== ZEBRA_ROUTE_BGP
&&
1764 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
))
1766 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1767 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1768 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1773 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1774 "Route Source", "Prefix Routes", "FIB",
1775 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1778 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1782 if (i
== ZEBRA_ROUTE_BGP
)
1784 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1785 rib_cnt
[ZEBRA_ROUTE_BGP
] - rib_cnt
[ZEBRA_ROUTE_IBGP
],
1786 fib_cnt
[ZEBRA_ROUTE_BGP
] - fib_cnt
[ZEBRA_ROUTE_IBGP
],
1788 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1789 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1793 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1794 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1798 vty_out (vty
, "------%s", VTY_NEWLINE
);
1799 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1800 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1801 vty_out (vty
, "%s", VTY_NEWLINE
);
1804 /* Show route summary. */
1805 DEFUN (show_ip_route_summary
,
1806 show_ip_route_summary_cmd
,
1807 "show ip route [vrf NAME] summary",
1810 "IP routing table\n"
1812 "Summary of all routes\n")
1814 struct route_table
*table
;
1815 vrf_id_t vrf_id
= VRF_DEFAULT
;
1817 if (strmatch(argv
[3]->text
, "vrf"))
1818 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1820 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1824 vty_show_ip_route_summary (vty
, table
);
1829 /* Show route summary prefix. */
1830 DEFUN (show_ip_route_summary_prefix
,
1831 show_ip_route_summary_prefix_cmd
,
1832 "show ip route [vrf NAME] summary prefix",
1835 "IP routing table\n"
1837 "Summary of all routes\n"
1840 struct route_table
*table
;
1841 vrf_id_t vrf_id
= VRF_DEFAULT
;
1843 if (strmatch(argv
[3]->text
, "vrf"))
1844 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1846 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1850 vty_show_ip_route_summary_prefix (vty
, table
);
1856 DEFUN (show_ip_route_vrf_all
,
1857 show_ip_route_vrf_all_cmd
,
1858 "show ip route vrf all",
1861 "IP routing table\n"
1862 VRF_ALL_CMD_HELP_STR
)
1864 struct route_table
*table
;
1865 struct route_node
*rn
;
1868 struct zebra_vrf
*zvrf
;
1872 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1874 if ((zvrf
= vrf
->info
) == NULL
||
1875 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1878 /* Show all IPv4 routes. */
1879 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1880 RNODE_FOREACH_RIB (rn
, rib
)
1884 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1890 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1893 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1901 DEFUN (show_ip_route_vrf_all_tag
,
1902 show_ip_route_vrf_all_tag_cmd
,
1903 "show ip route vrf all tag (1-4294967295)",
1906 "IP routing table\n"
1907 VRF_ALL_CMD_HELP_STR
1908 "Show only routes with tag\n"
1912 struct route_table
*table
;
1913 struct route_node
*rn
;
1916 struct zebra_vrf
*zvrf
;
1919 route_tag_t tag
= 0;
1921 if (argv
[idx_number
]->arg
)
1922 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
1924 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1926 if ((zvrf
= vrf
->info
) == NULL
||
1927 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1930 /* Show all IPv4 routes with matching tag value. */
1931 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1932 RNODE_FOREACH_RIB (rn
, rib
)
1934 if (rib
->tag
!= tag
)
1939 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1945 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1948 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1955 DEFUN (show_ip_route_vrf_all_prefix_longer
,
1956 show_ip_route_vrf_all_prefix_longer_cmd
,
1957 "show ip route vrf all A.B.C.D/M longer-prefixes",
1960 "IP routing table\n"
1961 VRF_ALL_CMD_HELP_STR
1962 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1963 "Show route matching the specified Network/Mask pair only\n")
1965 int idx_ipv4_prefixlen
= 5;
1966 struct route_table
*table
;
1967 struct route_node
*rn
;
1971 struct zebra_vrf
*zvrf
;
1976 ret
= str2prefix (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
1979 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1983 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1985 if ((zvrf
= vrf
->info
) == NULL
||
1986 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1989 /* Show matched type IPv4 routes. */
1990 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1991 RNODE_FOREACH_RIB (rn
, rib
)
1992 if (prefix_match (&p
, &rn
->p
))
1996 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2002 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2005 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2013 DEFUN (show_ip_route_vrf_all_supernets
,
2014 show_ip_route_vrf_all_supernets_cmd
,
2015 "show ip route vrf all supernets-only",
2018 "IP routing table\n"
2019 VRF_ALL_CMD_HELP_STR
2020 "Show supernet entries only\n")
2022 struct route_table
*table
;
2023 struct route_node
*rn
;
2026 struct zebra_vrf
*zvrf
;
2031 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2033 if ((zvrf
= vrf
->info
) == NULL
||
2034 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2037 /* Show matched type IPv4 routes. */
2038 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2039 RNODE_FOREACH_RIB (rn
, rib
)
2041 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
2043 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
2044 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
2045 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
2049 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2054 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2057 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2066 DEFUN (show_ip_route_vrf_all_protocol
,
2067 show_ip_route_vrf_all_protocol_cmd
,
2068 "show ip route vrf all " FRR_IP_REDIST_STR_ZEBRA
,
2071 "IP routing table\n"
2072 VRF_ALL_CMD_HELP_STR
2073 FRR_IP_REDIST_HELP_STR_ZEBRA
"\n")
2076 struct route_table
*table
;
2077 struct route_node
*rn
;
2080 struct zebra_vrf
*zvrf
;
2084 char *proto
= argv
[argc
- 1]->text
;
2085 type
= proto_redistnum (AFI_IP
, proto
);
2089 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
2093 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2095 if ((zvrf
= vrf
->info
) == NULL
||
2096 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2099 /* Show matched type IPv4 routes. */
2100 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2101 RNODE_FOREACH_RIB (rn
, rib
)
2102 if (rib
->type
== type
)
2106 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2112 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2115 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2123 DEFUN (show_ip_route_vrf_all_addr
,
2124 show_ip_route_vrf_all_addr_cmd
,
2125 "show ip route vrf all A.B.C.D",
2128 "IP routing table\n"
2129 VRF_ALL_CMD_HELP_STR
2130 "Network in the IP routing table to display\n")
2134 struct prefix_ipv4 p
;
2135 struct route_table
*table
;
2136 struct route_node
*rn
;
2138 struct zebra_vrf
*zvrf
;
2140 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
2143 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2147 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2149 if ((zvrf
= vrf
->info
) == NULL
||
2150 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2153 rn
= route_node_match (table
, (struct prefix
*) &p
);
2157 vty_show_ip_route_detail (vty
, rn
, 0);
2159 route_unlock_node (rn
);
2165 DEFUN (show_ip_route_vrf_all_prefix
,
2166 show_ip_route_vrf_all_prefix_cmd
,
2167 "show ip route vrf all A.B.C.D/M",
2170 "IP routing table\n"
2171 VRF_ALL_CMD_HELP_STR
2172 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2174 int idx_ipv4_prefixlen
= 5;
2176 struct prefix_ipv4 p
;
2177 struct route_table
*table
;
2178 struct route_node
*rn
;
2180 struct zebra_vrf
*zvrf
;
2182 ret
= str2prefix_ipv4 (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
2185 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2189 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2191 if ((zvrf
= vrf
->info
) == NULL
||
2192 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2195 rn
= route_node_match (table
, (struct prefix
*) &p
);
2198 if (rn
->p
.prefixlen
!= p
.prefixlen
)
2200 route_unlock_node (rn
);
2204 vty_show_ip_route_detail (vty
, rn
, 0);
2206 route_unlock_node (rn
);
2212 DEFUN (show_ip_route_vrf_all_summary
,
2213 show_ip_route_vrf_all_summary_cmd
,
2214 "show ip route vrf all summary ",
2217 "IP routing table\n"
2218 VRF_ALL_CMD_HELP_STR
2219 "Summary of all routes\n")
2222 struct zebra_vrf
*zvrf
;
2224 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2225 if ((zvrf
= vrf
->info
) != NULL
)
2226 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2231 DEFUN (show_ip_route_vrf_all_summary_prefix
,
2232 show_ip_route_vrf_all_summary_prefix_cmd
,
2233 "show ip route vrf all summary prefix",
2236 "IP routing table\n"
2237 VRF_ALL_CMD_HELP_STR
2238 "Summary of all routes\n"
2242 struct zebra_vrf
*zvrf
;
2244 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2245 if ((zvrf
= vrf
->info
) != NULL
)
2246 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2251 /* Write IPv4 static route configuration. */
2253 static_config_ipv4 (struct vty
*vty
, safi_t safi
, const char *cmd
)
2255 struct route_node
*rn
;
2256 struct static_route
*si
;
2257 struct route_table
*stable
;
2259 struct zebra_vrf
*zvrf
;
2263 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2265 if (!(zvrf
= vrf
->info
))
2267 if ((stable
= zvrf
->stable
[AFI_IP
][safi
]) == NULL
)
2270 for (rn
= route_top (stable
); rn
; rn
= route_next (rn
))
2271 for (si
= rn
->info
; si
; si
= si
->next
)
2273 vty_out (vty
, "%s %s", cmd
, prefix2str (&rn
->p
, buf
, sizeof buf
));
2277 case STATIC_IPV4_GATEWAY
:
2278 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
2280 case STATIC_IFINDEX
:
2281 vty_out (vty
, " %s", si
->ifname
);
2283 case STATIC_BLACKHOLE
:
2284 vty_out (vty
, " Null0");
2286 case STATIC_IPV6_GATEWAY
:
2287 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
2289 case STATIC_IPV6_GATEWAY_IFINDEX
:
2290 vty_out (vty
, " %s %s",
2291 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
2292 ifindex2ifname_vrf (si
->ifindex
, si
->vrf_id
));
2296 /* flags are incompatible with STATIC_BLACKHOLE */
2297 if (si
->type
!= STATIC_BLACKHOLE
)
2299 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
2300 vty_out (vty
, " %s", "reject");
2302 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
2303 vty_out (vty
, " %s", "blackhole");
2307 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
2309 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
2310 vty_out (vty
, " %d", si
->distance
);
2312 if (si
->vrf_id
!= VRF_DEFAULT
)
2313 vty_out (vty
, " vrf %s", zvrf
? zvrf_name (zvrf
) : "");
2315 /* Label information */
2316 if (si
->snh_label
.num_labels
)
2317 vty_out (vty
, " label %s",
2318 mpls_label2str (si
->snh_label
.num_labels
,
2319 si
->snh_label
.label
, buf
, sizeof buf
));
2321 vty_out (vty
, "%s", VTY_NEWLINE
);
2329 /* General fucntion for IPv6 static route. */
2331 static_ipv6_func (struct vty
*vty
, int add_cmd
, const char *dest_str
,
2332 const char *src_str
,
2333 const char *gate_str
, const char *ifname
,
2334 const char *flag_str
, const char *tag_str
,
2335 const char *distance_str
, const char *vrf_id_str
,
2336 const char *label_str
)
2340 struct prefix p
, src
;
2341 struct prefix_ipv6
*src_p
= NULL
;
2342 struct in6_addr
*gate
= NULL
;
2343 struct in6_addr gate_addr
;
2344 u_char type
= STATIC_BLACKHOLE
;
2346 route_tag_t tag
= 0;
2347 unsigned int ifindex
= 0;
2348 struct interface
*ifp
= NULL
;
2349 struct zebra_vrf
*zvrf
;
2350 struct static_nh_label snh_label
;
2352 ret
= str2prefix (dest_str
, &p
);
2355 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2361 ret
= str2prefix (src_str
, &src
);
2362 if (ret
<= 0 || src
.family
!= AF_INET6
)
2364 vty_out (vty
, "%% Malformed source address%s", VTY_NEWLINE
);
2367 src_p
= (struct prefix_ipv6
*)&src
;
2370 /* Apply mask for given prefix. */
2373 /* Administrative distance. */
2375 distance
= atoi (distance_str
);
2377 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
2381 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
2383 /* When gateway is valid IPv6 addrees, then gate is treated as
2384 nexthop address other case gate is treated as interface name. */
2385 ret
= inet_pton (AF_INET6
, gate_str
, &gate_addr
);
2388 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
2392 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
2397 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
2402 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
2406 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
2409 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
2414 /* Null0 static route. */
2415 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
2419 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
2423 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, NULL
, ifindex
, ifname
,
2424 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
2426 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, NULL
, ifindex
, tag
,
2427 distance
, zvrf
, &snh_label
);
2433 switch(flag_str
[0]) {
2436 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
2440 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
2443 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
2450 /* When ifname is specified. It must be come with gateway
2454 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2457 type
= STATIC_IPV6_GATEWAY_IFINDEX
;
2459 ifp
= if_lookup_by_name_vrf (ifname
, zvrf_id (zvrf
));
2462 vty_out (vty
, "%% Malformed Interface name %s%s", ifname
, VTY_NEWLINE
);
2465 ifindex
= ifp
->ifindex
;
2471 type
= STATIC_IPV6_GATEWAY
;
2476 type
= STATIC_IFINDEX
;
2477 ifp
= if_lookup_by_name_vrf (gate_str
, zvrf_id (zvrf
));
2480 vty_out (vty
, "%% Malformed Interface name %s%s", gate_str
, VTY_NEWLINE
);
2481 ifindex
= IFINDEX_DELETED
;
2484 ifindex
= ifp
->ifindex
;
2490 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, src_p
, (union g_addr
*)gate
,
2491 ifindex
, ifname
, flag
, tag
, distance
, zvrf
, &snh_label
);
2493 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, src_p
, (union g_addr
*)gate
,
2494 ifindex
, tag
, distance
, zvrf
, &snh_label
);
2501 "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2503 "Establish static routes\n"
2504 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2505 "IPv6 source-dest route\n"
2506 "IPv6 source prefix\n"
2507 "IPv6 gateway address\n"
2508 "IPv6 gateway interface name\n"
2511 "Set tag for this route\n"
2513 "Distance value for this prefix\n"
2515 "Specify labels for this route\n"
2516 "One or more labels separated by '/'\n")
2518 int idx_ipv6_prefixlen
= 2;
2519 int idx_ipv6_ifname
;
2521 char *src
, *tag
, *distance
, *vrf
;
2523 if (!strcmp(argv
[3]->text
, "from"))
2526 idx_ipv6_ifname
= 5;
2532 idx_ipv6_ifname
= 3;
2536 tag
= distance
= vrf
= NULL
;
2537 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2539 return static_ipv6_func (vty
, 1,
2540 argv
[idx_ipv6_prefixlen
]->arg
,
2542 argv
[idx_ipv6_ifname
]->arg
,
2544 tag
, distance
, vrf
, NULL
);
2547 DEFUN (ipv6_route_flags
,
2548 ipv6_route_flags_cmd
,
2549 "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2551 "Establish static routes\n"
2552 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2553 "IPv6 source-dest route\n"
2554 "IPv6 source prefix\n"
2555 "IPv6 gateway address\n"
2556 "IPv6 gateway interface name\n"
2557 "Emit an ICMP unreachable when matched\n"
2558 "Silently discard pkts when matched\n"
2559 "Silently discard pkts when matched\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;
2568 int idx_ipv6_ifname
;
2569 int idx_reject_blackhole
;
2571 char *src
, *tag
, *distance
, *vrf
;
2573 if (!strcmp(argv
[3]->text
, "from"))
2576 idx_ipv6_ifname
= 5;
2577 idx_reject_blackhole
= 6;
2583 idx_ipv6_ifname
= 3;
2584 idx_reject_blackhole
= 4;
2588 tag
= distance
= vrf
= NULL
;
2589 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2591 return static_ipv6_func (vty
, 1,
2592 argv
[idx_ipv6_prefixlen
]->arg
,
2594 argv
[idx_ipv6_ifname
]->arg
,
2596 argv
[idx_reject_blackhole
]->arg
,
2597 tag
, distance
, vrf
, NULL
);
2600 DEFUN (ipv6_route_ifname
,
2601 ipv6_route_ifname_cmd
,
2602 "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2604 "Establish static routes\n"
2605 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2606 "IPv6 source-dest route\n"
2607 "IPv6 source prefix\n"
2608 "IPv6 gateway address\n"
2609 "IPv6 gateway interface name\n"
2610 "Set tag for this route\n"
2612 "Distance value for this prefix\n"
2614 "Specify labels for this route\n"
2615 "One or more labels separated by '/'\n")
2617 int idx_ipv6_prefixlen
= 2;
2619 int idx_interface
= 4;
2621 char *src
, *tag
, *distance
, *vrf
;
2623 if (!strcmp(argv
[3]->text
, "from"))
2638 tag
= distance
= vrf
= NULL
;
2639 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2641 return static_ipv6_func (vty
, 1,
2642 argv
[idx_ipv6_prefixlen
]->arg
,
2644 argv
[idx_ipv6
]->arg
,
2645 argv
[idx_interface
]->arg
,
2647 tag
, distance
, vrf
, NULL
);
2650 DEFUN (ipv6_route_ifname_flags
,
2651 ipv6_route_ifname_flags_cmd
,
2652 "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2654 "Establish static routes\n"
2655 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2656 "IPv6 source-dest route\n"
2657 "IPv6 source prefix\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
= 2;
2672 int idx_reject_blackhole
;
2674 char *src
, *tag
, *distance
, *vrf
;
2676 if (!strcmp(argv
[3]->text
, "from"))
2681 idx_reject_blackhole
= 7;
2689 idx_reject_blackhole
= 5;
2693 tag
= distance
= vrf
= NULL
;
2694 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2696 return static_ipv6_func (vty
, 1,
2697 argv
[idx_ipv6_prefixlen
]->arg
,
2699 argv
[idx_ipv6
]->arg
,
2700 argv
[idx_interface
]->arg
,
2701 argv
[idx_reject_blackhole
]->arg
,
2702 tag
, distance
, vrf
, NULL
);
2705 DEFUN (no_ipv6_route
,
2707 "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2710 "Establish static routes\n"
2711 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2712 "IPv6 source-dest route\n"
2713 "IPv6 source prefix\n"
2714 "IPv6 gateway address\n"
2715 "IPv6 gateway interface name\n"
2717 "Set tag for this route\n"
2719 "Distance value for this prefix\n"
2721 "Specify labels for this route\n"
2722 "One or more labels separated by '/'\n")
2724 int idx_ipv6_prefixlen
= 3;
2725 int idx_ipv6_ifname
;
2727 char *src
, *tag
, *distance
, *vrf
;
2729 if (!strcmp(argv
[4]->text
, "from"))
2732 idx_ipv6_ifname
= 6;
2738 idx_ipv6_ifname
= 4;
2742 tag
= distance
= vrf
= NULL
;
2743 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2745 return static_ipv6_func (vty
, 0,
2746 argv
[idx_ipv6_prefixlen
]->arg
,
2748 argv
[idx_ipv6_ifname
]->arg
,
2750 tag
, distance
, vrf
, NULL
);
2753 DEFUN (no_ipv6_route_flags
,
2754 no_ipv6_route_flags_cmd
,
2755 "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2758 "Establish static routes\n"
2759 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2760 "IPv6 source-dest route\n"
2761 "IPv6 source prefix\n"
2762 "IPv6 gateway address\n"
2763 "IPv6 gateway interface name\n"
2764 "Emit an ICMP unreachable when matched\n"
2765 "Silently discard pkts when matched\n"
2766 "Set tag for this route\n"
2768 "Distance value for this prefix\n"
2770 "Specify labels for this route\n"
2771 "One or more labels separated by '/'\n")
2773 int idx_ipv6_prefixlen
= 3;
2774 int idx_ipv6_ifname
;
2775 int idx_reject_blackhole
;
2777 char *src
, *tag
, *distance
, *vrf
;
2779 if (!strcmp(argv
[4]->text
, "from"))
2782 idx_ipv6_ifname
= 6;
2783 idx_reject_blackhole
= 7;
2789 idx_ipv6_ifname
= 4;
2790 idx_reject_blackhole
= 5;
2794 tag
= distance
= vrf
= NULL
;
2795 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2797 return static_ipv6_func (vty
, 0,
2798 argv
[idx_ipv6_prefixlen
]->arg
,
2800 argv
[idx_ipv6_ifname
]->arg
,
2802 argv
[idx_reject_blackhole
]->arg
,
2803 tag
, distance
, vrf
, NULL
);
2806 DEFUN (no_ipv6_route_ifname
,
2807 no_ipv6_route_ifname_cmd
,
2808 "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2811 "Establish static routes\n"
2812 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2813 "IPv6 source-dest route\n"
2814 "IPv6 source prefix\n"
2815 "IPv6 gateway address\n"
2816 "IPv6 gateway interface name\n"
2817 "Set tag for this route\n"
2819 "Distance value for this prefix\n"
2821 "Specify labels for this route\n"
2822 "One or more labels separated by '/'\n")
2824 int idx_ipv6_prefixlen
= 3;
2828 char *src
, *tag
, *distance
, *vrf
;
2830 if (!strcmp(argv
[4]->text
, "from"))
2845 tag
= distance
= vrf
= NULL
;
2846 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2848 return static_ipv6_func (vty
, 0,
2849 argv
[idx_ipv6_prefixlen
]->arg
,
2851 argv
[idx_ipv6
]->arg
,
2852 argv
[idx_interface
]->arg
,
2854 tag
, distance
, vrf
, NULL
);
2857 DEFUN (no_ipv6_route_ifname_flags
,
2858 no_ipv6_route_ifname_flags_cmd
,
2859 "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
2862 "Establish static routes\n"
2863 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2864 "IPv6 source-dest route\n"
2865 "IPv6 source prefix\n"
2866 "IPv6 gateway address\n"
2867 "IPv6 gateway interface name\n"
2868 "Emit an ICMP unreachable when matched\n"
2869 "Silently discard pkts when matched\n"
2870 "Set tag for this route\n"
2872 "Distance value for this prefix\n"
2874 "Specify labels for this route\n"
2875 "One or more labels separated by '/'\n")
2877 int idx_ipv6_prefixlen
= 3;
2880 int idx_reject_blackhole
;
2882 char *src
, *tag
, *distance
, *vrf
;
2884 if (!strcmp(argv
[4]->text
, "from"))
2889 idx_reject_blackhole
= 8;
2897 idx_reject_blackhole
= 6;
2901 tag
= distance
= vrf
= NULL
;
2902 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2904 return static_ipv6_func (vty
, 0,
2905 argv
[idx_ipv6_prefixlen
]->arg
,
2907 argv
[idx_ipv6
]->arg
,
2908 argv
[idx_interface
]->arg
,
2909 argv
[idx_reject_blackhole
]->arg
,
2910 tag
, distance
, vrf
, NULL
);
2913 DEFUN (show_ipv6_route
,
2914 show_ipv6_route_cmd
,
2915 "show ipv6 route [vrf NAME] [json]",
2918 "IPv6 routing table\n"
2922 struct route_table
*table
;
2923 struct route_node
*rn
;
2926 vrf_id_t vrf_id
= VRF_DEFAULT
;
2927 struct zebra_vrf
*zvrf
= NULL
;
2928 char buf
[SRCDEST2STR_BUFFER
];
2929 json_object
*json
= NULL
;
2930 json_object
*json_prefix
= NULL
;
2932 int vrf
= (argc
> 3 && strmatch (argv
[3]->text
, "vrf"));
2933 int uj
= vrf
? argc
== 6 : argc
== 4;
2934 char *vrfname
= vrf
? argv
[4]->arg
: NULL
;
2938 if (!(zvrf
= zebra_vrf_lookup_by_name (vrfname
)))
2941 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2943 vty_out (vty
, "vrf %s not defined%s", vrfname
, VTY_NEWLINE
);
2947 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
2950 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2952 vty_out (vty
, "vrf %s inactive%s", vrfname
, VTY_NEWLINE
);
2956 vrf_id
= zvrf_id (zvrf
);
2959 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2963 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2969 json
= json_object_new_object();
2971 /* Show all IPv6 route. */
2972 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
2974 RNODE_FOREACH_RIB (rn
, rib
)
2977 json_prefix
= json_object_new_array();
2978 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
2983 srcdest_rnode2str (rn
, buf
, sizeof buf
);
2984 json_object_object_add(json
, buf
, json_prefix
);
2989 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
2990 json_object_free(json
);
2994 /* Show all IPv6 route. */
2995 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
2997 RNODE_FOREACH_RIB (rn
, rib
)
3001 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3004 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3012 DEFUN (show_ipv6_route_tag
,
3013 show_ipv6_route_tag_cmd
,
3014 "show ipv6 route [vrf NAME] tag (1-4294967295)",
3017 "IPv6 routing table\n"
3019 "Show only routes with tag\n"
3025 struct route_table
*table
;
3026 struct route_node
*rn
;
3029 route_tag_t tag
= 0;
3030 vrf_id_t vrf_id
= VRF_DEFAULT
;
3032 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
3034 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
3035 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
3040 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
3043 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3047 /* Show all IPv6 routes with matching tag value. */
3048 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3049 RNODE_FOREACH_RIB (rn
, rib
)
3051 if (rib
->tag
!= tag
)
3056 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3059 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3064 DEFUN (show_ipv6_route_prefix_longer
,
3065 show_ipv6_route_prefix_longer_cmd
,
3066 "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes",
3069 "IPv6 routing table\n"
3072 "Show route matching the specified Network/Mask pair only\n")
3074 struct route_table
*table
;
3075 struct route_node
*rn
;
3080 vrf_id_t vrf_id
= VRF_DEFAULT
;
3082 if (strmatch(argv
[3]->text
, "vrf"))
3084 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3085 ret
= str2prefix (argv
[5]->arg
, &p
);
3089 ret
= str2prefix (argv
[3]->arg
, &p
);
3094 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3098 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3102 /* Show matched type IPv6 routes. */
3103 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3104 RNODE_FOREACH_RIB (rn
, rib
)
3106 struct prefix
*p
, *src_p
;
3107 srcdest_rnode_prefixes(rn
, &p
, &src_p
);
3109 if (prefix_match (p
, &rn
->p
))
3113 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3116 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3122 DEFUN (show_ipv6_route_protocol
,
3123 show_ipv6_route_protocol_cmd
,
3124 "show ipv6 route [vrf NAME] " FRR_IP6_REDIST_STR_ZEBRA
,
3127 "IP routing table\n"
3129 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3132 struct route_table
*table
;
3133 struct route_node
*rn
;
3136 vrf_id_t vrf_id
= VRF_DEFAULT
;
3139 if (argv_find (argv
, argc
, "NAME", &idx
))
3140 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
3142 char *proto
= argv
[argc
- 1]->text
;
3143 type
= proto_redistnum (AFI_IP
, proto
);
3147 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3151 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3155 /* Show matched type IPv6 routes. */
3156 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3157 RNODE_FOREACH_RIB (rn
, rib
)
3158 if (rib
->type
== type
)
3162 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3165 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3170 DEFUN (show_ipv6_route_addr
,
3171 show_ipv6_route_addr_cmd
,
3172 "show ipv6 route [vrf NAME] X:X::X:X",
3175 "IPv6 routing table\n"
3180 struct prefix_ipv6 p
;
3181 struct route_table
*table
;
3182 struct route_node
*rn
;
3183 vrf_id_t vrf_id
= VRF_DEFAULT
;
3185 if (strmatch(argv
[3]->text
, "vrf"))
3187 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3188 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3192 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3197 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3201 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3205 rn
= route_node_match (table
, (struct prefix
*) &p
);
3208 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3212 vty_show_ip_route_detail (vty
, rn
, 0);
3214 route_unlock_node (rn
);
3219 DEFUN (show_ipv6_route_prefix
,
3220 show_ipv6_route_prefix_cmd
,
3221 "show ipv6 route [vrf NAME] X:X::X:X/M",
3224 "IPv6 routing table\n"
3229 struct prefix_ipv6 p
;
3230 struct route_table
*table
;
3231 struct route_node
*rn
;
3232 vrf_id_t vrf_id
= VRF_DEFAULT
;
3234 if (strmatch(argv
[3]->text
, "vrf"))
3236 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3237 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3240 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3244 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3248 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3252 rn
= route_node_match (table
, (struct prefix
*) &p
);
3253 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
3255 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3259 vty_show_ip_route_detail (vty
, rn
, 0);
3261 route_unlock_node (rn
);
3267 /* Show route summary. */
3268 DEFUN (show_ipv6_route_summary
,
3269 show_ipv6_route_summary_cmd
,
3270 "show ipv6 route [vrf NAME] summary",
3273 "IPv6 routing table\n"
3275 "Summary of all IPv6 routes\n")
3277 struct route_table
*table
;
3278 vrf_id_t vrf_id
= VRF_DEFAULT
;
3280 if (strmatch(argv
[3]->text
, "vrf"))
3281 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3283 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3287 vty_show_ip_route_summary (vty
, table
);
3293 /* Show ipv6 route summary prefix. */
3294 DEFUN (show_ipv6_route_summary_prefix
,
3295 show_ipv6_route_summary_prefix_cmd
,
3296 "show ipv6 route [vrf NAME] summary prefix",
3299 "IPv6 routing table\n"
3301 "Summary of all IPv6 routes\n"
3304 struct route_table
*table
;
3305 vrf_id_t vrf_id
= VRF_DEFAULT
;
3307 if (strmatch(argv
[3]->text
, "vrf"))
3308 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3310 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3314 vty_show_ip_route_summary_prefix (vty
, table
);
3321 * Show IPv6 mroute command.Used to dump
3322 * the Multicast routing table.
3324 DEFUN (show_ipv6_mroute
,
3325 show_ipv6_mroute_cmd
,
3326 "show ipv6 mroute [vrf NAME]",
3329 "IPv6 Multicast routing table\n"
3332 struct route_table
*table
;
3333 struct route_node
*rn
;
3336 vrf_id_t vrf_id
= VRF_DEFAULT
;
3338 if (strmatch(argv
[3]->text
, "vrf"))
3339 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3341 table
= zebra_vrf_table (AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
3345 /* Show all IPv6 route. */
3346 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3347 RNODE_FOREACH_RIB (rn
, rib
)
3351 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3354 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3360 DEFUN (show_ipv6_route_vrf_all
,
3361 show_ipv6_route_vrf_all_cmd
,
3362 "show ipv6 route vrf all",
3365 "IPv6 routing table\n"
3366 VRF_ALL_CMD_HELP_STR
)
3368 struct route_table
*table
;
3369 struct route_node
*rn
;
3372 struct zebra_vrf
*zvrf
;
3376 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3378 if ((zvrf
= vrf
->info
) == NULL
||
3379 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3382 /* Show all IPv6 route. */
3383 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3384 RNODE_FOREACH_RIB (rn
, rib
)
3388 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3394 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3397 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3405 DEFUN (show_ipv6_route_vrf_all_tag
,
3406 show_ipv6_route_vrf_all_tag_cmd
,
3407 "show ipv6 route vrf all tag (1-4294967295)",
3410 "IPv6 routing table\n"
3411 VRF_ALL_CMD_HELP_STR
3412 "Show only routes with tag\n"
3416 struct route_table
*table
;
3417 struct route_node
*rn
;
3420 struct zebra_vrf
*zvrf
;
3423 route_tag_t tag
= 0;
3425 if (argv
[idx_number
]->arg
)
3426 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
3428 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3430 if ((zvrf
= vrf
->info
) == NULL
||
3431 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
3434 /* Show all IPv6 routes with matching tag value. */
3435 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3436 RNODE_FOREACH_RIB (rn
, rib
)
3438 if (rib
->tag
!= tag
)
3443 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3449 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3452 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3460 DEFUN (show_ipv6_route_vrf_all_prefix_longer
,
3461 show_ipv6_route_vrf_all_prefix_longer_cmd
,
3462 "show ipv6 route vrf all X:X::X:X/M longer-prefixes",
3465 "IPv6 routing table\n"
3466 VRF_ALL_CMD_HELP_STR
3468 "Show route matching the specified Network/Mask pair only\n")
3470 int idx_ipv6_prefixlen
= 5;
3471 struct route_table
*table
;
3472 struct route_node
*rn
;
3476 struct zebra_vrf
*zvrf
;
3481 ret
= str2prefix (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3484 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3488 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3490 if ((zvrf
= vrf
->info
) == NULL
||
3491 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3494 /* Show matched type IPv6 routes. */
3495 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3496 RNODE_FOREACH_RIB (rn
, rib
)
3498 struct prefix
*p
, *src_p
;
3499 srcdest_rnode_prefixes(rn
, &p
, &src_p
);
3500 if (prefix_match (p
, &rn
->p
))
3504 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3510 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3513 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3522 DEFUN (show_ipv6_route_vrf_all_protocol
,
3523 show_ipv6_route_vrf_all_protocol_cmd
,
3524 "show ipv6 route vrf all " FRR_IP6_REDIST_STR_ZEBRA
,
3527 "IP routing table\n"
3528 VRF_ALL_CMD_HELP_STR
3529 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3532 struct route_table
*table
;
3533 struct route_node
*rn
;
3536 struct zebra_vrf
*zvrf
;
3540 char *proto
= argv
[argc
- 1]->text
;
3541 type
= proto_redistnum (AFI_IP
, proto
);
3545 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3549 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3551 if ((zvrf
= vrf
->info
) == NULL
||
3552 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3555 /* Show matched type IPv6 routes. */
3556 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3557 RNODE_FOREACH_RIB (rn
, rib
)
3558 if (rib
->type
== type
)
3562 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3568 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3571 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3579 DEFUN (show_ipv6_route_vrf_all_addr
,
3580 show_ipv6_route_vrf_all_addr_cmd
,
3581 "show ipv6 route vrf all X:X::X:X",
3584 "IPv6 routing table\n"
3585 VRF_ALL_CMD_HELP_STR
3590 struct prefix_ipv6 p
;
3591 struct route_table
*table
;
3592 struct route_node
*rn
;
3594 struct zebra_vrf
*zvrf
;
3596 ret
= str2prefix_ipv6 (argv
[idx_ipv6
]->arg
, &p
);
3599 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3603 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3605 if ((zvrf
= vrf
->info
) == NULL
||
3606 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3609 rn
= route_node_match (table
, (struct prefix
*) &p
);
3613 vty_show_ip_route_detail (vty
, rn
, 0);
3615 route_unlock_node (rn
);
3621 DEFUN (show_ipv6_route_vrf_all_prefix
,
3622 show_ipv6_route_vrf_all_prefix_cmd
,
3623 "show ipv6 route vrf all X:X::X:X/M",
3626 "IPv6 routing table\n"
3627 VRF_ALL_CMD_HELP_STR
3630 int idx_ipv6_prefixlen
= 5;
3632 struct prefix_ipv6 p
;
3633 struct route_table
*table
;
3634 struct route_node
*rn
;
3636 struct zebra_vrf
*zvrf
;
3638 ret
= str2prefix_ipv6 (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3641 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3645 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3647 if ((zvrf
= vrf
->info
) == NULL
||
3648 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3651 rn
= route_node_match (table
, (struct prefix
*) &p
);
3654 if (rn
->p
.prefixlen
!= p
.prefixlen
)
3656 route_unlock_node (rn
);
3660 vty_show_ip_route_detail (vty
, rn
, 0);
3662 route_unlock_node (rn
);
3668 DEFUN (show_ipv6_route_vrf_all_summary
,
3669 show_ipv6_route_vrf_all_summary_cmd
,
3670 "show ipv6 route vrf all summary",
3673 "IPv6 routing table\n"
3674 VRF_ALL_CMD_HELP_STR
3675 "Summary of all IPv6 routes\n")
3678 struct zebra_vrf
*zvrf
;
3680 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3681 if ((zvrf
= vrf
->info
) != NULL
)
3682 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3687 DEFUN (show_ipv6_mroute_vrf_all
,
3688 show_ipv6_mroute_vrf_all_cmd
,
3689 "show ipv6 mroute vrf all",
3692 "IPv6 Multicast routing table\n"
3693 VRF_ALL_CMD_HELP_STR
)
3695 struct route_table
*table
;
3696 struct route_node
*rn
;
3699 struct zebra_vrf
*zvrf
;
3702 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3704 if ((zvrf
= vrf
->info
) == NULL
||
3705 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3708 /* Show all IPv6 route. */
3709 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3710 RNODE_FOREACH_RIB (rn
, rib
)
3714 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3717 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3723 DEFUN (show_ipv6_route_vrf_all_summary_prefix
,
3724 show_ipv6_route_vrf_all_summary_prefix_cmd
,
3725 "show ipv6 route vrf all summary prefix",
3728 "IPv6 routing table\n"
3729 VRF_ALL_CMD_HELP_STR
3730 "Summary of all IPv6 routes\n"
3734 struct zebra_vrf
*zvrf
;
3736 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3737 if ((zvrf
= vrf
->info
) != NULL
)
3738 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3743 /* Write IPv6 static route configuration. */
3745 static_config_ipv6 (struct vty
*vty
)
3747 struct route_node
*rn
;
3748 struct static_route
*si
;
3750 char buf
[SRCDEST2STR_BUFFER
];
3751 struct route_table
*stable
;
3753 struct zebra_vrf
*zvrf
;
3755 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3757 if (!(zvrf
= vrf
->info
))
3759 if ((stable
= zvrf
->stable
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3762 for (rn
= route_top (stable
); rn
; rn
= srcdest_route_next (rn
))
3763 for (si
= rn
->info
; si
; si
= si
->next
)
3765 vty_out (vty
, "ipv6 route %s", srcdest_rnode2str (rn
, buf
, sizeof buf
));
3769 case STATIC_IPV4_GATEWAY
:
3770 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
3772 case STATIC_IPV6_GATEWAY
:
3773 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
3775 case STATIC_IFINDEX
:
3776 vty_out (vty
, " %s", si
->ifname
);
3778 case STATIC_BLACKHOLE
:
3779 vty_out (vty
, " Null0" );
3781 case STATIC_IPV6_GATEWAY_IFINDEX
:
3782 vty_out (vty
, " %s %s",
3783 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
3784 ifindex2ifname_vrf (si
->ifindex
, si
->vrf_id
));
3788 /* flags are incompatible with STATIC_BLACKHOLE */
3789 if (si
->type
!= STATIC_BLACKHOLE
)
3791 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
3792 vty_out (vty
, " %s", "reject");
3793 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
3794 vty_out (vty
, " %s", "blackhole");
3798 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
3800 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
3801 vty_out (vty
, " %d", si
->distance
);
3803 if (si
->vrf_id
!= VRF_DEFAULT
)
3805 vty_out (vty
, " vrf %s", zvrf_name (zvrf
));
3808 /* Label information */
3809 if (si
->snh_label
.num_labels
)
3810 vty_out (vty
, " label %s",
3811 mpls_label2str (si
->snh_label
.num_labels
,
3812 si
->snh_label
.label
, buf
, sizeof buf
));
3814 vty_out (vty
, "%s", VTY_NEWLINE
);
3822 DEFUN (allow_external_route_update
,
3823 allow_external_route_update_cmd
,
3824 "allow-external-route-update",
3825 "Allow Quagga routes to be overwritten by external processes")
3832 DEFUN (no_allow_external_route_update
,
3833 no_allow_external_route_update_cmd
,
3834 "no allow-external-route-update",
3835 "Allow Quagga routes to be overwritten by external processes")
3850 struct zebra_vrf
*zvrf
;
3852 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3854 if (!(zvrf
= vrf
->info
))
3856 if (!zvrf_id (zvrf
))
3859 vty_out (vty
, "vrf %s ", zvrf_name (zvrf
));
3860 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
3861 vty_out (vty
, "inactive");
3863 vty_out (vty
, "id %u table %u", zvrf_id (zvrf
), zvrf
->table_id
);
3864 vty_out (vty
, "%s", VTY_NEWLINE
);
3871 /* Static ip route configuration write function. */
3873 zebra_ip_config (struct vty
*vty
)
3877 write
+= static_config_ipv4 (vty
, SAFI_UNICAST
, "ip route");
3878 write
+= static_config_ipv4 (vty
, SAFI_MULTICAST
, "ip mroute");
3879 write
+= static_config_ipv6 (vty
);
3881 write
+= zebra_import_table_config (vty
);
3885 DEFUN (ip_zebra_import_table_distance
,
3886 ip_zebra_import_table_distance_cmd
,
3887 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
3889 "import routes from non-main kernel table\n"
3890 "kernel routing table id\n"
3891 "Distance for imported routes\n"
3892 "Default distance value\n"
3893 "route-map for filtering\n"
3896 u_int32_t table_id
= 0;
3898 VTY_GET_INTEGER("table", table_id
, argv
[2]->arg
);
3899 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
3900 char *rmap
= strmatch (argv
[argc
- 2]->text
, "route-map") ?
3901 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
) : NULL
;
3902 if (argc
== 7 || (argc
== 5 && !rmap
))
3903 VTY_GET_INTEGER_RANGE("distance", distance
, argv
[4]->arg
, 1, 255);
3905 if (!is_zebra_valid_kernel_table(table_id
))
3907 vty_out(vty
, "Invalid routing table ID, %d. Must be in range 1-252%s",
3908 table_id
, VTY_NEWLINE
);
3912 if (is_zebra_main_routing_table(table_id
))
3914 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3915 table_id
, VTY_NEWLINE
);
3919 return (zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1));
3922 DEFUN (no_ip_zebra_import_table
,
3923 no_ip_zebra_import_table_cmd
,
3924 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
3927 "import routes from non-main kernel table\n"
3928 "kernel routing table id\n"
3929 "Distance for imported routes\n"
3930 "Default distance value\n"
3931 "route-map for filtering\n"
3934 u_int32_t table_id
= 0;
3935 VTY_GET_INTEGER("table", table_id
, argv
[3]->arg
);
3937 if (!is_zebra_valid_kernel_table(table_id
))
3939 vty_out(vty
, "Invalid routing table ID. Must be in range 1-252%s",
3944 if (is_zebra_main_routing_table(table_id
))
3946 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3947 table_id
, VTY_NEWLINE
);
3951 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
3954 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
3958 config_write_protocol (struct vty
*vty
)
3961 vty_out(vty
, "allow-external-route-update%s", VTY_NEWLINE
);
3963 if (zebra_rnh_ip_default_route
)
3964 vty_out(vty
, "ip nht resolve-via-default%s", VTY_NEWLINE
);
3966 if (zebra_rnh_ipv6_default_route
)
3967 vty_out(vty
, "ipv6 nht resolve-via-default%s", VTY_NEWLINE
);
3969 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get ();
3971 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
3972 vty_out (vty
, "ip multicast rpf-lookup-mode %s%s",
3973 ipv4_multicast_mode
== MCAST_URIB_ONLY
? "urib-only" :
3974 ipv4_multicast_mode
== MCAST_MRIB_ONLY
? "mrib-only" :
3975 ipv4_multicast_mode
== MCAST_MIX_MRIB_FIRST
? "mrib-then-urib" :
3976 ipv4_multicast_mode
== MCAST_MIX_DISTANCE
? "lower-distance" :
3980 zebra_routemap_config_write_protocol(vty
);
3985 /* IP node for static routes. */
3986 static struct cmd_node ip_node
= { IP_NODE
, "", 1 };
3987 static struct cmd_node protocol_node
= { PROTOCOL_NODE
, "", 1 };
3991 zebra_vty_init (void)
3993 install_node (&ip_node
, zebra_ip_config
);
3994 install_node (&protocol_node
, config_write_protocol
);
3996 install_element (CONFIG_NODE
, &allow_external_route_update_cmd
);
3997 install_element (CONFIG_NODE
, &no_allow_external_route_update_cmd
);
3998 install_element (CONFIG_NODE
, &ip_mroute_dist_cmd
);
3999 install_element (CONFIG_NODE
, &no_ip_mroute_dist_cmd
);
4000 install_element (CONFIG_NODE
, &ip_multicast_mode_cmd
);
4001 install_element (CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
4002 install_element (CONFIG_NODE
, &ip_route_cmd
);
4003 install_element (CONFIG_NODE
, &ip_route_flags_cmd
);
4004 install_element (CONFIG_NODE
, &ip_route_mask_cmd
);
4005 install_element (CONFIG_NODE
, &ip_route_mask_flags_cmd
);
4006 install_element (CONFIG_NODE
, &no_ip_route_cmd
);
4007 install_element (CONFIG_NODE
, &no_ip_route_mask_cmd
);
4008 install_element (CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
4009 install_element (CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
4011 install_element (VIEW_NODE
, &show_vrf_cmd
);
4012 install_element (VIEW_NODE
, &show_ip_route_cmd
);
4013 install_element (VIEW_NODE
, &show_ip_route_ospf_instance_cmd
);
4014 install_element (VIEW_NODE
, &show_ip_route_tag_cmd
);
4015 install_element (VIEW_NODE
, &show_ip_nht_cmd
);
4016 install_element (VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
4017 install_element (VIEW_NODE
, &show_ipv6_nht_cmd
);
4018 install_element (VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
4019 install_element (VIEW_NODE
, &show_ip_route_addr_cmd
);
4020 install_element (VIEW_NODE
, &show_ip_route_prefix_cmd
);
4021 install_element (VIEW_NODE
, &show_ip_route_prefix_longer_cmd
);
4022 install_element (VIEW_NODE
, &show_ip_route_protocol_cmd
);
4023 install_element (VIEW_NODE
, &show_ip_route_supernets_cmd
);
4024 install_element (VIEW_NODE
, &show_ip_route_summary_cmd
);
4025 install_element (VIEW_NODE
, &show_ip_route_summary_prefix_cmd
);
4027 install_element (VIEW_NODE
, &show_ip_rpf_cmd
);
4028 install_element (VIEW_NODE
, &show_ip_rpf_addr_cmd
);
4030 /* Commands for VRF */
4032 install_element (CONFIG_NODE
, &no_ip_route_flags_cmd
);
4033 install_element (CONFIG_NODE
, &no_ip_route_mask_flags_cmd
);
4035 install_element (VIEW_NODE
, &show_ip_route_vrf_cmd
);
4037 install_element (VIEW_NODE
, &show_ip_route_vrf_all_cmd
);
4038 install_element (VIEW_NODE
, &show_ip_route_vrf_all_tag_cmd
);
4039 install_element (VIEW_NODE
, &show_ip_route_vrf_all_addr_cmd
);
4040 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_cmd
);
4041 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_longer_cmd
);
4042 install_element (VIEW_NODE
, &show_ip_route_vrf_all_protocol_cmd
);
4043 install_element (VIEW_NODE
, &show_ip_route_vrf_all_supernets_cmd
);
4044 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_cmd
);
4045 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_prefix_cmd
);
4047 install_element (CONFIG_NODE
, &ipv6_route_cmd
);
4048 install_element (CONFIG_NODE
, &ipv6_route_flags_cmd
);
4049 install_element (CONFIG_NODE
, &ipv6_route_ifname_cmd
);
4050 install_element (CONFIG_NODE
, &ipv6_route_ifname_flags_cmd
);
4051 install_element (CONFIG_NODE
, &no_ipv6_route_cmd
);
4052 install_element (CONFIG_NODE
, &no_ipv6_route_flags_cmd
);
4053 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_cmd
);
4054 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_flags_cmd
);
4055 install_element (CONFIG_NODE
, &ip_nht_default_route_cmd
);
4056 install_element (CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
4057 install_element (CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
4058 install_element (CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
4059 install_element (VIEW_NODE
, &show_ipv6_route_cmd
);
4060 install_element (VIEW_NODE
, &show_ipv6_route_tag_cmd
);
4061 install_element (VIEW_NODE
, &show_ipv6_route_summary_cmd
);
4062 install_element (VIEW_NODE
, &show_ipv6_route_summary_prefix_cmd
);
4063 install_element (VIEW_NODE
, &show_ipv6_route_protocol_cmd
);
4064 install_element (VIEW_NODE
, &show_ipv6_route_addr_cmd
);
4065 install_element (VIEW_NODE
, &show_ipv6_route_prefix_cmd
);
4066 install_element (VIEW_NODE
, &show_ipv6_route_prefix_longer_cmd
);
4068 install_element (VIEW_NODE
, &show_ipv6_mroute_cmd
);
4070 /* Commands for VRF */
4071 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_cmd
);
4072 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_tag_cmd
);
4073 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_cmd
);
4074 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_prefix_cmd
);
4075 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_protocol_cmd
);
4076 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_addr_cmd
);
4077 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_cmd
);
4078 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_longer_cmd
);
4080 install_element (VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);