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_MIN_RESERVED_LABEL
,
169 MPLS_MAX_RESERVED_LABEL
);
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
,
239 static_delete_route(afi
, safi
, type
, &p
, src_p
, gatep
, ifname
,
240 tag
, distance
, zvrf
, &snh_label
);
245 static int zebra_static_route(struct vty
*vty
, afi_t afi
, safi_t safi
,
246 const char *negate
, const char *dest_str
,
247 const char *mask_str
, const char *src_str
,
248 const char *gate_str
, const char *ifname
,
249 const char *flag_str
, const char *tag_str
,
250 const char *distance_str
, const char *vrf_id_str
,
251 const char *label_str
)
253 struct zebra_vrf
*zvrf
;
256 zvrf
= zebra_vrf_lookup_by_name(vrf_id_str
);
259 vty_out(vty
, "%% vrf %s is not defined\n", vrf_id_str
);
260 return CMD_WARNING_CONFIG_FAILED
;
263 return zebra_static_route_leak(vty
, zvrf
, zvrf
, afi
, safi
,
264 negate
, dest_str
, mask_str
, src_str
,
265 gate_str
, ifname
, flag_str
, tag_str
,
266 distance_str
, label_str
);
270 /* Static unicast routes for multicast RPF lookup. */
271 DEFPY (ip_mroute_dist
,
273 "[no] ip mroute A.B.C.D/M$prefix <A.B.C.D$gate|INTERFACE$ifname> [(1-255)$distance]",
276 "Configure static unicast route into MRIB for multicast RPF lookup\n"
277 "IP destination prefix (e.g. 10.0.0.0/8)\n"
279 "Nexthop interface name\n"
282 return zebra_static_route(vty
, AFI_IP
, SAFI_MULTICAST
, no
, prefix_str
,
283 NULL
, NULL
, gate_str
, ifname
, NULL
, NULL
,
284 distance_str
, NULL
, NULL
);
287 DEFUN (ip_multicast_mode
,
288 ip_multicast_mode_cmd
,
289 "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>",
291 "Multicast options\n"
292 "RPF lookup behavior\n"
293 "Lookup in unicast RIB only\n"
294 "Lookup in multicast RIB only\n"
295 "Try multicast RIB first, fall back to unicast RIB\n"
296 "Lookup both, use entry with lower distance\n"
297 "Lookup both, use entry with longer prefix\n")
299 char *mode
= argv
[3]->text
;
301 if (strmatch(mode
, "urib-only"))
302 multicast_mode_ipv4_set(MCAST_URIB_ONLY
);
303 else if (strmatch(mode
, "mrib-only"))
304 multicast_mode_ipv4_set(MCAST_MRIB_ONLY
);
305 else if (strmatch(mode
, "mrib-then-urib"))
306 multicast_mode_ipv4_set(MCAST_MIX_MRIB_FIRST
);
307 else if (strmatch(mode
, "lower-distance"))
308 multicast_mode_ipv4_set(MCAST_MIX_DISTANCE
);
309 else if (strmatch(mode
, "longer-prefix"))
310 multicast_mode_ipv4_set(MCAST_MIX_PFXLEN
);
312 vty_out(vty
, "Invalid mode specified\n");
313 return CMD_WARNING_CONFIG_FAILED
;
319 DEFUN (no_ip_multicast_mode
,
320 no_ip_multicast_mode_cmd
,
321 "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]",
324 "Multicast options\n"
325 "RPF lookup behavior\n"
326 "Lookup in unicast RIB only\n"
327 "Lookup in multicast RIB only\n"
328 "Try multicast RIB first, fall back to unicast RIB\n"
329 "Lookup both, use entry with lower distance\n"
330 "Lookup both, use entry with longer prefix\n")
332 multicast_mode_ipv4_set(MCAST_NO_CONFIG
);
339 "show ip rpf [json]",
342 "Display RPF information for multicast source\n"
345 int uj
= use_json(argc
, argv
);
346 return do_show_ip_route(vty
, VRF_DEFAULT_NAME
, AFI_IP
, SAFI_MULTICAST
,
347 false, uj
, 0, NULL
, false, 0, 0);
350 DEFUN (show_ip_rpf_addr
,
351 show_ip_rpf_addr_cmd
,
352 "show ip rpf A.B.C.D",
355 "Display RPF information for multicast source\n"
356 "IP multicast source address (e.g. 10.0.0.0)\n")
360 struct route_node
*rn
;
361 struct route_entry
*re
;
364 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
366 vty_out(vty
, "%% Malformed address\n");
370 re
= rib_match_ipv4_multicast(VRF_DEFAULT
, addr
, &rn
);
373 vty_show_ip_route_detail(vty
, rn
, 1);
375 vty_out(vty
, "%% No match for RPF lookup\n");
380 /* Static route configuration. */
381 DEFPY(ip_route_blackhole
,
382 ip_route_blackhole_cmd
,
384 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
385 <reject|blackhole>$flag \
393 "Establish static routes\n"
394 "IP destination prefix (e.g. 10.0.0.0/8)\n"
395 "IP destination prefix\n"
396 "IP destination prefix mask\n"
397 "Emit an ICMP unreachable when matched\n"
398 "Silently discard pkts when matched\n"
399 "Set tag for this route\n"
401 "Distance value for this route\n"
405 return zebra_static_route(vty
, AFI_IP
, SAFI_UNICAST
, no
, prefix
,
406 mask_str
, NULL
, NULL
, NULL
, flag
,
407 tag_str
, distance_str
, vrf
, label
);
410 DEFPY(ip_route_blackhole_vrf
,
411 ip_route_blackhole_vrf_cmd
,
413 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
414 <reject|blackhole>$flag \
421 "Establish static routes\n"
422 "IP destination prefix (e.g. 10.0.0.0/8)\n"
423 "IP destination prefix\n"
424 "IP destination prefix mask\n"
425 "Emit an ICMP unreachable when matched\n"
426 "Silently discard pkts when matched\n"
427 "Set tag for this route\n"
429 "Distance value for this route\n"
432 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
433 struct zebra_vrf
*zvrf
= vrf
->info
;
435 return zebra_static_route_leak(vty
, zvrf
, zvrf
,
436 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
437 mask_str
, NULL
, NULL
, NULL
, flag
,
438 tag_str
, distance_str
, label
);
441 DEFPY(ip_route_address_interface
,
442 ip_route_address_interface_cmd
,
444 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
455 "Establish static routes\n"
456 "IP destination prefix (e.g. 10.0.0.0/8)\n"
457 "IP destination prefix\n"
458 "IP destination prefix mask\n"
459 "IP gateway address\n"
460 "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \
462 "Set tag for this route\n"
464 "Distance value for this route\n"
469 struct zebra_vrf
*zvrf
;
470 struct zebra_vrf
*nh_zvrf
;
472 const char *flag
= NULL
;
473 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
478 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
480 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
482 return CMD_WARNING_CONFIG_FAILED
;
485 zvrf
= zebra_vrf_lookup_by_name(vrf
);
487 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
489 return CMD_WARNING_CONFIG_FAILED
;
492 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
493 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
494 mask_str
, NULL
, gate_str
, ifname
, flag
,
495 tag_str
, distance_str
, label
);
498 DEFPY(ip_route_address_interface_vrf
,
499 ip_route_address_interface_vrf_cmd
,
501 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
511 "Establish static routes\n"
512 "IP destination prefix (e.g. 10.0.0.0/8)\n"
513 "IP destination prefix\n"
514 "IP destination prefix mask\n"
515 "IP gateway address\n"
516 "IP gateway interface name. Specify 'Null0' (case-insensitive) for a \
518 "Set tag for this route\n"
520 "Distance value for this route\n"
524 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
525 const char *flag
= NULL
;
526 struct zebra_vrf
*zvrf
= vrf
->info
;
527 struct zebra_vrf
*nh_zvrf
;
529 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
534 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
536 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
538 return CMD_WARNING_CONFIG_FAILED
;
541 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
542 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
543 mask_str
, NULL
, gate_str
, ifname
, flag
,
544 tag_str
, distance_str
, label
);
550 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
551 <A.B.C.D$gate|INTERFACE$ifname> \
560 "Establish static routes\n"
561 "IP destination prefix (e.g. 10.0.0.0/8)\n"
562 "IP destination prefix\n"
563 "IP destination prefix mask\n"
564 "IP gateway address\n"
565 "IP gateway interface name\n"
566 "Set tag for this route\n"
568 "Distance value for this route\n"
573 struct zebra_vrf
*zvrf
;
574 struct zebra_vrf
*nh_zvrf
;
575 const char *flag
= NULL
;
577 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
582 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
584 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
586 return CMD_WARNING_CONFIG_FAILED
;
589 zvrf
= zebra_vrf_lookup_by_name(vrf
);
591 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
593 return CMD_WARNING_CONFIG_FAILED
;
596 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
597 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
598 mask_str
, NULL
, gate_str
, ifname
, flag
,
599 tag_str
, distance_str
, label
);
605 <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask> \
606 <A.B.C.D$gate|INTERFACE$ifname> \
614 "Establish static routes\n"
615 "IP destination prefix (e.g. 10.0.0.0/8)\n"
616 "IP destination prefix\n"
617 "IP destination prefix mask\n"
618 "IP gateway address\n"
619 "IP gateway interface name\n"
620 "Set tag for this route\n"
622 "Distance value for this route\n"
626 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
627 struct zebra_vrf
*zvrf
= vrf
->info
;
628 struct zebra_vrf
*nh_zvrf
;
630 const char *flag
= NULL
;
631 if (ifname
&& !strncasecmp(ifname
, "Null0", 5)) {
636 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
638 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
640 return CMD_WARNING_CONFIG_FAILED
;
643 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
644 AFI_IP
, SAFI_UNICAST
, no
, prefix
,
645 mask_str
, NULL
, gate_str
, ifname
, flag
,
646 tag_str
, distance_str
, label
);
649 /* New RIB. Detailed information for IPv4 route. */
650 static void vty_show_ip_route_detail(struct vty
*vty
, struct route_node
*rn
,
653 struct route_entry
*re
;
654 struct nexthop
*nexthop
;
655 char buf
[SRCDEST2STR_BUFFER
];
656 struct zebra_vrf
*zvrf
;
658 RNODE_FOREACH_RE (rn
, re
) {
659 const char *mcast_info
= "";
661 rib_table_info_t
*info
= srcdest_rnode_table_info(rn
);
662 mcast_info
= (info
->safi
== SAFI_MULTICAST
)
663 ? " using Multicast RIB"
664 : " using Unicast RIB";
667 vty_out(vty
, "Routing entry for %s%s\n",
668 srcdest_rnode2str(rn
, buf
, sizeof(buf
)), mcast_info
);
669 vty_out(vty
, " Known via \"%s", zebra_route_string(re
->type
));
671 vty_out(vty
, "[%d]", re
->instance
);
673 vty_out(vty
, ", distance %u, metric %u", re
->distance
,
676 vty_out(vty
, ", tag %u", re
->tag
);
677 #if defined(SUPPORT_REALMS)
678 if (re
->tag
> 0 && re
->tag
<= 255)
679 vty_out(vty
, "(realm)");
683 vty_out(vty
, ", mtu %u", re
->mtu
);
684 if (re
->vrf_id
!= VRF_DEFAULT
) {
685 zvrf
= vrf_info_lookup(re
->vrf_id
);
686 vty_out(vty
, ", vrf %s", zvrf_name(zvrf
));
688 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
689 vty_out(vty
, ", best");
696 uptime
-= re
->uptime
;
697 tm
= gmtime(&uptime
);
699 vty_out(vty
, " Last update ");
701 if (uptime
< ONE_DAY_SECOND
)
702 vty_out(vty
, "%02d:%02d:%02d", tm
->tm_hour
,
703 tm
->tm_min
, tm
->tm_sec
);
704 else if (uptime
< ONE_WEEK_SECOND
)
705 vty_out(vty
, "%dd%02dh%02dm", tm
->tm_yday
,
706 tm
->tm_hour
, tm
->tm_min
);
708 vty_out(vty
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
709 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
711 vty_out(vty
, " ago\n");
713 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
716 vty_out(vty
, " %c%s",
717 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
718 ? CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
)
721 nexthop
->rparent
? " " : "");
723 switch (nexthop
->type
) {
724 case NEXTHOP_TYPE_IPV4
:
725 case NEXTHOP_TYPE_IPV4_IFINDEX
:
727 inet_ntoa(nexthop
->gate
.ipv4
));
728 if (nexthop
->ifindex
)
729 vty_out(vty
, ", via %s",
730 ifindex2ifname(nexthop
->ifindex
,
733 case NEXTHOP_TYPE_IPV6
:
734 case NEXTHOP_TYPE_IPV6_IFINDEX
:
736 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
,
738 if (nexthop
->ifindex
)
739 vty_out(vty
, ", via %s",
740 ifindex2ifname(nexthop
->ifindex
,
743 case NEXTHOP_TYPE_IFINDEX
:
744 vty_out(vty
, " directly connected, %s",
745 ifindex2ifname(nexthop
->ifindex
,
748 case NEXTHOP_TYPE_BLACKHOLE
:
749 vty_out(vty
, " unreachable");
750 switch (nexthop
->bh_type
) {
751 case BLACKHOLE_REJECT
:
752 vty_out(vty
, " (ICMP unreachable)");
754 case BLACKHOLE_ADMINPROHIB
:
756 " (ICMP admin-prohibited)");
759 vty_out(vty
, " (blackhole)");
761 case BLACKHOLE_UNSPEC
:
769 if (re
->vrf_id
!= re
->nh_vrf_id
) {
771 vrf_lookup_by_id(re
->nh_vrf_id
);
773 vty_out(vty
, "(vrf %s)", vrf
->name
);
776 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
777 vty_out(vty
, " (duplicate nexthop removed)");
779 if (!CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
780 vty_out(vty
, " inactive");
782 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
783 vty_out(vty
, " onlink");
785 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
786 vty_out(vty
, " (recursive)");
788 switch (nexthop
->type
) {
789 case NEXTHOP_TYPE_IPV4
:
790 case NEXTHOP_TYPE_IPV4_IFINDEX
:
791 if (nexthop
->src
.ipv4
.s_addr
) {
792 if (inet_ntop(AF_INET
,
794 addrstr
, sizeof addrstr
))
795 vty_out(vty
, ", src %s",
799 case NEXTHOP_TYPE_IPV6
:
800 case NEXTHOP_TYPE_IPV6_IFINDEX
:
801 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
,
803 if (inet_ntop(AF_INET6
,
805 addrstr
, sizeof addrstr
))
806 vty_out(vty
, ", src %s",
815 vty_out(vty
, ", mtu %u", re
->nexthop_mtu
);
817 /* Label information */
818 if (nexthop
->nh_label
819 && nexthop
->nh_label
->num_labels
) {
820 vty_out(vty
, ", label %s",
822 nexthop
->nh_label
->num_labels
,
823 nexthop
->nh_label
->label
, buf
,
833 static void vty_show_ip_route(struct vty
*vty
, struct route_node
*rn
,
834 struct route_entry
*re
, json_object
*json
)
836 struct nexthop
*nexthop
;
838 char buf
[SRCDEST2STR_BUFFER
];
839 json_object
*json_nexthops
= NULL
;
840 json_object
*json_nexthop
= NULL
;
841 json_object
*json_route
= NULL
;
842 json_object
*json_labels
= NULL
;
847 uptime
-= re
->uptime
;
848 tm
= gmtime(&uptime
);
851 json_route
= json_object_new_object();
852 json_nexthops
= json_object_new_array();
854 json_object_string_add(json_route
, "prefix",
855 srcdest_rnode2str(rn
, buf
, sizeof buf
));
856 json_object_string_add(json_route
, "protocol",
857 zebra_route_string(re
->type
));
860 json_object_int_add(json_route
, "instance",
864 json_object_int_add(json_route
, "vrfId", re
->vrf_id
);
866 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
867 json_object_boolean_true_add(json_route
, "selected");
869 if (re
->type
!= ZEBRA_ROUTE_CONNECT
) {
870 json_object_int_add(json_route
, "distance",
872 json_object_int_add(json_route
, "metric", re
->metric
);
875 if (uptime
< ONE_DAY_SECOND
)
876 sprintf(buf
, "%02d:%02d:%02d", tm
->tm_hour
,
877 tm
->tm_min
, tm
->tm_sec
);
878 else if (uptime
< ONE_WEEK_SECOND
)
879 sprintf(buf
, "%dd%02dh%02dm", tm
->tm_yday
,
880 tm
->tm_hour
, tm
->tm_min
);
882 sprintf(buf
, "%02dw%dd%02dh", tm
->tm_yday
/ 7,
883 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
886 json_object_string_add(json_route
, "uptime", buf
);
888 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
889 json_nexthop
= json_object_new_object();
891 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
892 json_object_boolean_true_add(json_nexthop
,
895 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
))
896 json_object_boolean_true_add(json_nexthop
,
899 switch (nexthop
->type
) {
900 case NEXTHOP_TYPE_IPV4
:
901 case NEXTHOP_TYPE_IPV4_IFINDEX
:
902 json_object_string_add(
904 inet_ntoa(nexthop
->gate
.ipv4
));
905 json_object_string_add(json_nexthop
, "afi",
908 if (nexthop
->ifindex
) {
909 json_object_int_add(json_nexthop
,
912 json_object_string_add(
913 json_nexthop
, "interfaceName",
914 ifindex2ifname(nexthop
->ifindex
,
918 case NEXTHOP_TYPE_IPV6
:
919 case NEXTHOP_TYPE_IPV6_IFINDEX
:
920 json_object_string_add(
922 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
,
924 json_object_string_add(json_nexthop
, "afi",
927 if (nexthop
->ifindex
) {
928 json_object_int_add(json_nexthop
,
931 json_object_string_add(
932 json_nexthop
, "interfaceName",
933 ifindex2ifname(nexthop
->ifindex
,
938 case NEXTHOP_TYPE_IFINDEX
:
939 json_object_boolean_true_add(
940 json_nexthop
, "directlyConnected");
941 json_object_int_add(json_nexthop
,
944 json_object_string_add(
945 json_nexthop
, "interfaceName",
946 ifindex2ifname(nexthop
->ifindex
,
949 case NEXTHOP_TYPE_BLACKHOLE
:
950 json_object_boolean_true_add(json_nexthop
,
952 switch (nexthop
->bh_type
) {
953 case BLACKHOLE_REJECT
:
954 json_object_boolean_true_add(
955 json_nexthop
, "reject");
957 case BLACKHOLE_ADMINPROHIB
:
958 json_object_boolean_true_add(
963 json_object_boolean_true_add(
964 json_nexthop
, "blackhole");
966 case BLACKHOLE_UNSPEC
:
974 if (re
->nh_vrf_id
!= re
->vrf_id
) {
976 vrf_lookup_by_id(re
->nh_vrf_id
);
978 json_object_string_add(json_nexthop
,
982 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
983 json_object_boolean_true_add(json_nexthop
,
986 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
987 json_object_boolean_true_add(json_nexthop
,
990 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
991 json_object_boolean_true_add(json_nexthop
,
994 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
995 json_object_boolean_true_add(json_nexthop
,
998 switch (nexthop
->type
) {
999 case NEXTHOP_TYPE_IPV4
:
1000 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1001 if (nexthop
->src
.ipv4
.s_addr
) {
1002 if (inet_ntop(AF_INET
,
1003 &nexthop
->src
.ipv4
, buf
,
1005 json_object_string_add(
1006 json_nexthop
, "source",
1010 case NEXTHOP_TYPE_IPV6
:
1011 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1012 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
,
1014 if (inet_ntop(AF_INET6
,
1015 &nexthop
->src
.ipv6
, buf
,
1017 json_object_string_add(
1018 json_nexthop
, "source",
1026 if (nexthop
->nh_label
1027 && nexthop
->nh_label
->num_labels
) {
1028 json_labels
= json_object_new_array();
1030 for (int label_index
= 0;
1032 < nexthop
->nh_label
->num_labels
;
1034 json_object_array_add(
1036 json_object_new_int(
1037 nexthop
->nh_label
->label
1040 json_object_object_add(json_nexthop
, "labels",
1044 json_object_array_add(json_nexthops
, json_nexthop
);
1047 json_object_object_add(json_route
, "nexthops", json_nexthops
);
1048 json_object_array_add(json
, json_route
);
1052 /* Nexthop information. */
1053 for (ALL_NEXTHOPS(re
->nexthop
, nexthop
)) {
1054 if (nexthop
== re
->nexthop
) {
1055 /* Prefix information. */
1056 len
= vty_out(vty
, "%c", zebra_route_char(re
->type
));
1058 len
+= vty_out(vty
, "[%d]", re
->instance
);
1061 CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
)
1064 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
1067 srcdest_rnode2str(rn
, buf
, sizeof buf
));
1069 /* Distance and metric display. */
1070 if (re
->type
!= ZEBRA_ROUTE_CONNECT
)
1071 len
+= vty_out(vty
, " [%u/%u]", re
->distance
,
1074 vty_out(vty
, " %c%*c",
1075 CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
)
1076 ? CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
)
1079 len
- 3 + (2 * nexthop_level(nexthop
)), ' ');
1082 switch (nexthop
->type
) {
1083 case NEXTHOP_TYPE_IPV4
:
1084 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1085 vty_out(vty
, " via %s", inet_ntoa(nexthop
->gate
.ipv4
));
1086 if (nexthop
->ifindex
)
1087 vty_out(vty
, ", %s",
1088 ifindex2ifname(nexthop
->ifindex
,
1091 case NEXTHOP_TYPE_IPV6
:
1092 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1093 vty_out(vty
, " via %s",
1094 inet_ntop(AF_INET6
, &nexthop
->gate
.ipv6
, buf
,
1096 if (nexthop
->ifindex
)
1097 vty_out(vty
, ", %s",
1098 ifindex2ifname(nexthop
->ifindex
,
1102 case NEXTHOP_TYPE_IFINDEX
:
1103 vty_out(vty
, " is directly connected, %s",
1104 ifindex2ifname(nexthop
->ifindex
,
1107 case NEXTHOP_TYPE_BLACKHOLE
:
1108 vty_out(vty
, " unreachable");
1109 switch (nexthop
->bh_type
) {
1110 case BLACKHOLE_REJECT
:
1111 vty_out(vty
, " (ICMP unreachable)");
1113 case BLACKHOLE_ADMINPROHIB
:
1114 vty_out(vty
, " (ICMP admin-prohibited)");
1116 case BLACKHOLE_NULL
:
1117 vty_out(vty
, " (blackhole)");
1119 case BLACKHOLE_UNSPEC
:
1127 if (re
->nh_vrf_id
!= re
->vrf_id
) {
1129 vrf_lookup_by_id(re
->nh_vrf_id
);
1131 vty_out(vty
, "(vrf %s)", vrf
->name
);
1134 if (!CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
1135 vty_out(vty
, " inactive");
1137 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
1138 vty_out(vty
, " onlink");
1140 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
1141 vty_out(vty
, " (recursive)");
1143 switch (nexthop
->type
) {
1144 case NEXTHOP_TYPE_IPV4
:
1145 case NEXTHOP_TYPE_IPV4_IFINDEX
:
1146 if (nexthop
->src
.ipv4
.s_addr
) {
1147 if (inet_ntop(AF_INET
, &nexthop
->src
.ipv4
, buf
,
1149 vty_out(vty
, ", src %s", buf
);
1152 case NEXTHOP_TYPE_IPV6
:
1153 case NEXTHOP_TYPE_IPV6_IFINDEX
:
1154 if (!IPV6_ADDR_SAME(&nexthop
->src
.ipv6
, &in6addr_any
)) {
1155 if (inet_ntop(AF_INET6
, &nexthop
->src
.ipv6
, buf
,
1157 vty_out(vty
, ", src %s", buf
);
1164 /* Label information */
1165 if (nexthop
->nh_label
&& nexthop
->nh_label
->num_labels
) {
1166 vty_out(vty
, ", label %s",
1167 mpls_label2str(nexthop
->nh_label
->num_labels
,
1168 nexthop
->nh_label
->label
, buf
,
1172 if (uptime
< ONE_DAY_SECOND
)
1173 vty_out(vty
, ", %02d:%02d:%02d", tm
->tm_hour
,
1174 tm
->tm_min
, tm
->tm_sec
);
1175 else if (uptime
< ONE_WEEK_SECOND
)
1176 vty_out(vty
, ", %dd%02dh%02dm", tm
->tm_yday
,
1177 tm
->tm_hour
, tm
->tm_min
);
1179 vty_out(vty
, ", %02dw%dd%02dh", tm
->tm_yday
/ 7,
1180 tm
->tm_yday
- ((tm
->tm_yday
/ 7) * 7),
1186 static int do_show_ip_route(struct vty
*vty
, const char *vrf_name
, afi_t afi
,
1187 safi_t safi
, bool use_fib
, u_char use_json
,
1189 const struct prefix
*longer_prefix_p
,
1190 bool supernets_only
, int type
,
1191 u_short ospf_instance_id
)
1193 struct route_table
*table
;
1195 struct route_node
*rn
;
1196 struct route_entry
*re
;
1198 struct zebra_vrf
*zvrf
= NULL
;
1200 json_object
*json
= NULL
;
1201 json_object
*json_prefix
= NULL
;
1204 if (!(zvrf
= zebra_vrf_lookup_by_name(vrf_name
))) {
1206 vty_out(vty
, "{}\n");
1208 vty_out(vty
, "vrf %s not defined\n", vrf_name
);
1212 if (zvrf_id(zvrf
) == VRF_UNKNOWN
) {
1214 vty_out(vty
, "{}\n");
1216 vty_out(vty
, "vrf %s inactive\n", vrf_name
);
1220 table
= zebra_vrf_table(afi
, safi
, zvrf_id(zvrf
));
1223 vty_out(vty
, "{}\n");
1228 json
= json_object_new_object();
1230 /* Show all routes. */
1231 for (rn
= route_top(table
); rn
; rn
= route_next(rn
)) {
1232 dest
= rib_dest_from_rnode(rn
);
1234 RNODE_FOREACH_RE (rn
, re
) {
1236 && re
!= dest
->selected_fib
)
1239 if (tag
&& re
->tag
!= tag
)
1243 && !prefix_match(longer_prefix_p
, &rn
->p
))
1246 /* This can only be true when the afi is IPv4 */
1247 if (supernets_only
) {
1248 addr
= ntohl(rn
->p
.u
.prefix4
.s_addr
);
1250 if (IN_CLASSC(addr
) && rn
->p
.prefixlen
>= 24)
1253 if (IN_CLASSB(addr
) && rn
->p
.prefixlen
>= 16)
1256 if (IN_CLASSA(addr
) && rn
->p
.prefixlen
>= 8)
1260 if (type
&& re
->type
!= type
)
1263 if (ospf_instance_id
1264 && (re
->type
!= ZEBRA_ROUTE_OSPF
1265 || re
->instance
!= ospf_instance_id
))
1270 json_prefix
= json_object_new_array();
1275 SHOW_ROUTE_V4_HEADER
);
1278 SHOW_ROUTE_V6_HEADER
);
1280 if (zvrf_id(zvrf
) != VRF_DEFAULT
)
1281 vty_out(vty
, "\nVRF %s:\n",
1288 vty_show_ip_route(vty
, rn
, re
, json_prefix
);
1292 prefix2str(&rn
->p
, buf
, sizeof buf
);
1293 json_object_object_add(json
, buf
, json_prefix
);
1299 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
1300 json
, JSON_C_TO_STRING_PRETTY
));
1301 json_object_free(json
);
1309 "show ip nht [vrf NAME]",
1312 "IP nexthop tracking table\n"
1316 vrf_id_t vrf_id
= VRF_DEFAULT
;
1319 VRF_GET_ID(vrf_id
, argv
[idx_vrf
]->arg
);
1321 zebra_print_rnh_table(vrf_id
, AF_INET
, vty
, RNH_NEXTHOP_TYPE
);
1326 DEFUN (show_ip_nht_vrf_all
,
1327 show_ip_nht_vrf_all_cmd
,
1328 "show ip nht vrf all",
1331 "IP nexthop tracking table\n"
1332 VRF_ALL_CMD_HELP_STR
)
1335 struct zebra_vrf
*zvrf
;
1337 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1338 if ((zvrf
= vrf
->info
) != NULL
) {
1339 vty_out(vty
, "\nVRF %s:\n", zvrf_name(zvrf
));
1340 zebra_print_rnh_table(zvrf_id(zvrf
), AF_INET
, vty
,
1347 DEFUN (show_ipv6_nht
,
1349 "show ipv6 nht [vrf NAME]",
1352 "IPv6 nexthop tracking table\n"
1356 vrf_id_t vrf_id
= VRF_DEFAULT
;
1359 VRF_GET_ID(vrf_id
, argv
[idx_vrf
]->arg
);
1361 zebra_print_rnh_table(vrf_id
, AF_INET6
, vty
, RNH_NEXTHOP_TYPE
);
1366 DEFUN (show_ipv6_nht_vrf_all
,
1367 show_ipv6_nht_vrf_all_cmd
,
1368 "show ipv6 nht vrf all",
1371 "IPv6 nexthop tracking table\n"
1372 VRF_ALL_CMD_HELP_STR
)
1375 struct zebra_vrf
*zvrf
;
1377 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
1378 if ((zvrf
= vrf
->info
) != NULL
) {
1379 vty_out(vty
, "\nVRF %s:\n", zvrf_name(zvrf
));
1380 zebra_print_rnh_table(zvrf_id(zvrf
), AF_INET6
, vty
,
1387 DEFUN (ip_nht_default_route
,
1388 ip_nht_default_route_cmd
,
1389 "ip nht resolve-via-default",
1391 "Filter Next Hop tracking route resolution\n"
1392 "Resolve via default route\n")
1394 if (zebra_rnh_ip_default_route
)
1397 zebra_rnh_ip_default_route
= 1;
1398 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1402 DEFUN (no_ip_nht_default_route
,
1403 no_ip_nht_default_route_cmd
,
1404 "no ip nht resolve-via-default",
1407 "Filter Next Hop tracking route resolution\n"
1408 "Resolve via default route\n")
1410 if (!zebra_rnh_ip_default_route
)
1413 zebra_rnh_ip_default_route
= 0;
1414 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1418 DEFUN (ipv6_nht_default_route
,
1419 ipv6_nht_default_route_cmd
,
1420 "ipv6 nht resolve-via-default",
1422 "Filter Next Hop tracking route resolution\n"
1423 "Resolve via default route\n")
1425 if (zebra_rnh_ipv6_default_route
)
1428 zebra_rnh_ipv6_default_route
= 1;
1429 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1433 DEFUN (no_ipv6_nht_default_route
,
1434 no_ipv6_nht_default_route_cmd
,
1435 "no ipv6 nht resolve-via-default",
1438 "Filter Next Hop tracking route resolution\n"
1439 "Resolve via default route\n")
1441 if (!zebra_rnh_ipv6_default_route
)
1444 zebra_rnh_ipv6_default_route
= 0;
1445 zebra_evaluate_rnh(VRF_DEFAULT
, AF_INET6
, 1, RNH_NEXTHOP_TYPE
, NULL
);
1453 ip$ipv4 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
1456 |A.B.C.D/M$prefix longer-prefixes\
1457 |supernets-only$supernets_only\
1460 " FRR_IP_REDIST_STR_ZEBRA
"$type_str\
1461 |ospf$type_str (1-65535)$ospf_instance_id\
1463 |ipv6$ipv6 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
1466 |X:X::X:X/M$prefix longer-prefixes\
1468 [" FRR_IP6_REDIST_STR_ZEBRA
"$type_str]\
1473 "IP forwarding table\n"
1474 "IP routing table\n"
1475 VRF_FULL_CMD_HELP_STR
1476 "Show only routes with tag\n"
1478 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1479 "Show route matching the specified Network/Mask pair only\n"
1480 "Show supernet entries only\n"
1481 FRR_IP_REDIST_HELP_STR_ZEBRA
1482 "Open Shortest Path First (OSPFv2)\n"
1485 "IP forwarding table\n"
1486 "IP routing table\n"
1487 VRF_FULL_CMD_HELP_STR
1488 "Show only routes with tag\n"
1491 "Show route matching the specified Network/Mask pair only\n"
1492 FRR_IP6_REDIST_HELP_STR_ZEBRA
1495 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1500 type
= proto_redistnum(afi
, type_str
);
1502 vty_out(vty
, "Unknown route type\n");
1508 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
1509 struct zebra_vrf
*zvrf
;
1510 struct route_table
*table
;
1512 if ((zvrf
= vrf
->info
) == NULL
1513 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1517 vty
, zvrf_name(zvrf
), afi
, SAFI_UNICAST
, !!fib
,
1518 !!json
, tag
, prefix_str
? prefix
: NULL
,
1519 !!supernets_only
, type
, ospf_instance_id
);
1522 vrf_id_t vrf_id
= VRF_DEFAULT
;
1525 VRF_GET_ID(vrf_id
, vrf_name
);
1526 vrf
= vrf_lookup_by_id(vrf_id
);
1527 do_show_ip_route(vty
, vrf
->name
, afi
, SAFI_UNICAST
, !!fib
,
1528 !!json
, tag
, prefix_str
? prefix
: NULL
,
1529 !!supernets_only
, type
, ospf_instance_id
);
1535 DEFPY (show_route_detail
,
1536 show_route_detail_cmd
,
1539 ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
1544 |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
1552 "IP routing table\n"
1553 VRF_FULL_CMD_HELP_STR
1554 "Network in the IP routing table to display\n"
1555 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1557 "IP routing table\n"
1558 VRF_FULL_CMD_HELP_STR
1562 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1563 struct route_table
*table
;
1565 struct route_node
*rn
;
1568 prefix_str
= address_str
;
1569 if (str2prefix(prefix_str
, &p
) < 0) {
1570 vty_out(vty
, "%% Malformed address\n");
1576 struct zebra_vrf
*zvrf
;
1578 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
1579 if ((zvrf
= vrf
->info
) == NULL
1580 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1583 rn
= route_node_match(table
, &p
);
1586 if (!address_str
&& rn
->p
.prefixlen
!= p
.prefixlen
) {
1587 route_unlock_node(rn
);
1591 vty_show_ip_route_detail(vty
, rn
, 0);
1593 route_unlock_node(rn
);
1596 vrf_id_t vrf_id
= VRF_DEFAULT
;
1599 VRF_GET_ID(vrf_id
, vrf_name
);
1601 table
= zebra_vrf_table(afi
, SAFI_UNICAST
, vrf_id
);
1605 rn
= route_node_match(table
, &p
);
1607 vty_out(vty
, "%% Network not in table\n");
1610 if (!address_str
&& rn
->p
.prefixlen
!= p
.prefixlen
) {
1611 vty_out(vty
, "%% Network not in table\n");
1612 route_unlock_node(rn
);
1616 vty_show_ip_route_detail(vty
, rn
, 0);
1618 route_unlock_node(rn
);
1624 DEFPY (show_route_summary
,
1625 show_route_summary_cmd
,
1628 ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
1629 summary [prefix$prefix]\
1630 |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
1631 summary [prefix$prefix]\
1635 "IP routing table\n"
1636 VRF_FULL_CMD_HELP_STR
1637 "Summary of all routes\n"
1640 "IP routing table\n"
1641 VRF_FULL_CMD_HELP_STR
1642 "Summary of all routes\n"
1645 afi_t afi
= ipv4
? AFI_IP
: AFI_IP6
;
1646 struct route_table
*table
;
1650 struct zebra_vrf
*zvrf
;
1652 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
1653 if ((zvrf
= vrf
->info
) == NULL
1654 || (table
= zvrf
->table
[afi
][SAFI_UNICAST
]) == NULL
)
1658 vty_show_ip_route_summary_prefix(vty
, table
);
1660 vty_show_ip_route_summary(vty
, table
);
1663 vrf_id_t vrf_id
= VRF_DEFAULT
;
1666 VRF_GET_ID(vrf_id
, vrf_name
);
1668 table
= zebra_vrf_table(afi
, SAFI_UNICAST
, vrf_id
);
1673 vty_show_ip_route_summary_prefix(vty
, table
);
1675 vty_show_ip_route_summary(vty
, table
);
1681 static void vty_show_ip_route_summary(struct vty
*vty
,
1682 struct route_table
*table
)
1684 struct route_node
*rn
;
1685 struct route_entry
*re
;
1686 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1687 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1688 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1689 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1693 memset(&rib_cnt
, 0, sizeof(rib_cnt
));
1694 memset(&fib_cnt
, 0, sizeof(fib_cnt
));
1695 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
1696 RNODE_FOREACH_RE (rn
, re
) {
1697 is_ibgp
= (re
->type
== ZEBRA_ROUTE_BGP
1698 && CHECK_FLAG(re
->flags
, ZEBRA_FLAG_IBGP
));
1700 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1702 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1704 rib_cnt
[re
->type
]++;
1706 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
)) {
1707 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1710 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1712 fib_cnt
[re
->type
]++;
1716 vty_out(vty
, "%-20s %-20s %s (vrf %s)\n", "Route Source", "Routes",
1717 "FIB", zvrf_name(((rib_table_info_t
*)table
->info
)->zvrf
));
1719 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1720 if ((rib_cnt
[i
] > 0) || (i
== ZEBRA_ROUTE_BGP
1721 && rib_cnt
[ZEBRA_ROUTE_IBGP
] > 0)) {
1722 if (i
== ZEBRA_ROUTE_BGP
) {
1723 vty_out(vty
, "%-20s %-20d %-20d \n", "ebgp",
1724 rib_cnt
[ZEBRA_ROUTE_BGP
],
1725 fib_cnt
[ZEBRA_ROUTE_BGP
]);
1726 vty_out(vty
, "%-20s %-20d %-20d \n", "ibgp",
1727 rib_cnt
[ZEBRA_ROUTE_IBGP
],
1728 fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1730 vty_out(vty
, "%-20s %-20d %-20d \n",
1731 zebra_route_string(i
), rib_cnt
[i
],
1736 vty_out(vty
, "------\n");
1737 vty_out(vty
, "%-20s %-20d %-20d \n", "Totals",
1738 rib_cnt
[ZEBRA_ROUTE_TOTAL
], fib_cnt
[ZEBRA_ROUTE_TOTAL
]);
1743 * Implementation of the ip route summary prefix command.
1745 * This command prints the primary prefixes that have been installed by various
1746 * protocols on the box.
1749 static void vty_show_ip_route_summary_prefix(struct vty
*vty
,
1750 struct route_table
*table
)
1752 struct route_node
*rn
;
1753 struct route_entry
*re
;
1754 struct nexthop
*nexthop
;
1755 #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1756 #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1757 u_int32_t rib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1758 u_int32_t fib_cnt
[ZEBRA_ROUTE_TOTAL
+ 1];
1762 memset(&rib_cnt
, 0, sizeof(rib_cnt
));
1763 memset(&fib_cnt
, 0, sizeof(fib_cnt
));
1764 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
1765 RNODE_FOREACH_RE (rn
, re
) {
1768 * In case of ECMP, count only once.
1771 for (nexthop
= re
->nexthop
; (!cnt
&& nexthop
);
1772 nexthop
= nexthop
->next
) {
1774 rib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1775 rib_cnt
[re
->type
]++;
1776 if (CHECK_FLAG(nexthop
->flags
,
1777 NEXTHOP_FLAG_FIB
)) {
1778 fib_cnt
[ZEBRA_ROUTE_TOTAL
]++;
1779 fib_cnt
[re
->type
]++;
1781 if (re
->type
== ZEBRA_ROUTE_BGP
1782 && CHECK_FLAG(re
->flags
, ZEBRA_FLAG_IBGP
)) {
1783 rib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1784 if (CHECK_FLAG(nexthop
->flags
,
1786 fib_cnt
[ZEBRA_ROUTE_IBGP
]++;
1791 vty_out(vty
, "%-20s %-20s %s (vrf %s)\n", "Route Source",
1792 "Prefix Routes", "FIB",
1793 zvrf_name(((rib_table_info_t
*)table
->info
)->zvrf
));
1795 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1796 if (rib_cnt
[i
] > 0) {
1797 if (i
== ZEBRA_ROUTE_BGP
) {
1798 vty_out(vty
, "%-20s %-20d %-20d \n", "ebgp",
1799 rib_cnt
[ZEBRA_ROUTE_BGP
]
1800 - rib_cnt
[ZEBRA_ROUTE_IBGP
],
1801 fib_cnt
[ZEBRA_ROUTE_BGP
]
1802 - fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1803 vty_out(vty
, "%-20s %-20d %-20d \n", "ibgp",
1804 rib_cnt
[ZEBRA_ROUTE_IBGP
],
1805 fib_cnt
[ZEBRA_ROUTE_IBGP
]);
1807 vty_out(vty
, "%-20s %-20d %-20d \n",
1808 zebra_route_string(i
), rib_cnt
[i
],
1813 vty_out(vty
, "------\n");
1814 vty_out(vty
, "%-20s %-20d %-20d \n", "Totals",
1815 rib_cnt
[ZEBRA_ROUTE_TOTAL
], fib_cnt
[ZEBRA_ROUTE_TOTAL
]);
1819 /* Write static route configuration. */
1820 int static_config(struct vty
*vty
, struct zebra_vrf
*zvrf
,
1821 afi_t afi
, safi_t safi
, const char *cmd
)
1824 struct route_node
*rn
;
1825 struct static_route
*si
;
1826 struct route_table
*stable
;
1827 char buf
[SRCDEST2STR_BUFFER
];
1830 if ((stable
= zvrf
->stable
[afi
][safi
]) == NULL
)
1833 sprintf(spacing
, "%s%s",
1834 (zvrf
->vrf
->vrf_id
== VRF_DEFAULT
) ? "" : " ",
1837 for (rn
= route_top(stable
); rn
; rn
= srcdest_route_next(rn
))
1838 for (si
= rn
->info
; si
; si
= si
->next
) {
1839 vty_out(vty
, "%s %s", spacing
,
1840 srcdest_rnode2str(rn
, buf
, sizeof buf
));
1843 case STATIC_IPV4_GATEWAY
:
1845 inet_ntoa(si
->addr
.ipv4
));
1847 case STATIC_IPV6_GATEWAY
:
1850 &si
->addr
.ipv6
, buf
,
1854 vty_out(vty
, " %s", si
->ifname
);
1856 case STATIC_BLACKHOLE
:
1857 switch (si
->bh_type
) {
1858 case STATIC_BLACKHOLE_DROP
:
1859 vty_out(vty
, " blackhole");
1861 case STATIC_BLACKHOLE_NULL
:
1862 vty_out(vty
, " Null0");
1864 case STATIC_BLACKHOLE_REJECT
:
1865 vty_out(vty
, " reject");
1869 case STATIC_IPV4_GATEWAY_IFNAME
:
1870 vty_out(vty
, " %s %s",
1872 &si
->addr
.ipv4
, buf
,
1876 case STATIC_IPV6_GATEWAY_IFNAME
:
1877 vty_out(vty
, " %s %s",
1879 &si
->addr
.ipv6
, buf
,
1886 vty_out(vty
, " tag %" ROUTE_TAG_PRI
,
1890 != ZEBRA_STATIC_DISTANCE_DEFAULT
)
1891 vty_out(vty
, " %d", si
->distance
);
1893 if (si
->nh_vrf_id
!= si
->vrf_id
) {
1896 vrf
= vrf_lookup_by_id(si
->nh_vrf_id
);
1897 vty_out(vty
, " nexthop-vrf %s",
1898 (vrf
) ? vrf
->name
: "Unknown");
1901 /* Label information */
1902 if (si
->snh_label
.num_labels
)
1903 vty_out(vty
, " label %s",
1904 mpls_label2str(si
->snh_label
.num_labels
,
1905 si
->snh_label
.label
,
1906 buf
, sizeof buf
, 0));
1915 DEFPY(ipv6_route_blackhole
,
1916 ipv6_route_blackhole_cmd
,
1917 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
1918 <Null0|reject|blackhole>$flag \
1920 tag (1-4294967295) \
1927 "Establish static routes\n"
1928 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1929 "IPv6 source-dest route\n"
1930 "IPv6 source prefix\n"
1932 "Emit an ICMP unreachable when matched\n"
1933 "Silently discard pkts when matched\n"
1934 "Set tag for this route\n"
1936 "Distance value for this prefix\n"
1940 return zebra_static_route(vty
, AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
1941 NULL
, from_str
, NULL
, NULL
, flag
,
1942 tag_str
, distance_str
, vrf
, label
);
1945 DEFPY(ipv6_route_blackhole_vrf
,
1946 ipv6_route_blackhole_vrf_cmd
,
1947 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
1948 <Null0|reject|blackhole>$flag \
1950 tag (1-4294967295) \
1956 "Establish static routes\n"
1957 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1958 "IPv6 source-dest route\n"
1959 "IPv6 source prefix\n"
1961 "Emit an ICMP unreachable when matched\n"
1962 "Silently discard pkts when matched\n"
1963 "Set tag for this route\n"
1965 "Distance value for this prefix\n"
1968 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
1969 struct zebra_vrf
*zvrf
= vrf
->info
;
1971 return zebra_static_route_leak(vty
, zvrf
, zvrf
,
1972 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
1973 NULL
, from_str
, NULL
, NULL
, flag
,
1974 tag_str
, distance_str
, label
);
1977 DEFPY(ipv6_route_address_interface
,
1978 ipv6_route_address_interface_cmd
,
1979 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
1983 tag (1-4294967295) \
1991 "Establish static routes\n"
1992 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1993 "IPv6 source-dest route\n"
1994 "IPv6 source prefix\n"
1995 "IPv6 gateway address\n"
1996 "IPv6 gateway interface name\n"
1997 "Set tag for this route\n"
1999 "Distance value for this prefix\n"
2004 struct zebra_vrf
*zvrf
;
2005 struct zebra_vrf
*nh_zvrf
;
2007 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2009 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2011 return CMD_WARNING_CONFIG_FAILED
;
2014 zvrf
= zebra_vrf_lookup_by_name(vrf
);
2016 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2018 return CMD_WARNING_CONFIG_FAILED
;
2021 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2022 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2023 NULL
, from_str
, gate_str
, ifname
, NULL
,
2024 tag_str
, distance_str
, label
);
2027 DEFPY(ipv6_route_address_interface_vrf
,
2028 ipv6_route_address_interface_vrf_cmd
,
2029 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2033 tag (1-4294967295) \
2040 "Establish static routes\n"
2041 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2042 "IPv6 source-dest route\n"
2043 "IPv6 source prefix\n"
2044 "IPv6 gateway address\n"
2045 "IPv6 gateway interface name\n"
2046 "Set tag for this route\n"
2048 "Distance value for this prefix\n"
2052 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
2053 struct zebra_vrf
*zvrf
= vrf
->info
;
2054 struct zebra_vrf
*nh_zvrf
;
2056 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2058 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2060 return CMD_WARNING_CONFIG_FAILED
;
2063 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2064 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2065 NULL
, from_str
, gate_str
, ifname
, NULL
,
2066 tag_str
, distance_str
, label
);
2071 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2072 <X:X::X:X$gate|INTERFACE$ifname> \
2074 tag (1-4294967295) \
2082 "Establish static routes\n"
2083 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2084 "IPv6 source-dest route\n"
2085 "IPv6 source prefix\n"
2086 "IPv6 gateway address\n"
2087 "IPv6 gateway interface name\n"
2088 "Set tag for this route\n"
2090 "Distance value for this prefix\n"
2095 struct zebra_vrf
*zvrf
;
2096 struct zebra_vrf
*nh_zvrf
;
2098 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2100 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2102 return CMD_WARNING_CONFIG_FAILED
;
2105 zvrf
= zebra_vrf_lookup_by_name(vrf
);
2107 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2109 return CMD_WARNING_CONFIG_FAILED
;
2112 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2113 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2114 NULL
, from_str
, gate_str
, ifname
, NULL
,
2115 tag_str
, distance_str
, label
);
2118 DEFPY(ipv6_route_vrf
,
2120 "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M] \
2121 <X:X::X:X$gate|INTERFACE$ifname> \
2123 tag (1-4294967295) \
2130 "Establish static routes\n"
2131 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2132 "IPv6 source-dest route\n"
2133 "IPv6 source prefix\n"
2134 "IPv6 gateway address\n"
2135 "IPv6 gateway interface name\n"
2136 "Set tag for this route\n"
2138 "Distance value for this prefix\n"
2142 VTY_DECLVAR_CONTEXT(vrf
, vrf
);
2143 struct zebra_vrf
*zvrf
= vrf
->info
;
2144 struct zebra_vrf
*nh_zvrf
;
2146 nh_zvrf
= zebra_vrf_lookup_by_name(nexthop_vrf
);
2148 vty_out(vty
, "%% nexthop vrf %s is not defined\n",
2150 return CMD_WARNING_CONFIG_FAILED
;
2153 return zebra_static_route_leak(vty
, zvrf
, nh_zvrf
,
2154 AFI_IP6
, SAFI_UNICAST
, no
, prefix_str
,
2155 NULL
, from_str
, gate_str
, ifname
, NULL
,
2156 tag_str
, distance_str
, label
);
2160 * Show IPv6 mroute command.Used to dump
2161 * the Multicast routing table.
2163 DEFUN (show_ipv6_mroute
,
2164 show_ipv6_mroute_cmd
,
2165 "show ipv6 mroute [vrf NAME]",
2168 "IPv6 Multicast routing table\n"
2171 struct route_table
*table
;
2172 struct route_node
*rn
;
2173 struct route_entry
*re
;
2175 vrf_id_t vrf_id
= VRF_DEFAULT
;
2178 VRF_GET_ID(vrf_id
, argv
[4]->arg
);
2180 table
= zebra_vrf_table(AFI_IP6
, SAFI_MULTICAST
, vrf_id
);
2184 /* Show all IPv6 route. */
2185 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
2186 RNODE_FOREACH_RE (rn
, re
) {
2188 vty_out(vty
, SHOW_ROUTE_V6_HEADER
);
2191 vty_show_ip_route(vty
, rn
, re
, NULL
);
2196 DEFUN (show_ipv6_mroute_vrf_all
,
2197 show_ipv6_mroute_vrf_all_cmd
,
2198 "show ipv6 mroute vrf all",
2201 "IPv6 Multicast routing table\n"
2202 VRF_ALL_CMD_HELP_STR
)
2204 struct route_table
*table
;
2205 struct route_node
*rn
;
2206 struct route_entry
*re
;
2208 struct zebra_vrf
*zvrf
;
2211 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
2212 if ((zvrf
= vrf
->info
) == NULL
2213 || (table
= zvrf
->table
[AFI_IP6
][SAFI_MULTICAST
]) == NULL
)
2216 /* Show all IPv6 route. */
2217 for (rn
= route_top(table
); rn
; rn
= srcdest_route_next(rn
))
2218 RNODE_FOREACH_RE (rn
, re
) {
2220 vty_out(vty
, SHOW_ROUTE_V6_HEADER
);
2223 vty_show_ip_route(vty
, rn
, re
, NULL
);
2229 DEFUN (allow_external_route_update
,
2230 allow_external_route_update_cmd
,
2231 "allow-external-route-update",
2232 "Allow FRR routes to be overwritten by external processes\n")
2239 DEFUN (no_allow_external_route_update
,
2240 no_allow_external_route_update_cmd
,
2241 "no allow-external-route-update",
2243 "Allow FRR routes to be overwritten by external processes\n")
2258 struct zebra_vrf
*zvrf
;
2260 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
2261 if (!(zvrf
= vrf
->info
))
2263 if (zvrf_id(zvrf
) == VRF_DEFAULT
)
2266 vty_out(vty
, "vrf %s ", zvrf_name(zvrf
));
2267 if (zvrf_id(zvrf
) == VRF_UNKNOWN
)
2268 vty_out(vty
, "inactive");
2270 vty_out(vty
, "id %u table %u", zvrf_id(zvrf
),
2278 DEFUN (vrf_vni_mapping
,
2279 vrf_vni_mapping_cmd
,
2280 "vni " CMD_VNI_RANGE
,
2286 ZEBRA_DECLVAR_CONTEXT(vrf
, zvrf
);
2287 vni_t vni
= strtoul(argv
[1]->arg
, NULL
, 10);
2288 char err
[ERR_STR_SZ
];
2293 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 1);
2295 vty_out(vty
, "%s\n", err
);
2302 DEFUN (no_vrf_vni_mapping
,
2303 no_vrf_vni_mapping_cmd
,
2304 "no vni " CMD_VNI_RANGE
,
2310 char err
[ERR_STR_SZ
];
2311 vni_t vni
= strtoul(argv
[2]->arg
, NULL
, 10);
2313 ZEBRA_DECLVAR_CONTEXT(vrf
, zvrf
);
2318 ret
= zebra_vxlan_process_vrf_vni_cmd(zvrf
, vni
, err
, ERR_STR_SZ
, 0);
2320 vty_out(vty
, "%s\n", err
);
2328 DEFUN (show_vrf_vni
,
2330 "show vrf vni [json]",
2337 struct zebra_vrf
*zvrf
;
2338 json_object
*json
= NULL
;
2339 json_object
*json_vrfs
= NULL
;
2340 u_char uj
= use_json(argc
, argv
);
2343 json
= json_object_new_object();
2344 json_vrfs
= json_object_new_array();
2347 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
2356 vty_out(vty
, "vrf: %s VNI: %u",
2361 json_object
*json_vrf
= NULL
;
2363 json_vrf
= json_object_new_object();
2364 json_object_string_add(json_vrf
, "vrf",
2366 json_object_int_add(json_vrf
, "l3vni",
2368 json_object_array_add(json_vrfs
, json_vrf
);
2373 json_object_object_add(json
, "vrfs", json_vrfs
);
2374 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
2375 json
, JSON_C_TO_STRING_PRETTY
));
2376 json_object_free(json
);
2382 DEFUN (show_evpn_vni
,
2384 "show evpn vni [json]",
2387 "VxLAN information\n"
2390 struct zebra_vrf
*zvrf
;
2391 u_char uj
= use_json(argc
, argv
);
2393 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2394 zebra_vxlan_print_vnis(vty
, zvrf
, uj
);
2398 DEFUN (show_evpn_vni_vni
,
2399 show_evpn_vni_vni_cmd
,
2400 "show evpn vni " CMD_VNI_RANGE
"[json]",
2403 "VxLAN Network Identifier\n"
2407 struct zebra_vrf
*zvrf
;
2409 u_char uj
= use_json(argc
, argv
);
2411 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
2412 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2413 zebra_vxlan_print_vni(vty
, zvrf
, vni
, uj
);
2417 DEFUN (show_evpn_l3vni
,
2418 show_evpn_l3vni_cmd
,
2419 "show evpn l3vni [json]",
2425 u_char uj
= use_json(argc
, argv
);
2427 zebra_vxlan_print_l3vnis(vty
, uj
);
2431 DEFUN (show_evpn_l3vni_vni
,
2432 show_evpn_l3vni_vni_cmd
,
2433 "show evpn l3vni " CMD_VNI_RANGE
"[json]",
2436 "L3 VxLAN Network Identifier\n"
2441 u_char uj
= use_json(argc
, argv
);
2443 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
2444 zebra_vxlan_print_l3vni(vty
, vni
, uj
);
2448 DEFUN (show_evpn_rmac_l3vni_mac
,
2449 show_evpn_rmac_l3vni_mac_cmd
,
2450 "show evpn rmac l3vni " CMD_VNI_RANGE
" mac WORD [json]",
2457 "mac-address (e.g. 0a:0a:0a:0a:0a:0a)\n"
2462 u_char uj
= use_json(argc
, argv
);
2464 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2465 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
2466 vty_out(vty
, "%% Malformed MAC address\n");
2469 zebra_vxlan_print_specific_rmac_l3vni(vty
, l3vni
, &mac
, uj
);
2473 DEFUN (show_evpn_rmac_l3vni
,
2474 show_evpn_rmac_l3vni_cmd
,
2475 "show evpn rmac l3vni " CMD_VNI_RANGE
"[json]",
2484 u_char uj
= use_json(argc
, argv
);
2486 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2487 zebra_vxlan_print_rmacs_l3vni(vty
, l3vni
, uj
);
2492 DEFUN (show_evpn_rmac_l3vni_all
,
2493 show_evpn_rmac_l3vni_all_cmd
,
2494 "show evpn rmac l3vni all [json]",
2502 u_char uj
= use_json(argc
, argv
);
2504 zebra_vxlan_print_rmacs_all_l3vni(vty
, uj
);
2509 DEFUN (show_evpn_nh_l3vni_ip
,
2510 show_evpn_nh_l3vni_ip_cmd
,
2511 "show evpn next-hops l3vni " CMD_VNI_RANGE
" ip WORD [json]",
2518 "Host address (ipv4 or ipv6)\n"
2523 u_char uj
= use_json(argc
, argv
);
2525 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2526 if (str2ipaddr(argv
[6]->arg
, &ip
) != 0) {
2528 vty_out(vty
, "%% Malformed Neighbor address\n");
2531 zebra_vxlan_print_specific_nh_l3vni(vty
, l3vni
, &ip
, uj
);
2536 DEFUN (show_evpn_nh_l3vni
,
2537 show_evpn_nh_l3vni_cmd
,
2538 "show evpn next-hops l3vni " CMD_VNI_RANGE
"[json]",
2547 u_char uj
= use_json(argc
, argv
);
2549 l3vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2550 zebra_vxlan_print_nh_l3vni(vty
, l3vni
, uj
);
2555 DEFUN (show_evpn_nh_l3vni_all
,
2556 show_evpn_nh_l3vni_all_cmd
,
2557 "show evpn next-hops l3vni all [json]",
2565 u_char uj
= use_json(argc
, argv
);
2567 zebra_vxlan_print_nh_all_l3vni(vty
, uj
);
2572 DEFUN (show_evpn_mac_vni
,
2573 show_evpn_mac_vni_cmd
,
2574 "show evpn mac vni " CMD_VNI_RANGE
"[json]",
2578 "VxLAN Network Identifier\n"
2582 struct zebra_vrf
*zvrf
;
2584 u_char uj
= use_json(argc
, argv
);
2586 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2587 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2588 zebra_vxlan_print_macs_vni(vty
, zvrf
, vni
, uj
);
2592 DEFUN (show_evpn_mac_vni_all
,
2593 show_evpn_mac_vni_all_cmd
,
2594 "show evpn mac vni all [json]",
2598 "VxLAN Network Identifier\n"
2602 struct zebra_vrf
*zvrf
;
2603 u_char uj
= use_json(argc
, argv
);
2605 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2606 zebra_vxlan_print_macs_all_vni(vty
, zvrf
, uj
);
2610 DEFUN (show_evpn_mac_vni_all_vtep
,
2611 show_evpn_mac_vni_all_vtep_cmd
,
2612 "show evpn mac vni all vtep A.B.C.D [json]",
2616 "VxLAN Network Identifier\n"
2619 "Remote VTEP IP address\n"
2622 struct zebra_vrf
*zvrf
;
2623 struct in_addr vtep_ip
;
2624 u_char uj
= use_json(argc
, argv
);
2626 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2628 vty_out(vty
, "%% Malformed VTEP IP address\n");
2631 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2632 zebra_vxlan_print_macs_all_vni_vtep(vty
, zvrf
, vtep_ip
, uj
);
2638 DEFUN (show_evpn_mac_vni_mac
,
2639 show_evpn_mac_vni_mac_cmd
,
2640 "show evpn mac vni " CMD_VNI_RANGE
" mac WORD",
2644 "VxLAN Network Identifier\n"
2647 "MAC address (e.g., 00:e0:ec:20:12:62)\n")
2649 struct zebra_vrf
*zvrf
;
2653 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2654 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
2655 vty_out(vty
, "%% Malformed MAC address");
2658 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2659 zebra_vxlan_print_specific_mac_vni(vty
, zvrf
, vni
, &mac
);
2663 DEFUN (show_evpn_mac_vni_vtep
,
2664 show_evpn_mac_vni_vtep_cmd
,
2665 "show evpn mac vni " CMD_VNI_RANGE
" vtep A.B.C.D" "[json]",
2669 "VxLAN Network Identifier\n"
2672 "Remote VTEP IP address\n"
2675 struct zebra_vrf
*zvrf
;
2677 struct in_addr vtep_ip
;
2678 u_char uj
= use_json(argc
, argv
);
2680 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2681 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2683 vty_out(vty
, "%% Malformed VTEP IP address\n");
2687 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2688 zebra_vxlan_print_macs_vni_vtep(vty
, zvrf
, vni
, vtep_ip
, uj
);
2692 DEFUN (show_evpn_neigh_vni
,
2693 show_evpn_neigh_vni_cmd
,
2694 "show evpn arp-cache vni " CMD_VNI_RANGE
"[json]",
2697 "ARP and ND cache\n"
2698 "VxLAN Network Identifier\n"
2702 struct zebra_vrf
*zvrf
;
2704 u_char uj
= use_json(argc
, argv
);
2706 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2707 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2708 zebra_vxlan_print_neigh_vni(vty
, zvrf
, vni
, uj
);
2712 DEFUN (show_evpn_neigh_vni_all
,
2713 show_evpn_neigh_vni_all_cmd
,
2714 "show evpn arp-cache vni all [json]",
2717 "ARP and ND cache\n"
2718 "VxLAN Network Identifier\n"
2722 struct zebra_vrf
*zvrf
;
2723 u_char uj
= use_json(argc
, argv
);
2725 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2726 zebra_vxlan_print_neigh_all_vni(vty
, zvrf
, uj
);
2730 DEFUN (show_evpn_neigh_vni_neigh
,
2731 show_evpn_neigh_vni_neigh_cmd
,
2732 "show evpn arp-cache vni " CMD_VNI_RANGE
" ip WORD [json]",
2735 "ARP and ND cache\n"
2736 "VxLAN Network Identifier\n"
2739 "Neighbor address (IPv4 or IPv6 address)\n"
2742 struct zebra_vrf
*zvrf
;
2745 u_char uj
= use_json(argc
, argv
);
2747 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2748 if (str2ipaddr(argv
[6]->arg
, &ip
) != 0) {
2750 vty_out(vty
, "%% Malformed Neighbor address\n");
2753 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2754 zebra_vxlan_print_specific_neigh_vni(vty
, zvrf
, vni
, &ip
, uj
);
2758 DEFUN (show_evpn_neigh_vni_vtep
,
2759 show_evpn_neigh_vni_vtep_cmd
,
2760 "show evpn arp-cache vni " CMD_VNI_RANGE
" vtep A.B.C.D [json]",
2763 "ARP and ND cache\n"
2764 "VxLAN Network Identifier\n"
2767 "Remote VTEP IP address\n"
2770 struct zebra_vrf
*zvrf
;
2772 struct in_addr vtep_ip
;
2773 u_char uj
= use_json(argc
, argv
);
2775 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
2776 if (!inet_aton(argv
[6]->arg
, &vtep_ip
)) {
2778 vty_out(vty
, "%% Malformed VTEP IP address\n");
2782 zvrf
= vrf_info_lookup(VRF_DEFAULT
);
2783 zebra_vxlan_print_neigh_vni_vtep(vty
, zvrf
, vni
, vtep_ip
, uj
);
2787 /* Static ip route configuration write function. */
2788 static int zebra_ip_config(struct vty
*vty
)
2792 write
+= zebra_import_table_config(vty
);
2797 DEFUN (ip_zebra_import_table_distance
,
2798 ip_zebra_import_table_distance_cmd
,
2799 "ip import-table (1-252) [distance (1-255)] [route-map WORD]",
2801 "import routes from non-main kernel table\n"
2802 "kernel routing table id\n"
2803 "Distance for imported routes\n"
2804 "Default distance value\n"
2805 "route-map for filtering\n"
2808 u_int32_t table_id
= 0;
2810 table_id
= strtoul(argv
[2]->arg
, NULL
, 10);
2811 int distance
= ZEBRA_TABLE_DISTANCE_DEFAULT
;
2813 strmatch(argv
[argc
- 2]->text
, "route-map")
2814 ? XSTRDUP(MTYPE_ROUTE_MAP_NAME
, argv
[argc
- 1]->arg
)
2818 if (argc
== 7 || (argc
== 5 && !rmap
))
2819 distance
= strtoul(argv
[4]->arg
, NULL
, 10);
2821 if (!is_zebra_valid_kernel_table(table_id
)) {
2823 "Invalid routing table ID, %d. Must be in range 1-252\n",
2826 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2830 if (is_zebra_main_routing_table(table_id
)) {
2832 "Invalid routing table ID, %d. Must be non-default table\n",
2835 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2839 ret
= zebra_import_table(AFI_IP
, table_id
, distance
, rmap
, 1);
2841 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
);
2846 DEFUN_HIDDEN (zebra_packet_process
,
2847 zebra_packet_process_cmd
,
2848 "zebra zapi-packets (1-10000)",
2851 "Number of packets to process before relinquishing thread\n")
2853 uint32_t packets
= strtoul(argv
[2]->arg
, NULL
, 10);
2855 zebrad
.packets_to_process
= packets
;
2860 DEFUN_HIDDEN (no_zebra_packet_process
,
2861 no_zebra_packet_process_cmd
,
2862 "no zebra zapi-packets [(1-10000)]",
2866 "Number of packets to process before relinquishing thread\n")
2868 zebrad
.packets_to_process
= ZEBRA_ZAPI_PACKETS_TO_PROCESS
;
2873 DEFUN_HIDDEN (zebra_workqueue_timer
,
2874 zebra_workqueue_timer_cmd
,
2875 "zebra work-queue (0-10000)",
2878 "Time in milliseconds\n")
2880 uint32_t timer
= strtoul(argv
[2]->arg
, NULL
, 10);
2881 zebrad
.ribq
->spec
.hold
= timer
;
2886 DEFUN_HIDDEN (no_zebra_workqueue_timer
,
2887 no_zebra_workqueue_timer_cmd
,
2888 "no zebra work-queue [(0-10000)]",
2892 "Time in milliseconds\n")
2894 zebrad
.ribq
->spec
.hold
= ZEBRA_RIB_PROCESS_HOLD_TIME
;
2899 DEFUN (no_ip_zebra_import_table
,
2900 no_ip_zebra_import_table_cmd
,
2901 "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
2904 "import routes from non-main kernel table\n"
2905 "kernel routing table id\n"
2906 "Distance for imported routes\n"
2907 "Default distance value\n"
2908 "route-map for filtering\n"
2911 u_int32_t table_id
= 0;
2912 table_id
= strtoul(argv
[3]->arg
, NULL
, 10);
2914 if (!is_zebra_valid_kernel_table(table_id
)) {
2916 "Invalid routing table ID. Must be in range 1-252\n");
2920 if (is_zebra_main_routing_table(table_id
)) {
2922 "Invalid routing table ID, %d. Must be non-default table\n",
2927 if (!is_zebra_import_table_enabled(AFI_IP
, table_id
))
2930 return (zebra_import_table(AFI_IP
, table_id
, 0, NULL
, 0));
2933 static int config_write_protocol(struct vty
*vty
)
2936 vty_out(vty
, "allow-external-route-update\n");
2938 if (zebra_rnh_ip_default_route
)
2939 vty_out(vty
, "ip nht resolve-via-default\n");
2941 if (zebra_rnh_ipv6_default_route
)
2942 vty_out(vty
, "ipv6 nht resolve-via-default\n");
2944 if (zebrad
.ribq
->spec
.hold
!= ZEBRA_RIB_PROCESS_HOLD_TIME
)
2945 vty_out(vty
, "zebra work-queue %u\n", zebrad
.ribq
->spec
.hold
);
2947 if (zebrad
.packets_to_process
!= ZEBRA_ZAPI_PACKETS_TO_PROCESS
)
2949 "zebra zapi-packets %u\n", zebrad
.packets_to_process
);
2951 enum multicast_mode ipv4_multicast_mode
= multicast_mode_ipv4_get();
2953 if (ipv4_multicast_mode
!= MCAST_NO_CONFIG
)
2954 vty_out(vty
, "ip multicast rpf-lookup-mode %s\n",
2955 ipv4_multicast_mode
== MCAST_URIB_ONLY
2957 : ipv4_multicast_mode
== MCAST_MRIB_ONLY
2959 : ipv4_multicast_mode
2960 == MCAST_MIX_MRIB_FIRST
2962 : ipv4_multicast_mode
2963 == MCAST_MIX_DISTANCE
2967 zebra_routemap_config_write_protocol(vty
);
2973 /* Display default rtm_table for all clients. */
2978 "default routing table to use for all clients\n")
2980 vty_out(vty
, "table %d\n", zebrad
.rtm_table_default
);
2984 DEFUN (config_table
,
2987 "Configure target kernel routing table\n"
2990 zebrad
.rtm_table_default
= strtol(argv
[1]->arg
, (char **)0, 10);
2994 DEFUN (no_config_table
,
2995 no_config_table_cmd
,
2996 "no table [TABLENO]",
2998 "Configure target kernel routing table\n"
3001 zebrad
.rtm_table_default
= 0;
3015 " Route Route Neighbor LSP LSP\n");
3017 "VRF Installs Removals Updates Installs Removals\n");
3019 RB_FOREACH(vrf
, vrf_name_head
, &vrfs_by_name
) {
3020 struct zebra_vrf
*zvrf
= vrf
->info
;
3022 vty_out(vty
, "%-25s %10" PRIu64
" %10" PRIu64
" %10" PRIu64
3023 " %10" PRIu64
" %10" PRIu64
"\n",
3024 vrf
->name
, zvrf
->installs
, zvrf
->removals
,
3025 zvrf
->neigh_updates
, zvrf
->lsp_installs
,
3026 zvrf
->lsp_removals
);
3032 DEFUN (ip_forwarding
,
3036 "Turn on IP forwarding\n")
3042 ret
= ipforward_on();
3045 vty_out(vty
, "Can't turn on IP forwarding\n");
3046 return CMD_WARNING_CONFIG_FAILED
;
3052 DEFUN (no_ip_forwarding
,
3053 no_ip_forwarding_cmd
,
3057 "Turn off IP forwarding\n")
3063 ret
= ipforward_off();
3066 vty_out(vty
, "Can't turn off IP forwarding\n");
3067 return CMD_WARNING_CONFIG_FAILED
;
3073 /* Only display ip forwarding is enabled or not. */
3074 DEFUN (show_ip_forwarding
,
3075 show_ip_forwarding_cmd
,
3076 "show ip forwarding",
3079 "IP forwarding status\n")
3086 vty_out(vty
, "IP forwarding is off\n");
3088 vty_out(vty
, "IP forwarding is on\n");
3092 /* Only display ipv6 forwarding is enabled or not. */
3093 DEFUN (show_ipv6_forwarding
,
3094 show_ipv6_forwarding_cmd
,
3095 "show ipv6 forwarding",
3097 "IPv6 information\n"
3098 "Forwarding status\n")
3102 ret
= ipforward_ipv6();
3106 vty_out(vty
, "ipv6 forwarding is unknown\n");
3109 vty_out(vty
, "ipv6 forwarding is %s\n", "off");
3112 vty_out(vty
, "ipv6 forwarding is %s\n", "on");
3115 vty_out(vty
, "ipv6 forwarding is %s\n", "off");
3121 DEFUN (ipv6_forwarding
,
3122 ipv6_forwarding_cmd
,
3125 "Turn on IPv6 forwarding\n")
3129 ret
= ipforward_ipv6();
3131 ret
= ipforward_ipv6_on();
3134 vty_out(vty
, "Can't turn on IPv6 forwarding\n");
3135 return CMD_WARNING_CONFIG_FAILED
;
3141 DEFUN (no_ipv6_forwarding
,
3142 no_ipv6_forwarding_cmd
,
3143 "no ipv6 forwarding",
3146 "Turn off IPv6 forwarding\n")
3150 ret
= ipforward_ipv6();
3152 ret
= ipforward_ipv6_off();
3155 vty_out(vty
, "Can't turn off IPv6 forwarding\n");
3156 return CMD_WARNING_CONFIG_FAILED
;
3162 /* Table configuration write function. */
3163 static int config_write_table(struct vty
*vty
)
3165 if (zebrad
.rtm_table_default
)
3166 vty_out(vty
, "table %d\n", zebrad
.rtm_table_default
);
3170 /* IPForwarding configuration write function. */
3171 static int config_write_forwarding(struct vty
*vty
)
3173 /* FIXME: Find better place for that. */
3174 router_id_write(vty
);
3177 vty_out(vty
, "no ip forwarding\n");
3178 if (!ipforward_ipv6())
3179 vty_out(vty
, "no ipv6 forwarding\n");
3180 vty_out(vty
, "!\n");
3184 /* IP node for static routes. */
3185 static struct cmd_node ip_node
= {IP_NODE
, "", 1};
3186 static struct cmd_node protocol_node
= {PROTOCOL_NODE
, "", 1};
3187 /* table node for routing tables. */
3188 static struct cmd_node table_node
= {TABLE_NODE
,
3189 "", /* This node has no interface. */
3191 static struct cmd_node forwarding_node
= {FORWARDING_NODE
,
3192 "", /* This node has no interface. */
3196 void zebra_vty_init(void)
3198 /* Install configuration write function. */
3199 install_node(&table_node
, config_write_table
);
3200 install_node(&forwarding_node
, config_write_forwarding
);
3202 install_element(VIEW_NODE
, &show_ip_forwarding_cmd
);
3203 install_element(CONFIG_NODE
, &ip_forwarding_cmd
);
3204 install_element(CONFIG_NODE
, &no_ip_forwarding_cmd
);
3205 install_element(ENABLE_NODE
, &show_zebra_cmd
);
3208 install_element(VIEW_NODE
, &show_table_cmd
);
3209 install_element(CONFIG_NODE
, &config_table_cmd
);
3210 install_element(CONFIG_NODE
, &no_config_table_cmd
);
3211 #endif /* HAVE_NETLINK */
3213 install_element(VIEW_NODE
, &show_ipv6_forwarding_cmd
);
3214 install_element(CONFIG_NODE
, &ipv6_forwarding_cmd
);
3215 install_element(CONFIG_NODE
, &no_ipv6_forwarding_cmd
);
3218 zebra_route_map_init();
3220 install_node(&ip_node
, zebra_ip_config
);
3221 install_node(&protocol_node
, config_write_protocol
);
3223 install_element(CONFIG_NODE
, &allow_external_route_update_cmd
);
3224 install_element(CONFIG_NODE
, &no_allow_external_route_update_cmd
);
3225 install_element(CONFIG_NODE
, &ip_mroute_dist_cmd
);
3226 install_element(CONFIG_NODE
, &ip_multicast_mode_cmd
);
3227 install_element(CONFIG_NODE
, &no_ip_multicast_mode_cmd
);
3228 install_element(CONFIG_NODE
, &ip_route_blackhole_cmd
);
3229 install_element(VRF_NODE
, &ip_route_blackhole_vrf_cmd
);
3230 install_element(CONFIG_NODE
, &ip_route_address_interface_cmd
);
3231 install_element(VRF_NODE
, &ip_route_address_interface_vrf_cmd
);
3232 install_element(CONFIG_NODE
, &ip_route_cmd
);
3233 install_element(VRF_NODE
, &ip_route_vrf_cmd
);
3234 install_element(CONFIG_NODE
, &ip_zebra_import_table_distance_cmd
);
3235 install_element(CONFIG_NODE
, &no_ip_zebra_import_table_cmd
);
3236 install_element(CONFIG_NODE
, &zebra_workqueue_timer_cmd
);
3237 install_element(CONFIG_NODE
, &no_zebra_workqueue_timer_cmd
);
3238 install_element(CONFIG_NODE
, &zebra_packet_process_cmd
);
3239 install_element(CONFIG_NODE
, &no_zebra_packet_process_cmd
);
3241 install_element(VIEW_NODE
, &show_vrf_cmd
);
3242 install_element(VIEW_NODE
, &show_vrf_vni_cmd
);
3243 install_element(VIEW_NODE
, &show_route_cmd
);
3244 install_element(VIEW_NODE
, &show_route_detail_cmd
);
3245 install_element(VIEW_NODE
, &show_route_summary_cmd
);
3246 install_element(VIEW_NODE
, &show_ip_nht_cmd
);
3247 install_element(VIEW_NODE
, &show_ip_nht_vrf_all_cmd
);
3248 install_element(VIEW_NODE
, &show_ipv6_nht_cmd
);
3249 install_element(VIEW_NODE
, &show_ipv6_nht_vrf_all_cmd
);
3251 install_element(VIEW_NODE
, &show_ip_rpf_cmd
);
3252 install_element(VIEW_NODE
, &show_ip_rpf_addr_cmd
);
3254 install_element(CONFIG_NODE
, &ipv6_route_blackhole_cmd
);
3255 install_element(VRF_NODE
, &ipv6_route_blackhole_vrf_cmd
);
3256 install_element(CONFIG_NODE
, &ipv6_route_address_interface_cmd
);
3257 install_element(VRF_NODE
, &ipv6_route_address_interface_vrf_cmd
);
3258 install_element(CONFIG_NODE
, &ipv6_route_cmd
);
3259 install_element(VRF_NODE
, &ipv6_route_vrf_cmd
);
3260 install_element(CONFIG_NODE
, &ip_nht_default_route_cmd
);
3261 install_element(CONFIG_NODE
, &no_ip_nht_default_route_cmd
);
3262 install_element(CONFIG_NODE
, &ipv6_nht_default_route_cmd
);
3263 install_element(CONFIG_NODE
, &no_ipv6_nht_default_route_cmd
);
3264 install_element(VIEW_NODE
, &show_ipv6_mroute_cmd
);
3266 /* Commands for VRF */
3267 install_element(VIEW_NODE
, &show_ipv6_mroute_vrf_all_cmd
);
3269 install_element(VIEW_NODE
, &show_evpn_vni_cmd
);
3270 install_element(VIEW_NODE
, &show_evpn_vni_vni_cmd
);
3271 install_element(VIEW_NODE
, &show_evpn_l3vni_cmd
);
3272 install_element(VIEW_NODE
, &show_evpn_l3vni_vni_cmd
);
3273 install_element(VIEW_NODE
, &show_evpn_rmac_l3vni_mac_cmd
);
3274 install_element(VIEW_NODE
, &show_evpn_rmac_l3vni_cmd
);
3275 install_element(VIEW_NODE
, &show_evpn_rmac_l3vni_all_cmd
);
3276 install_element(VIEW_NODE
, &show_evpn_nh_l3vni_ip_cmd
);
3277 install_element(VIEW_NODE
, &show_evpn_nh_l3vni_cmd
);
3278 install_element(VIEW_NODE
, &show_evpn_nh_l3vni_all_cmd
);
3279 install_element(VIEW_NODE
, &show_evpn_mac_vni_cmd
);
3280 install_element(VIEW_NODE
, &show_evpn_mac_vni_all_cmd
);
3281 install_element(VIEW_NODE
, &show_evpn_mac_vni_all_vtep_cmd
);
3282 install_element(VIEW_NODE
, &show_evpn_mac_vni_mac_cmd
);
3283 install_element(VIEW_NODE
, &show_evpn_mac_vni_vtep_cmd
);
3284 install_element(VIEW_NODE
, &show_evpn_neigh_vni_cmd
);
3285 install_element(VIEW_NODE
, &show_evpn_neigh_vni_all_cmd
);
3286 install_element(VIEW_NODE
, &show_evpn_neigh_vni_neigh_cmd
);
3287 install_element(VIEW_NODE
, &show_evpn_neigh_vni_vtep_cmd
);
3289 install_element(CONFIG_NODE
, &no_vrf_vni_mapping_cmd
);
3290 install_element(VRF_NODE
, &vrf_vni_mapping_cmd
);
3291 install_element(VRF_NODE
, &no_vrf_vni_mapping_cmd
);