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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "zebra_memory.h"
34 #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"
45 #include "zebra/zebra_vxlan.h"
46 #ifndef VTYSH_EXTRACT_PL
47 #include "zebra/zebra_vty_clippy.c"
49 #include "zebra/zserv.h"
50 #include "zebra/router-id.h"
51 #include "zebra/ipforward.h"
52 #include "zebra/zebra_vxlan_private.h"
54 extern int allow_delete
;
56 static int do_show_ip_route(struct vty
*vty
, const char *vrf_name
, afi_t afi
,
57 safi_t safi
, bool use_fib
, u_char use_json
,
59 const struct prefix
*longer_prefix_p
,
60 bool supernets_only
, int type
,
61 u_short ospf_instance_id
);
62 static void vty_show_ip_route_detail(struct vty
*vty
, struct route_node
*rn
,
64 static void vty_show_ip_route_summary(struct vty
*vty
,
65 struct route_table
*table
);
66 static void vty_show_ip_route_summary_prefix(struct vty
*vty
,
67 struct route_table
*table
);
70 * special macro to allow us to get the correct zebra_vrf
72 #define ZEBRA_DECLVAR_CONTEXT(A, B) \
73 struct vrf *A = VTY_GET_CONTEXT(vrf); \
74 struct zebra_vrf *B = \
75 (vrf) ? vrf->info : NULL; \
77 /* VNI range as per RFC 7432 */
78 #define CMD_VNI_RANGE "(1-16777215)"
80 /* General function for static route. */
81 static int zebra_static_route_leak(struct vty
*vty
,
82 struct zebra_vrf
*zvrf
,
83 struct zebra_vrf
*nh_zvrf
,
84 afi_t afi
, safi_t safi
,
85 const char *negate
, const char *dest_str
,
86 const char *mask_str
, const char *src_str
,
87 const char *gate_str
, const char *ifname
,
88 const char *flag_str
, const char *tag_str
,
89 const char *distance_str
,
90 const char *label_str
)
95 struct prefix_ipv6
*src_p
= NULL
;
97 union g_addr
*gatep
= NULL
;
99 enum static_blackhole_type bh_type
= 0;
102 struct static_nh_label snh_label
;
104 ret
= str2prefix(dest_str
, &p
);
106 vty_out(vty
, "%% Malformed address\n");
107 return CMD_WARNING_CONFIG_FAILED
;
112 /* Cisco like mask notation. */
114 ret
= inet_aton(mask_str
, &mask
);
116 vty_out(vty
, "%% Malformed address\n");
117 return CMD_WARNING_CONFIG_FAILED
;
119 p
.prefixlen
= ip_masklen(mask
);
123 /* srcdest routing */
125 ret
= str2prefix(src_str
, &src
);
126 if (ret
<= 0 || src
.family
!= AF_INET6
) {
127 vty_out(vty
, "%% Malformed source address\n");
128 return CMD_WARNING_CONFIG_FAILED
;
130 src_p
= (struct prefix_ipv6
*)&src
;
137 /* Apply mask for given prefix. */
140 /* Administrative distance. */
142 distance
= atoi(distance_str
);
144 distance
= ZEBRA_STATIC_DISTANCE_DEFAULT
;
148 tag
= strtoul(tag_str
, NULL
, 10);
151 memset(&snh_label
, 0, sizeof(struct static_nh_label
));
155 "%% MPLS not turned on in kernel, ignoring command\n");
156 return CMD_WARNING_CONFIG_FAILED
;
158 int rc
= mpls_str2label(label_str
, &snh_label
.num_labels
,
163 vty_out(vty
, "%% Malformed label(s)\n");
167 "%% Cannot use reserved label(s) (%d-%d)\n",
168 MPLS_LABEL_RESERVED_MIN
,
169 MPLS_LABEL_RESERVED_MAX
);
173 "%% Too many labels. Enter %d or fewer\n",
177 return CMD_WARNING_CONFIG_FAILED
;
181 /* Null0 static route. */
182 if (ifname
!= NULL
) {
183 if (strncasecmp(ifname
, "Null0", strlen(ifname
)) == 0 ||
184 strncasecmp(ifname
, "reject", strlen(ifname
)) == 0 ||
185 strncasecmp(ifname
, "blackhole", strlen(ifname
)) == 0) {
186 vty_out(vty
, "%% Nexthop interface cannot be Null0, reject or blackhole\n");
187 return CMD_WARNING_CONFIG_FAILED
;
193 switch (flag_str
[0]) {
195 bh_type
= STATIC_BLACKHOLE_REJECT
;
198 bh_type
= STATIC_BLACKHOLE_DROP
;
201 bh_type
= STATIC_BLACKHOLE_NULL
;
204 vty_out(vty
, "%% Malformed flag %s \n", flag_str
);
205 return CMD_WARNING_CONFIG_FAILED
;
210 if (inet_pton(afi2family(afi
), gate_str
, &gate
) != 1) {
211 vty_out(vty
, "%% Malformed nexthop address %s\n",
213 return CMD_WARNING_CONFIG_FAILED
;
218 if (gate_str
== NULL
&& ifname
== NULL
)
219 type
= STATIC_BLACKHOLE
;
220 else if (gate_str
&& ifname
) {
222 type
= STATIC_IPV4_GATEWAY_IFNAME
;
224 type
= STATIC_IPV6_GATEWAY_IFNAME
;
226 type
= STATIC_IFNAME
;
229 type
= STATIC_IPV4_GATEWAY
;
231 type
= STATIC_IPV6_GATEWAY
;
235 static_add_route(afi
, safi
, type
, &p
, src_p
, gatep
, ifname
,
236 bh_type
, tag
, distance
, zvrf
, nh_zvrf
,
238 /* Mark as having FRR configuration */
239 vrf_set_user_cfged(zvrf
->vrf
);
241 static_delete_route(afi
, safi
, type
, &p
, src_p
, gatep
, ifname
,
242 tag
, distance
, zvrf
, &snh_label
);
243 /* If no other FRR config for this VRF, mark accordingly. */
244 if (!zebra_vrf_has_config(zvrf
))
245 vrf_reset_user_cfged(zvrf
->vrf
);
251 static int zebra_static_route(struct vty
*vty
, afi_t afi
, safi_t safi
,
252 const char *negate
, const char *dest_str
,
253 const char *mask_str
, const char *src_str
,
254 const char *gate_str
, const char *ifname
,
255 const char *flag_str
, const char *tag_str
,
256 const char *distance_str
, const char *vrf_name
,
257 const char *label_str
)
259 struct zebra_vrf
*zvrf
;
263 zvrf
= zebra_vrf_lookup_by_name(vrf_name
);
265 /* When trying to delete, the VRF must exist. */
266 if (negate
&& !zvrf
) {
267 vty_out(vty
, "%% vrf %s is not defined\n", vrf_name
);
268 return CMD_WARNING_CONFIG_FAILED
;
271 /* When trying to create, create the VRF if it doesn't exist.
272 * Note: The VRF isn't active until we hear about it from the kernel.
275 vrf
= vrf_get(VRF_UNKNOWN
, vrf_name
);
277 vty_out(vty
, "%% Could not create vrf %s\n", vrf_name
);
278 return CMD_WARNING_CONFIG_FAILED
;
282 vty_out(vty
, "%% Could not create vrf-info %s\n",
284 return CMD_WARNING_CONFIG_FAILED
;
286 /* Mark as having FRR configuration */
287 vrf_set_user_cfged(vrf
);
289 return zebra_static_route_leak(vty
, zvrf
, zvrf
, afi
, safi
,
290 negate
, dest_str
, mask_str
, src_str
,
291 gate_str
, ifname
, flag_str
, tag_str
,
292 distance_str
, label_str
);
296 /* Static unicast routes for multicast RPF lookup. */
297 DEFPY (ip_mroute_dist
,
299 "[no] ip mroute A.B.C.D/M$prefix <A.B.C.D$gate|INTERFACE$ifname> [(1-255)$distance]",
302 "Configure static unicast route into MRIB for multicast RPF lookup\n"
303 "IP destination prefix (e.g. 10.0.0.0/8)\n"
305 "Nexthop interface name\n"
308 return zebra_static_route(vty
, AFI_IP
, SAFI_MULTICAST
, no
, prefix_str
,
309 NULL
, NULL
, gate_str
, ifname
, NULL
, NULL
,
310 distance_str
, NULL
, NULL
);
313 DEFUN (ip_multicast_mode
,
314 ip_multicast_mode_cmd
,
315 "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>",
317 "Multicast options\n"
318 "RPF lookup behavior\n"
319 "Lookup in unicast RIB only\n"
320 "Lookup in multicast RIB only\n"
321 "Try multicast RIB first, fall back to unicast RIB\n"
322 "Lookup both, use entry with lower distance\n"
323 "Lookup both, use entry with longer prefix\n")
325 char *mode
= argv
[3]->text
;
327 if (strmatch(mode
, "urib-only"))
328 multicast_mode_ipv4_set(MCAST_URIB_ONLY
);
329 else if (strmatch(mode
, "mrib-only"))
330 multicast_mode_ipv4_set(MCAST_MRIB_ONLY
);
331 else if (strmatch(mode
, "mrib-then-urib"))
332 multicast_mode_ipv4_set(MCAST_MIX_MRIB_FIRST
);
333 else if (strmatch(mode
, "lower-distance"))
334 multicast_mode_ipv4_set(MCAST_MIX_DISTANCE
);
335 else if (strmatch(mode
, "longer-prefix"))
336 multicast_mode_ipv4_set(MCAST_MIX_PFXLEN
);
338 vty_out(vty
, "Invalid mode specified\n");
339 return CMD_WARNING_CONFIG_FAILED
;
345 DEFUN (no_ip_multicast_mode
,
346 no_ip_multicast_mode_cmd
,
347 "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]",
350 "Multicast options\n"
351 "RPF lookup behavior\n"
352 "Lookup in unicast RIB only\n"
353 "Lookup in multicast RIB only\n"
354 "Try multicast RIB first, fall back to unicast RIB\n"
355 "Lookup both, use entry with lower distance\n"
356 "Lookup both, use entry with longer prefix\n")
358 multicast_mode_ipv4_set(MCAST_NO_CONFIG
);
365 "show ip rpf [json]",
368 "Display RPF information for multicast source\n"
371 int uj
= use_json(argc
, argv
);
372 return do_show_ip_route(vty
, VRF_DEFAULT_NAME
, AFI_IP
, SAFI_MULTICAST
,
373 false, uj
, 0, NULL
, false, 0, 0);
376 DEFUN (show_ip_rpf_addr
,
377 show_ip_rpf_addr_cmd
,
378 "show ip rpf A.B.C.D",
381 "Display RPF information for multicast source\n"
382 "IP multicast source address (e.g. 10.0.0.0)\n")
386 struct route_node
*rn
;
387 struct route_entry
*re
;
390 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
392 vty_out(vty
, "%% Malformed address\n");
396 re
= rib_match_ipv4_multicast(VRF_DEFAULT
, addr
, &rn
);
399 vty_show_ip_route_detail(vty
, rn
, 1);
401 vty_out(vty
, "%% No match for RPF lookup\n");
406 /* Static route configuration. */
407 DEFPY(ip_route_blackhole
,
408 ip_route_blackhole_cmd
,
410 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
411 <reject|blackhole>$flag \
419 "Establish static routes\n"
420 "IP destination prefix (e.g. 10.0.0.0/8)\n"
421 "IP destination prefix\n"
422 "IP destination prefix mask\n"
423 "Emit an ICMP unreachable when matched\n"
424 "Silently discard pkts when matched\n"
425 "Set tag for this route\n"
427 "Distance value for this route\n"
431 return zebra_static_route(vty
, AFI_IP
, SAFI_UNICAST
, no
, prefix
,
432 mask_str
, NULL
, NULL
, NULL
, flag
,
433 tag_str
, distance_str
, vrf
, label
);
436 DEFPY(ip_route_blackhole_vrf
,
437 ip_route_blackhole_vrf_cmd
,
439 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
440 <reject|blackhole>$flag \
447 "Establish static routes\n"
448 "IP destination prefix (e.g. 10.0.0.0/8)\n"
449 "IP destination prefix\n"
450 "IP destination prefix mask\n"
451 "Emit an ICMP unreachable when matched\n"
452 "Silently discard pkts when matched\n"
453 "Set tag for this route\n"
455 "Distance value for this route\n"
458 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
459 struct zebra_vrf
*zvrf
= vrf
->info
;
462 * Coverity is complaining that prefix could
463 * be dereferenced, but we know that prefix will
464 * valid. Add an assert to make it happy
467 return zebra_static_route_leak(vty
, zvrf
, zvrf
,
468 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
469 mask_str
, NULL
, NULL
, NULL
, flag
,
470 tag_str
, distance_str
, label
);
473 DEFPY(ip_route_address_interface
,
474 ip_route_address_interface_cmd
,
476 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
487 "Establish static routes\n"
488 "IP destination prefix (e.g. 10.0.0.0/8)\n"
489 "IP destination prefix\n"
490 "IP destination prefix mask\n"
491 "IP gateway address\n"
492 "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \
494 "Set tag for this route\n"
496 "Distance value for this route\n"
501 struct zebra_vrf
*zvrf
;
502 struct zebra_vrf
*nh_zvrf
;
504 const char *flag
= NULL
;
505 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
510 zvrf
= zebra_vrf_lookup_by_name(vrf
);
512 vty_out(vty
, "%% vrf %s is not defined\n",
514 return CMD_WARNING_CONFIG_FAILED
;
518 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
523 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
525 return CMD_WARNING_CONFIG_FAILED
;
528 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
529 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
530 mask_str
, NULL
, gate_str
, ifname
, flag
,
531 tag_str
, distance_str
, label
);
534 DEFPY(ip_route_address_interface_vrf
,
535 ip_route_address_interface_vrf_cmd
,
537 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
547 "Establish static routes\n"
548 "IP destination prefix (e.g. 10.0.0.0/8)\n"
549 "IP destination prefix\n"
550 "IP destination prefix mask\n"
551 "IP gateway address\n"
552 "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \
554 "Set tag for this route\n"
556 "Distance value for this route\n"
560 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
561 const char *flag
= NULL
;
562 struct zebra_vrf
*zvrf
= vrf
->info
;
563 struct zebra_vrf
*nh_zvrf
;
565 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
571 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
576 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
578 return CMD_WARNING_CONFIG_FAILED
;
581 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
582 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
583 mask_str
, NULL
, gate_str
, ifname
, flag
,
584 tag_str
, distance_str
, label
);
590 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
591 <A.B.C.D$gate|INTERFACE$ifname> \
600 "Establish static routes\n"
601 "IP destination prefix (e.g. 10.0.0.0/8)\n"
602 "IP destination prefix\n"
603 "IP destination prefix mask\n"
604 "IP gateway address\n"
605 "IP gateway interface name\n"
606 "Set tag for this route\n"
608 "Distance value for this route\n"
613 struct zebra_vrf
*zvrf
;
614 struct zebra_vrf
*nh_zvrf
;
615 const char *flag
= NULL
;
617 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
622 zvrf
= zebra_vrf_lookup_by_name(vrf
);
624 vty_out(vty
, "%% vrf %s is not defined\n",
626 return CMD_WARNING_CONFIG_FAILED
;
630 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
635 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
637 return CMD_WARNING_CONFIG_FAILED
;
641 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
642 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
643 mask_str
, NULL
, gate_str
, ifname
, flag
,
644 tag_str
, distance_str
, label
);
650 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
651 <A.B.C.D$gate|INTERFACE$ifname> \
659 "Establish static routes\n"
660 "IP destination prefix (e.g. 10.0.0.0/8)\n"
661 "IP destination prefix\n"
662 "IP destination prefix mask\n"
663 "IP gateway address\n"
664 "IP gateway interface name\n"
665 "Set tag for this route\n"
667 "Distance value for this route\n"
671 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
672 struct zebra_vrf
*zvrf
= vrf
->info
;
673 struct zebra_vrf
*nh_zvrf
;
675 const char *flag
= NULL
;
676 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
682 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
687 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
689 return CMD_WARNING_CONFIG_FAILED
;
692 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
693 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
694 mask_str
, NULL
, gate_str
, ifname
, flag
,
695 tag_str
, distance_str
, label
);
698 /* New RIB. Detailed information for IPv4 route. */
699 static void vty_show_ip_route_detail(struct vty
*vty
, struct route_node
*rn
,
702 struct route_entry
*re
;
703 struct nexthop
*nexthop
;
704 char buf
[SRCDEST2STR_BUFFER
];
705 struct zebra_vrf
*zvrf
;
707 RNODE_FOREACH_RE (rn
, re
) {
708 const char *mcast_info
= "";
710 rib_table_info_t
*info
= srcdest_rnode_table_info(rn
);
711 mcast_info
= (info
->safi
== SAFI_MULTICAST
)
712 ? " using Multicast RIB"
713 : " using Unicast RIB";
716 vty_out(vty
, "Routing entry for %s%s\n",
717 srcdest_rnode2str(rn
, buf
, sizeof(buf
)), mcast_info
);
718 vty_out(vty
, " Known via \"%s", zebra_route_string(re
->type
));
720 vty_out(vty
, "[%d]", re
->instance
);
722 vty_out(vty
, ", distance %u, metric %u", re
->distance
,
725 vty_out(vty
, ", tag %u", re
->tag
);
726 #if defined(SUPPORT_REALMS)
727 if (re
->tag
> 0 && re
->tag
<= 255)
728 vty_out(vty
, "(realm)");
732 vty_out(vty
, ", mtu %u", re
->mtu
);
733 if (re
->vrf_id
!= VRF_DEFAULT
) {
734 zvrf
= vrf_info_lookup(re
->vrf_id
);
735 vty_out(vty
, ", vrf %s", zvrf_name(zvrf
));
737 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
738 vty_out(vty
, ", best");
745 uptime
-= re
->uptime
;
746 tm
= gmtime(&uptime
);
748 vty_out(vty
, " Last update ");
750 if (uptime
< ONE_DAY_SECOND
)
751 vty_out(vty
, "%02d:%02d:%02d", tm
->tm_hour
,
752 tm
->tm_min
, tm
->tm_sec
);
753 else if (uptime
< ONE_WEEK_SECOND
)
754 vty_out(vty
, "%dd%02dh%02dm", tm
->tm_yday
,
755 tm
->tm_hour
, tm
->tm_min
);
757 vty_out(vty
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
758 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
760 vty_out(vty
, " ago\n");
762 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
765 vty_out(vty
, " %c%s",
766 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
767 ? CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
)
770 nexthop
->rparent
? " " : "");
772 switch (nexthop
->type
) {
773 case NEXTHOP_TYPE_IPV4
:
774 case NEXTHOP_TYPE_IPV4_IFINDEX
:
776 inet_ntoa(nexthop
->gate
.ipv4
));
777 if (nexthop
->ifindex
)
778 vty_out(vty
, ", via %s",
783 case NEXTHOP_TYPE_IPV6
:
784 case NEXTHOP_TYPE_IPV6_IFINDEX
:
786 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
,
788 if (nexthop
->ifindex
)
789 vty_out(vty
, ", via %s",
794 case NEXTHOP_TYPE_IFINDEX
:
795 vty_out(vty
, " directly connected, %s",
796 ifindex2ifname(nexthop
->ifindex
,
799 case NEXTHOP_TYPE_BLACKHOLE
:
800 vty_out(vty
, " unreachable");
801 switch (nexthop
->bh_type
) {
802 case BLACKHOLE_REJECT
:
803 vty_out(vty
, " (ICMP unreachable)");
805 case BLACKHOLE_ADMINPROHIB
:
807 " (ICMP admin-prohibited)");
810 vty_out(vty
, " (blackhole)");
812 case BLACKHOLE_UNSPEC
:
820 if (re
->vrf_id
!= nexthop
->vrf_id
) {
822 vrf_lookup_by_id(nexthop
->vrf_id
);
824 vty_out(vty
, "(vrf %s)", vrf
->name
);
827 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
828 vty_out(vty
, " (duplicate nexthop removed)");
830 if (!CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
831 vty_out(vty
, " inactive");
833 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
834 vty_out(vty
, " onlink");
836 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
837 vty_out(vty
, " (recursive)");
839 switch (nexthop
->type
) {
840 case NEXTHOP_TYPE_IPV4
:
841 case NEXTHOP_TYPE_IPV4_IFINDEX
:
842 if (nexthop
->src
.ipv4
.s_addr
) {
843 if (inet_ntop(AF_INET
,
845 addrstr
, sizeof addrstr
))
846 vty_out(vty
, ", src %s",
850 case NEXTHOP_TYPE_IPV6
:
851 case NEXTHOP_TYPE_IPV6_IFINDEX
:
852 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
,
854 if (inet_ntop(AF_INET6
,
856 addrstr
, sizeof addrstr
))
857 vty_out(vty
, ", src %s",
866 vty_out(vty
, ", mtu %u", re
->nexthop_mtu
);
868 /* Label information */
869 if (nexthop
->nh_label
870 && nexthop
->nh_label
->num_labels
) {
871 vty_out(vty
, ", label %s",
873 nexthop
->nh_label
->num_labels
,
874 nexthop
->nh_label
->label
, buf
,
884 static void vty_show_ip_route(struct vty
*vty
, struct route_node
*rn
,
885 struct route_entry
*re
, json_object
*json
)
887 struct nexthop
*nexthop
;
889 char buf
[SRCDEST2STR_BUFFER
];
890 json_object
*json_nexthops
= NULL
;
891 json_object
*json_nexthop
= NULL
;
892 json_object
*json_route
= NULL
;
893 json_object
*json_labels
= NULL
;
898 uptime
-= re
->uptime
;
899 tm
= gmtime(&uptime
);
902 json_route
= json_object_new_object();
903 json_nexthops
= json_object_new_array();
905 json_object_string_add(json_route
, "prefix",
906 srcdest_rnode2str(rn
, buf
, sizeof buf
));
907 json_object_string_add(json_route
, "protocol",
908 zebra_route_string(re
->type
));
911 json_object_int_add(json_route
, "instance",
915 json_object_int_add(json_route
, "vrfId", re
->vrf_id
);
917 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
918 json_object_boolean_true_add(json_route
, "selected");
920 if (re
->type
!= ZEBRA_ROUTE_CONNECT
) {
921 json_object_int_add(json_route
, "distance",
923 json_object_int_add(json_route
, "metric", re
->metric
);
926 if (uptime
< ONE_DAY_SECOND
)
927 sprintf(buf
, "%02d:%02d:%02d", tm
->tm_hour
,
928 tm
->tm_min
, tm
->tm_sec
);
929 else if (uptime
< ONE_WEEK_SECOND
)
930 sprintf(buf
, "%dd%02dh%02dm", tm
->tm_yday
,
931 tm
->tm_hour
, tm
->tm_min
);
933 sprintf(buf
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
934 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
937 json_object_string_add(json_route
, "uptime", buf
);
939 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
940 json_nexthop
= json_object_new_object();
942 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
943 json_object_boolean_true_add(json_nexthop
,
946 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
))
947 json_object_boolean_true_add(json_nexthop
,
950 switch (nexthop
->type
) {
951 case NEXTHOP_TYPE_IPV4
:
952 case NEXTHOP_TYPE_IPV4_IFINDEX
:
953 json_object_string_add(
955 inet_ntoa(nexthop
->gate
.ipv4
));
956 json_object_string_add(json_nexthop
, "afi",
959 if (nexthop
->ifindex
) {
960 json_object_int_add(json_nexthop
,
963 json_object_string_add(
964 json_nexthop
, "interfaceName",
970 case NEXTHOP_TYPE_IPV6
:
971 case NEXTHOP_TYPE_IPV6_IFINDEX
:
972 json_object_string_add(
974 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
,
976 json_object_string_add(json_nexthop
, "afi",
979 if (nexthop
->ifindex
) {
980 json_object_int_add(json_nexthop
,
983 json_object_string_add(
984 json_nexthop
, "interfaceName",
991 case NEXTHOP_TYPE_IFINDEX
:
992 json_object_boolean_true_add(
993 json_nexthop
, "directlyConnected");
994 json_object_int_add(json_nexthop
,
997 json_object_string_add(
998 json_nexthop
, "interfaceName",
999 ifindex2ifname(nexthop
->ifindex
,
1002 case NEXTHOP_TYPE_BLACKHOLE
:
1003 json_object_boolean_true_add(json_nexthop
,
1005 switch (nexthop
->bh_type
) {
1006 case BLACKHOLE_REJECT
:
1007 json_object_boolean_true_add(
1008 json_nexthop
, "reject");
1010 case BLACKHOLE_ADMINPROHIB
:
1011 json_object_boolean_true_add(
1013 "admin-prohibited");
1015 case BLACKHOLE_NULL
:
1016 json_object_boolean_true_add(
1017 json_nexthop
, "blackhole");
1019 case BLACKHOLE_UNSPEC
:
1027 if (nexthop
->vrf_id
!= re
->vrf_id
) {
1029 vrf_lookup_by_id(nexthop
->vrf_id
);
1031 json_object_string_add(json_nexthop
,
1035 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
1036 json_object_boolean_true_add(json_nexthop
,
1039 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
1040 json_object_boolean_true_add(json_nexthop
,
1043 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1044 json_object_boolean_true_add(json_nexthop
,
1047 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1048 json_object_boolean_true_add(json_nexthop
,
1051 switch (nexthop
->type
) {
1052 case NEXTHOP_TYPE_IPV4
:
1053 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1054 if (nexthop
->src
.ipv4
.s_addr
) {
1055 if (inet_ntop(AF_INET
,
1056 &nexthop
->src
.ipv4
, buf
,
1058 json_object_string_add(
1059 json_nexthop
, "source",
1063 case NEXTHOP_TYPE_IPV6
:
1064 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1065 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
,
1067 if (inet_ntop(AF_INET6
,
1068 &nexthop
->src
.ipv6
, buf
,
1070 json_object_string_add(
1071 json_nexthop
, "source",
1079 if (nexthop
->nh_label
1080 && nexthop
->nh_label
->num_labels
) {
1081 json_labels
= json_object_new_array();
1083 for (int label_index
= 0;
1085 < nexthop
->nh_label
->num_labels
;
1087 json_object_array_add(
1089 json_object_new_int(
1090 nexthop
->nh_label
->label
1093 json_object_object_add(json_nexthop
, "labels",
1097 json_object_array_add(json_nexthops
, json_nexthop
);
1100 json_object_object_add(json_route
, "nexthops", json_nexthops
);
1101 json_object_array_add(json
, json_route
);
1105 /* Nexthop information. */
1106 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
1107 if (nexthop
== re
->nexthop
) {
1108 /* Prefix information. */
1109 len
= vty_out(vty
, "%c", zebra_route_char(re
->type
));
1111 len
+= vty_out(vty
, "[%d]", re
->instance
);
1114 CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
)
1117 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
1120 srcdest_rnode2str(rn
, buf
, sizeof buf
));
1122 /* Distance and metric display. */
1123 if (re
->type
!= ZEBRA_ROUTE_CONNECT
)
1124 len
+= vty_out(vty
, " [%u/%u]", re
->distance
,
1127 vty_out(vty
, " %c%*c",
1128 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
1129 ? CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
)
1132 len
- 3 + (2 * nexthop_level(nexthop
)), ' ');
1135 switch (nexthop
->type
) {
1136 case NEXTHOP_TYPE_IPV4
:
1137 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1138 vty_out(vty
, " via %s", inet_ntoa(nexthop
->gate
.ipv4
));
1139 if (nexthop
->ifindex
)
1140 vty_out(vty
, ", %s",
1141 ifindex2ifname(nexthop
->ifindex
,
1144 case NEXTHOP_TYPE_IPV6
:
1145 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1146 vty_out(vty
, " via %s",
1147 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
, buf
,
1149 if (nexthop
->ifindex
)
1150 vty_out(vty
, ", %s",
1151 ifindex2ifname(nexthop
->ifindex
,
1155 case NEXTHOP_TYPE_IFINDEX
:
1156 vty_out(vty
, " is directly connected, %s",
1157 ifindex2ifname(nexthop
->ifindex
,
1160 case NEXTHOP_TYPE_BLACKHOLE
:
1161 vty_out(vty
, " unreachable");
1162 switch (nexthop
->bh_type
) {
1163 case BLACKHOLE_REJECT
:
1164 vty_out(vty
, " (ICMP unreachable)");
1166 case BLACKHOLE_ADMINPROHIB
:
1167 vty_out(vty
, " (ICMP admin-prohibited)");
1169 case BLACKHOLE_NULL
:
1170 vty_out(vty
, " (blackhole)");
1172 case BLACKHOLE_UNSPEC
:
1180 if (nexthop
->vrf_id
!= re
->vrf_id
) {
1181 struct vrf
*vrf
= vrf_lookup_by_id(nexthop
->vrf_id
);
1183 vty_out(vty
, "(vrf %s)", vrf
->name
);
1186 if (!CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
1187 vty_out(vty
, " inactive");
1189 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1190 vty_out(vty
, " onlink");
1192 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1193 vty_out(vty
, " (recursive)");
1195 switch (nexthop
->type
) {
1196 case NEXTHOP_TYPE_IPV4
:
1197 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1198 if (nexthop
->src
.ipv4
.s_addr
) {
1199 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
,
1201 vty_out(vty
, ", src %s", buf
);
1204 case NEXTHOP_TYPE_IPV6
:
1205 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1206 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
)) {
1207 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
,
1209 vty_out(vty
, ", src %s", buf
);
1216 /* Label information */
1217 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
) {
1218 vty_out(vty
, ", label %s",
1219 mpls_label2str(nexthop
->nh_label
->num_labels
,
1220 nexthop
->nh_label
->label
, buf
,
1224 if (uptime
< ONE_DAY_SECOND
)
1225 vty_out(vty
, ", %02d:%02d:%02d", tm
->tm_hour
,
1226 tm
->tm_min
, tm
->tm_sec
);
1227 else if (uptime
< ONE_WEEK_SECOND
)
1228 vty_out(vty
, ", %dd%02dh%02dm", tm
->tm_yday
,
1229 tm
->tm_hour
, tm
->tm_min
);
1231 vty_out(vty
, ", %02dw%dd%02dh", tm
->tm_yday
/ 7,
1232 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
1238 static int do_show_ip_route(struct vty
*vty
, const char *vrf_name
, afi_t afi
,
1239 safi_t safi
, bool use_fib
, u_char use_json
,
1241 const struct prefix
*longer_prefix_p
,
1242 bool supernets_only
, int type
,
1243 u_short ospf_instance_id
)
1245 struct route_table
*table
;
1247 struct route_node
*rn
;
1248 struct route_entry
*re
;
1250 struct zebra_vrf
*zvrf
= NULL
;
1252 json_object
*json
= NULL
;
1253 json_object
*json_prefix
= NULL
;
1256 if (!(zvrf
= zebra_vrf_lookup_by_name(vrf_name
))) {
1258 vty_out(vty
, "{}\n");
1260 vty_out(vty
, "vrf %s not defined\n", vrf_name
);
1264 if (zvrf_id(zvrf
) == VRF_UNKNOWN
) {
1266 vty_out(vty
, "{}\n");
1268 vty_out(vty
, "vrf %s inactive\n", vrf_name
);
1272 table
= zebra_vrf_table(afi
, safi
, zvrf_id(zvrf
));
1275 vty_out(vty
, "{}\n");
1280 json
= json_object_new_object();
1282 /* Show all routes. */
1283 for (rn
= route_top(table
); rn
; rn
= route_next(rn
)) {
1284 dest
= rib_dest_from_rnode(rn
);
1286 RNODE_FOREACH_RE (rn
, re
) {
1288 && re
!= dest
->selected_fib
)
1291 if (tag
&& re
->tag
!= tag
)
1295 && !prefix_match(longer_prefix_p
, &rn
->p
))
1298 /* This can only be true when the afi is IPv4 */
1299 if (supernets_only
) {
1300 addr
= ntohl(rn
->p
.u
.prefix4
.s_addr
);
1302 if (IN_CLASSC(addr
) && rn
->p
.prefixlen
>= 24)
1305 if (IN_CLASSB(addr
) && rn
->p
.prefixlen
>= 16)
1308 if (IN_CLASSA(addr
) && rn
->p
.prefixlen
>= 8)
1312 if (type
&& re
->type
!= type
)
1315 if (ospf_instance_id
1316 && (re
->type
!= ZEBRA_ROUTE_OSPF
1317 || re
->instance
!= ospf_instance_id
))
1322 json_prefix
= json_object_new_array();
1327 SHOW_ROUTE_V4_HEADER
);
1330 SHOW_ROUTE_V6_HEADER
);
1332 if (zvrf_id(zvrf
) != VRF_DEFAULT
)
1333 vty_out(vty
, "\nVRF %s:\n",
1340 vty_show_ip_route(vty
, rn
, re
, json_prefix
);
1344 prefix2str(&rn
->p
, buf
, sizeof buf
);
1345 json_object_object_add(json
, buf
, json_prefix
);
1351 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1352 json
, JSON_C_TO_STRING_PRETTY
));
1353 json_object_free(json
);
1361 "show ip nht [vrf NAME]",
1364 "IP nexthop tracking table\n"
1368 vrf_id_t vrf_id
= VRF_DEFAULT
;
1371 VRF_GET_ID(vrf_id
, argv
[idx_vrf
]->arg
);
1373 zebra_print_rnh_table(vrf_id
, AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1378 DEFUN (show_ip_nht_vrf_all
,
1379 show_ip_nht_vrf_all_cmd
,
1380 "show ip nht vrf all",
1383 "IP nexthop tracking table\n"
1384 VRF_ALL_CMD_HELP_STR
)
1387 struct zebra_vrf
*zvrf
;
1389 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1390 if ((zvrf
= vrf
->info
) != NULL
) {
1391 vty_out(vty
, "\nVRF %s:\n", zvrf_name(zvrf
));
1392 zebra_print_rnh_table(zvrf_id(zvrf
), AF_INET
, vty
,
1399 DEFUN (show_ipv6_nht
,
1401 "show ipv6 nht [vrf NAME]",
1404 "IPv6 nexthop tracking table\n"
1408 vrf_id_t vrf_id
= VRF_DEFAULT
;
1411 VRF_GET_ID(vrf_id
, argv
[idx_vrf
]->arg
);
1413 zebra_print_rnh_table(vrf_id
, AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1418 DEFUN (show_ipv6_nht_vrf_all
,
1419 show_ipv6_nht_vrf_all_cmd
,
1420 "show ipv6 nht vrf all",
1423 "IPv6 nexthop tracking table\n"
1424 VRF_ALL_CMD_HELP_STR
)
1427 struct zebra_vrf
*zvrf
;
1429 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1430 if ((zvrf
= vrf
->info
) != NULL
) {
1431 vty_out(vty
, "\nVRF %s:\n", zvrf_name(zvrf
));
1432 zebra_print_rnh_table(zvrf_id(zvrf
), AF_INET6
, vty
,
1439 DEFUN (ip_nht_default_route
,
1440 ip_nht_default_route_cmd
,
1441 "ip nht resolve-via-default",
1443 "Filter Next Hop tracking route resolution\n"
1444 "Resolve via default route\n")
1446 if (zebra_rnh_ip_default_route
)
1449 zebra_rnh_ip_default_route
= 1;
1450 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1454 DEFUN (no_ip_nht_default_route
,
1455 no_ip_nht_default_route_cmd
,
1456 "no ip nht resolve-via-default",
1459 "Filter Next Hop tracking route resolution\n"
1460 "Resolve via default route\n")
1462 if (!zebra_rnh_ip_default_route
)
1465 zebra_rnh_ip_default_route
= 0;
1466 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1470 DEFUN (ipv6_nht_default_route
,
1471 ipv6_nht_default_route_cmd
,
1472 "ipv6 nht resolve-via-default",
1474 "Filter Next Hop tracking route resolution\n"
1475 "Resolve via default route\n")
1477 if (zebra_rnh_ipv6_default_route
)
1480 zebra_rnh_ipv6_default_route
= 1;
1481 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1485 DEFUN (no_ipv6_nht_default_route
,
1486 no_ipv6_nht_default_route_cmd
,
1487 "no ipv6 nht resolve-via-default",
1490 "Filter Next Hop tracking route resolution\n"
1491 "Resolve via default route\n")
1493 if (!zebra_rnh_ipv6_default_route
)
1496 zebra_rnh_ipv6_default_route
= 0;
1497 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1505 ip$ipv4 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
1508 |A.B.C.D/M$prefix longer-prefixes\
1509 |supernets-only$supernets_only\
1512 " FRR_IP_REDIST_STR_ZEBRA
"$type_str\
1513 |ospf$type_str (1-65535)$ospf_instance_id\
1515 |ipv6$ipv6 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
1518 |X:X::X:X/M$prefix longer-prefixes\
1520 [" FRR_IP6_REDIST_STR_ZEBRA
"$type_str]\
1525 "IP forwarding table\n"
1526 "IP routing table\n"
1527 VRF_FULL_CMD_HELP_STR
1528 "Show only routes with tag\n"
1530 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1531 "Show route matching the specified Network/Mask pair only\n"
1532 "Show supernet entries only\n"
1533 FRR_IP_REDIST_HELP_STR_ZEBRA
1534 "Open Shortest Path First (OSPFv2)\n"
1537 "IP forwarding table\n"
1538 "IP routing table\n"
1539 VRF_FULL_CMD_HELP_STR
1540 "Show only routes with tag\n"
1543 "Show route matching the specified Network/Mask pair only\n"
1544 FRR_IP6_REDIST_HELP_STR_ZEBRA
1547 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1552 type
= proto_redistnum(afi
, type_str
);
1554 vty_out(vty
, "Unknown route type\n");
1560 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
1561 struct zebra_vrf
*zvrf
;
1562 struct route_table
*table
;
1564 if ((zvrf
= vrf
->info
) == NULL
1565 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1569 vty
, zvrf_name(zvrf
), afi
, SAFI_UNICAST
, !!fib
,
1570 !!json
, tag
, prefix_str
? prefix
: NULL
,
1571 !!supernets_only
, type
, ospf_instance_id
);
1574 vrf_id_t vrf_id
= VRF_DEFAULT
;
1577 VRF_GET_ID(vrf_id
, vrf_name
);
1578 vrf
= vrf_lookup_by_id(vrf_id
);
1579 do_show_ip_route(vty
, vrf
->name
, afi
, SAFI_UNICAST
, !!fib
,
1580 !!json
, tag
, prefix_str
? prefix
: NULL
,
1581 !!supernets_only
, type
, ospf_instance_id
);
1587 DEFPY (show_route_detail
,
1588 show_route_detail_cmd
,
1591 ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
1596 |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
1604 "IP routing table\n"
1605 VRF_FULL_CMD_HELP_STR
1606 "Network in the IP routing table to display\n"
1607 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1609 "IP routing table\n"
1610 VRF_FULL_CMD_HELP_STR
1614 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1615 struct route_table
*table
;
1617 struct route_node
*rn
;
1620 prefix_str
= address_str
;
1621 if (str2prefix(prefix_str
, &p
) < 0) {
1622 vty_out(vty
, "%% Malformed address\n");
1628 struct zebra_vrf
*zvrf
;
1630 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
1631 if ((zvrf
= vrf
->info
) == NULL
1632 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1635 rn
= route_node_match(table
, &p
);
1638 if (!address_str
&& rn
->p
.prefixlen
!= p
.prefixlen
) {
1639 route_unlock_node(rn
);
1643 vty_show_ip_route_detail(vty
, rn
, 0);
1645 route_unlock_node(rn
);
1648 vrf_id_t vrf_id
= VRF_DEFAULT
;
1651 VRF_GET_ID(vrf_id
, vrf_name
);
1653 table
= zebra_vrf_table(afi
, SAFI_UNICAST
, vrf_id
);
1657 rn
= route_node_match(table
, &p
);
1659 vty_out(vty
, "%% Network not in table\n");
1662 if (!address_str
&& rn
->p
.prefixlen
!= p
.prefixlen
) {
1663 vty_out(vty
, "%% Network not in table\n");
1664 route_unlock_node(rn
);
1668 vty_show_ip_route_detail(vty
, rn
, 0);
1670 route_unlock_node(rn
);
1676 DEFPY (show_route_summary
,
1677 show_route_summary_cmd
,
1680 ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
1681 summary [prefix$prefix]\
1682 |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
1683 summary [prefix$prefix]\
1687 "IP routing table\n"
1688 VRF_FULL_CMD_HELP_STR
1689 "Summary of all routes\n"
1692 "IP routing table\n"
1693 VRF_FULL_CMD_HELP_STR
1694 "Summary of all routes\n"
1697 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1698 struct route_table
*table
;
1702 struct zebra_vrf
*zvrf
;
1704 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
1705 if ((zvrf
= vrf
->info
) == NULL
1706 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1710 vty_show_ip_route_summary_prefix(vty
, table
);
1712 vty_show_ip_route_summary(vty
, table
);
1715 vrf_id_t vrf_id
= VRF_DEFAULT
;
1718 VRF_GET_ID(vrf_id
, vrf_name
);
1720 table
= zebra_vrf_table(afi
, SAFI_UNICAST
, vrf_id
);
1725 vty_show_ip_route_summary_prefix(vty
, table
);
1727 vty_show_ip_route_summary(vty
, table
);
1733 static void vty_show_ip_route_summary(struct vty
*vty
,
1734 struct route_table
*table
)
1736 struct route_node
*rn
;
1737 struct route_entry
*re
;
1738 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1739 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1740 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1741 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1745 memset(&rib_cnt
, 0, sizeof(rib_cnt
));
1746 memset(&fib_cnt
, 0, sizeof(fib_cnt
));
1747 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
1748 RNODE_FOREACH_RE (rn
, re
) {
1749 is_ibgp
= (re
->type
== ZEBRA_ROUTE_BGP
1750 && CHECK_FLAG(re
->flags
, ZEBRA_FLAG_IBGP
));
1752 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1754 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1756 rib_cnt
[re
->type
]++;
1758 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
)) {
1759 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1762 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1764 fib_cnt
[re
->type
]++;
1768 vty_out(vty
, "%-20s %-20s %s (vrf %s)\n", "Route Source", "Routes",
1769 "FIB", zvrf_name(((rib_table_info_t
*)table
->info
)->zvrf
));
1771 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1772 if ((rib_cnt
[i
] > 0) || (i
== ZEBRA_ROUTE_BGP
1773 && rib_cnt
[ZEBRA_ROUTE_IBGP
] > 0)) {
1774 if (i
== ZEBRA_ROUTE_BGP
) {
1775 vty_out(vty
, "%-20s %-20d %-20d \n", "ebgp",
1776 rib_cnt
[ZEBRA_ROUTE_BGP
],
1777 fib_cnt
[ZEBRA_ROUTE_BGP
]);
1778 vty_out(vty
, "%-20s %-20d %-20d \n", "ibgp",
1779 rib_cnt
[ZEBRA_ROUTE_IBGP
],
1780 fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1782 vty_out(vty
, "%-20s %-20d %-20d \n",
1783 zebra_route_string(i
), rib_cnt
[i
],
1788 vty_out(vty
, "------\n");
1789 vty_out(vty
, "%-20s %-20d %-20d \n", "Totals",
1790 rib_cnt
[ZEBRA_ROUTE_TOTAL
], fib_cnt
[ZEBRA_ROUTE_TOTAL
]);
1795 * Implementation of the ip route summary prefix command.
1797 * This command prints the primary prefixes that have been installed by various
1798 * protocols on the box.
1801 static void vty_show_ip_route_summary_prefix(struct vty
*vty
,
1802 struct route_table
*table
)
1804 struct route_node
*rn
;
1805 struct route_entry
*re
;
1806 struct nexthop
*nexthop
;
1807 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1808 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1809 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1810 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1814 memset(&rib_cnt
, 0, sizeof(rib_cnt
));
1815 memset(&fib_cnt
, 0, sizeof(fib_cnt
));
1816 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
1817 RNODE_FOREACH_RE (rn
, re
) {
1820 * In case of ECMP, count only once.
1823 for (nexthop
= re
->nexthop
; (!cnt
&& nexthop
);
1824 nexthop
= nexthop
->next
) {
1826 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1827 rib_cnt
[re
->type
]++;
1828 if (CHECK_FLAG(nexthop
->flags
,
1829 NEXTHOP_FLAG_FIB
)) {
1830 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1831 fib_cnt
[re
->type
]++;
1833 if (re
->type
== ZEBRA_ROUTE_BGP
1834 && CHECK_FLAG(re
->flags
, ZEBRA_FLAG_IBGP
)) {
1835 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1836 if (CHECK_FLAG(nexthop
->flags
,
1838 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1843 vty_out(vty
, "%-20s %-20s %s (vrf %s)\n", "Route Source",
1844 "Prefix Routes", "FIB",
1845 zvrf_name(((rib_table_info_t
*)table
->info
)->zvrf
));
1847 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1848 if (rib_cnt
[i
] > 0) {
1849 if (i
== ZEBRA_ROUTE_BGP
) {
1850 vty_out(vty
, "%-20s %-20d %-20d \n", "ebgp",
1851 rib_cnt
[ZEBRA_ROUTE_BGP
]
1852 - rib_cnt
[ZEBRA_ROUTE_IBGP
],
1853 fib_cnt
[ZEBRA_ROUTE_BGP
]
1854 - fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1855 vty_out(vty
, "%-20s %-20d %-20d \n", "ibgp",
1856 rib_cnt
[ZEBRA_ROUTE_IBGP
],
1857 fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1859 vty_out(vty
, "%-20s %-20d %-20d \n",
1860 zebra_route_string(i
), rib_cnt
[i
],
1865 vty_out(vty
, "------\n");
1866 vty_out(vty
, "%-20s %-20d %-20d \n", "Totals",
1867 rib_cnt
[ZEBRA_ROUTE_TOTAL
], fib_cnt
[ZEBRA_ROUTE_TOTAL
]);
1871 /* Write static route configuration. */
1872 int static_config(struct vty
*vty
, struct zebra_vrf
*zvrf
,
1873 afi_t afi
, safi_t safi
, const char *cmd
)
1876 struct route_node
*rn
;
1877 struct static_route
*si
;
1878 struct route_table
*stable
;
1879 char buf
[SRCDEST2STR_BUFFER
];
1882 if ((stable
= zvrf
->stable
[afi
][safi
]) == NULL
)
1885 sprintf(spacing
, "%s%s",
1886 (zvrf
->vrf
->vrf_id
== VRF_DEFAULT
) ? "" : " ",
1889 for (rn
= route_top(stable
); rn
; rn
= srcdest_route_next(rn
))
1890 for (si
= rn
->info
; si
; si
= si
->next
) {
1891 vty_out(vty
, "%s %s", spacing
,
1892 srcdest_rnode2str(rn
, buf
, sizeof buf
));
1895 case STATIC_IPV4_GATEWAY
:
1897 inet_ntoa(si
->addr
.ipv4
));
1899 case STATIC_IPV6_GATEWAY
:
1902 &si
->addr
.ipv6
, buf
,
1906 vty_out(vty
, " %s", si
->ifname
);
1908 case STATIC_BLACKHOLE
:
1909 switch (si
->bh_type
) {
1910 case STATIC_BLACKHOLE_DROP
:
1911 vty_out(vty
, " blackhole");
1913 case STATIC_BLACKHOLE_NULL
:
1914 vty_out(vty
, " Null0");
1916 case STATIC_BLACKHOLE_REJECT
:
1917 vty_out(vty
, " reject");
1921 case STATIC_IPV4_GATEWAY_IFNAME
:
1922 vty_out(vty
, " %s %s",
1924 &si
->addr
.ipv4
, buf
,
1928 case STATIC_IPV6_GATEWAY_IFNAME
:
1929 vty_out(vty
, " %s %s",
1931 &si
->addr
.ipv6
, buf
,
1938 vty_out(vty
, " tag %" ROUTE_TAG_PRI
,
1942 != ZEBRA_STATIC_DISTANCE_DEFAULT
)
1943 vty_out(vty
, " %d", si
->distance
);
1945 if (si
->nh_vrf_id
!= si
->vrf_id
) {
1948 vrf
= vrf_lookup_by_id(si
->nh_vrf_id
);
1949 vty_out(vty
, " nexthop-vrf %s",
1950 (vrf
) ? vrf
->name
: "Unknown");
1953 /* Label information */
1954 if (si
->snh_label
.num_labels
)
1955 vty_out(vty
, " label %s",
1956 mpls_label2str(si
->snh_label
.num_labels
,
1957 si
->snh_label
.label
,
1958 buf
, sizeof buf
, 0));
1967 DEFPY(ipv6_route_blackhole
,
1968 ipv6_route_blackhole_cmd
,
1969 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
1970 <Null0|reject|blackhole>$flag \
1972 tag (1-4294967295) \
1979 "Establish static routes\n"
1980 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1981 "IPv6 source-dest route\n"
1982 "IPv6 source prefix\n"
1984 "Emit an ICMP unreachable when matched\n"
1985 "Silently discard pkts when matched\n"
1986 "Set tag for this route\n"
1988 "Distance value for this prefix\n"
1992 return zebra_static_route(vty
, AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
1993 NULL
, from_str
, NULL
, NULL
, flag
,
1994 tag_str
, distance_str
, vrf
, label
);
1997 DEFPY(ipv6_route_blackhole_vrf
,
1998 ipv6_route_blackhole_vrf_cmd
,
1999 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2000 <Null0|reject|blackhole>$flag \
2002 tag (1-4294967295) \
2008 "Establish static routes\n"
2009 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2010 "IPv6 source-dest route\n"
2011 "IPv6 source prefix\n"
2013 "Emit an ICMP unreachable when matched\n"
2014 "Silently discard pkts when matched\n"
2015 "Set tag for this route\n"
2017 "Distance value for this prefix\n"
2020 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
2021 struct zebra_vrf
*zvrf
= vrf
->info
;
2024 * Coverity is complaining that prefix could
2025 * be dereferenced, but we know that prefix will
2026 * valid. Add an assert to make it happy
2029 return zebra_static_route_leak(vty
, zvrf
, zvrf
,
2030 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2031 NULL
, from_str
, NULL
, NULL
, flag
,
2032 tag_str
, distance_str
, label
);
2035 DEFPY(ipv6_route_address_interface
,
2036 ipv6_route_address_interface_cmd
,
2037 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2041 tag (1-4294967295) \
2049 "Establish static routes\n"
2050 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2051 "IPv6 source-dest route\n"
2052 "IPv6 source prefix\n"
2053 "IPv6 gateway address\n"
2054 "IPv6 gateway interface name\n"
2055 "Set tag for this route\n"
2057 "Distance value for this prefix\n"
2062 struct zebra_vrf
*zvrf
;
2063 struct zebra_vrf
*nh_zvrf
;
2065 zvrf
= zebra_vrf_lookup_by_name(vrf
);
2067 vty_out(vty
, "%% vrf %s is not defined\n",
2069 return CMD_WARNING_CONFIG_FAILED
;
2073 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2078 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2080 return CMD_WARNING_CONFIG_FAILED
;
2083 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2084 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2085 NULL
, from_str
, gate_str
, ifname
, NULL
,
2086 tag_str
, distance_str
, label
);
2089 DEFPY(ipv6_route_address_interface_vrf
,
2090 ipv6_route_address_interface_vrf_cmd
,
2091 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2095 tag (1-4294967295) \
2102 "Establish static routes\n"
2103 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2104 "IPv6 source-dest route\n"
2105 "IPv6 source prefix\n"
2106 "IPv6 gateway address\n"
2107 "IPv6 gateway interface name\n"
2108 "Set tag for this route\n"
2110 "Distance value for this prefix\n"
2114 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
2115 struct zebra_vrf
*zvrf
= vrf
->info
;
2116 struct zebra_vrf
*nh_zvrf
;
2119 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2124 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2126 return CMD_WARNING_CONFIG_FAILED
;
2129 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2130 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2131 NULL
, from_str
, gate_str
, ifname
, NULL
,
2132 tag_str
, distance_str
, label
);
2137 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2138 <X:X::X:X$gate|INTERFACE$ifname> \
2140 tag (1-4294967295) \
2148 "Establish static routes\n"
2149 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2150 "IPv6 source-dest route\n"
2151 "IPv6 source prefix\n"
2152 "IPv6 gateway address\n"
2153 "IPv6 gateway interface name\n"
2154 "Set tag for this route\n"
2156 "Distance value for this prefix\n"
2161 struct zebra_vrf
*zvrf
;
2162 struct zebra_vrf
*nh_zvrf
;
2164 zvrf
= zebra_vrf_lookup_by_name(vrf
);
2166 vty_out(vty
, "%% vrf %s is not defined\n",
2168 return CMD_WARNING_CONFIG_FAILED
;
2172 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2177 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2179 return CMD_WARNING_CONFIG_FAILED
;
2182 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2183 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2184 NULL
, from_str
, gate_str
, ifname
, NULL
,
2185 tag_str
, distance_str
, label
);
2188 DEFPY(ipv6_route_vrf
,
2190 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2191 <X:X::X:X$gate|INTERFACE$ifname> \
2193 tag (1-4294967295) \
2200 "Establish static routes\n"
2201 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2202 "IPv6 source-dest route\n"
2203 "IPv6 source prefix\n"
2204 "IPv6 gateway address\n"
2205 "IPv6 gateway interface name\n"
2206 "Set tag for this route\n"
2208 "Distance value for this prefix\n"
2212 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
2213 struct zebra_vrf
*zvrf
= vrf
->info
;
2214 struct zebra_vrf
*nh_zvrf
;
2217 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2222 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2224 return CMD_WARNING_CONFIG_FAILED
;
2227 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2228 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2229 NULL
, from_str
, gate_str
, ifname
, NULL
,
2230 tag_str
, distance_str
, label
);
2234 * Show IPv6 mroute command.Used to dump
2235 * the Multicast routing table.
2237 DEFUN (show_ipv6_mroute
,
2238 show_ipv6_mroute_cmd
,
2239 "show ipv6 mroute [vrf NAME]",
2242 "IPv6 Multicast routing table\n"
2245 struct route_table
*table
;
2246 struct route_node
*rn
;
2247 struct route_entry
*re
;
2249 vrf_id_t vrf_id
= VRF_DEFAULT
;
2252 VRF_GET_ID(vrf_id
, argv
[4]->arg
);
2254 table
= zebra_vrf_table(AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
2258 /* Show all IPv6 route. */
2259 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
2260 RNODE_FOREACH_RE (rn
, re
) {
2262 vty_out(vty
, SHOW_ROUTE_V6_HEADER
);
2265 vty_show_ip_route(vty
, rn
, re
, NULL
);
2270 DEFUN (show_ipv6_mroute_vrf_all
,
2271 show_ipv6_mroute_vrf_all_cmd
,
2272 "show ipv6 mroute vrf all",
2275 "IPv6 Multicast routing table\n"
2276 VRF_ALL_CMD_HELP_STR
)
2278 struct route_table
*table
;
2279 struct route_node
*rn
;
2280 struct route_entry
*re
;
2282 struct zebra_vrf
*zvrf
;
2285 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
2286 if ((zvrf
= vrf
->info
) == NULL
2287 || (table
= zvrf
->table
[AFI_IP6
][SAFI_MULTICAST
]) == NULL
)
2290 /* Show all IPv6 route. */
2291 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
2292 RNODE_FOREACH_RE (rn
, re
) {
2294 vty_out(vty
, SHOW_ROUTE_V6_HEADER
);
2297 vty_show_ip_route(vty
, rn
, re
, NULL
);
2303 DEFUN (allow_external_route_update
,
2304 allow_external_route_update_cmd
,
2305 "allow-external-route-update",
2306 "Allow FRR routes to be overwritten by external processes\n")
2313 DEFUN (no_allow_external_route_update
,
2314 no_allow_external_route_update_cmd
,
2315 "no allow-external-route-update",
2317 "Allow FRR routes to be overwritten by external processes\n")
2332 struct zebra_vrf
*zvrf
;
2334 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
2335 if (!(zvrf
= vrf
->info
))
2337 if (zvrf_id(zvrf
) == VRF_DEFAULT
)
2340 vty_out(vty
, "vrf %s ", zvrf_name(zvrf
));
2341 if (zvrf_id(zvrf
) == VRF_UNKNOWN
)
2342 vty_out(vty
, "inactive");
2344 vty_out(vty
, "id %u table %u", zvrf_id(zvrf
),
2346 if (vrf_is_user_cfged(vrf
))
2347 vty_out(vty
, " (configured)");
2354 DEFUN (default_vrf_vni_mapping
,
2355 default_vrf_vni_mapping_cmd
,
2356 "vni " CMD_VNI_RANGE
,
2357 "VNI corresponding to the DEFAULT VRF\n"
2361 char err
[ERR_STR_SZ
];
2362 struct zebra_vrf
*zvrf
= NULL
;
2363 vni_t vni
= strtoul(argv
[1]->arg
, NULL
, 10);
2365 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2369 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 1);
2371 vty_out(vty
, "%s\n", err
);
2378 DEFUN (no_default_vrf_vni_mapping
,
2379 no_default_vrf_vni_mapping_cmd
,
2380 "no vni " CMD_VNI_RANGE
,
2382 "VNI corresponding to DEFAULT VRF\n"
2386 char err
[ERR_STR_SZ
];
2387 vni_t vni
= strtoul(argv
[2]->arg
, NULL
, 10);
2388 struct zebra_vrf
*zvrf
= NULL
;
2390 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2394 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 0);
2396 vty_out(vty
, "%s\n", err
);
2403 DEFUN (vrf_vni_mapping
,
2404 vrf_vni_mapping_cmd
,
2405 "vni " CMD_VNI_RANGE
,
2406 "VNI corresponding to tenant VRF\n"
2411 ZEBRA_DECLVAR_CONTEXT(vrf
, zvrf
);
2412 vni_t vni
= strtoul(argv
[1]->arg
, NULL
, 10);
2413 char err
[ERR_STR_SZ
];
2418 /* Mark as having FRR configuration */
2419 vrf_set_user_cfged(vrf
);
2420 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 1);
2422 vty_out(vty
, "%s\n", err
);
2429 DEFUN (no_vrf_vni_mapping
,
2430 no_vrf_vni_mapping_cmd
,
2431 "no vni " CMD_VNI_RANGE
,
2433 "VNI corresponding to tenant VRF\n"
2437 char err
[ERR_STR_SZ
];
2438 vni_t vni
= strtoul(argv
[2]->arg
, NULL
, 10);
2440 ZEBRA_DECLVAR_CONTEXT(vrf
, zvrf
);
2445 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 0);
2447 vty_out(vty
, "%s\n", err
);
2451 /* If no other FRR config for this VRF, mark accordingly. */
2452 if (!zebra_vrf_has_config(zvrf
))
2453 vrf_reset_user_cfged(vrf
);
2459 DEFUN (show_vrf_vni
,
2461 "show vrf vni [json]",
2468 struct zebra_vrf
*zvrf
;
2469 json_object
*json
= NULL
;
2470 json_object
*json_vrfs
= NULL
;
2471 u_char uj
= use_json(argc
, argv
);
2474 json
= json_object_new_object();
2475 json_vrfs
= json_object_new_array();
2479 vty_out(vty
, "%-37s %-10s %-20s %-20s %-5s %-18s\n",
2480 "VRF", "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac");
2482 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
2487 zebra_vxlan_print_vrf_vni(vty
, zvrf
, json_vrfs
);
2491 json_object_object_add(json
, "vrfs", json_vrfs
);
2492 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2493 json
, JSON_C_TO_STRING_PRETTY
));
2494 json_object_free(json
);
2500 DEFUN (show_evpn_global
,
2501 show_evpn_global_cmd
,
2507 u_char uj
= use_json(argc
, argv
);
2509 zebra_vxlan_print_evpn(vty
, uj
);
2513 DEFUN (show_evpn_vni
,
2515 "show evpn vni [json]",
2518 "VxLAN information\n"
2521 struct zebra_vrf
*zvrf
;
2522 u_char uj
= use_json(argc
, argv
);
2524 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2525 zebra_vxlan_print_vnis(vty
, zvrf
, uj
);
2529 DEFUN (show_evpn_vni_vni
,
2530 show_evpn_vni_vni_cmd
,
2531 "show evpn vni " CMD_VNI_RANGE
"[json]",
2534 "VxLAN Network Identifier\n"
2538 struct zebra_vrf
*zvrf
;
2540 u_char uj
= use_json(argc
, argv
);
2542 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
2543 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2544 zebra_vxlan_print_vni(vty
, zvrf
, vni
, uj
);
2548 DEFUN (show_evpn_rmac_vni_mac
,
2549 show_evpn_rmac_vni_mac_cmd
,
2550 "show evpn rmac vni " CMD_VNI_RANGE
" mac WORD [json]",
2557 "mac-address (e.g. 0a:0a:0a:0a:0a:0a)\n"
2562 u_char uj
= use_json(argc
, argv
);
2564 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2565 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
2566 vty_out(vty
, "%% Malformed MAC address\n");
2569 zebra_vxlan_print_specific_rmac_l3vni(vty
, l3vni
, &mac
, uj
);
2573 DEFUN (show_evpn_rmac_vni
,
2574 show_evpn_rmac_vni_cmd
,
2575 "show evpn rmac vni " CMD_VNI_RANGE
"[json]",
2584 u_char uj
= use_json(argc
, argv
);
2586 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2587 zebra_vxlan_print_rmacs_l3vni(vty
, l3vni
, uj
);
2592 DEFUN (show_evpn_rmac_vni_all
,
2593 show_evpn_rmac_vni_all_cmd
,
2594 "show evpn rmac vni all [json]",
2602 u_char uj
= use_json(argc
, argv
);
2604 zebra_vxlan_print_rmacs_all_l3vni(vty
, uj
);
2609 DEFUN (show_evpn_nh_vni_ip
,
2610 show_evpn_nh_vni_ip_cmd
,
2611 "show evpn next-hops vni " CMD_VNI_RANGE
" ip WORD [json]",
2618 "Host address (ipv4 or ipv6)\n"
2623 u_char uj
= use_json(argc
, argv
);
2625 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2626 if (str2ipaddr(argv
[6]->arg
, &ip
) != 0) {
2628 vty_out(vty
, "%% Malformed Neighbor address\n");
2631 zebra_vxlan_print_specific_nh_l3vni(vty
, l3vni
, &ip
, uj
);
2636 DEFUN (show_evpn_nh_vni
,
2637 show_evpn_nh_vni_cmd
,
2638 "show evpn next-hops vni " CMD_VNI_RANGE
"[json]",
2647 u_char uj
= use_json(argc
, argv
);
2649 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2650 zebra_vxlan_print_nh_l3vni(vty
, l3vni
, uj
);
2655 DEFUN (show_evpn_nh_vni_all
,
2656 show_evpn_nh_vni_all_cmd
,
2657 "show evpn next-hops vni all [json]",
2665 u_char uj
= use_json(argc
, argv
);
2667 zebra_vxlan_print_nh_all_l3vni(vty
, uj
);
2672 DEFUN (show_evpn_mac_vni
,
2673 show_evpn_mac_vni_cmd
,
2674 "show evpn mac vni " CMD_VNI_RANGE
"[json]",
2678 "VxLAN Network Identifier\n"
2682 struct zebra_vrf
*zvrf
;
2684 u_char uj
= use_json(argc
, argv
);
2686 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2687 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2688 zebra_vxlan_print_macs_vni(vty
, zvrf
, vni
, uj
);
2692 DEFUN (show_evpn_mac_vni_all
,
2693 show_evpn_mac_vni_all_cmd
,
2694 "show evpn mac vni all [json]",
2698 "VxLAN Network Identifier\n"
2702 struct zebra_vrf
*zvrf
;
2703 u_char uj
= use_json(argc
, argv
);
2705 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2706 zebra_vxlan_print_macs_all_vni(vty
, zvrf
, uj
);
2710 DEFUN (show_evpn_mac_vni_all_vtep
,
2711 show_evpn_mac_vni_all_vtep_cmd
,
2712 "show evpn mac vni all vtep A.B.C.D [json]",
2716 "VxLAN Network Identifier\n"
2719 "Remote VTEP IP address\n"
2722 struct zebra_vrf
*zvrf
;
2723 struct in_addr vtep_ip
;
2724 u_char uj
= use_json(argc
, argv
);
2726 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2728 vty_out(vty
, "%% Malformed VTEP IP address\n");
2731 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2732 zebra_vxlan_print_macs_all_vni_vtep(vty
, zvrf
, vtep_ip
, uj
);
2738 DEFUN (show_evpn_mac_vni_mac
,
2739 show_evpn_mac_vni_mac_cmd
,
2740 "show evpn mac vni " CMD_VNI_RANGE
" mac WORD",
2744 "VxLAN Network Identifier\n"
2747 "MAC address (e.g., 00:e0:ec:20:12:62)\n")
2749 struct zebra_vrf
*zvrf
;
2753 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2754 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
2755 vty_out(vty
, "%% Malformed MAC address");
2758 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2759 zebra_vxlan_print_specific_mac_vni(vty
, zvrf
, vni
, &mac
);
2763 DEFUN (show_evpn_mac_vni_vtep
,
2764 show_evpn_mac_vni_vtep_cmd
,
2765 "show evpn mac vni " CMD_VNI_RANGE
" vtep A.B.C.D" "[json]",
2769 "VxLAN Network Identifier\n"
2772 "Remote VTEP IP address\n"
2775 struct zebra_vrf
*zvrf
;
2777 struct in_addr vtep_ip
;
2778 u_char uj
= use_json(argc
, argv
);
2780 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2781 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2783 vty_out(vty
, "%% Malformed VTEP IP address\n");
2787 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2788 zebra_vxlan_print_macs_vni_vtep(vty
, zvrf
, vni
, vtep_ip
, uj
);
2792 DEFUN (show_evpn_neigh_vni
,
2793 show_evpn_neigh_vni_cmd
,
2794 "show evpn arp-cache vni " CMD_VNI_RANGE
"[json]",
2797 "ARP and ND cache\n"
2798 "VxLAN Network Identifier\n"
2802 struct zebra_vrf
*zvrf
;
2804 u_char uj
= use_json(argc
, argv
);
2806 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2807 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2808 zebra_vxlan_print_neigh_vni(vty
, zvrf
, vni
, uj
);
2812 DEFUN (show_evpn_neigh_vni_all
,
2813 show_evpn_neigh_vni_all_cmd
,
2814 "show evpn arp-cache vni all [json]",
2817 "ARP and ND cache\n"
2818 "VxLAN Network Identifier\n"
2822 struct zebra_vrf
*zvrf
;
2823 u_char uj
= use_json(argc
, argv
);
2825 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2826 zebra_vxlan_print_neigh_all_vni(vty
, zvrf
, uj
);
2830 DEFUN (show_evpn_neigh_vni_neigh
,
2831 show_evpn_neigh_vni_neigh_cmd
,
2832 "show evpn arp-cache vni " CMD_VNI_RANGE
" ip WORD [json]",
2835 "ARP and ND cache\n"
2836 "VxLAN Network Identifier\n"
2839 "Neighbor address (IPv4 or IPv6 address)\n"
2842 struct zebra_vrf
*zvrf
;
2845 u_char uj
= use_json(argc
, argv
);
2847 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2848 if (str2ipaddr(argv
[6]->arg
, &ip
) != 0) {
2850 vty_out(vty
, "%% Malformed Neighbor address\n");
2853 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2854 zebra_vxlan_print_specific_neigh_vni(vty
, zvrf
, vni
, &ip
, uj
);
2858 DEFUN (show_evpn_neigh_vni_vtep
,
2859 show_evpn_neigh_vni_vtep_cmd
,
2860 "show evpn arp-cache vni " CMD_VNI_RANGE
" vtep A.B.C.D [json]",
2863 "ARP and ND cache\n"
2864 "VxLAN Network Identifier\n"
2867 "Remote VTEP IP address\n"
2870 struct zebra_vrf
*zvrf
;
2872 struct in_addr vtep_ip
;
2873 u_char uj
= use_json(argc
, argv
);
2875 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2876 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2878 vty_out(vty
, "%% Malformed VTEP IP address\n");
2882 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2883 zebra_vxlan_print_neigh_vni_vtep(vty
, zvrf
, vni
, vtep_ip
, uj
);
2887 /* Static ip route configuration write function. */
2888 static int zebra_ip_config(struct vty
*vty
)
2892 write
+= zebra_import_table_config(vty
);
2897 DEFUN (ip_zebra_import_table_distance
,
2898 ip_zebra_import_table_distance_cmd
,
2899 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
2901 "import routes from non-main kernel table\n"
2902 "kernel routing table id\n"
2903 "Distance for imported routes\n"
2904 "Default distance value\n"
2905 "route-map for filtering\n"
2908 u_int32_t table_id
= 0;
2910 table_id
= strtoul(argv
[2]->arg
, NULL
, 10);
2911 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
2913 strmatch(argv
[argc
- 2]->text
, "route-map")
2914 ? XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
)
2918 if (argc
== 7 || (argc
== 5 && !rmap
))
2919 distance
= strtoul(argv
[4]->arg
, NULL
, 10);
2921 if (!is_zebra_valid_kernel_table(table_id
)) {
2923 "Invalid routing table ID, %d. Must be in range 1-252\n",
2926 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2930 if (is_zebra_main_routing_table(table_id
)) {
2932 "Invalid routing table ID, %d. Must be non-default table\n",
2935 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2939 ret
= zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1);
2941 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2946 DEFUN_HIDDEN (zebra_packet_process
,
2947 zebra_packet_process_cmd
,
2948 "zebra zapi-packets (1-10000)",
2951 "Number of packets to process before relinquishing thread\n")
2953 uint32_t packets
= strtoul(argv
[2]->arg
, NULL
, 10);
2955 zebrad
.packets_to_process
= packets
;
2960 DEFUN_HIDDEN (no_zebra_packet_process
,
2961 no_zebra_packet_process_cmd
,
2962 "no zebra zapi-packets [(1-10000)]",
2966 "Number of packets to process before relinquishing thread\n")
2968 zebrad
.packets_to_process
= ZEBRA_ZAPI_PACKETS_TO_PROCESS
;
2973 DEFUN_HIDDEN (zebra_workqueue_timer
,
2974 zebra_workqueue_timer_cmd
,
2975 "zebra work-queue (0-10000)",
2978 "Time in milliseconds\n")
2980 uint32_t timer
= strtoul(argv
[2]->arg
, NULL
, 10);
2981 zebrad
.ribq
->spec
.hold
= timer
;
2986 DEFUN_HIDDEN (no_zebra_workqueue_timer
,
2987 no_zebra_workqueue_timer_cmd
,
2988 "no zebra work-queue [(0-10000)]",
2992 "Time in milliseconds\n")
2994 zebrad
.ribq
->spec
.hold
= ZEBRA_RIB_PROCESS_HOLD_TIME
;
2999 DEFUN (no_ip_zebra_import_table
,
3000 no_ip_zebra_import_table_cmd
,
3001 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
3004 "import routes from non-main kernel table\n"
3005 "kernel routing table id\n"
3006 "Distance for imported routes\n"
3007 "Default distance value\n"
3008 "route-map for filtering\n"
3011 u_int32_t table_id
= 0;
3012 table_id
= strtoul(argv
[3]->arg
, NULL
, 10);
3014 if (!is_zebra_valid_kernel_table(table_id
)) {
3016 "Invalid routing table ID. Must be in range 1-252\n");
3020 if (is_zebra_main_routing_table(table_id
)) {
3022 "Invalid routing table ID, %d. Must be non-default table\n",
3027 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
3030 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
3033 static int config_write_protocol(struct vty
*vty
)
3036 vty_out(vty
, "allow-external-route-update\n");
3038 if (zebra_rnh_ip_default_route
)
3039 vty_out(vty
, "ip nht resolve-via-default\n");
3041 if (zebra_rnh_ipv6_default_route
)
3042 vty_out(vty
, "ipv6 nht resolve-via-default\n");
3044 if (zebrad
.ribq
->spec
.hold
!= ZEBRA_RIB_PROCESS_HOLD_TIME
)
3045 vty_out(vty
, "zebra work-queue %u\n", zebrad
.ribq
->spec
.hold
);
3047 if (zebrad
.packets_to_process
!= ZEBRA_ZAPI_PACKETS_TO_PROCESS
)
3049 "zebra zapi-packets %u\n", zebrad
.packets_to_process
);
3051 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get();
3053 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
3054 vty_out(vty
, "ip multicast rpf-lookup-mode %s\n",
3055 ipv4_multicast_mode
== MCAST_URIB_ONLY
3057 : ipv4_multicast_mode
== MCAST_MRIB_ONLY
3059 : ipv4_multicast_mode
3060 == MCAST_MIX_MRIB_FIRST
3062 : ipv4_multicast_mode
3063 == MCAST_MIX_DISTANCE
3067 zebra_routemap_config_write_protocol(vty
);
3073 /* Display default rtm_table for all clients. */
3078 "default routing table to use for all clients\n")
3080 vty_out(vty
, "table %d\n", zebrad
.rtm_table_default
);
3084 DEFUN (config_table
,
3087 "Configure target kernel routing table\n"
3090 zebrad
.rtm_table_default
= strtol(argv
[1]->arg
, (char **)0, 10);
3094 DEFUN (no_config_table
,
3095 no_config_table_cmd
,
3096 "no table [TABLENO]",
3098 "Configure target kernel routing table\n"
3101 zebrad
.rtm_table_default
= 0;
3115 " Route Route Neighbor LSP LSP\n");
3117 "VRF Installs Removals Updates Installs Removals\n");
3119 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
3120 struct zebra_vrf
*zvrf
= vrf
->info
;
3122 vty_out(vty
, "%-25s %10" PRIu64
" %10" PRIu64
" %10" PRIu64
3123 " %10" PRIu64
" %10" PRIu64
"\n",
3124 vrf
->name
, zvrf
->installs
, zvrf
->removals
,
3125 zvrf
->neigh_updates
, zvrf
->lsp_installs
,
3126 zvrf
->lsp_removals
);
3132 DEFUN (ip_forwarding
,
3136 "Turn on IP forwarding\n")
3142 ret
= ipforward_on();
3145 vty_out(vty
, "Can't turn on IP forwarding\n");
3146 return CMD_WARNING_CONFIG_FAILED
;
3152 DEFUN (no_ip_forwarding
,
3153 no_ip_forwarding_cmd
,
3157 "Turn off IP forwarding\n")
3163 ret
= ipforward_off();
3166 vty_out(vty
, "Can't turn off IP forwarding\n");
3167 return CMD_WARNING_CONFIG_FAILED
;
3173 /* Only display ip forwarding is enabled or not. */
3174 DEFUN (show_ip_forwarding
,
3175 show_ip_forwarding_cmd
,
3176 "show ip forwarding",
3179 "IP forwarding status\n")
3186 vty_out(vty
, "IP forwarding is off\n");
3188 vty_out(vty
, "IP forwarding is on\n");
3192 /* Only display ipv6 forwarding is enabled or not. */
3193 DEFUN (show_ipv6_forwarding
,
3194 show_ipv6_forwarding_cmd
,
3195 "show ipv6 forwarding",
3197 "IPv6 information\n"
3198 "Forwarding status\n")
3202 ret
= ipforward_ipv6();
3206 vty_out(vty
, "ipv6 forwarding is unknown\n");
3209 vty_out(vty
, "ipv6 forwarding is %s\n", "off");
3212 vty_out(vty
, "ipv6 forwarding is %s\n", "on");
3215 vty_out(vty
, "ipv6 forwarding is %s\n", "off");
3221 DEFUN (ipv6_forwarding
,
3222 ipv6_forwarding_cmd
,
3225 "Turn on IPv6 forwarding\n")
3229 ret
= ipforward_ipv6();
3231 ret
= ipforward_ipv6_on();
3234 vty_out(vty
, "Can't turn on IPv6 forwarding\n");
3235 return CMD_WARNING_CONFIG_FAILED
;
3241 DEFUN (no_ipv6_forwarding
,
3242 no_ipv6_forwarding_cmd
,
3243 "no ipv6 forwarding",
3246 "Turn off IPv6 forwarding\n")
3250 ret
= ipforward_ipv6();
3252 ret
= ipforward_ipv6_off();
3255 vty_out(vty
, "Can't turn off IPv6 forwarding\n");
3256 return CMD_WARNING_CONFIG_FAILED
;
3262 /* Table configuration write function. */
3263 static int config_write_table(struct vty
*vty
)
3265 if (zebrad
.rtm_table_default
)
3266 vty_out(vty
, "table %d\n", zebrad
.rtm_table_default
);
3270 /* IPForwarding configuration write function. */
3271 static int config_write_forwarding(struct vty
*vty
)
3273 /* FIXME: Find better place for that. */
3274 router_id_write(vty
);
3277 vty_out(vty
, "no ip forwarding\n");
3278 if (!ipforward_ipv6())
3279 vty_out(vty
, "no ipv6 forwarding\n");
3280 vty_out(vty
, "!\n");
3284 /* IP node for static routes. */
3285 static struct cmd_node ip_node
= {IP_NODE
, "", 1};
3286 static struct cmd_node protocol_node
= {PROTOCOL_NODE
, "", 1};
3287 /* table node for routing tables. */
3288 static struct cmd_node table_node
= {TABLE_NODE
,
3289 "", /* This node has no interface. */
3291 static struct cmd_node forwarding_node
= {FORWARDING_NODE
,
3292 "", /* This node has no interface. */
3296 void zebra_vty_init(void)
3298 /* Install configuration write function. */
3299 install_node(&table_node
, config_write_table
);
3300 install_node(&forwarding_node
, config_write_forwarding
);
3302 install_element(VIEW_NODE
, &show_ip_forwarding_cmd
);
3303 install_element(CONFIG_NODE
, &ip_forwarding_cmd
);
3304 install_element(CONFIG_NODE
, &no_ip_forwarding_cmd
);
3305 install_element(ENABLE_NODE
, &show_zebra_cmd
);
3308 install_element(VIEW_NODE
, &show_table_cmd
);
3309 install_element(CONFIG_NODE
, &config_table_cmd
);
3310 install_element(CONFIG_NODE
, &no_config_table_cmd
);
3311 #endif /* HAVE_NETLINK */
3313 install_element(VIEW_NODE
, &show_ipv6_forwarding_cmd
);
3314 install_element(CONFIG_NODE
, &ipv6_forwarding_cmd
);
3315 install_element(CONFIG_NODE
, &no_ipv6_forwarding_cmd
);
3318 zebra_route_map_init();
3320 install_node(&ip_node
, zebra_ip_config
);
3321 install_node(&protocol_node
, config_write_protocol
);
3323 install_element(CONFIG_NODE
, &allow_external_route_update_cmd
);
3324 install_element(CONFIG_NODE
, &no_allow_external_route_update_cmd
);
3325 install_element(CONFIG_NODE
, &ip_mroute_dist_cmd
);
3326 install_element(CONFIG_NODE
, &ip_multicast_mode_cmd
);
3327 install_element(CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
3328 install_element(CONFIG_NODE
, &ip_route_blackhole_cmd
);
3329 install_element(VRF_NODE
, &ip_route_blackhole_vrf_cmd
);
3330 install_element(CONFIG_NODE
, &ip_route_address_interface_cmd
);
3331 install_element(VRF_NODE
, &ip_route_address_interface_vrf_cmd
);
3332 install_element(CONFIG_NODE
, &ip_route_cmd
);
3333 install_element(VRF_NODE
, &ip_route_vrf_cmd
);
3334 install_element(CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
3335 install_element(CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
3336 install_element(CONFIG_NODE
, &zebra_workqueue_timer_cmd
);
3337 install_element(CONFIG_NODE
, &no_zebra_workqueue_timer_cmd
);
3338 install_element(CONFIG_NODE
, &zebra_packet_process_cmd
);
3339 install_element(CONFIG_NODE
, &no_zebra_packet_process_cmd
);
3341 install_element(VIEW_NODE
, &show_vrf_cmd
);
3342 install_element(VIEW_NODE
, &show_vrf_vni_cmd
);
3343 install_element(VIEW_NODE
, &show_route_cmd
);
3344 install_element(VIEW_NODE
, &show_route_detail_cmd
);
3345 install_element(VIEW_NODE
, &show_route_summary_cmd
);
3346 install_element(VIEW_NODE
, &show_ip_nht_cmd
);
3347 install_element(VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
3348 install_element(VIEW_NODE
, &show_ipv6_nht_cmd
);
3349 install_element(VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
3351 install_element(VIEW_NODE
, &show_ip_rpf_cmd
);
3352 install_element(VIEW_NODE
, &show_ip_rpf_addr_cmd
);
3354 install_element(CONFIG_NODE
, &ipv6_route_blackhole_cmd
);
3355 install_element(VRF_NODE
, &ipv6_route_blackhole_vrf_cmd
);
3356 install_element(CONFIG_NODE
, &ipv6_route_address_interface_cmd
);
3357 install_element(VRF_NODE
, &ipv6_route_address_interface_vrf_cmd
);
3358 install_element(CONFIG_NODE
, &ipv6_route_cmd
);
3359 install_element(VRF_NODE
, &ipv6_route_vrf_cmd
);
3360 install_element(CONFIG_NODE
, &ip_nht_default_route_cmd
);
3361 install_element(CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
3362 install_element(CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
3363 install_element(CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
3364 install_element(VIEW_NODE
, &show_ipv6_mroute_cmd
);
3366 /* Commands for VRF */
3367 install_element(VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);
3369 install_element(VIEW_NODE
, &show_evpn_global_cmd
);
3370 install_element(VIEW_NODE
, &show_evpn_vni_cmd
);
3371 install_element(VIEW_NODE
, &show_evpn_vni_vni_cmd
);
3372 install_element(VIEW_NODE
, &show_evpn_rmac_vni_mac_cmd
);
3373 install_element(VIEW_NODE
, &show_evpn_rmac_vni_cmd
);
3374 install_element(VIEW_NODE
, &show_evpn_rmac_vni_all_cmd
);
3375 install_element(VIEW_NODE
, &show_evpn_nh_vni_ip_cmd
);
3376 install_element(VIEW_NODE
, &show_evpn_nh_vni_cmd
);
3377 install_element(VIEW_NODE
, &show_evpn_nh_vni_all_cmd
);
3378 install_element(VIEW_NODE
, &show_evpn_mac_vni_cmd
);
3379 install_element(VIEW_NODE
, &show_evpn_mac_vni_all_cmd
);
3380 install_element(VIEW_NODE
, &show_evpn_mac_vni_all_vtep_cmd
);
3381 install_element(VIEW_NODE
, &show_evpn_mac_vni_mac_cmd
);
3382 install_element(VIEW_NODE
, &show_evpn_mac_vni_vtep_cmd
);
3383 install_element(VIEW_NODE
, &show_evpn_neigh_vni_cmd
);
3384 install_element(VIEW_NODE
, &show_evpn_neigh_vni_all_cmd
);
3385 install_element(VIEW_NODE
, &show_evpn_neigh_vni_neigh_cmd
);
3386 install_element(VIEW_NODE
, &show_evpn_neigh_vni_vtep_cmd
);
3388 install_element(CONFIG_NODE
, &default_vrf_vni_mapping_cmd
);
3389 install_element(CONFIG_NODE
, &no_default_vrf_vni_mapping_cmd
);
3390 install_element(VRF_NODE
, &vrf_vni_mapping_cmd
);
3391 install_element(VRF_NODE
, &no_vrf_vni_mapping_cmd
);