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 (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_NHRP
688 || rib
->type
== ZEBRA_ROUTE_TABLE
689 || rib
->type
== ZEBRA_ROUTE_BGP
)
694 uptime
= time (NULL
);
695 uptime
-= rib
->uptime
;
696 tm
= gmtime (&uptime
);
698 vty_out (vty
, " Last update ");
700 if (uptime
< ONE_DAY_SECOND
)
701 vty_out (vty
, "%02d:%02d:%02d",
702 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
703 else if (uptime
< ONE_WEEK_SECOND
)
704 vty_out (vty
, "%dd%02dh%02dm",
705 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
707 vty_out (vty
, "%02dw%dd%02dh",
709 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
710 vty_out (vty
, " ago%s", VTY_NEWLINE
);
713 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
717 vty_out (vty
, " %c%s",
718 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
) ? '*' : ' ',
719 recursing
? " " : "");
721 switch (nexthop
->type
)
723 case NEXTHOP_TYPE_IPV4
:
724 case NEXTHOP_TYPE_IPV4_IFINDEX
:
725 vty_out (vty
, " %s", inet_ntoa (nexthop
->gate
.ipv4
));
726 if (nexthop
->ifindex
)
727 vty_out (vty
, ", via %s",
728 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
730 case NEXTHOP_TYPE_IPV6
:
731 case NEXTHOP_TYPE_IPV6_IFINDEX
:
733 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
734 if (nexthop
->ifindex
)
735 vty_out (vty
, ", via %s",
736 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
738 case NEXTHOP_TYPE_IFINDEX
:
739 vty_out (vty
, " directly connected, %s",
740 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
742 case NEXTHOP_TYPE_BLACKHOLE
:
743 vty_out (vty
, " directly connected, Null0");
748 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
749 vty_out (vty
, " inactive");
751 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
752 vty_out (vty
, " onlink");
754 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
755 vty_out (vty
, " (recursive)");
757 switch (nexthop
->type
)
759 case NEXTHOP_TYPE_IPV4
:
760 case NEXTHOP_TYPE_IPV4_IFINDEX
:
761 if (nexthop
->src
.ipv4
.s_addr
)
763 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, addrstr
,
765 vty_out (vty
, ", src %s", addrstr
);
768 case NEXTHOP_TYPE_IPV6
:
769 case NEXTHOP_TYPE_IPV6_IFINDEX
:
770 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
772 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, addrstr
,
774 vty_out (vty
, ", src %s", addrstr
);
781 /* Label information */
782 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
784 vty_out (vty
, " label %s",
785 mpls_label2str (nexthop
->nh_label
->num_labels
,
786 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
789 vty_out (vty
, "%s", VTY_NEWLINE
);
791 vty_out (vty
, "%s", VTY_NEWLINE
);
796 vty_show_ip_route (struct vty
*vty
, struct route_node
*rn
, struct rib
*rib
,
799 struct nexthop
*nexthop
, *tnexthop
;
802 char buf
[SRCDEST2STR_BUFFER
];
803 json_object
*json_nexthops
= NULL
;
804 json_object
*json_nexthop
= NULL
;
805 json_object
*json_route
= NULL
;
809 json_route
= json_object_new_object();
810 json_nexthops
= json_object_new_array();
812 json_object_string_add(json_route
, "prefix", srcdest_rnode2str (rn
, buf
, sizeof buf
));
813 json_object_string_add(json_route
, "protocol", zebra_route_string(rib
->type
));
816 json_object_int_add(json_route
, "instance", rib
->instance
);
819 json_object_int_add(json_route
, "vrfId", rib
->vrf_id
);
821 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
822 json_object_boolean_true_add(json_route
, "selected");
824 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
&& rib
->type
!= ZEBRA_ROUTE_KERNEL
)
826 json_object_int_add(json_route
, "distance", rib
->distance
);
827 json_object_int_add(json_route
, "metric", rib
->metric
);
830 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
831 json_object_boolean_true_add(json_route
, "blackhole");
833 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
834 json_object_boolean_true_add(json_route
, "reject");
836 if (rib
->type
== ZEBRA_ROUTE_RIP
837 || rib
->type
== ZEBRA_ROUTE_OSPF
838 || rib
->type
== ZEBRA_ROUTE_ISIS
839 || rib
->type
== ZEBRA_ROUTE_NHRP
840 || rib
->type
== ZEBRA_ROUTE_TABLE
841 || rib
->type
== ZEBRA_ROUTE_BGP
)
846 uptime
= time (NULL
);
847 uptime
-= rib
->uptime
;
848 tm
= gmtime (&uptime
);
850 if (uptime
< ONE_DAY_SECOND
)
851 sprintf(buf
, "%02d:%02d:%02d", tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
852 else if (uptime
< ONE_WEEK_SECOND
)
853 sprintf(buf
, "%dd%02dh%02dm", tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
855 sprintf(buf
, "%02dw%dd%02dh", tm
->tm_yday
/7, tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
857 json_object_string_add(json_route
, "uptime", buf
);
860 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
862 json_nexthop
= json_object_new_object();
864 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
865 json_object_boolean_true_add(json_nexthop
, "fib");
867 switch (nexthop
->type
)
869 case NEXTHOP_TYPE_IPV4
:
870 case NEXTHOP_TYPE_IPV4_IFINDEX
:
871 json_object_string_add(json_nexthop
, "ip", inet_ntoa (nexthop
->gate
.ipv4
));
872 json_object_string_add(json_nexthop
, "afi", "ipv4");
874 if (nexthop
->ifindex
)
876 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
877 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
880 case NEXTHOP_TYPE_IPV6
:
881 case NEXTHOP_TYPE_IPV6_IFINDEX
:
882 json_object_string_add(json_nexthop
, "ip", inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
883 json_object_string_add(json_nexthop
, "afi", "ipv6");
885 if (nexthop
->ifindex
)
887 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
888 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
892 case NEXTHOP_TYPE_IFINDEX
:
893 json_object_boolean_true_add(json_nexthop
, "directlyConnected");
894 json_object_int_add(json_nexthop
, "interfaceIndex", nexthop
->ifindex
);
895 json_object_string_add(json_nexthop
, "interfaceName", ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
897 case NEXTHOP_TYPE_BLACKHOLE
:
898 json_object_boolean_true_add(json_nexthop
, "blackhole");
904 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
905 json_object_boolean_true_add(json_nexthop
, "active");
907 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
908 json_object_boolean_true_add(json_nexthop
, "onLink");
910 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
911 json_object_boolean_true_add(json_nexthop
, "recursive");
913 switch (nexthop
->type
)
915 case NEXTHOP_TYPE_IPV4
:
916 case NEXTHOP_TYPE_IPV4_IFINDEX
:
917 if (nexthop
->src
.ipv4
.s_addr
)
919 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
920 json_object_string_add(json_nexthop
, "source", buf
);
923 case NEXTHOP_TYPE_IPV6
:
924 case NEXTHOP_TYPE_IPV6_IFINDEX
:
925 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
927 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
928 json_object_string_add(json_nexthop
, "source", buf
);
935 json_object_array_add(json_nexthops
, json_nexthop
);
938 json_object_object_add(json_route
, "nexthops", json_nexthops
);
939 json_object_array_add(json
, json_route
);
943 /* Nexthop information. */
944 for (ALL_NEXTHOPS_RO(rib
->nexthop
, nexthop
, tnexthop
, recursing
))
946 if (nexthop
== rib
->nexthop
)
948 /* Prefix information. */
949 len
= vty_out (vty
, "%c", zebra_route_char (rib
->type
));
951 len
+= vty_out (vty
, "[%d]", rib
->instance
);
952 len
+= vty_out (vty
, "%c%c %s",
953 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
)
955 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
957 srcdest_rnode2str (rn
, buf
, sizeof buf
));
959 /* Distance and metric display. */
960 if (rib
->type
!= ZEBRA_ROUTE_CONNECT
961 && rib
->type
!= ZEBRA_ROUTE_KERNEL
)
962 len
+= vty_out (vty
, " [%d/%d]", rib
->distance
,
966 vty_out (vty
, " %c%*c",
967 CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
)
969 len
- 3 + (2 * recursing
), ' ');
971 switch (nexthop
->type
)
973 case NEXTHOP_TYPE_IPV4
:
974 case NEXTHOP_TYPE_IPV4_IFINDEX
:
975 vty_out (vty
, " via %s", inet_ntoa (nexthop
->gate
.ipv4
));
976 if (nexthop
->ifindex
)
977 vty_out (vty
, ", %s",
978 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
980 case NEXTHOP_TYPE_IPV6
:
981 case NEXTHOP_TYPE_IPV6_IFINDEX
:
982 vty_out (vty
, " via %s",
983 inet_ntop (AF_INET6
, &nexthop
->gate
.ipv6
, buf
, BUFSIZ
));
984 if (nexthop
->ifindex
)
985 vty_out (vty
, ", %s",
986 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
989 case NEXTHOP_TYPE_IFINDEX
:
990 vty_out (vty
, " is directly connected, %s",
991 ifindex2ifname (nexthop
->ifindex
, rib
->vrf_id
));
993 case NEXTHOP_TYPE_BLACKHOLE
:
994 vty_out (vty
, " is directly connected, Null0");
999 if (! CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
1000 vty_out (vty
, " inactive");
1002 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1003 vty_out (vty
, " onlink");
1005 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1006 vty_out (vty
, " (recursive)");
1008 switch (nexthop
->type
)
1010 case NEXTHOP_TYPE_IPV4
:
1011 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1012 if (nexthop
->src
.ipv4
.s_addr
)
1014 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
, sizeof buf
))
1015 vty_out (vty
, ", src %s", buf
);
1018 case NEXTHOP_TYPE_IPV6
:
1019 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1020 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
))
1022 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
, sizeof buf
))
1023 vty_out (vty
, ", src %s", buf
);
1030 /* Label information */
1031 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
)
1033 vty_out (vty
, " label %s",
1034 mpls_label2str (nexthop
->nh_label
->num_labels
,
1035 nexthop
->nh_label
->label
, buf
, BUFSIZ
));
1038 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_BLACKHOLE
))
1039 vty_out (vty
, ", bh");
1040 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_REJECT
))
1041 vty_out (vty
, ", rej");
1043 if (rib
->type
== ZEBRA_ROUTE_RIP
1044 || rib
->type
== ZEBRA_ROUTE_OSPF
1045 || rib
->type
== ZEBRA_ROUTE_ISIS
1046 || rib
->type
== ZEBRA_ROUTE_NHRP
1047 || rib
->type
== ZEBRA_ROUTE_TABLE
1048 || rib
->type
== ZEBRA_ROUTE_BGP
)
1053 uptime
= time (NULL
);
1054 uptime
-= rib
->uptime
;
1055 tm
= gmtime (&uptime
);
1057 if (uptime
< ONE_DAY_SECOND
)
1058 vty_out (vty
, ", %02d:%02d:%02d",
1059 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
1060 else if (uptime
< ONE_WEEK_SECOND
)
1061 vty_out (vty
, ", %dd%02dh%02dm",
1062 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
1064 vty_out (vty
, ", %02dw%dd%02dh",
1066 tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
1068 vty_out (vty
, "%s", VTY_NEWLINE
);
1072 DEFUN (show_ip_route
,
1074 "show ip route [json]",
1077 "IP routing table\n"
1080 return do_show_ip_route (vty
, VRF_DEFAULT_NAME
, SAFI_UNICAST
, use_json(argc
, argv
));
1084 do_show_ip_route (struct vty
*vty
, const char *vrf_name
, safi_t safi
,
1087 struct route_table
*table
;
1088 struct route_node
*rn
;
1091 struct zebra_vrf
*zvrf
= NULL
;
1093 json_object
*json
= NULL
;
1094 json_object
*json_prefix
= NULL
;
1096 if (!(zvrf
= zebra_vrf_lookup_by_name (vrf_name
)))
1099 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1101 vty_out (vty
, "vrf %s not defined%s", vrf_name
, VTY_NEWLINE
);
1105 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
1108 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1110 vty_out (vty
, "vrf %s inactive%s", vrf_name
, VTY_NEWLINE
);
1114 table
= zebra_vrf_table (AFI_IP
, safi
, zvrf_id (zvrf
));
1118 vty_out (vty
, "{}%s", VTY_NEWLINE
);
1124 json
= json_object_new_object();
1126 /* Show all IPv4 routes. */
1127 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1129 RNODE_FOREACH_RIB (rn
, rib
)
1132 json_prefix
= json_object_new_array();
1133 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
1138 prefix2str (&rn
->p
, buf
, sizeof buf
);
1139 json_object_object_add(json
, buf
, json_prefix
);
1144 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
1145 json_object_free(json
);
1149 /* Show all IPv4 routes. */
1150 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1152 RNODE_FOREACH_RIB (rn
, rib
)
1156 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1159 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1167 DEFUN (show_ip_route_vrf
,
1168 show_ip_route_vrf_cmd
,
1169 "show ip route vrf NAME [json]",
1172 "IP routing table\n"
1177 u_char uj
= use_json(argc
, argv
);
1179 return do_show_ip_route (vty
, argv
[idx_vrf
]->arg
, SAFI_UNICAST
, uj
);
1184 "show ip nht [vrf NAME]",
1187 "IP nexthop tracking table\n"
1191 vrf_id_t vrf_id
= VRF_DEFAULT
;
1194 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1196 zebra_print_rnh_table(vrf_id
, AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1201 DEFUN (show_ip_nht_vrf_all
,
1202 show_ip_nht_vrf_all_cmd
,
1203 "show ip nht vrf all",
1206 "IP nexthop tracking table\n"
1207 VRF_ALL_CMD_HELP_STR
)
1210 struct zebra_vrf
*zvrf
;
1212 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1213 if ((zvrf
= vrf
->info
) != NULL
)
1215 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1216 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1222 DEFUN (show_ipv6_nht
,
1224 "show ipv6 nht [vrf NAME]",
1227 "IPv6 nexthop tracking table\n"
1231 vrf_id_t vrf_id
= VRF_DEFAULT
;
1234 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
1236 zebra_print_rnh_table(vrf_id
, AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1241 DEFUN (show_ipv6_nht_vrf_all
,
1242 show_ipv6_nht_vrf_all_cmd
,
1243 "show ipv6 nht vrf all",
1246 "IPv6 nexthop tracking table\n"
1247 VRF_ALL_CMD_HELP_STR
)
1250 struct zebra_vrf
*zvrf
;
1252 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1253 if ((zvrf
= vrf
->info
) != NULL
)
1255 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1256 zebra_print_rnh_table(zvrf_id (zvrf
), AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1262 DEFUN (ip_nht_default_route
,
1263 ip_nht_default_route_cmd
,
1264 "ip nht resolve-via-default",
1266 "Filter Next Hop tracking route resolution\n"
1267 "Resolve via default route\n")
1269 if (zebra_rnh_ip_default_route
)
1272 zebra_rnh_ip_default_route
= 1;
1273 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1277 DEFUN (no_ip_nht_default_route
,
1278 no_ip_nht_default_route_cmd
,
1279 "no ip nht resolve-via-default",
1282 "Filter Next Hop tracking route resolution\n"
1283 "Resolve via default route\n")
1285 if (!zebra_rnh_ip_default_route
)
1288 zebra_rnh_ip_default_route
= 0;
1289 zebra_evaluate_rnh(0, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1293 DEFUN (ipv6_nht_default_route
,
1294 ipv6_nht_default_route_cmd
,
1295 "ipv6 nht resolve-via-default",
1297 "Filter Next Hop tracking route resolution\n"
1298 "Resolve via default route\n")
1300 if (zebra_rnh_ipv6_default_route
)
1303 zebra_rnh_ipv6_default_route
= 1;
1304 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1308 DEFUN (no_ipv6_nht_default_route
,
1309 no_ipv6_nht_default_route_cmd
,
1310 "no ipv6 nht resolve-via-default",
1313 "Filter Next Hop tracking route resolution\n"
1314 "Resolve via default route\n")
1316 if (!zebra_rnh_ipv6_default_route
)
1319 zebra_rnh_ipv6_default_route
= 0;
1320 zebra_evaluate_rnh(0, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1324 DEFUN (show_ip_route_tag
,
1325 show_ip_route_tag_cmd
,
1326 "show ip route [vrf NAME] tag (1-4294967295)",
1329 "IP routing table\n"
1331 "Show only routes with tag\n"
1337 struct route_table
*table
;
1338 struct route_node
*rn
;
1341 route_tag_t tag
= 0;
1342 vrf_id_t vrf_id
= VRF_DEFAULT
;
1344 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
1346 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
1347 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1352 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
1355 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1359 /* Show all IPv4 routes with matching tag value. */
1360 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1361 RNODE_FOREACH_RIB (rn
, rib
)
1363 if (rib
->tag
!= tag
)
1368 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1371 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1376 DEFUN (show_ip_route_prefix_longer
,
1377 show_ip_route_prefix_longer_cmd
,
1378 "show ip route [vrf NAME] A.B.C.D/M longer-prefixes",
1381 "IP routing table\n"
1383 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1384 "Show route matching the specified Network/Mask pair only\n")
1386 struct route_table
*table
;
1387 struct route_node
*rn
;
1392 vrf_id_t vrf_id
= VRF_DEFAULT
;
1394 if (strmatch(argv
[3]->text
, "vrf"))
1396 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1397 ret
= str2prefix (argv
[5]->arg
, &p
);
1401 ret
= str2prefix (argv
[3]->arg
, &p
);
1406 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1410 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1414 /* Show matched type IPv4 routes. */
1415 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1416 RNODE_FOREACH_RIB (rn
, rib
)
1417 if (prefix_match (&p
, &rn
->p
))
1421 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1424 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1429 DEFUN (show_ip_route_supernets
,
1430 show_ip_route_supernets_cmd
,
1431 "show ip route [vrf NAME] supernets-only",
1434 "IP routing table\n"
1436 "Show supernet entries only\n")
1438 struct route_table
*table
;
1439 struct route_node
*rn
;
1443 vrf_id_t vrf_id
= VRF_DEFAULT
;
1445 if (strmatch(argv
[3]->text
, "vrf"))
1446 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1448 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1452 /* Show matched type IPv4 routes. */
1453 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1454 RNODE_FOREACH_RIB (rn
, rib
)
1456 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
1458 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
1459 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
1460 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
1464 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1467 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1473 DEFUN (show_ip_route_protocol
,
1474 show_ip_route_protocol_cmd
,
1475 "show ip route [vrf NAME] " FRR_IP_REDIST_STR_ZEBRA
,
1478 "IP routing table\n"
1480 FRR_IP_REDIST_HELP_STR_ZEBRA
)
1483 struct route_table
*table
;
1484 struct route_node
*rn
;
1487 vrf_id_t vrf_id
= VRF_DEFAULT
;
1490 if (argv_find (argv
, argc
, "NAME", &idx
))
1491 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
1493 char *proto
= argv
[argc
- 1]->text
;
1494 type
= proto_redistnum (AFI_IP
, proto
);
1498 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
1502 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1506 /* Show matched type IPv4 routes. */
1507 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1508 RNODE_FOREACH_RIB (rn
, rib
)
1509 if (rib
->type
== type
)
1513 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1516 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1522 DEFUN (show_ip_route_ospf_instance
,
1523 show_ip_route_ospf_instance_cmd
,
1524 "show ip route ospf (1-65535)",
1527 "IP routing table\n"
1528 "Open Shortest Path First (OSPFv2)\n"
1532 struct route_table
*table
;
1533 struct route_node
*rn
;
1536 u_short instance
= 0;
1538 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
1540 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, VRF_DEFAULT
);
1544 /* Show matched type IPv4 routes. */
1545 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1546 RNODE_FOREACH_RIB (rn
, rib
)
1547 if (rib
->type
== ZEBRA_ROUTE_OSPF
&& rib
->instance
== instance
)
1551 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1554 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1559 DEFUN (show_ip_route_addr
,
1560 show_ip_route_addr_cmd
,
1561 "show ip route [vrf NAME] A.B.C.D",
1564 "IP routing table\n"
1566 "Network in the IP routing table to display\n")
1569 struct prefix_ipv4 p
;
1570 struct route_table
*table
;
1571 struct route_node
*rn
;
1572 vrf_id_t vrf_id
= VRF_DEFAULT
;
1574 if (strmatch(argv
[3]->text
, "vrf"))
1576 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1577 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1581 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1586 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1590 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1594 rn
= route_node_match (table
, (struct prefix
*) &p
);
1597 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1601 vty_show_ip_route_detail (vty
, rn
, 0);
1603 route_unlock_node (rn
);
1608 DEFUN (show_ip_route_prefix
,
1609 show_ip_route_prefix_cmd
,
1610 "show ip route [vrf NAME] A.B.C.D/M",
1613 "IP routing table\n"
1615 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1618 struct prefix_ipv4 p
;
1619 struct route_table
*table
;
1620 struct route_node
*rn
;
1621 vrf_id_t vrf_id
= VRF_DEFAULT
;
1623 if (strmatch(argv
[3]->text
, "vrf"))
1625 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1626 ret
= str2prefix_ipv4 (argv
[5]->arg
, &p
);
1630 ret
= str2prefix_ipv4 (argv
[3]->arg
, &p
);
1635 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
1639 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1643 rn
= route_node_match (table
, (struct prefix
*) &p
);
1644 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
1646 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
1650 vty_show_ip_route_detail (vty
, rn
, 0);
1652 route_unlock_node (rn
);
1659 vty_show_ip_route_summary (struct vty
*vty
, struct route_table
*table
)
1661 struct route_node
*rn
;
1663 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1664 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1665 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1666 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1670 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1671 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1672 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
1673 RNODE_FOREACH_RIB (rn
, rib
)
1675 is_ibgp
= (rib
->type
== ZEBRA_ROUTE_BGP
&&
1676 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
));
1678 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1680 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1682 rib_cnt
[rib
->type
]++;
1684 if (CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_SELECTED
))
1686 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1689 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1691 fib_cnt
[rib
->type
]++;
1695 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1696 "Route Source", "Routes", "FIB",
1697 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1700 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1702 if ((rib_cnt
[i
] > 0) ||
1703 (i
== ZEBRA_ROUTE_BGP
&& rib_cnt
[ZEBRA_ROUTE_IBGP
] > 0))
1705 if (i
== ZEBRA_ROUTE_BGP
)
1707 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1708 rib_cnt
[ZEBRA_ROUTE_BGP
], fib_cnt
[ZEBRA_ROUTE_BGP
],
1710 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1711 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1715 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1716 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1720 vty_out (vty
, "------%s", VTY_NEWLINE
);
1721 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1722 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1723 vty_out (vty
, "%s", VTY_NEWLINE
);
1727 * Implementation of the ip route summary prefix command.
1729 * This command prints the primary prefixes that have been installed by various
1730 * protocols on the box.
1734 vty_show_ip_route_summary_prefix (struct vty
*vty
, struct route_table
*table
)
1736 struct route_node
*rn
;
1738 struct nexthop
*nexthop
;
1739 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1740 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1741 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1742 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1746 memset (&rib_cnt
, 0, sizeof(rib_cnt
));
1747 memset (&fib_cnt
, 0, sizeof(fib_cnt
));
1748 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
1749 RNODE_FOREACH_RIB (rn
, rib
)
1753 * In case of ECMP, count only once.
1756 for (nexthop
= rib
->nexthop
; (!cnt
&& nexthop
); nexthop
= nexthop
->next
)
1759 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1760 rib_cnt
[rib
->type
]++;
1761 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1763 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1764 fib_cnt
[rib
->type
]++;
1766 if (rib
->type
== ZEBRA_ROUTE_BGP
&&
1767 CHECK_FLAG (rib
->flags
, ZEBRA_FLAG_IBGP
))
1769 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1770 if (CHECK_FLAG (nexthop
->flags
, NEXTHOP_FLAG_FIB
))
1771 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1776 vty_out (vty
, "%-20s %-20s %s (vrf %s)%s",
1777 "Route Source", "Prefix Routes", "FIB",
1778 zvrf_name (((rib_table_info_t
*)table
->info
)->zvrf
),
1781 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1785 if (i
== ZEBRA_ROUTE_BGP
)
1787 vty_out (vty
, "%-20s %-20d %-20d %s", "ebgp",
1788 rib_cnt
[ZEBRA_ROUTE_BGP
] - rib_cnt
[ZEBRA_ROUTE_IBGP
],
1789 fib_cnt
[ZEBRA_ROUTE_BGP
] - fib_cnt
[ZEBRA_ROUTE_IBGP
],
1791 vty_out (vty
, "%-20s %-20d %-20d %s", "ibgp",
1792 rib_cnt
[ZEBRA_ROUTE_IBGP
], fib_cnt
[ZEBRA_ROUTE_IBGP
],
1796 vty_out (vty
, "%-20s %-20d %-20d %s", zebra_route_string(i
),
1797 rib_cnt
[i
], fib_cnt
[i
], VTY_NEWLINE
);
1801 vty_out (vty
, "------%s", VTY_NEWLINE
);
1802 vty_out (vty
, "%-20s %-20d %-20d %s", "Totals", rib_cnt
[ZEBRA_ROUTE_TOTAL
],
1803 fib_cnt
[ZEBRA_ROUTE_TOTAL
], VTY_NEWLINE
);
1804 vty_out (vty
, "%s", VTY_NEWLINE
);
1807 /* Show route summary. */
1808 DEFUN (show_ip_route_summary
,
1809 show_ip_route_summary_cmd
,
1810 "show ip route [vrf NAME] summary",
1813 "IP routing table\n"
1815 "Summary of all routes\n")
1817 struct route_table
*table
;
1818 vrf_id_t vrf_id
= VRF_DEFAULT
;
1820 if (strmatch(argv
[3]->text
, "vrf"))
1821 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1823 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1827 vty_show_ip_route_summary (vty
, table
);
1832 /* Show route summary prefix. */
1833 DEFUN (show_ip_route_summary_prefix
,
1834 show_ip_route_summary_prefix_cmd
,
1835 "show ip route [vrf NAME] summary prefix",
1838 "IP routing table\n"
1840 "Summary of all routes\n"
1843 struct route_table
*table
;
1844 vrf_id_t vrf_id
= VRF_DEFAULT
;
1846 if (strmatch(argv
[3]->text
, "vrf"))
1847 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
1849 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
1853 vty_show_ip_route_summary_prefix (vty
, table
);
1859 DEFUN (show_ip_route_vrf_all
,
1860 show_ip_route_vrf_all_cmd
,
1861 "show ip route vrf all",
1864 "IP routing table\n"
1865 VRF_ALL_CMD_HELP_STR
)
1867 struct route_table
*table
;
1868 struct route_node
*rn
;
1871 struct zebra_vrf
*zvrf
;
1875 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1877 if ((zvrf
= vrf
->info
) == NULL
||
1878 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1881 /* Show all IPv4 routes. */
1882 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1883 RNODE_FOREACH_RIB (rn
, rib
)
1887 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1893 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1896 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1904 DEFUN (show_ip_route_vrf_all_tag
,
1905 show_ip_route_vrf_all_tag_cmd
,
1906 "show ip route vrf all tag (1-4294967295)",
1909 "IP routing table\n"
1910 VRF_ALL_CMD_HELP_STR
1911 "Show only routes with tag\n"
1915 struct route_table
*table
;
1916 struct route_node
*rn
;
1919 struct zebra_vrf
*zvrf
;
1922 route_tag_t tag
= 0;
1924 if (argv
[idx_number
]->arg
)
1925 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
1927 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1929 if ((zvrf
= vrf
->info
) == NULL
||
1930 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1933 /* Show all IPv4 routes with matching tag value. */
1934 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1935 RNODE_FOREACH_RIB (rn
, rib
)
1937 if (rib
->tag
!= tag
)
1942 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
1948 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
1951 vty_show_ip_route (vty
, rn
, rib
, NULL
);
1958 DEFUN (show_ip_route_vrf_all_prefix_longer
,
1959 show_ip_route_vrf_all_prefix_longer_cmd
,
1960 "show ip route vrf all A.B.C.D/M longer-prefixes",
1963 "IP routing table\n"
1964 VRF_ALL_CMD_HELP_STR
1965 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1966 "Show route matching the specified Network/Mask pair only\n")
1968 int idx_ipv4_prefixlen
= 5;
1969 struct route_table
*table
;
1970 struct route_node
*rn
;
1974 struct zebra_vrf
*zvrf
;
1979 ret
= str2prefix (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
1982 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1986 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1988 if ((zvrf
= vrf
->info
) == NULL
||
1989 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
1992 /* Show matched type IPv4 routes. */
1993 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
1994 RNODE_FOREACH_RIB (rn
, rib
)
1995 if (prefix_match (&p
, &rn
->p
))
1999 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2005 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2008 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2016 DEFUN (show_ip_route_vrf_all_supernets
,
2017 show_ip_route_vrf_all_supernets_cmd
,
2018 "show ip route vrf all supernets-only",
2021 "IP routing table\n"
2022 VRF_ALL_CMD_HELP_STR
2023 "Show supernet entries only\n")
2025 struct route_table
*table
;
2026 struct route_node
*rn
;
2029 struct zebra_vrf
*zvrf
;
2034 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2036 if ((zvrf
= vrf
->info
) == NULL
||
2037 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2040 /* Show matched type IPv4 routes. */
2041 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2042 RNODE_FOREACH_RIB (rn
, rib
)
2044 addr
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
2046 if ((IN_CLASSC (addr
) && rn
->p
.prefixlen
< 24)
2047 || (IN_CLASSB (addr
) && rn
->p
.prefixlen
< 16)
2048 || (IN_CLASSA (addr
) && rn
->p
.prefixlen
< 8))
2052 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2057 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2060 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2069 DEFUN (show_ip_route_vrf_all_protocol
,
2070 show_ip_route_vrf_all_protocol_cmd
,
2071 "show ip route vrf all " FRR_IP_REDIST_STR_ZEBRA
,
2074 "IP routing table\n"
2075 VRF_ALL_CMD_HELP_STR
2076 FRR_IP_REDIST_HELP_STR_ZEBRA
"\n")
2079 struct route_table
*table
;
2080 struct route_node
*rn
;
2083 struct zebra_vrf
*zvrf
;
2087 char *proto
= argv
[argc
- 1]->text
;
2088 type
= proto_redistnum (AFI_IP
, proto
);
2092 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
2096 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2098 if ((zvrf
= vrf
->info
) == NULL
||
2099 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2102 /* Show matched type IPv4 routes. */
2103 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
2104 RNODE_FOREACH_RIB (rn
, rib
)
2105 if (rib
->type
== type
)
2109 vty_out (vty
, SHOW_ROUTE_V4_HEADER
);
2115 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
2118 vty_show_ip_route (vty
, rn
, rib
, NULL
);
2126 DEFUN (show_ip_route_vrf_all_addr
,
2127 show_ip_route_vrf_all_addr_cmd
,
2128 "show ip route vrf all A.B.C.D",
2131 "IP routing table\n"
2132 VRF_ALL_CMD_HELP_STR
2133 "Network in the IP routing table to display\n")
2137 struct prefix_ipv4 p
;
2138 struct route_table
*table
;
2139 struct route_node
*rn
;
2141 struct zebra_vrf
*zvrf
;
2143 ret
= str2prefix_ipv4 (argv
[idx_ipv4
]->arg
, &p
);
2146 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2150 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2152 if ((zvrf
= vrf
->info
) == NULL
||
2153 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2156 rn
= route_node_match (table
, (struct prefix
*) &p
);
2160 vty_show_ip_route_detail (vty
, rn
, 0);
2162 route_unlock_node (rn
);
2168 DEFUN (show_ip_route_vrf_all_prefix
,
2169 show_ip_route_vrf_all_prefix_cmd
,
2170 "show ip route vrf all A.B.C.D/M",
2173 "IP routing table\n"
2174 VRF_ALL_CMD_HELP_STR
2175 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2177 int idx_ipv4_prefixlen
= 5;
2179 struct prefix_ipv4 p
;
2180 struct route_table
*table
;
2181 struct route_node
*rn
;
2183 struct zebra_vrf
*zvrf
;
2185 ret
= str2prefix_ipv4 (argv
[idx_ipv4_prefixlen
]->arg
, &p
);
2188 vty_out (vty
, "%% Malformed IPv4 address%s", VTY_NEWLINE
);
2192 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2194 if ((zvrf
= vrf
->info
) == NULL
||
2195 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
2198 rn
= route_node_match (table
, (struct prefix
*) &p
);
2201 if (rn
->p
.prefixlen
!= p
.prefixlen
)
2203 route_unlock_node (rn
);
2207 vty_show_ip_route_detail (vty
, rn
, 0);
2209 route_unlock_node (rn
);
2215 DEFUN (show_ip_route_vrf_all_summary
,
2216 show_ip_route_vrf_all_summary_cmd
,
2217 "show ip route vrf all summary ",
2220 "IP routing table\n"
2221 VRF_ALL_CMD_HELP_STR
2222 "Summary of all routes\n")
2225 struct zebra_vrf
*zvrf
;
2227 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2228 if ((zvrf
= vrf
->info
) != NULL
)
2229 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2234 DEFUN (show_ip_route_vrf_all_summary_prefix
,
2235 show_ip_route_vrf_all_summary_prefix_cmd
,
2236 "show ip route vrf all summary prefix",
2239 "IP routing table\n"
2240 VRF_ALL_CMD_HELP_STR
2241 "Summary of all routes\n"
2245 struct zebra_vrf
*zvrf
;
2247 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2248 if ((zvrf
= vrf
->info
) != NULL
)
2249 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP
][SAFI_UNICAST
]);
2254 /* Write IPv4 static route configuration. */
2256 static_config_ipv4 (struct vty
*vty
, safi_t safi
, const char *cmd
)
2258 struct route_node
*rn
;
2259 struct static_route
*si
;
2260 struct route_table
*stable
;
2262 struct zebra_vrf
*zvrf
;
2266 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
2268 if (!(zvrf
= vrf
->info
))
2270 if ((stable
= zvrf
->stable
[AFI_IP
][safi
]) == NULL
)
2273 for (rn
= route_top (stable
); rn
; rn
= route_next (rn
))
2274 for (si
= rn
->info
; si
; si
= si
->next
)
2276 vty_out (vty
, "%s %s", cmd
, prefix2str (&rn
->p
, buf
, sizeof buf
));
2280 case STATIC_IPV4_GATEWAY
:
2281 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
2283 case STATIC_IFINDEX
:
2284 vty_out (vty
, " %s", si
->ifname
);
2286 case STATIC_BLACKHOLE
:
2287 vty_out (vty
, " Null0");
2289 case STATIC_IPV6_GATEWAY
:
2290 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
2292 case STATIC_IPV6_GATEWAY_IFINDEX
:
2293 vty_out (vty
, " %s %s",
2294 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
2295 ifindex2ifname (si
->ifindex
, si
->vrf_id
));
2299 /* flags are incompatible with STATIC_BLACKHOLE */
2300 if (si
->type
!= STATIC_BLACKHOLE
)
2302 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
2303 vty_out (vty
, " %s", "reject");
2305 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
2306 vty_out (vty
, " %s", "blackhole");
2310 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
2312 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
2313 vty_out (vty
, " %d", si
->distance
);
2315 if (si
->vrf_id
!= VRF_DEFAULT
)
2316 vty_out (vty
, " vrf %s", zvrf
? zvrf_name (zvrf
) : "");
2318 /* Label information */
2319 if (si
->snh_label
.num_labels
)
2320 vty_out (vty
, " label %s",
2321 mpls_label2str (si
->snh_label
.num_labels
,
2322 si
->snh_label
.label
, buf
, sizeof buf
));
2324 vty_out (vty
, "%s", VTY_NEWLINE
);
2332 /* General fucntion for IPv6 static route. */
2334 static_ipv6_func (struct vty
*vty
, int add_cmd
, const char *dest_str
,
2335 const char *src_str
,
2336 const char *gate_str
, const char *ifname
,
2337 const char *flag_str
, const char *tag_str
,
2338 const char *distance_str
, const char *vrf_id_str
,
2339 const char *label_str
)
2343 struct prefix p
, src
;
2344 struct prefix_ipv6
*src_p
= NULL
;
2345 struct in6_addr
*gate
= NULL
;
2346 struct in6_addr gate_addr
;
2347 u_char type
= STATIC_BLACKHOLE
;
2349 route_tag_t tag
= 0;
2350 unsigned int ifindex
= 0;
2351 struct interface
*ifp
= NULL
;
2352 struct zebra_vrf
*zvrf
;
2353 struct static_nh_label snh_label
;
2355 ret
= str2prefix (dest_str
, &p
);
2358 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2364 ret
= str2prefix (src_str
, &src
);
2365 if (ret
<= 0 || src
.family
!= AF_INET6
)
2367 vty_out (vty
, "%% Malformed source address%s", VTY_NEWLINE
);
2370 src_p
= (struct prefix_ipv6
*)&src
;
2373 /* Apply mask for given prefix. */
2376 /* Administrative distance. */
2378 distance
= atoi (distance_str
);
2380 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
2384 VTY_GET_INTEGER_RANGE("tag", tag
, tag_str
, 0, 4294967295);
2386 /* When gateway is valid IPv6 addrees, then gate is treated as
2387 nexthop address other case gate is treated as interface name. */
2388 ret
= inet_pton (AF_INET6
, gate_str
, &gate_addr
);
2391 zvrf
= zebra_vrf_lookup_by_name (vrf_id_str
);
2395 vty_out (vty
, "%% vrf %s is not defined%s", vrf_id_str
, VTY_NEWLINE
);
2400 memset (&snh_label
, 0, sizeof (struct static_nh_label
));
2405 vty_out (vty
, "%% MPLS not turned on in kernel, ignoring command%s",
2409 if (mpls_str2label (label_str
, &snh_label
.num_labels
,
2412 vty_out (vty
, "%% Malformed label(s)%s", VTY_NEWLINE
);
2417 /* Null0 static route. */
2418 if ((gate_str
!= NULL
) && (strncasecmp (gate_str
, "Null0", strlen (gate_str
)) == 0))
2422 vty_out (vty
, "%% can not have flag %s with Null0%s", flag_str
, VTY_NEWLINE
);
2426 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, NULL
, ifindex
, ifname
,
2427 ZEBRA_FLAG_BLACKHOLE
, tag
, distance
, zvrf
, &snh_label
);
2429 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, NULL
, NULL
, ifindex
, tag
,
2430 distance
, zvrf
, &snh_label
);
2436 switch(flag_str
[0]) {
2439 SET_FLAG (flag
, ZEBRA_FLAG_REJECT
);
2443 SET_FLAG (flag
, ZEBRA_FLAG_BLACKHOLE
);
2446 vty_out (vty
, "%% Malformed flag %s %s", flag_str
, VTY_NEWLINE
);
2453 /* When ifname is specified. It must be come with gateway
2457 vty_out (vty
, "%% Malformed address%s", VTY_NEWLINE
);
2460 type
= STATIC_IPV6_GATEWAY_IFINDEX
;
2462 ifp
= if_lookup_by_name (ifname
, zvrf_id (zvrf
));
2465 vty_out (vty
, "%% Malformed Interface name %s%s", ifname
, VTY_NEWLINE
);
2468 ifindex
= ifp
->ifindex
;
2474 type
= STATIC_IPV6_GATEWAY
;
2479 type
= STATIC_IFINDEX
;
2480 ifp
= if_lookup_by_name (gate_str
, zvrf_id (zvrf
));
2483 vty_out (vty
, "%% Malformed Interface name %s%s", gate_str
, VTY_NEWLINE
);
2484 ifindex
= IFINDEX_DELETED
;
2487 ifindex
= ifp
->ifindex
;
2493 static_add_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, src_p
, (union g_addr
*)gate
,
2494 ifindex
, ifname
, flag
, tag
, distance
, zvrf
, &snh_label
);
2496 static_delete_route (AFI_IP6
, SAFI_UNICAST
, type
, &p
, src_p
, (union g_addr
*)gate
,
2497 ifindex
, tag
, distance
, zvrf
, &snh_label
);
2504 "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]",
2506 "Establish static routes\n"
2507 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2508 "IPv6 source-dest route\n"
2509 "IPv6 source prefix\n"
2510 "IPv6 gateway address\n"
2511 "IPv6 gateway interface name\n"
2514 "Set tag for this route\n"
2516 "Distance value for this prefix\n"
2518 "Specify labels for this route\n"
2519 "One or more labels separated by '/'\n")
2521 int idx_ipv6_prefixlen
= 2;
2522 int idx_ipv6_ifname
;
2524 char *src
, *tag
, *distance
, *vrf
;
2526 if (!strcmp(argv
[3]->text
, "from"))
2529 idx_ipv6_ifname
= 5;
2535 idx_ipv6_ifname
= 3;
2539 tag
= distance
= vrf
= NULL
;
2540 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2542 return static_ipv6_func (vty
, 1,
2543 argv
[idx_ipv6_prefixlen
]->arg
,
2545 argv
[idx_ipv6_ifname
]->arg
,
2547 tag
, distance
, vrf
, NULL
);
2550 DEFUN (ipv6_route_flags
,
2551 ipv6_route_flags_cmd
,
2552 "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]",
2554 "Establish static routes\n"
2555 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2556 "IPv6 source-dest route\n"
2557 "IPv6 source prefix\n"
2558 "IPv6 gateway address\n"
2559 "IPv6 gateway interface name\n"
2560 "Emit an ICMP unreachable when matched\n"
2561 "Silently discard pkts when matched\n"
2562 "Silently discard pkts when matched\n"
2563 "Set tag for this route\n"
2565 "Distance value for this prefix\n"
2567 "Specify labels for this route\n"
2568 "One or more labels separated by '/'\n")
2570 int idx_ipv6_prefixlen
= 2;
2571 int idx_ipv6_ifname
;
2572 int idx_reject_blackhole
;
2574 char *src
, *tag
, *distance
, *vrf
;
2576 if (!strcmp(argv
[3]->text
, "from"))
2579 idx_ipv6_ifname
= 5;
2580 idx_reject_blackhole
= 6;
2586 idx_ipv6_ifname
= 3;
2587 idx_reject_blackhole
= 4;
2591 tag
= distance
= vrf
= NULL
;
2592 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2594 return static_ipv6_func (vty
, 1,
2595 argv
[idx_ipv6_prefixlen
]->arg
,
2597 argv
[idx_ipv6_ifname
]->arg
,
2599 argv
[idx_reject_blackhole
]->arg
,
2600 tag
, distance
, vrf
, NULL
);
2603 DEFUN (ipv6_route_ifname
,
2604 ipv6_route_ifname_cmd
,
2605 "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]",
2607 "Establish static routes\n"
2608 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2609 "IPv6 source-dest route\n"
2610 "IPv6 source prefix\n"
2611 "IPv6 gateway address\n"
2612 "IPv6 gateway interface name\n"
2613 "Set tag for this route\n"
2615 "Distance value for this prefix\n"
2617 "Specify labels for this route\n"
2618 "One or more labels separated by '/'\n")
2620 int idx_ipv6_prefixlen
= 2;
2622 int idx_interface
= 4;
2624 char *src
, *tag
, *distance
, *vrf
;
2626 if (!strcmp(argv
[3]->text
, "from"))
2641 tag
= distance
= vrf
= NULL
;
2642 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2644 return static_ipv6_func (vty
, 1,
2645 argv
[idx_ipv6_prefixlen
]->arg
,
2647 argv
[idx_ipv6
]->arg
,
2648 argv
[idx_interface
]->arg
,
2650 tag
, distance
, vrf
, NULL
);
2653 DEFUN (ipv6_route_ifname_flags
,
2654 ipv6_route_ifname_flags_cmd
,
2655 "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]",
2657 "Establish static routes\n"
2658 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2659 "IPv6 source-dest route\n"
2660 "IPv6 source prefix\n"
2661 "IPv6 gateway address\n"
2662 "IPv6 gateway interface name\n"
2663 "Emit an ICMP unreachable when matched\n"
2664 "Silently discard pkts when matched\n"
2665 "Set tag for this route\n"
2667 "Distance value for this prefix\n"
2669 "Specify labels for this route\n"
2670 "One or more labels separated by '/'\n")
2672 int idx_ipv6_prefixlen
= 2;
2675 int idx_reject_blackhole
;
2677 char *src
, *tag
, *distance
, *vrf
;
2679 if (!strcmp(argv
[3]->text
, "from"))
2684 idx_reject_blackhole
= 7;
2692 idx_reject_blackhole
= 5;
2696 tag
= distance
= vrf
= NULL
;
2697 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2699 return static_ipv6_func (vty
, 1,
2700 argv
[idx_ipv6_prefixlen
]->arg
,
2702 argv
[idx_ipv6
]->arg
,
2703 argv
[idx_interface
]->arg
,
2704 argv
[idx_reject_blackhole
]->arg
,
2705 tag
, distance
, vrf
, NULL
);
2708 DEFUN (no_ipv6_route
,
2710 "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]",
2713 "Establish static routes\n"
2714 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2715 "IPv6 source-dest route\n"
2716 "IPv6 source prefix\n"
2717 "IPv6 gateway address\n"
2718 "IPv6 gateway interface name\n"
2720 "Set tag for this route\n"
2722 "Distance value for this prefix\n"
2724 "Specify labels for this route\n"
2725 "One or more labels separated by '/'\n")
2727 int idx_ipv6_prefixlen
= 3;
2728 int idx_ipv6_ifname
;
2730 char *src
, *tag
, *distance
, *vrf
;
2732 if (!strcmp(argv
[4]->text
, "from"))
2735 idx_ipv6_ifname
= 6;
2741 idx_ipv6_ifname
= 4;
2745 tag
= distance
= vrf
= NULL
;
2746 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2748 return static_ipv6_func (vty
, 0,
2749 argv
[idx_ipv6_prefixlen
]->arg
,
2751 argv
[idx_ipv6_ifname
]->arg
,
2753 tag
, distance
, vrf
, NULL
);
2756 DEFUN (no_ipv6_route_flags
,
2757 no_ipv6_route_flags_cmd
,
2758 "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]",
2761 "Establish static routes\n"
2762 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2763 "IPv6 source-dest route\n"
2764 "IPv6 source prefix\n"
2765 "IPv6 gateway address\n"
2766 "IPv6 gateway interface name\n"
2767 "Emit an ICMP unreachable when matched\n"
2768 "Silently discard pkts when matched\n"
2769 "Set tag for this route\n"
2771 "Distance value for this prefix\n"
2773 "Specify labels for this route\n"
2774 "One or more labels separated by '/'\n")
2776 int idx_ipv6_prefixlen
= 3;
2777 int idx_ipv6_ifname
;
2778 int idx_reject_blackhole
;
2780 char *src
, *tag
, *distance
, *vrf
;
2782 if (!strcmp(argv
[4]->text
, "from"))
2785 idx_ipv6_ifname
= 6;
2786 idx_reject_blackhole
= 7;
2792 idx_ipv6_ifname
= 4;
2793 idx_reject_blackhole
= 5;
2797 tag
= distance
= vrf
= NULL
;
2798 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2800 return static_ipv6_func (vty
, 0,
2801 argv
[idx_ipv6_prefixlen
]->arg
,
2803 argv
[idx_ipv6_ifname
]->arg
,
2805 argv
[idx_reject_blackhole
]->arg
,
2806 tag
, distance
, vrf
, NULL
);
2809 DEFUN (no_ipv6_route_ifname
,
2810 no_ipv6_route_ifname_cmd
,
2811 "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]",
2814 "Establish static routes\n"
2815 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2816 "IPv6 source-dest route\n"
2817 "IPv6 source prefix\n"
2818 "IPv6 gateway address\n"
2819 "IPv6 gateway interface name\n"
2820 "Set tag for this route\n"
2822 "Distance value for this prefix\n"
2824 "Specify labels for this route\n"
2825 "One or more labels separated by '/'\n")
2827 int idx_ipv6_prefixlen
= 3;
2831 char *src
, *tag
, *distance
, *vrf
;
2833 if (!strcmp(argv
[4]->text
, "from"))
2848 tag
= distance
= vrf
= NULL
;
2849 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2851 return static_ipv6_func (vty
, 0,
2852 argv
[idx_ipv6_prefixlen
]->arg
,
2854 argv
[idx_ipv6
]->arg
,
2855 argv
[idx_interface
]->arg
,
2857 tag
, distance
, vrf
, NULL
);
2860 DEFUN (no_ipv6_route_ifname_flags
,
2861 no_ipv6_route_ifname_flags_cmd
,
2862 "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]",
2865 "Establish static routes\n"
2866 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2867 "IPv6 source-dest route\n"
2868 "IPv6 source prefix\n"
2869 "IPv6 gateway address\n"
2870 "IPv6 gateway interface name\n"
2871 "Emit an ICMP unreachable when matched\n"
2872 "Silently discard pkts when matched\n"
2873 "Set tag for this route\n"
2875 "Distance value for this prefix\n"
2877 "Specify labels for this route\n"
2878 "One or more labels separated by '/'\n")
2880 int idx_ipv6_prefixlen
= 3;
2883 int idx_reject_blackhole
;
2885 char *src
, *tag
, *distance
, *vrf
;
2887 if (!strcmp(argv
[4]->text
, "from"))
2892 idx_reject_blackhole
= 8;
2900 idx_reject_blackhole
= 6;
2904 tag
= distance
= vrf
= NULL
;
2905 zebra_vty_ip_route_tdv_helper (argc
, argv
, idx_curr
, &tag
, &distance
, &vrf
, NULL
);
2907 return static_ipv6_func (vty
, 0,
2908 argv
[idx_ipv6_prefixlen
]->arg
,
2910 argv
[idx_ipv6
]->arg
,
2911 argv
[idx_interface
]->arg
,
2912 argv
[idx_reject_blackhole
]->arg
,
2913 tag
, distance
, vrf
, NULL
);
2916 DEFUN (show_ipv6_route
,
2917 show_ipv6_route_cmd
,
2918 "show ipv6 route [vrf NAME] [json]",
2921 "IPv6 routing table\n"
2925 struct route_table
*table
;
2926 struct route_node
*rn
;
2929 vrf_id_t vrf_id
= VRF_DEFAULT
;
2930 struct zebra_vrf
*zvrf
= NULL
;
2931 char buf
[SRCDEST2STR_BUFFER
];
2932 json_object
*json
= NULL
;
2933 json_object
*json_prefix
= NULL
;
2935 int vrf
= (argc
> 3 && strmatch (argv
[3]->text
, "vrf"));
2936 int uj
= vrf
? argc
== 6 : argc
== 4;
2937 char *vrfname
= vrf
? argv
[4]->arg
: NULL
;
2941 if (!(zvrf
= zebra_vrf_lookup_by_name (vrfname
)))
2944 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2946 vty_out (vty
, "vrf %s not defined%s", vrfname
, VTY_NEWLINE
);
2950 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
2953 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2955 vty_out (vty
, "vrf %s inactive%s", vrfname
, VTY_NEWLINE
);
2959 vrf_id
= zvrf_id (zvrf
);
2962 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
2966 vty_out (vty
, "{}%s", VTY_NEWLINE
);
2972 json
= json_object_new_object();
2974 /* Show all IPv6 route. */
2975 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
2977 RNODE_FOREACH_RIB (rn
, rib
)
2980 json_prefix
= json_object_new_array();
2981 vty_show_ip_route (vty
, rn
, rib
, json_prefix
);
2986 srcdest_rnode2str (rn
, buf
, sizeof buf
);
2987 json_object_object_add(json
, buf
, json_prefix
);
2992 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
2993 json_object_free(json
);
2997 /* Show all IPv6 route. */
2998 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3000 RNODE_FOREACH_RIB (rn
, rib
)
3004 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3007 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3015 DEFUN (show_ipv6_route_tag
,
3016 show_ipv6_route_tag_cmd
,
3017 "show ipv6 route [vrf NAME] tag (1-4294967295)",
3020 "IPv6 routing table\n"
3022 "Show only routes with tag\n"
3028 struct route_table
*table
;
3029 struct route_node
*rn
;
3032 route_tag_t tag
= 0;
3033 vrf_id_t vrf_id
= VRF_DEFAULT
;
3035 if (strmatch(argv
[idx_vrf
]->text
, "vrf"))
3037 VRF_GET_ID (vrf_id
, argv
[idx_name
]->arg
);
3038 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
3043 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_tag
]->arg
, 0, 4294967295);
3046 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3050 /* Show all IPv6 routes with matching tag value. */
3051 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3052 RNODE_FOREACH_RIB (rn
, rib
)
3054 if (rib
->tag
!= tag
)
3059 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3062 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3067 DEFUN (show_ipv6_route_prefix_longer
,
3068 show_ipv6_route_prefix_longer_cmd
,
3069 "show ipv6 route [vrf NAME] X:X::X:X/M longer-prefixes",
3072 "IPv6 routing table\n"
3075 "Show route matching the specified Network/Mask pair only\n")
3077 struct route_table
*table
;
3078 struct route_node
*rn
;
3083 vrf_id_t vrf_id
= VRF_DEFAULT
;
3085 if (strmatch(argv
[3]->text
, "vrf"))
3087 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3088 ret
= str2prefix (argv
[5]->arg
, &p
);
3092 ret
= str2prefix (argv
[3]->arg
, &p
);
3097 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3101 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3105 /* Show matched type IPv6 routes. */
3106 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3107 RNODE_FOREACH_RIB (rn
, rib
)
3109 struct prefix
*p
, *src_p
;
3110 srcdest_rnode_prefixes(rn
, &p
, &src_p
);
3112 if (prefix_match (p
, &rn
->p
))
3116 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3119 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3125 DEFUN (show_ipv6_route_protocol
,
3126 show_ipv6_route_protocol_cmd
,
3127 "show ipv6 route [vrf NAME] " FRR_IP6_REDIST_STR_ZEBRA
,
3130 "IP routing table\n"
3132 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3135 struct route_table
*table
;
3136 struct route_node
*rn
;
3139 vrf_id_t vrf_id
= VRF_DEFAULT
;
3142 if (argv_find (argv
, argc
, "NAME", &idx
))
3143 VRF_GET_ID (vrf_id
, argv
[idx
]->arg
);
3145 char *proto
= argv
[argc
- 1]->text
;
3146 type
= proto_redistnum (AFI_IP
, proto
);
3150 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3154 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3158 /* Show matched type IPv6 routes. */
3159 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3160 RNODE_FOREACH_RIB (rn
, rib
)
3161 if (rib
->type
== type
)
3165 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3168 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3173 DEFUN (show_ipv6_route_addr
,
3174 show_ipv6_route_addr_cmd
,
3175 "show ipv6 route [vrf NAME] X:X::X:X",
3178 "IPv6 routing table\n"
3183 struct prefix_ipv6 p
;
3184 struct route_table
*table
;
3185 struct route_node
*rn
;
3186 vrf_id_t vrf_id
= VRF_DEFAULT
;
3188 if (strmatch(argv
[3]->text
, "vrf"))
3190 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3191 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3195 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3200 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3204 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3208 rn
= route_node_match (table
, (struct prefix
*) &p
);
3211 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3215 vty_show_ip_route_detail (vty
, rn
, 0);
3217 route_unlock_node (rn
);
3222 DEFUN (show_ipv6_route_prefix
,
3223 show_ipv6_route_prefix_cmd
,
3224 "show ipv6 route [vrf NAME] X:X::X:X/M",
3227 "IPv6 routing table\n"
3232 struct prefix_ipv6 p
;
3233 struct route_table
*table
;
3234 struct route_node
*rn
;
3235 vrf_id_t vrf_id
= VRF_DEFAULT
;
3237 if (strmatch(argv
[3]->text
, "vrf"))
3239 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3240 ret
= str2prefix_ipv6 (argv
[5]->arg
, &p
);
3243 ret
= str2prefix_ipv6 (argv
[3]->arg
, &p
);
3247 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3251 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3255 rn
= route_node_match (table
, (struct prefix
*) &p
);
3256 if (! rn
|| rn
->p
.prefixlen
!= p
.prefixlen
)
3258 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
3262 vty_show_ip_route_detail (vty
, rn
, 0);
3264 route_unlock_node (rn
);
3270 /* Show route summary. */
3271 DEFUN (show_ipv6_route_summary
,
3272 show_ipv6_route_summary_cmd
,
3273 "show ipv6 route [vrf NAME] summary",
3276 "IPv6 routing table\n"
3278 "Summary of all IPv6 routes\n")
3280 struct route_table
*table
;
3281 vrf_id_t vrf_id
= VRF_DEFAULT
;
3283 if (strmatch(argv
[3]->text
, "vrf"))
3284 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3286 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3290 vty_show_ip_route_summary (vty
, table
);
3296 /* Show ipv6 route summary prefix. */
3297 DEFUN (show_ipv6_route_summary_prefix
,
3298 show_ipv6_route_summary_prefix_cmd
,
3299 "show ipv6 route [vrf NAME] summary prefix",
3302 "IPv6 routing table\n"
3304 "Summary of all IPv6 routes\n"
3307 struct route_table
*table
;
3308 vrf_id_t vrf_id
= VRF_DEFAULT
;
3310 if (strmatch(argv
[3]->text
, "vrf"))
3311 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3313 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
3317 vty_show_ip_route_summary_prefix (vty
, table
);
3324 * Show IPv6 mroute command.Used to dump
3325 * the Multicast routing table.
3327 DEFUN (show_ipv6_mroute
,
3328 show_ipv6_mroute_cmd
,
3329 "show ipv6 mroute [vrf NAME]",
3332 "IPv6 Multicast routing table\n"
3335 struct route_table
*table
;
3336 struct route_node
*rn
;
3339 vrf_id_t vrf_id
= VRF_DEFAULT
;
3341 if (strmatch(argv
[3]->text
, "vrf"))
3342 VRF_GET_ID (vrf_id
, argv
[4]->arg
);
3344 table
= zebra_vrf_table (AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
3348 /* Show all IPv6 route. */
3349 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3350 RNODE_FOREACH_RIB (rn
, rib
)
3354 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3357 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3363 DEFUN (show_ipv6_route_vrf_all
,
3364 show_ipv6_route_vrf_all_cmd
,
3365 "show ipv6 route vrf all",
3368 "IPv6 routing table\n"
3369 VRF_ALL_CMD_HELP_STR
)
3371 struct route_table
*table
;
3372 struct route_node
*rn
;
3375 struct zebra_vrf
*zvrf
;
3379 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3381 if ((zvrf
= vrf
->info
) == NULL
||
3382 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3385 /* Show all IPv6 route. */
3386 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3387 RNODE_FOREACH_RIB (rn
, rib
)
3391 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3397 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3400 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3408 DEFUN (show_ipv6_route_vrf_all_tag
,
3409 show_ipv6_route_vrf_all_tag_cmd
,
3410 "show ipv6 route vrf all tag (1-4294967295)",
3413 "IPv6 routing table\n"
3414 VRF_ALL_CMD_HELP_STR
3415 "Show only routes with tag\n"
3419 struct route_table
*table
;
3420 struct route_node
*rn
;
3423 struct zebra_vrf
*zvrf
;
3426 route_tag_t tag
= 0;
3428 if (argv
[idx_number
]->arg
)
3429 VTY_GET_INTEGER_RANGE("tag", tag
, argv
[idx_number
]->arg
, 0, 4294967295);
3431 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3433 if ((zvrf
= vrf
->info
) == NULL
||
3434 (table
= zvrf
->table
[AFI_IP
][SAFI_UNICAST
]) == NULL
)
3437 /* Show all IPv6 routes with matching tag value. */
3438 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3439 RNODE_FOREACH_RIB (rn
, rib
)
3441 if (rib
->tag
!= tag
)
3446 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3452 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3455 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3463 DEFUN (show_ipv6_route_vrf_all_prefix_longer
,
3464 show_ipv6_route_vrf_all_prefix_longer_cmd
,
3465 "show ipv6 route vrf all X:X::X:X/M longer-prefixes",
3468 "IPv6 routing table\n"
3469 VRF_ALL_CMD_HELP_STR
3471 "Show route matching the specified Network/Mask pair only\n")
3473 int idx_ipv6_prefixlen
= 5;
3474 struct route_table
*table
;
3475 struct route_node
*rn
;
3479 struct zebra_vrf
*zvrf
;
3484 ret
= str2prefix (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3487 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
3491 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3493 if ((zvrf
= vrf
->info
) == NULL
||
3494 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3497 /* Show matched type IPv6 routes. */
3498 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3499 RNODE_FOREACH_RIB (rn
, rib
)
3501 struct prefix
*p
, *src_p
;
3502 srcdest_rnode_prefixes(rn
, &p
, &src_p
);
3503 if (prefix_match (p
, &rn
->p
))
3507 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3513 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3516 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3525 DEFUN (show_ipv6_route_vrf_all_protocol
,
3526 show_ipv6_route_vrf_all_protocol_cmd
,
3527 "show ipv6 route vrf all " FRR_IP6_REDIST_STR_ZEBRA
,
3530 "IP routing table\n"
3531 VRF_ALL_CMD_HELP_STR
3532 FRR_IP6_REDIST_HELP_STR_ZEBRA
)
3535 struct route_table
*table
;
3536 struct route_node
*rn
;
3539 struct zebra_vrf
*zvrf
;
3543 char *proto
= argv
[argc
- 1]->text
;
3544 type
= proto_redistnum (AFI_IP
, proto
);
3548 vty_out (vty
, "Unknown route type%s", VTY_NEWLINE
);
3552 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3554 if ((zvrf
= vrf
->info
) == NULL
||
3555 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3558 /* Show matched type IPv6 routes. */
3559 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3560 RNODE_FOREACH_RIB (rn
, rib
)
3561 if (rib
->type
== type
)
3565 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3571 vty_out (vty
, "%sVRF %s:%s", VTY_NEWLINE
, zvrf_name (zvrf
), VTY_NEWLINE
);
3574 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3582 DEFUN (show_ipv6_route_vrf_all_addr
,
3583 show_ipv6_route_vrf_all_addr_cmd
,
3584 "show ipv6 route vrf all X:X::X:X",
3587 "IPv6 routing table\n"
3588 VRF_ALL_CMD_HELP_STR
3593 struct prefix_ipv6 p
;
3594 struct route_table
*table
;
3595 struct route_node
*rn
;
3597 struct zebra_vrf
*zvrf
;
3599 ret
= str2prefix_ipv6 (argv
[idx_ipv6
]->arg
, &p
);
3602 vty_out (vty
, "Malformed IPv6 address%s", VTY_NEWLINE
);
3606 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3608 if ((zvrf
= vrf
->info
) == NULL
||
3609 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3612 rn
= route_node_match (table
, (struct prefix
*) &p
);
3616 vty_show_ip_route_detail (vty
, rn
, 0);
3618 route_unlock_node (rn
);
3624 DEFUN (show_ipv6_route_vrf_all_prefix
,
3625 show_ipv6_route_vrf_all_prefix_cmd
,
3626 "show ipv6 route vrf all X:X::X:X/M",
3629 "IPv6 routing table\n"
3630 VRF_ALL_CMD_HELP_STR
3633 int idx_ipv6_prefixlen
= 5;
3635 struct prefix_ipv6 p
;
3636 struct route_table
*table
;
3637 struct route_node
*rn
;
3639 struct zebra_vrf
*zvrf
;
3641 ret
= str2prefix_ipv6 (argv
[idx_ipv6_prefixlen
]->arg
, &p
);
3644 vty_out (vty
, "Malformed IPv6 prefix%s", VTY_NEWLINE
);
3648 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3650 if ((zvrf
= vrf
->info
) == NULL
||
3651 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3654 rn
= route_node_match (table
, (struct prefix
*) &p
);
3657 if (rn
->p
.prefixlen
!= p
.prefixlen
)
3659 route_unlock_node (rn
);
3663 vty_show_ip_route_detail (vty
, rn
, 0);
3665 route_unlock_node (rn
);
3671 DEFUN (show_ipv6_route_vrf_all_summary
,
3672 show_ipv6_route_vrf_all_summary_cmd
,
3673 "show ipv6 route vrf all summary",
3676 "IPv6 routing table\n"
3677 VRF_ALL_CMD_HELP_STR
3678 "Summary of all IPv6 routes\n")
3681 struct zebra_vrf
*zvrf
;
3683 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3684 if ((zvrf
= vrf
->info
) != NULL
)
3685 vty_show_ip_route_summary (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3690 DEFUN (show_ipv6_mroute_vrf_all
,
3691 show_ipv6_mroute_vrf_all_cmd
,
3692 "show ipv6 mroute vrf all",
3695 "IPv6 Multicast routing table\n"
3696 VRF_ALL_CMD_HELP_STR
)
3698 struct route_table
*table
;
3699 struct route_node
*rn
;
3702 struct zebra_vrf
*zvrf
;
3705 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3707 if ((zvrf
= vrf
->info
) == NULL
||
3708 (table
= zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3711 /* Show all IPv6 route. */
3712 for (rn
= route_top (table
); rn
; rn
= srcdest_route_next (rn
))
3713 RNODE_FOREACH_RIB (rn
, rib
)
3717 vty_out (vty
, SHOW_ROUTE_V6_HEADER
);
3720 vty_show_ip_route (vty
, rn
, rib
, NULL
);
3726 DEFUN (show_ipv6_route_vrf_all_summary_prefix
,
3727 show_ipv6_route_vrf_all_summary_prefix_cmd
,
3728 "show ipv6 route vrf all summary prefix",
3731 "IPv6 routing table\n"
3732 VRF_ALL_CMD_HELP_STR
3733 "Summary of all IPv6 routes\n"
3737 struct zebra_vrf
*zvrf
;
3739 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3740 if ((zvrf
= vrf
->info
) != NULL
)
3741 vty_show_ip_route_summary_prefix (vty
, zvrf
->table
[AFI_IP6
][SAFI_UNICAST
]);
3746 /* Write IPv6 static route configuration. */
3748 static_config_ipv6 (struct vty
*vty
)
3750 struct route_node
*rn
;
3751 struct static_route
*si
;
3753 char buf
[SRCDEST2STR_BUFFER
];
3754 struct route_table
*stable
;
3756 struct zebra_vrf
*zvrf
;
3758 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3760 if (!(zvrf
= vrf
->info
))
3762 if ((stable
= zvrf
->stable
[AFI_IP6
][SAFI_UNICAST
]) == NULL
)
3765 for (rn
= route_top (stable
); rn
; rn
= srcdest_route_next (rn
))
3766 for (si
= rn
->info
; si
; si
= si
->next
)
3768 vty_out (vty
, "ipv6 route %s", srcdest_rnode2str (rn
, buf
, sizeof buf
));
3772 case STATIC_IPV4_GATEWAY
:
3773 vty_out (vty
, " %s", inet_ntoa (si
->addr
.ipv4
));
3775 case STATIC_IPV6_GATEWAY
:
3776 vty_out (vty
, " %s", inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
));
3778 case STATIC_IFINDEX
:
3779 vty_out (vty
, " %s", si
->ifname
);
3781 case STATIC_BLACKHOLE
:
3782 vty_out (vty
, " Null0" );
3784 case STATIC_IPV6_GATEWAY_IFINDEX
:
3785 vty_out (vty
, " %s %s",
3786 inet_ntop (AF_INET6
, &si
->addr
.ipv6
, buf
, BUFSIZ
),
3787 ifindex2ifname (si
->ifindex
, si
->vrf_id
));
3791 /* flags are incompatible with STATIC_BLACKHOLE */
3792 if (si
->type
!= STATIC_BLACKHOLE
)
3794 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_REJECT
))
3795 vty_out (vty
, " %s", "reject");
3796 if (CHECK_FLAG(si
->flags
, ZEBRA_FLAG_BLACKHOLE
))
3797 vty_out (vty
, " %s", "blackhole");
3801 vty_out (vty
, " tag %"ROUTE_TAG_PRI
, si
->tag
);
3803 if (si
->distance
!= ZEBRA_STATIC_DISTANCE_DEFAULT
)
3804 vty_out (vty
, " %d", si
->distance
);
3806 if (si
->vrf_id
!= VRF_DEFAULT
)
3808 vty_out (vty
, " vrf %s", zvrf_name (zvrf
));
3811 /* Label information */
3812 if (si
->snh_label
.num_labels
)
3813 vty_out (vty
, " label %s",
3814 mpls_label2str (si
->snh_label
.num_labels
,
3815 si
->snh_label
.label
, buf
, sizeof buf
));
3817 vty_out (vty
, "%s", VTY_NEWLINE
);
3825 DEFUN (allow_external_route_update
,
3826 allow_external_route_update_cmd
,
3827 "allow-external-route-update",
3828 "Allow FRR routes to be overwritten by external processes\n")
3835 DEFUN (no_allow_external_route_update
,
3836 no_allow_external_route_update_cmd
,
3837 "no allow-external-route-update",
3839 "Allow FRR routes to be overwritten by external processes\n")
3854 struct zebra_vrf
*zvrf
;
3856 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
3858 if (!(zvrf
= vrf
->info
))
3860 if (!zvrf_id (zvrf
))
3863 vty_out (vty
, "vrf %s ", zvrf_name (zvrf
));
3864 if (zvrf_id (zvrf
) == VRF_UNKNOWN
)
3865 vty_out (vty
, "inactive");
3867 vty_out (vty
, "id %u table %u", zvrf_id (zvrf
), zvrf
->table_id
);
3868 vty_out (vty
, "%s", VTY_NEWLINE
);
3875 /* Static ip route configuration write function. */
3877 zebra_ip_config (struct vty
*vty
)
3881 write
+= static_config_ipv4 (vty
, SAFI_UNICAST
, "ip route");
3882 write
+= static_config_ipv4 (vty
, SAFI_MULTICAST
, "ip mroute");
3883 write
+= static_config_ipv6 (vty
);
3885 write
+= zebra_import_table_config (vty
);
3889 DEFUN (ip_zebra_import_table_distance
,
3890 ip_zebra_import_table_distance_cmd
,
3891 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
3893 "import routes from non-main kernel table\n"
3894 "kernel routing table id\n"
3895 "Distance for imported routes\n"
3896 "Default distance value\n"
3897 "route-map for filtering\n"
3900 u_int32_t table_id
= 0;
3902 VTY_GET_INTEGER("table", table_id
, argv
[2]->arg
);
3903 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
3904 char *rmap
= strmatch (argv
[argc
- 2]->text
, "route-map") ?
3905 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
) : NULL
;
3906 if (argc
== 7 || (argc
== 5 && !rmap
))
3907 VTY_GET_INTEGER_RANGE("distance", distance
, argv
[4]->arg
, 1, 255);
3909 if (!is_zebra_valid_kernel_table(table_id
))
3911 vty_out(vty
, "Invalid routing table ID, %d. Must be in range 1-252%s",
3912 table_id
, VTY_NEWLINE
);
3916 if (is_zebra_main_routing_table(table_id
))
3918 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3919 table_id
, VTY_NEWLINE
);
3923 return (zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1));
3926 DEFUN (no_ip_zebra_import_table
,
3927 no_ip_zebra_import_table_cmd
,
3928 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
3931 "import routes from non-main kernel table\n"
3932 "kernel routing table id\n"
3933 "Distance for imported routes\n"
3934 "Default distance value\n"
3935 "route-map for filtering\n"
3938 u_int32_t table_id
= 0;
3939 VTY_GET_INTEGER("table", table_id
, argv
[3]->arg
);
3941 if (!is_zebra_valid_kernel_table(table_id
))
3943 vty_out(vty
, "Invalid routing table ID. Must be in range 1-252%s",
3948 if (is_zebra_main_routing_table(table_id
))
3950 vty_out(vty
, "Invalid routing table ID, %d. Must be non-default table%s",
3951 table_id
, VTY_NEWLINE
);
3955 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
3958 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
3962 config_write_protocol (struct vty
*vty
)
3965 vty_out(vty
, "allow-external-route-update%s", VTY_NEWLINE
);
3967 if (zebra_rnh_ip_default_route
)
3968 vty_out(vty
, "ip nht resolve-via-default%s", VTY_NEWLINE
);
3970 if (zebra_rnh_ipv6_default_route
)
3971 vty_out(vty
, "ipv6 nht resolve-via-default%s", VTY_NEWLINE
);
3973 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get ();
3975 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
3976 vty_out (vty
, "ip multicast rpf-lookup-mode %s%s",
3977 ipv4_multicast_mode
== MCAST_URIB_ONLY
? "urib-only" :
3978 ipv4_multicast_mode
== MCAST_MRIB_ONLY
? "mrib-only" :
3979 ipv4_multicast_mode
== MCAST_MIX_MRIB_FIRST
? "mrib-then-urib" :
3980 ipv4_multicast_mode
== MCAST_MIX_DISTANCE
? "lower-distance" :
3984 zebra_routemap_config_write_protocol(vty
);
3989 /* IP node for static routes. */
3990 static struct cmd_node ip_node
= { IP_NODE
, "", 1 };
3991 static struct cmd_node protocol_node
= { PROTOCOL_NODE
, "", 1 };
3995 zebra_vty_init (void)
3997 install_node (&ip_node
, zebra_ip_config
);
3998 install_node (&protocol_node
, config_write_protocol
);
4000 install_element (CONFIG_NODE
, &allow_external_route_update_cmd
);
4001 install_element (CONFIG_NODE
, &no_allow_external_route_update_cmd
);
4002 install_element (CONFIG_NODE
, &ip_mroute_dist_cmd
);
4003 install_element (CONFIG_NODE
, &no_ip_mroute_dist_cmd
);
4004 install_element (CONFIG_NODE
, &ip_multicast_mode_cmd
);
4005 install_element (CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
4006 install_element (CONFIG_NODE
, &ip_route_cmd
);
4007 install_element (CONFIG_NODE
, &ip_route_flags_cmd
);
4008 install_element (CONFIG_NODE
, &ip_route_mask_cmd
);
4009 install_element (CONFIG_NODE
, &ip_route_mask_flags_cmd
);
4010 install_element (CONFIG_NODE
, &no_ip_route_cmd
);
4011 install_element (CONFIG_NODE
, &no_ip_route_mask_cmd
);
4012 install_element (CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
4013 install_element (CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
4015 install_element (VIEW_NODE
, &show_vrf_cmd
);
4016 install_element (VIEW_NODE
, &show_ip_route_cmd
);
4017 install_element (VIEW_NODE
, &show_ip_route_ospf_instance_cmd
);
4018 install_element (VIEW_NODE
, &show_ip_route_tag_cmd
);
4019 install_element (VIEW_NODE
, &show_ip_nht_cmd
);
4020 install_element (VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
4021 install_element (VIEW_NODE
, &show_ipv6_nht_cmd
);
4022 install_element (VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
4023 install_element (VIEW_NODE
, &show_ip_route_addr_cmd
);
4024 install_element (VIEW_NODE
, &show_ip_route_prefix_cmd
);
4025 install_element (VIEW_NODE
, &show_ip_route_prefix_longer_cmd
);
4026 install_element (VIEW_NODE
, &show_ip_route_protocol_cmd
);
4027 install_element (VIEW_NODE
, &show_ip_route_supernets_cmd
);
4028 install_element (VIEW_NODE
, &show_ip_route_summary_cmd
);
4029 install_element (VIEW_NODE
, &show_ip_route_summary_prefix_cmd
);
4031 install_element (VIEW_NODE
, &show_ip_rpf_cmd
);
4032 install_element (VIEW_NODE
, &show_ip_rpf_addr_cmd
);
4034 /* Commands for VRF */
4036 install_element (CONFIG_NODE
, &no_ip_route_flags_cmd
);
4037 install_element (CONFIG_NODE
, &no_ip_route_mask_flags_cmd
);
4039 install_element (VIEW_NODE
, &show_ip_route_vrf_cmd
);
4041 install_element (VIEW_NODE
, &show_ip_route_vrf_all_cmd
);
4042 install_element (VIEW_NODE
, &show_ip_route_vrf_all_tag_cmd
);
4043 install_element (VIEW_NODE
, &show_ip_route_vrf_all_addr_cmd
);
4044 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_cmd
);
4045 install_element (VIEW_NODE
, &show_ip_route_vrf_all_prefix_longer_cmd
);
4046 install_element (VIEW_NODE
, &show_ip_route_vrf_all_protocol_cmd
);
4047 install_element (VIEW_NODE
, &show_ip_route_vrf_all_supernets_cmd
);
4048 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_cmd
);
4049 install_element (VIEW_NODE
, &show_ip_route_vrf_all_summary_prefix_cmd
);
4051 install_element (CONFIG_NODE
, &ipv6_route_cmd
);
4052 install_element (CONFIG_NODE
, &ipv6_route_flags_cmd
);
4053 install_element (CONFIG_NODE
, &ipv6_route_ifname_cmd
);
4054 install_element (CONFIG_NODE
, &ipv6_route_ifname_flags_cmd
);
4055 install_element (CONFIG_NODE
, &no_ipv6_route_cmd
);
4056 install_element (CONFIG_NODE
, &no_ipv6_route_flags_cmd
);
4057 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_cmd
);
4058 install_element (CONFIG_NODE
, &no_ipv6_route_ifname_flags_cmd
);
4059 install_element (CONFIG_NODE
, &ip_nht_default_route_cmd
);
4060 install_element (CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
4061 install_element (CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
4062 install_element (CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
4063 install_element (VIEW_NODE
, &show_ipv6_route_cmd
);
4064 install_element (VIEW_NODE
, &show_ipv6_route_tag_cmd
);
4065 install_element (VIEW_NODE
, &show_ipv6_route_summary_cmd
);
4066 install_element (VIEW_NODE
, &show_ipv6_route_summary_prefix_cmd
);
4067 install_element (VIEW_NODE
, &show_ipv6_route_protocol_cmd
);
4068 install_element (VIEW_NODE
, &show_ipv6_route_addr_cmd
);
4069 install_element (VIEW_NODE
, &show_ipv6_route_prefix_cmd
);
4070 install_element (VIEW_NODE
, &show_ipv6_route_prefix_longer_cmd
);
4072 install_element (VIEW_NODE
, &show_ipv6_mroute_cmd
);
4074 /* Commands for VRF */
4075 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_cmd
);
4076 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_tag_cmd
);
4077 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_cmd
);
4078 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_summary_prefix_cmd
);
4079 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_protocol_cmd
);
4080 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_addr_cmd
);
4081 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_cmd
);
4082 install_element (VIEW_NODE
, &show_ipv6_route_vrf_all_prefix_longer_cmd
);
4084 install_element (VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);