]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* Zebra VTY functions |
2 | * Copyright (C) 2002 Kunihiro Ishiguro | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
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 | |
9 | * later version. | |
10 | * | |
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. | |
15 | * | |
896014f4 DL |
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 | |
718e3744 | 19 | */ |
20 | ||
21 | #include <zebra.h> | |
22 | ||
7514fb77 | 23 | #include "memory.h" |
4a1ab8e4 | 24 | #include "zebra_memory.h" |
718e3744 | 25 | #include "if.h" |
26 | #include "prefix.h" | |
27 | #include "command.h" | |
28 | #include "table.h" | |
29 | #include "rib.h" | |
fb018d25 | 30 | #include "nexthop.h" |
b72ede27 | 31 | #include "vrf.h" |
4060008b | 32 | #include "linklist.h" |
7758e3f3 | 33 | #include "mpls.h" |
4a1ab8e4 | 34 | #include "routemap.h" |
05737783 | 35 | #include "srcdest_table.h" |
cec2e17d | 36 | #include "vxlan.h" |
718e3744 | 37 | |
89272910 | 38 | #include "zebra/zebra_router.h" |
a1ac18c4 | 39 | #include "zebra/zserv.h" |
7c551956 | 40 | #include "zebra/zebra_vrf.h" |
7758e3f3 | 41 | #include "zebra/zebra_mpls.h" |
fb018d25 | 42 | #include "zebra/zebra_rnh.h" |
7a4bb9c5 | 43 | #include "zebra/redistribute.h" |
6baf7bb8 | 44 | #include "zebra/zebra_routemap.h" |
1d666fcb | 45 | #include "lib/json.h" |
cec2e17d | 46 | #include "zebra/zebra_vxlan.h" |
ab59f4f7 | 47 | #ifndef VTYSH_EXTRACT_PL |
00685a85 | 48 | #include "zebra/zebra_vty_clippy.c" |
ab59f4f7 | 49 | #endif |
3a30f50f | 50 | #include "zebra/zserv.h" |
c0d136ae DS |
51 | #include "zebra/router-id.h" |
52 | #include "zebra/ipforward.h" | |
b7cfce93 | 53 | #include "zebra/zebra_vxlan_private.h" |
586f4ccf | 54 | #include "zebra/zebra_pbr.h" |
6baf7bb8 DS |
55 | |
56 | extern int allow_delete; | |
a1ac18c4 | 57 | |
d62a17ae | 58 | static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, |
9f049418 | 59 | safi_t safi, bool use_fib, bool use_json, |
ecffa493 RW |
60 | route_tag_t tag, |
61 | const struct prefix *longer_prefix_p, | |
d62a17ae | 62 | bool supernets_only, int type, |
d7c0a89a | 63 | unsigned short ospf_instance_id); |
d62a17ae | 64 | static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, |
65 | int mcast); | |
5ce91022 RW |
66 | static void vty_show_ip_route_summary(struct vty *vty, |
67 | struct route_table *table); | |
68 | static void vty_show_ip_route_summary_prefix(struct vty *vty, | |
69 | struct route_table *table); | |
b78a80d7 | 70 | |
4623d897 DL |
71 | DEFUN (ip_multicast_mode, |
72 | ip_multicast_mode_cmd, | |
6147e2c6 | 73 | "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>", |
4623d897 DL |
74 | IP_STR |
75 | "Multicast options\n" | |
76 | "RPF lookup behavior\n" | |
77 | "Lookup in unicast RIB only\n" | |
78 | "Lookup in multicast RIB only\n" | |
79 | "Try multicast RIB first, fall back to unicast RIB\n" | |
80 | "Lookup both, use entry with lower distance\n" | |
81 | "Lookup both, use entry with longer prefix\n") | |
82 | { | |
d62a17ae | 83 | char *mode = argv[3]->text; |
84 | ||
85 | if (strmatch(mode, "urib-only")) | |
86 | multicast_mode_ipv4_set(MCAST_URIB_ONLY); | |
87 | else if (strmatch(mode, "mrib-only")) | |
88 | multicast_mode_ipv4_set(MCAST_MRIB_ONLY); | |
89 | else if (strmatch(mode, "mrib-then-urib")) | |
90 | multicast_mode_ipv4_set(MCAST_MIX_MRIB_FIRST); | |
91 | else if (strmatch(mode, "lower-distance")) | |
92 | multicast_mode_ipv4_set(MCAST_MIX_DISTANCE); | |
93 | else if (strmatch(mode, "longer-prefix")) | |
94 | multicast_mode_ipv4_set(MCAST_MIX_PFXLEN); | |
95 | else { | |
96 | vty_out(vty, "Invalid mode specified\n"); | |
97 | return CMD_WARNING_CONFIG_FAILED; | |
98 | } | |
4623d897 | 99 | |
d62a17ae | 100 | return CMD_SUCCESS; |
4623d897 DL |
101 | } |
102 | ||
103 | DEFUN (no_ip_multicast_mode, | |
104 | no_ip_multicast_mode_cmd, | |
b62ecea5 | 105 | "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]", |
4623d897 DL |
106 | NO_STR |
107 | IP_STR | |
108 | "Multicast options\n" | |
109 | "RPF lookup behavior\n" | |
110 | "Lookup in unicast RIB only\n" | |
111 | "Lookup in multicast RIB only\n" | |
112 | "Try multicast RIB first, fall back to unicast RIB\n" | |
113 | "Lookup both, use entry with lower distance\n" | |
114 | "Lookup both, use entry with longer prefix\n") | |
115 | { | |
d62a17ae | 116 | multicast_mode_ipv4_set(MCAST_NO_CONFIG); |
117 | return CMD_SUCCESS; | |
4623d897 DL |
118 | } |
119 | ||
4623d897 | 120 | |
b78a80d7 EM |
121 | DEFUN (show_ip_rpf, |
122 | show_ip_rpf_cmd, | |
acb25e73 | 123 | "show ip rpf [json]", |
b78a80d7 EM |
124 | SHOW_STR |
125 | IP_STR | |
acb25e73 DW |
126 | "Display RPF information for multicast source\n" |
127 | JSON_STR) | |
b78a80d7 | 128 | { |
9f049418 | 129 | bool uj = use_json(argc, argv); |
d62a17ae | 130 | return do_show_ip_route(vty, VRF_DEFAULT_NAME, AFI_IP, SAFI_MULTICAST, |
fba31af2 | 131 | false, uj, 0, NULL, false, 0, 0); |
b78a80d7 EM |
132 | } |
133 | ||
65dd94cf DL |
134 | DEFUN (show_ip_rpf_addr, |
135 | show_ip_rpf_addr_cmd, | |
136 | "show ip rpf A.B.C.D", | |
137 | SHOW_STR | |
138 | IP_STR | |
139 | "Display RPF information for multicast source\n" | |
140 | "IP multicast source address (e.g. 10.0.0.0)\n") | |
141 | { | |
d62a17ae | 142 | int idx_ipv4 = 3; |
143 | struct in_addr addr; | |
144 | struct route_node *rn; | |
145 | struct route_entry *re; | |
146 | int ret; | |
147 | ||
148 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
149 | if (ret == 0) { | |
150 | vty_out(vty, "%% Malformed address\n"); | |
151 | return CMD_WARNING; | |
152 | } | |
153 | ||
154 | re = rib_match_ipv4_multicast(VRF_DEFAULT, addr, &rn); | |
155 | ||
156 | if (re) | |
157 | vty_show_ip_route_detail(vty, rn, 1); | |
158 | else | |
159 | vty_out(vty, "%% No match for RPF lookup\n"); | |
160 | ||
161 | return CMD_SUCCESS; | |
162 | } | |
163 | ||
4a2f796f DS |
164 | static char re_status_output_char(struct route_entry *re, struct nexthop *nhop) |
165 | { | |
677c1dd5 DS |
166 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED)) { |
167 | if (!CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_DUPLICATE)) | |
4a2f796f | 168 | return '*'; |
677c1dd5 DS |
169 | else |
170 | return ' '; | |
4a2f796f DS |
171 | } |
172 | ||
677c1dd5 DS |
173 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_FAILED)) { |
174 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_QUEUED)) | |
175 | return 'q'; | |
176 | ||
177 | return 'f'; | |
178 | } | |
179 | ||
180 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_QUEUED)) | |
181 | return 'q'; | |
182 | ||
4a2f796f DS |
183 | return ' '; |
184 | } | |
185 | ||
8f527c5e | 186 | /* New RIB. Detailed information for IPv4 route. */ |
d62a17ae | 187 | static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, |
188 | int mcast) | |
189 | { | |
190 | struct route_entry *re; | |
191 | struct nexthop *nexthop; | |
192 | char buf[SRCDEST2STR_BUFFER]; | |
193 | struct zebra_vrf *zvrf; | |
194 | ||
a2addae8 | 195 | RNODE_FOREACH_RE (rn, re) { |
d62a17ae | 196 | const char *mcast_info = ""; |
197 | if (mcast) { | |
198 | rib_table_info_t *info = srcdest_rnode_table_info(rn); | |
199 | mcast_info = (info->safi == SAFI_MULTICAST) | |
200 | ? " using Multicast RIB" | |
201 | : " using Unicast RIB"; | |
202 | } | |
203 | ||
204 | vty_out(vty, "Routing entry for %s%s\n", | |
205 | srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info); | |
206 | vty_out(vty, " Known via \"%s", zebra_route_string(re->type)); | |
207 | if (re->instance) | |
208 | vty_out(vty, "[%d]", re->instance); | |
209 | vty_out(vty, "\""); | |
210 | vty_out(vty, ", distance %u, metric %u", re->distance, | |
211 | re->metric); | |
0efb5e9b | 212 | if (re->tag) { |
8526b842 | 213 | vty_out(vty, ", tag %u", re->tag); |
0efb5e9b DS |
214 | #if defined(SUPPORT_REALMS) |
215 | if (re->tag > 0 && re->tag <= 255) | |
216 | vty_out(vty, "(realm)"); | |
217 | #endif | |
218 | } | |
d62a17ae | 219 | if (re->mtu) |
220 | vty_out(vty, ", mtu %u", re->mtu); | |
221 | if (re->vrf_id != VRF_DEFAULT) { | |
222 | zvrf = vrf_info_lookup(re->vrf_id); | |
223 | vty_out(vty, ", vrf %s", zvrf_name(zvrf)); | |
224 | } | |
225 | if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) | |
226 | vty_out(vty, ", best"); | |
d62a17ae | 227 | vty_out(vty, "\n"); |
228 | ||
14a481d9 DS |
229 | time_t uptime; |
230 | struct tm *tm; | |
231 | ||
232 | uptime = time(NULL); | |
233 | uptime -= re->uptime; | |
234 | tm = gmtime(&uptime); | |
235 | ||
236 | vty_out(vty, " Last update "); | |
237 | ||
238 | if (uptime < ONE_DAY_SECOND) | |
996c9314 LB |
239 | vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, |
240 | tm->tm_sec); | |
14a481d9 | 241 | else if (uptime < ONE_WEEK_SECOND) |
996c9314 LB |
242 | vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, |
243 | tm->tm_min); | |
14a481d9 DS |
244 | else |
245 | vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7, | |
246 | tm->tm_yday - ((tm->tm_yday / 7) * 7), | |
247 | tm->tm_hour); | |
248 | vty_out(vty, " ago\n"); | |
d62a17ae | 249 | |
7ee30f28 | 250 | for (ALL_NEXTHOPS(re->ng, nexthop)) { |
d62a17ae | 251 | char addrstr[32]; |
252 | ||
253 | vty_out(vty, " %c%s", | |
4a2f796f | 254 | re_status_output_char(re, nexthop), |
d62a17ae | 255 | nexthop->rparent ? " " : ""); |
256 | ||
257 | switch (nexthop->type) { | |
258 | case NEXTHOP_TYPE_IPV4: | |
259 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
260 | vty_out(vty, " %s", | |
261 | inet_ntoa(nexthop->gate.ipv4)); | |
262 | if (nexthop->ifindex) | |
263 | vty_out(vty, ", via %s", | |
4a7371e9 DS |
264 | ifindex2ifname( |
265 | nexthop->ifindex, | |
266 | nexthop->vrf_id)); | |
d62a17ae | 267 | break; |
268 | case NEXTHOP_TYPE_IPV6: | |
269 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
270 | vty_out(vty, " %s", | |
271 | inet_ntop(AF_INET6, &nexthop->gate.ipv6, | |
272 | buf, sizeof buf)); | |
273 | if (nexthop->ifindex) | |
274 | vty_out(vty, ", via %s", | |
4a7371e9 DS |
275 | ifindex2ifname( |
276 | nexthop->ifindex, | |
277 | nexthop->vrf_id)); | |
d62a17ae | 278 | break; |
279 | case NEXTHOP_TYPE_IFINDEX: | |
280 | vty_out(vty, " directly connected, %s", | |
281 | ifindex2ifname(nexthop->ifindex, | |
4a7371e9 | 282 | nexthop->vrf_id)); |
d62a17ae | 283 | break; |
284 | case NEXTHOP_TYPE_BLACKHOLE: | |
a8309422 DL |
285 | vty_out(vty, " unreachable"); |
286 | switch (nexthop->bh_type) { | |
287 | case BLACKHOLE_REJECT: | |
288 | vty_out(vty, " (ICMP unreachable)"); | |
289 | break; | |
290 | case BLACKHOLE_ADMINPROHIB: | |
60466a63 QY |
291 | vty_out(vty, |
292 | " (ICMP admin-prohibited)"); | |
a8309422 DL |
293 | break; |
294 | case BLACKHOLE_NULL: | |
295 | vty_out(vty, " (blackhole)"); | |
296 | break; | |
297 | case BLACKHOLE_UNSPEC: | |
298 | break; | |
299 | } | |
d62a17ae | 300 | break; |
301 | default: | |
302 | break; | |
303 | } | |
2793a098 | 304 | |
fc132690 | 305 | if ((re->vrf_id != nexthop->vrf_id) |
bbde7a0f | 306 | && (nexthop->type != NEXTHOP_TYPE_BLACKHOLE)) { |
2793a098 | 307 | struct vrf *vrf = |
4a7371e9 | 308 | vrf_lookup_by_id(nexthop->vrf_id); |
2793a098 | 309 | |
4c66767c DS |
310 | if (vrf) |
311 | vty_out(vty, "(vrf %s)", vrf->name); | |
312 | else | |
0437e105 | 313 | vty_out(vty, "(vrf UNKNOWN)"); |
2793a098 DS |
314 | } |
315 | ||
eaf5150f DS |
316 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)) |
317 | vty_out(vty, " (duplicate nexthop removed)"); | |
318 | ||
d62a17ae | 319 | if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
320 | vty_out(vty, " inactive"); | |
321 | ||
322 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) | |
323 | vty_out(vty, " onlink"); | |
324 | ||
325 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) | |
326 | vty_out(vty, " (recursive)"); | |
327 | ||
328 | switch (nexthop->type) { | |
329 | case NEXTHOP_TYPE_IPV4: | |
330 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
331 | if (nexthop->src.ipv4.s_addr) { | |
332 | if (inet_ntop(AF_INET, | |
333 | &nexthop->src.ipv4, | |
334 | addrstr, sizeof addrstr)) | |
335 | vty_out(vty, ", src %s", | |
336 | addrstr); | |
337 | } | |
338 | break; | |
339 | case NEXTHOP_TYPE_IPV6: | |
340 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
341 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, | |
342 | &in6addr_any)) { | |
343 | if (inet_ntop(AF_INET6, | |
344 | &nexthop->src.ipv6, | |
345 | addrstr, sizeof addrstr)) | |
346 | vty_out(vty, ", src %s", | |
347 | addrstr); | |
348 | } | |
349 | break; | |
350 | default: | |
351 | break; | |
352 | } | |
353 | ||
1994ae60 JB |
354 | if (re->nexthop_mtu) |
355 | vty_out(vty, ", mtu %u", re->nexthop_mtu); | |
356 | ||
d62a17ae | 357 | /* Label information */ |
358 | if (nexthop->nh_label | |
359 | && nexthop->nh_label->num_labels) { | |
360 | vty_out(vty, ", label %s", | |
361 | mpls_label2str( | |
362 | nexthop->nh_label->num_labels, | |
363 | nexthop->nh_label->label, buf, | |
364 | sizeof buf, 1)); | |
365 | } | |
366 | ||
367 | vty_out(vty, "\n"); | |
368 | } | |
369 | vty_out(vty, "\n"); | |
370 | } | |
371 | } | |
372 | ||
373 | static void vty_show_ip_route(struct vty *vty, struct route_node *rn, | |
374 | struct route_entry *re, json_object *json) | |
375 | { | |
376 | struct nexthop *nexthop; | |
377 | int len = 0; | |
378 | char buf[SRCDEST2STR_BUFFER]; | |
379 | json_object *json_nexthops = NULL; | |
380 | json_object *json_nexthop = NULL; | |
381 | json_object *json_route = NULL; | |
382 | json_object *json_labels = NULL; | |
14a481d9 DS |
383 | time_t uptime; |
384 | struct tm *tm; | |
385 | ||
386 | uptime = time(NULL); | |
387 | uptime -= re->uptime; | |
388 | tm = gmtime(&uptime); | |
d62a17ae | 389 | |
390 | if (json) { | |
391 | json_route = json_object_new_object(); | |
392 | json_nexthops = json_object_new_array(); | |
393 | ||
394 | json_object_string_add(json_route, "prefix", | |
395 | srcdest_rnode2str(rn, buf, sizeof buf)); | |
396 | json_object_string_add(json_route, "protocol", | |
397 | zebra_route_string(re->type)); | |
398 | ||
399 | if (re->instance) | |
400 | json_object_int_add(json_route, "instance", | |
401 | re->instance); | |
402 | ||
403 | if (re->vrf_id) | |
404 | json_object_int_add(json_route, "vrfId", re->vrf_id); | |
405 | ||
406 | if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) | |
407 | json_object_boolean_true_add(json_route, "selected"); | |
408 | ||
059c79ba AK |
409 | json_object_int_add(json_route, "distance", |
410 | re->distance); | |
411 | json_object_int_add(json_route, "metric", re->metric); | |
d62a17ae | 412 | |
677c1dd5 DS |
413 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED)) |
414 | json_object_boolean_true_add(json_route, "installed"); | |
415 | ||
416 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_FAILED)) | |
417 | json_object_boolean_true_add(json_route, "failed"); | |
418 | ||
419 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_QUEUED)) | |
420 | json_object_boolean_true_add(json_route, "queued"); | |
421 | ||
422 | if (re->type != ZEBRA_ROUTE_CONNECT) { | |
423 | json_object_int_add(json_route, "distance", | |
424 | re->distance); | |
425 | json_object_int_add(json_route, "metric", re->metric); | |
426 | } | |
427 | ||
96d71e38 AD |
428 | if (re->tag) |
429 | json_object_int_add(json_route, "tag", re->tag); | |
430 | ||
f03098f9 DS |
431 | json_object_int_add(json_route, "internalStatus", |
432 | re->status); | |
433 | json_object_int_add(json_route, "internalFlags", | |
434 | re->flags); | |
14a481d9 | 435 | if (uptime < ONE_DAY_SECOND) |
996c9314 LB |
436 | sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, |
437 | tm->tm_sec); | |
14a481d9 | 438 | else if (uptime < ONE_WEEK_SECOND) |
996c9314 LB |
439 | sprintf(buf, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, |
440 | tm->tm_min); | |
14a481d9 DS |
441 | else |
442 | sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7, | |
443 | tm->tm_yday - ((tm->tm_yday / 7) * 7), | |
444 | tm->tm_hour); | |
445 | ||
446 | json_object_string_add(json_route, "uptime", buf); | |
d62a17ae | 447 | |
7ee30f28 | 448 | for (ALL_NEXTHOPS(re->ng, nexthop)) { |
d62a17ae | 449 | json_nexthop = json_object_new_object(); |
450 | ||
f03098f9 DS |
451 | json_object_int_add(json_nexthop, "flags", |
452 | nexthop->flags); | |
453 | ||
eaf5150f DS |
454 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)) |
455 | json_object_boolean_true_add(json_nexthop, | |
456 | "duplicate"); | |
457 | ||
d62a17ae | 458 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) |
459 | json_object_boolean_true_add(json_nexthop, | |
460 | "fib"); | |
461 | ||
462 | switch (nexthop->type) { | |
463 | case NEXTHOP_TYPE_IPV4: | |
464 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
465 | json_object_string_add( | |
466 | json_nexthop, "ip", | |
467 | inet_ntoa(nexthop->gate.ipv4)); | |
468 | json_object_string_add(json_nexthop, "afi", | |
469 | "ipv4"); | |
470 | ||
471 | if (nexthop->ifindex) { | |
472 | json_object_int_add(json_nexthop, | |
473 | "interfaceIndex", | |
474 | nexthop->ifindex); | |
475 | json_object_string_add( | |
476 | json_nexthop, "interfaceName", | |
4a7371e9 DS |
477 | ifindex2ifname( |
478 | nexthop->ifindex, | |
479 | nexthop->vrf_id)); | |
d62a17ae | 480 | } |
481 | break; | |
482 | case NEXTHOP_TYPE_IPV6: | |
483 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
484 | json_object_string_add( | |
485 | json_nexthop, "ip", | |
486 | inet_ntop(AF_INET6, &nexthop->gate.ipv6, | |
487 | buf, sizeof buf)); | |
488 | json_object_string_add(json_nexthop, "afi", | |
489 | "ipv6"); | |
490 | ||
491 | if (nexthop->ifindex) { | |
492 | json_object_int_add(json_nexthop, | |
493 | "interfaceIndex", | |
494 | nexthop->ifindex); | |
495 | json_object_string_add( | |
496 | json_nexthop, "interfaceName", | |
4a7371e9 DS |
497 | ifindex2ifname( |
498 | nexthop->ifindex, | |
499 | nexthop->vrf_id)); | |
d62a17ae | 500 | } |
501 | break; | |
502 | ||
503 | case NEXTHOP_TYPE_IFINDEX: | |
504 | json_object_boolean_true_add( | |
505 | json_nexthop, "directlyConnected"); | |
506 | json_object_int_add(json_nexthop, | |
507 | "interfaceIndex", | |
508 | nexthop->ifindex); | |
509 | json_object_string_add( | |
510 | json_nexthop, "interfaceName", | |
511 | ifindex2ifname(nexthop->ifindex, | |
4a7371e9 | 512 | nexthop->vrf_id)); |
d62a17ae | 513 | break; |
514 | case NEXTHOP_TYPE_BLACKHOLE: | |
515 | json_object_boolean_true_add(json_nexthop, | |
a8309422 DL |
516 | "unreachable"); |
517 | switch (nexthop->bh_type) { | |
518 | case BLACKHOLE_REJECT: | |
519 | json_object_boolean_true_add( | |
60466a63 | 520 | json_nexthop, "reject"); |
a8309422 DL |
521 | break; |
522 | case BLACKHOLE_ADMINPROHIB: | |
523 | json_object_boolean_true_add( | |
60466a63 QY |
524 | json_nexthop, |
525 | "admin-prohibited"); | |
a8309422 DL |
526 | break; |
527 | case BLACKHOLE_NULL: | |
528 | json_object_boolean_true_add( | |
60466a63 | 529 | json_nexthop, "blackhole"); |
a8309422 DL |
530 | break; |
531 | case BLACKHOLE_UNSPEC: | |
532 | break; | |
533 | } | |
d62a17ae | 534 | break; |
535 | default: | |
536 | break; | |
537 | } | |
538 | ||
fc132690 | 539 | if ((nexthop->vrf_id != re->vrf_id) |
bbde7a0f | 540 | && (nexthop->type != NEXTHOP_TYPE_BLACKHOLE)) { |
2793a098 | 541 | struct vrf *vrf = |
4a7371e9 | 542 | vrf_lookup_by_id(nexthop->vrf_id); |
2793a098 | 543 | |
996c9314 | 544 | json_object_string_add(json_nexthop, "vrf", |
2793a098 DS |
545 | vrf->name); |
546 | } | |
eaf5150f DS |
547 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)) |
548 | json_object_boolean_true_add(json_nexthop, | |
549 | "duplicate"); | |
550 | ||
d62a17ae | 551 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
552 | json_object_boolean_true_add(json_nexthop, | |
553 | "active"); | |
554 | ||
555 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) | |
556 | json_object_boolean_true_add(json_nexthop, | |
557 | "onLink"); | |
558 | ||
559 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) | |
560 | json_object_boolean_true_add(json_nexthop, | |
561 | "recursive"); | |
562 | ||
563 | switch (nexthop->type) { | |
564 | case NEXTHOP_TYPE_IPV4: | |
565 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
566 | if (nexthop->src.ipv4.s_addr) { | |
567 | if (inet_ntop(AF_INET, | |
568 | &nexthop->src.ipv4, buf, | |
569 | sizeof buf)) | |
570 | json_object_string_add( | |
571 | json_nexthop, "source", | |
572 | buf); | |
573 | } | |
574 | break; | |
575 | case NEXTHOP_TYPE_IPV6: | |
576 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
577 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, | |
578 | &in6addr_any)) { | |
579 | if (inet_ntop(AF_INET6, | |
580 | &nexthop->src.ipv6, buf, | |
581 | sizeof buf)) | |
582 | json_object_string_add( | |
583 | json_nexthop, "source", | |
584 | buf); | |
585 | } | |
586 | break; | |
587 | default: | |
588 | break; | |
589 | } | |
590 | ||
591 | if (nexthop->nh_label | |
592 | && nexthop->nh_label->num_labels) { | |
593 | json_labels = json_object_new_array(); | |
594 | ||
595 | for (int label_index = 0; | |
596 | label_index | |
597 | < nexthop->nh_label->num_labels; | |
598 | label_index++) | |
599 | json_object_array_add( | |
600 | json_labels, | |
601 | json_object_new_int( | |
602 | nexthop->nh_label->label | |
603 | [label_index])); | |
604 | ||
605 | json_object_object_add(json_nexthop, "labels", | |
606 | json_labels); | |
607 | } | |
608 | ||
609 | json_object_array_add(json_nexthops, json_nexthop); | |
610 | } | |
611 | ||
612 | json_object_object_add(json_route, "nexthops", json_nexthops); | |
613 | json_object_array_add(json, json_route); | |
614 | return; | |
615 | } | |
616 | ||
617 | /* Nexthop information. */ | |
7ee30f28 DS |
618 | for (ALL_NEXTHOPS(re->ng, nexthop)) { |
619 | if (nexthop == re->ng.nexthop) { | |
d62a17ae | 620 | /* Prefix information. */ |
621 | len = vty_out(vty, "%c", zebra_route_char(re->type)); | |
622 | if (re->instance) | |
623 | len += vty_out(vty, "[%d]", re->instance); | |
624 | len += vty_out( | |
625 | vty, "%c%c %s", | |
626 | CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED) | |
627 | ? '>' | |
628 | : ' ', | |
4a2f796f | 629 | re_status_output_char(re, nexthop), |
d62a17ae | 630 | srcdest_rnode2str(rn, buf, sizeof buf)); |
631 | ||
632 | /* Distance and metric display. */ | |
059c79ba AK |
633 | if (((re->type == ZEBRA_ROUTE_CONNECT) && |
634 | (re->distance || re->metric)) || | |
635 | (re->type != ZEBRA_ROUTE_CONNECT)) | |
8526b842 | 636 | len += vty_out(vty, " [%u/%u]", re->distance, |
d62a17ae | 637 | re->metric); |
eaf5150f | 638 | } else { |
d62a17ae | 639 | vty_out(vty, " %c%*c", |
4a2f796f | 640 | re_status_output_char(re, nexthop), |
d62a17ae | 641 | len - 3 + (2 * nexthop_level(nexthop)), ' '); |
eaf5150f | 642 | } |
d62a17ae | 643 | |
644 | switch (nexthop->type) { | |
645 | case NEXTHOP_TYPE_IPV4: | |
646 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
647 | vty_out(vty, " via %s", inet_ntoa(nexthop->gate.ipv4)); | |
648 | if (nexthop->ifindex) | |
649 | vty_out(vty, ", %s", | |
650 | ifindex2ifname(nexthop->ifindex, | |
4a7371e9 | 651 | nexthop->vrf_id)); |
d62a17ae | 652 | break; |
653 | case NEXTHOP_TYPE_IPV6: | |
654 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
655 | vty_out(vty, " via %s", | |
656 | inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, | |
657 | sizeof buf)); | |
658 | if (nexthop->ifindex) | |
659 | vty_out(vty, ", %s", | |
660 | ifindex2ifname(nexthop->ifindex, | |
4a7371e9 | 661 | nexthop->vrf_id)); |
d62a17ae | 662 | break; |
663 | ||
664 | case NEXTHOP_TYPE_IFINDEX: | |
665 | vty_out(vty, " is directly connected, %s", | |
99b9d960 | 666 | ifindex2ifname(nexthop->ifindex, |
4a7371e9 | 667 | nexthop->vrf_id)); |
d62a17ae | 668 | break; |
669 | case NEXTHOP_TYPE_BLACKHOLE: | |
a8309422 DL |
670 | vty_out(vty, " unreachable"); |
671 | switch (nexthop->bh_type) { | |
672 | case BLACKHOLE_REJECT: | |
673 | vty_out(vty, " (ICMP unreachable)"); | |
674 | break; | |
675 | case BLACKHOLE_ADMINPROHIB: | |
676 | vty_out(vty, " (ICMP admin-prohibited)"); | |
677 | break; | |
678 | case BLACKHOLE_NULL: | |
679 | vty_out(vty, " (blackhole)"); | |
680 | break; | |
681 | case BLACKHOLE_UNSPEC: | |
682 | break; | |
683 | } | |
d62a17ae | 684 | break; |
685 | default: | |
686 | break; | |
687 | } | |
2793a098 | 688 | |
fc132690 | 689 | if ((nexthop->vrf_id != re->vrf_id) |
bbde7a0f | 690 | && (nexthop->type != NEXTHOP_TYPE_BLACKHOLE)) { |
4a7371e9 | 691 | struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); |
2793a098 | 692 | |
4c66767c DS |
693 | if (vrf) |
694 | vty_out(vty, "(vrf %s)", vrf->name); | |
695 | else | |
0437e105 | 696 | vty_out(vty, "(vrf UNKNOWN)"); |
2793a098 DS |
697 | } |
698 | ||
d62a17ae | 699 | if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
700 | vty_out(vty, " inactive"); | |
701 | ||
702 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) | |
703 | vty_out(vty, " onlink"); | |
704 | ||
705 | if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) | |
706 | vty_out(vty, " (recursive)"); | |
707 | ||
708 | switch (nexthop->type) { | |
709 | case NEXTHOP_TYPE_IPV4: | |
710 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
711 | if (nexthop->src.ipv4.s_addr) { | |
712 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, | |
713 | sizeof buf)) | |
714 | vty_out(vty, ", src %s", buf); | |
715 | } | |
716 | break; | |
717 | case NEXTHOP_TYPE_IPV6: | |
718 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
719 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) { | |
720 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, | |
721 | sizeof buf)) | |
722 | vty_out(vty, ", src %s", buf); | |
723 | } | |
724 | break; | |
725 | default: | |
726 | break; | |
727 | } | |
728 | ||
729 | /* Label information */ | |
730 | if (nexthop->nh_label && nexthop->nh_label->num_labels) { | |
731 | vty_out(vty, ", label %s", | |
732 | mpls_label2str(nexthop->nh_label->num_labels, | |
733 | nexthop->nh_label->label, buf, | |
734 | sizeof buf, 1)); | |
735 | } | |
736 | ||
14a481d9 DS |
737 | if (uptime < ONE_DAY_SECOND) |
738 | vty_out(vty, ", %02d:%02d:%02d", tm->tm_hour, | |
739 | tm->tm_min, tm->tm_sec); | |
740 | else if (uptime < ONE_WEEK_SECOND) | |
741 | vty_out(vty, ", %dd%02dh%02dm", tm->tm_yday, | |
742 | tm->tm_hour, tm->tm_min); | |
743 | else | |
744 | vty_out(vty, ", %02dw%dd%02dh", tm->tm_yday / 7, | |
745 | tm->tm_yday - ((tm->tm_yday / 7) * 7), | |
746 | tm->tm_hour); | |
d62a17ae | 747 | vty_out(vty, "\n"); |
748 | } | |
749 | } | |
750 | ||
96d71e38 AD |
751 | static void vty_show_ip_route_detail_json(struct vty *vty, |
752 | struct route_node *rn) | |
753 | { | |
754 | json_object *json = NULL; | |
755 | json_object *json_prefix = NULL; | |
756 | struct route_entry *re; | |
757 | char buf[BUFSIZ]; | |
758 | ||
759 | json = json_object_new_object(); | |
9e7cd6fd | 760 | json_prefix = json_object_new_array(); |
96d71e38 AD |
761 | |
762 | RNODE_FOREACH_RE (rn, re) { | |
96d71e38 | 763 | vty_show_ip_route(vty, rn, re, json_prefix); |
96d71e38 AD |
764 | } |
765 | ||
9e7cd6fd DS |
766 | prefix2str(&rn->p, buf, sizeof(buf)); |
767 | json_object_object_add(json, buf, json_prefix); | |
96d71e38 AD |
768 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
769 | json, JSON_C_TO_STRING_PRETTY)); | |
770 | json_object_free(json); | |
771 | } | |
772 | ||
ae825b8b DS |
773 | static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, |
774 | struct route_table *table, afi_t afi, | |
775 | bool use_fib, route_tag_t tag, | |
776 | const struct prefix *longer_prefix_p, | |
777 | bool supernets_only, int type, | |
9f049418 | 778 | unsigned short ospf_instance_id, bool use_json) |
d62a17ae | 779 | { |
d62a17ae | 780 | struct route_node *rn; |
781 | struct route_entry *re; | |
782 | int first = 1; | |
ae825b8b | 783 | rib_dest_t *dest; |
d62a17ae | 784 | json_object *json = NULL; |
785 | json_object *json_prefix = NULL; | |
ae825b8b DS |
786 | uint32_t addr; |
787 | char buf[BUFSIZ]; | |
d62a17ae | 788 | |
789 | if (use_json) | |
790 | json = json_object_new_object(); | |
791 | ||
792 | /* Show all routes. */ | |
c9591045 | 793 | for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) { |
5f7a4718 DS |
794 | dest = rib_dest_from_rnode(rn); |
795 | ||
a2addae8 | 796 | RNODE_FOREACH_RE (rn, re) { |
996c9314 | 797 | if (use_fib && re != dest->selected_fib) |
d62a17ae | 798 | continue; |
799 | ||
800 | if (tag && re->tag != tag) | |
801 | continue; | |
802 | ||
803 | if (longer_prefix_p | |
804 | && !prefix_match(longer_prefix_p, &rn->p)) | |
805 | continue; | |
806 | ||
807 | /* This can only be true when the afi is IPv4 */ | |
808 | if (supernets_only) { | |
809 | addr = ntohl(rn->p.u.prefix4.s_addr); | |
810 | ||
811 | if (IN_CLASSC(addr) && rn->p.prefixlen >= 24) | |
812 | continue; | |
813 | ||
814 | if (IN_CLASSB(addr) && rn->p.prefixlen >= 16) | |
815 | continue; | |
816 | ||
817 | if (IN_CLASSA(addr) && rn->p.prefixlen >= 8) | |
818 | continue; | |
819 | } | |
820 | ||
821 | if (type && re->type != type) | |
822 | continue; | |
823 | ||
824 | if (ospf_instance_id | |
825 | && (re->type != ZEBRA_ROUTE_OSPF | |
826 | || re->instance != ospf_instance_id)) | |
827 | continue; | |
828 | ||
829 | if (use_json) { | |
830 | if (!json_prefix) | |
831 | json_prefix = json_object_new_array(); | |
832 | } else { | |
833 | if (first) { | |
834 | if (afi == AFI_IP) | |
835 | vty_out(vty, | |
836 | SHOW_ROUTE_V4_HEADER); | |
837 | else | |
838 | vty_out(vty, | |
839 | SHOW_ROUTE_V6_HEADER); | |
840 | ||
841 | if (zvrf_id(zvrf) != VRF_DEFAULT) | |
842 | vty_out(vty, "\nVRF %s:\n", | |
843 | zvrf_name(zvrf)); | |
844 | ||
845 | first = 0; | |
846 | } | |
847 | } | |
848 | ||
849 | vty_show_ip_route(vty, rn, re, json_prefix); | |
850 | } | |
851 | ||
852 | if (json_prefix) { | |
96d71e38 | 853 | prefix2str(&rn->p, buf, sizeof(buf)); |
d62a17ae | 854 | json_object_object_add(json, buf, json_prefix); |
855 | json_prefix = NULL; | |
856 | } | |
857 | } | |
858 | ||
859 | if (use_json) { | |
96d71e38 AD |
860 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, |
861 | JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 862 | json_object_free(json); |
863 | } | |
ae825b8b DS |
864 | } |
865 | ||
866 | static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, | |
9f049418 | 867 | safi_t safi, bool use_fib, bool use_json, |
ae825b8b DS |
868 | route_tag_t tag, |
869 | const struct prefix *longer_prefix_p, | |
870 | bool supernets_only, int type, | |
d7c0a89a | 871 | unsigned short ospf_instance_id) |
ae825b8b DS |
872 | { |
873 | struct route_table *table; | |
874 | struct zebra_vrf *zvrf = NULL; | |
875 | ||
876 | if (!(zvrf = zebra_vrf_lookup_by_name(vrf_name))) { | |
877 | if (use_json) | |
878 | vty_out(vty, "{}\n"); | |
879 | else | |
880 | vty_out(vty, "vrf %s not defined\n", vrf_name); | |
881 | return CMD_SUCCESS; | |
882 | } | |
883 | ||
884 | if (zvrf_id(zvrf) == VRF_UNKNOWN) { | |
885 | if (use_json) | |
886 | vty_out(vty, "{}\n"); | |
887 | else | |
888 | vty_out(vty, "vrf %s inactive\n", vrf_name); | |
889 | return CMD_SUCCESS; | |
890 | } | |
891 | ||
892 | table = zebra_vrf_table(afi, safi, zvrf_id(zvrf)); | |
893 | if (!table) { | |
894 | if (use_json) | |
895 | vty_out(vty, "{}\n"); | |
896 | return CMD_SUCCESS; | |
897 | } | |
898 | ||
899 | do_show_route_helper(vty, zvrf, table, afi, use_fib, tag, | |
900 | longer_prefix_p, supernets_only, type, | |
901 | ospf_instance_id, use_json); | |
902 | ||
903 | return CMD_SUCCESS; | |
904 | } | |
905 | ||
906 | DEFPY (show_route_table, | |
907 | show_route_table_cmd, | |
908 | "show <ip$ipv4|ipv6$ipv6> route table (1-4294967295)$table [json$json]", | |
909 | SHOW_STR | |
910 | IP_STR | |
911 | IP6_STR | |
912 | "IP routing table\n" | |
913 | "Table to display\n" | |
914 | "The table number to display, if available\n" | |
915 | JSON_STR) | |
916 | { | |
917 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; | |
918 | struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); | |
919 | struct route_table *t; | |
920 | ||
89272910 | 921 | t = zebra_router_find_table(zvrf, table, afi, SAFI_UNICAST); |
ae825b8b DS |
922 | if (t) |
923 | do_show_route_helper(vty, zvrf, t, afi, false, 0, false, false, | |
924 | 0, 0, !!json); | |
d62a17ae | 925 | |
926 | return CMD_SUCCESS; | |
abbda2d4 | 927 | } |
d511d7f1 | 928 | |
87d6ac7a PG |
929 | DEFPY (show_route_table_vrf, |
930 | show_route_table_vrf_cmd, | |
931 | "show <ip$ipv4|ipv6$ipv6> route table (1-4294967295)$table vrf NAME$vrf_name [json$json]", | |
932 | SHOW_STR | |
933 | IP_STR | |
934 | IP6_STR | |
935 | "IP routing table\n" | |
936 | "Table to display\n" | |
937 | "The table number to display, if available\n" | |
938 | VRF_CMD_HELP_STR | |
939 | JSON_STR) | |
940 | { | |
941 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; | |
942 | struct zebra_vrf *zvrf; | |
943 | struct route_table *t; | |
944 | vrf_id_t vrf_id = VRF_DEFAULT; | |
945 | ||
946 | if (vrf_name) | |
ec1db588 | 947 | VRF_GET_ID(vrf_id, vrf_name, !!json); |
87d6ac7a PG |
948 | zvrf = zebra_vrf_lookup_by_id(vrf_id); |
949 | ||
89272910 | 950 | t = zebra_router_find_table(zvrf, table, afi, SAFI_UNICAST); |
87d6ac7a PG |
951 | if (t) |
952 | do_show_route_helper(vty, zvrf, t, afi, false, 0, false, false, | |
953 | 0, 0, !!json); | |
954 | ||
955 | return CMD_SUCCESS; | |
956 | } | |
957 | ||
7004c67b | 958 | DEFPY (show_ip_nht, |
8f527c5e | 959 | show_ip_nht_cmd, |
7004c67b | 960 | "show <ip$ipv4|ipv6$ipv6> nht [vrf NAME$vrf_name|vrf all$vrf_all]", |
8f527c5e FL |
961 | SHOW_STR |
962 | IP_STR | |
7004c67b | 963 | IP6_STR |
9bf96c84 | 964 | "IP nexthop tracking table\n" |
7004c67b RW |
965 | VRF_CMD_HELP_STR |
966 | VRF_ALL_CMD_HELP_STR) | |
8f527c5e | 967 | { |
7004c67b | 968 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; |
d62a17ae | 969 | vrf_id_t vrf_id = VRF_DEFAULT; |
12f6fb97 | 970 | |
7004c67b RW |
971 | if (vrf_all) { |
972 | struct vrf *vrf; | |
973 | struct zebra_vrf *zvrf; | |
974 | ||
975 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) | |
976 | if ((zvrf = vrf->info) != NULL) { | |
977 | vty_out(vty, "\nVRF %s:\n", zvrf_name(zvrf)); | |
978 | zebra_print_rnh_table(zvrf_id(zvrf), afi, vty, | |
979 | RNH_NEXTHOP_TYPE); | |
980 | } | |
981 | return CMD_SUCCESS; | |
982 | } | |
983 | if (vrf_name) | |
984 | VRF_GET_ID(vrf_id, vrf_name, false); | |
12f6fb97 | 985 | |
7004c67b | 986 | zebra_print_rnh_table(vrf_id, afi, vty, RNH_NEXTHOP_TYPE); |
d62a17ae | 987 | return CMD_SUCCESS; |
8f527c5e FL |
988 | } |
989 | ||
b85c8275 PG |
990 | DEFPY (show_ip_import_check, |
991 | show_ip_import_check_cmd, | |
992 | "show <ip$ipv4|ipv6$ipv6> import-check [vrf NAME$vrf_name|vrf all$vrf_all]", | |
993 | SHOW_STR | |
994 | IP_STR | |
995 | IP6_STR | |
996 | "IP import check tracking table\n" | |
997 | VRF_CMD_HELP_STR | |
998 | VRF_ALL_CMD_HELP_STR) | |
999 | { | |
73bf60a0 | 1000 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; |
b85c8275 PG |
1001 | vrf_id_t vrf_id = VRF_DEFAULT; |
1002 | ||
1003 | if (vrf_all) { | |
1004 | struct vrf *vrf; | |
1005 | struct zebra_vrf *zvrf; | |
1006 | ||
1007 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) | |
1008 | if ((zvrf = vrf->info) != NULL) { | |
1009 | vty_out(vty, "\nVRF %s:\n", | |
1010 | zvrf_name(zvrf)); | |
73bf60a0 | 1011 | zebra_print_rnh_table(zvrf_id(zvrf), afi, vty, |
6f95d11a | 1012 | RNH_IMPORT_CHECK_TYPE); |
b85c8275 PG |
1013 | } |
1014 | return CMD_SUCCESS; | |
1015 | } | |
1016 | if (vrf_name) | |
1017 | VRF_GET_ID(vrf_id, vrf_name, false); | |
1018 | ||
73bf60a0 | 1019 | zebra_print_rnh_table(vrf_id, afi, vty, RNH_IMPORT_CHECK_TYPE); |
b85c8275 PG |
1020 | return CMD_SUCCESS; |
1021 | } | |
12f6fb97 | 1022 | |
8f527c5e FL |
1023 | DEFUN (ip_nht_default_route, |
1024 | ip_nht_default_route_cmd, | |
1025 | "ip nht resolve-via-default", | |
1026 | IP_STR | |
1027 | "Filter Next Hop tracking route resolution\n" | |
1028 | "Resolve via default route\n") | |
1029 | { | |
214e5c26 | 1030 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); |
6d53d7b1 | 1031 | |
1032 | if (!zvrf) | |
1033 | return CMD_WARNING; | |
1034 | ||
214e5c26 | 1035 | if (zebra_rnh_ip_default_route) |
1036 | return CMD_SUCCESS; | |
1037 | ||
d62a17ae | 1038 | zebra_rnh_ip_default_route = 1; |
214e5c26 | 1039 | |
73bf60a0 | 1040 | zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); |
d62a17ae | 1041 | return CMD_SUCCESS; |
8f527c5e FL |
1042 | } |
1043 | ||
1044 | DEFUN (no_ip_nht_default_route, | |
1045 | no_ip_nht_default_route_cmd, | |
1046 | "no ip nht resolve-via-default", | |
1047 | NO_STR | |
1048 | IP_STR | |
1049 | "Filter Next Hop tracking route resolution\n" | |
1050 | "Resolve via default route\n") | |
1051 | { | |
214e5c26 | 1052 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); |
6d53d7b1 | 1053 | |
1054 | if (!zvrf) | |
1055 | return CMD_WARNING; | |
1056 | ||
214e5c26 | 1057 | if (!zebra_rnh_ip_default_route) |
1058 | return CMD_SUCCESS; | |
1059 | ||
d62a17ae | 1060 | zebra_rnh_ip_default_route = 0; |
73bf60a0 | 1061 | zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); |
d62a17ae | 1062 | return CMD_SUCCESS; |
8f527c5e FL |
1063 | } |
1064 | ||
1065 | DEFUN (ipv6_nht_default_route, | |
1066 | ipv6_nht_default_route_cmd, | |
1067 | "ipv6 nht resolve-via-default", | |
1068 | IP6_STR | |
1069 | "Filter Next Hop tracking route resolution\n" | |
1070 | "Resolve via default route\n") | |
1071 | { | |
214e5c26 | 1072 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); |
6d53d7b1 | 1073 | |
1074 | if (!zvrf) | |
1075 | return CMD_WARNING; | |
1076 | ||
214e5c26 | 1077 | if (zebra_rnh_ipv6_default_route) |
1078 | return CMD_SUCCESS; | |
1079 | ||
d62a17ae | 1080 | zebra_rnh_ipv6_default_route = 1; |
73bf60a0 | 1081 | zebra_evaluate_rnh(zvrf, AFI_IP6, 1, RNH_NEXTHOP_TYPE, NULL); |
d62a17ae | 1082 | return CMD_SUCCESS; |
8f527c5e FL |
1083 | } |
1084 | ||
1085 | DEFUN (no_ipv6_nht_default_route, | |
1086 | no_ipv6_nht_default_route_cmd, | |
1087 | "no ipv6 nht resolve-via-default", | |
1088 | NO_STR | |
1089 | IP6_STR | |
1090 | "Filter Next Hop tracking route resolution\n" | |
1091 | "Resolve via default route\n") | |
1092 | { | |
8f527c5e | 1093 | |
214e5c26 | 1094 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); |
6d53d7b1 | 1095 | |
1096 | if (!zvrf) | |
1097 | return CMD_WARNING; | |
1098 | ||
214e5c26 | 1099 | if (!zebra_rnh_ipv6_default_route) |
1100 | return CMD_SUCCESS; | |
1101 | ||
d62a17ae | 1102 | zebra_rnh_ipv6_default_route = 0; |
73bf60a0 | 1103 | zebra_evaluate_rnh(zvrf, AFI_IP6, 1, RNH_NEXTHOP_TYPE, NULL); |
d62a17ae | 1104 | return CMD_SUCCESS; |
8f527c5e FL |
1105 | } |
1106 | ||
ecffa493 RW |
1107 | DEFPY (show_route, |
1108 | show_route_cmd, | |
1109 | "show\ | |
1110 | <\ | |
1111 | ip$ipv4 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\ | |
a3e13ef3 | 1112 | [{\ |
ecffa493 RW |
1113 | tag (1-4294967295)\ |
1114 | |A.B.C.D/M$prefix longer-prefixes\ | |
1115 | |supernets-only$supernets_only\ | |
a3e13ef3 RW |
1116 | }]\ |
1117 | [<\ | |
1118 | " FRR_IP_REDIST_STR_ZEBRA "$type_str\ | |
ecffa493 | 1119 | |ospf$type_str (1-65535)$ospf_instance_id\ |
a3e13ef3 | 1120 | >]\ |
ecffa493 | 1121 | |ipv6$ipv6 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\ |
a3e13ef3 | 1122 | [{\ |
ecffa493 RW |
1123 | tag (1-4294967295)\ |
1124 | |X:X::X:X/M$prefix longer-prefixes\ | |
a3e13ef3 RW |
1125 | }]\ |
1126 | [" FRR_IP6_REDIST_STR_ZEBRA "$type_str]\ | |
ecffa493 RW |
1127 | >\ |
1128 | [json$json]", | |
8f527c5e FL |
1129 | SHOW_STR |
1130 | IP_STR | |
87a88962 | 1131 | "IP forwarding table\n" |
8f527c5e | 1132 | "IP routing table\n" |
ecffa493 | 1133 | VRF_FULL_CMD_HELP_STR |
8f527c5e | 1134 | "Show only routes with tag\n" |
acb25e73 DW |
1135 | "Tag value\n" |
1136 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
1137 | "Show route matching the specified Network/Mask pair only\n" | |
1138 | "Show supernet entries only\n" | |
1139 | FRR_IP_REDIST_HELP_STR_ZEBRA | |
1140 | "Open Shortest Path First (OSPFv2)\n" | |
1141 | "Instance ID\n" | |
ecffa493 RW |
1142 | IPV6_STR |
1143 | "IP forwarding table\n" | |
1144 | "IP routing table\n" | |
1145 | VRF_FULL_CMD_HELP_STR | |
1146 | "Show only routes with tag\n" | |
1147 | "Tag value\n" | |
1148 | "IPv6 prefix\n" | |
1149 | "Show route matching the specified Network/Mask pair only\n" | |
1150 | FRR_IP6_REDIST_HELP_STR_ZEBRA | |
acb25e73 | 1151 | JSON_STR) |
8f527c5e | 1152 | { |
ecffa493 | 1153 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; |
d62a17ae | 1154 | struct vrf *vrf; |
d62a17ae | 1155 | int type = 0; |
d62a17ae | 1156 | |
ecffa493 RW |
1157 | if (type_str) { |
1158 | type = proto_redistnum(afi, type_str); | |
d62a17ae | 1159 | if (type < 0) { |
1160 | vty_out(vty, "Unknown route type\n"); | |
1161 | return CMD_WARNING; | |
1162 | } | |
1163 | } | |
1164 | ||
1165 | if (vrf_all) { | |
a2addae8 | 1166 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
ecffa493 RW |
1167 | struct zebra_vrf *zvrf; |
1168 | struct route_table *table; | |
1169 | ||
d62a17ae | 1170 | if ((zvrf = vrf->info) == NULL |
ecffa493 | 1171 | || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL) |
d62a17ae | 1172 | continue; |
1173 | ||
1174 | do_show_ip_route( | |
ecffa493 RW |
1175 | vty, zvrf_name(zvrf), afi, SAFI_UNICAST, !!fib, |
1176 | !!json, tag, prefix_str ? prefix : NULL, | |
1177 | !!supernets_only, type, ospf_instance_id); | |
d62a17ae | 1178 | } |
1179 | } else { | |
ecffa493 RW |
1180 | vrf_id_t vrf_id = VRF_DEFAULT; |
1181 | ||
1182 | if (vrf_name) | |
ec1db588 | 1183 | VRF_GET_ID(vrf_id, vrf_name, !!json); |
d62a17ae | 1184 | vrf = vrf_lookup_by_id(vrf_id); |
ecffa493 RW |
1185 | do_show_ip_route(vty, vrf->name, afi, SAFI_UNICAST, !!fib, |
1186 | !!json, tag, prefix_str ? prefix : NULL, | |
1187 | !!supernets_only, type, ospf_instance_id); | |
d62a17ae | 1188 | } |
ecffa493 | 1189 | |
d62a17ae | 1190 | return CMD_SUCCESS; |
8f527c5e FL |
1191 | } |
1192 | ||
5ce91022 RW |
1193 | DEFPY (show_route_detail, |
1194 | show_route_detail_cmd, | |
1195 | "show\ | |
1196 | <\ | |
1197 | ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\ | |
1198 | <\ | |
1199 | A.B.C.D$address\ | |
1200 | |A.B.C.D/M$prefix\ | |
1201 | >\ | |
1202 | |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\ | |
1203 | <\ | |
1204 | X:X::X:X$address\ | |
1205 | |X:X::X:X/M$prefix\ | |
1206 | >\ | |
96d71e38 AD |
1207 | >\ |
1208 | [json$json]", | |
8f527c5e FL |
1209 | SHOW_STR |
1210 | IP_STR | |
1211 | "IP routing table\n" | |
5ce91022 RW |
1212 | VRF_FULL_CMD_HELP_STR |
1213 | "Network in the IP routing table to display\n" | |
1214 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" | |
1215 | IP6_STR | |
1216 | "IP routing table\n" | |
1217 | VRF_FULL_CMD_HELP_STR | |
1218 | "IPv6 Address\n" | |
96d71e38 AD |
1219 | "IPv6 prefix\n" |
1220 | JSON_STR) | |
8f527c5e | 1221 | { |
5ce91022 | 1222 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; |
d62a17ae | 1223 | struct route_table *table; |
5ce91022 | 1224 | struct prefix p; |
d62a17ae | 1225 | struct route_node *rn; |
d511d7f1 | 1226 | |
5ce91022 RW |
1227 | if (address_str) |
1228 | prefix_str = address_str; | |
1229 | if (str2prefix(prefix_str, &p) < 0) { | |
1230 | vty_out(vty, "%% Malformed address\n"); | |
d62a17ae | 1231 | return CMD_WARNING; |
1232 | } | |
8f527c5e | 1233 | |
5ce91022 RW |
1234 | if (vrf_all) { |
1235 | struct vrf *vrf; | |
1236 | struct zebra_vrf *zvrf; | |
8f527c5e | 1237 | |
996c9314 | 1238 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
5ce91022 RW |
1239 | if ((zvrf = vrf->info) == NULL |
1240 | || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL) | |
1241 | continue; | |
1242 | ||
1243 | rn = route_node_match(table, &p); | |
1244 | if (!rn) | |
1245 | continue; | |
1246 | if (!address_str && rn->p.prefixlen != p.prefixlen) { | |
1247 | route_unlock_node(rn); | |
1248 | continue; | |
1249 | } | |
1250 | ||
96d71e38 AD |
1251 | if (json) |
1252 | vty_show_ip_route_detail_json(vty, rn); | |
1253 | else | |
1254 | vty_show_ip_route_detail(vty, rn, 0); | |
5ce91022 RW |
1255 | |
1256 | route_unlock_node(rn); | |
1257 | } | |
1258 | } else { | |
1259 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1260 | ||
1261 | if (vrf_name) | |
ec1db588 | 1262 | VRF_GET_ID(vrf_id, vrf_name, false); |
5ce91022 RW |
1263 | |
1264 | table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id); | |
1265 | if (!table) | |
1266 | return CMD_SUCCESS; | |
8f527c5e | 1267 | |
5ce91022 RW |
1268 | rn = route_node_match(table, &p); |
1269 | if (!rn) { | |
1270 | vty_out(vty, "%% Network not in table\n"); | |
1271 | return CMD_WARNING; | |
1272 | } | |
1273 | if (!address_str && rn->p.prefixlen != p.prefixlen) { | |
1274 | vty_out(vty, "%% Network not in table\n"); | |
1275 | route_unlock_node(rn); | |
1276 | return CMD_WARNING; | |
1277 | } | |
8f527c5e | 1278 | |
96d71e38 AD |
1279 | if (json) |
1280 | vty_show_ip_route_detail_json(vty, rn); | |
1281 | else | |
1282 | vty_show_ip_route_detail(vty, rn, 0); | |
5ce91022 RW |
1283 | |
1284 | route_unlock_node(rn); | |
1285 | } | |
8f527c5e | 1286 | |
d62a17ae | 1287 | return CMD_SUCCESS; |
8f527c5e FL |
1288 | } |
1289 | ||
5ce91022 RW |
1290 | DEFPY (show_route_summary, |
1291 | show_route_summary_cmd, | |
1292 | "show\ | |
1293 | <\ | |
1294 | ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\ | |
1295 | summary [prefix$prefix]\ | |
1296 | |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\ | |
1297 | summary [prefix$prefix]\ | |
1298 | >", | |
8f527c5e FL |
1299 | SHOW_STR |
1300 | IP_STR | |
1301 | "IP routing table\n" | |
5ce91022 RW |
1302 | VRF_FULL_CMD_HELP_STR |
1303 | "Summary of all routes\n" | |
1304 | "Prefix routes\n" | |
1305 | IP6_STR | |
1306 | "IP routing table\n" | |
1307 | VRF_FULL_CMD_HELP_STR | |
1308 | "Summary of all routes\n" | |
1309 | "Prefix routes\n") | |
8f527c5e | 1310 | { |
5ce91022 | 1311 | afi_t afi = ipv4 ? AFI_IP : AFI_IP6; |
d62a17ae | 1312 | struct route_table *table; |
d62a17ae | 1313 | |
5ce91022 RW |
1314 | if (vrf_all) { |
1315 | struct vrf *vrf; | |
1316 | struct zebra_vrf *zvrf; | |
d511d7f1 | 1317 | |
996c9314 | 1318 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
5ce91022 RW |
1319 | if ((zvrf = vrf->info) == NULL |
1320 | || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL) | |
1321 | continue; | |
8f527c5e | 1322 | |
5ce91022 RW |
1323 | if (prefix) |
1324 | vty_show_ip_route_summary_prefix(vty, table); | |
1325 | else | |
1326 | vty_show_ip_route_summary(vty, table); | |
1327 | } | |
1328 | } else { | |
1329 | vrf_id_t vrf_id = VRF_DEFAULT; | |
8f527c5e | 1330 | |
5ce91022 | 1331 | if (vrf_name) |
ec1db588 | 1332 | VRF_GET_ID(vrf_id, vrf_name, false); |
8f527c5e | 1333 | |
5ce91022 RW |
1334 | table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id); |
1335 | if (!table) | |
1336 | return CMD_SUCCESS; | |
8f527c5e | 1337 | |
5ce91022 RW |
1338 | if (prefix) |
1339 | vty_show_ip_route_summary_prefix(vty, table); | |
1340 | else | |
1341 | vty_show_ip_route_summary(vty, table); | |
1342 | } | |
8f527c5e | 1343 | |
d62a17ae | 1344 | return CMD_SUCCESS; |
8f527c5e FL |
1345 | } |
1346 | ||
d62a17ae | 1347 | static void vty_show_ip_route_summary(struct vty *vty, |
1348 | struct route_table *table) | |
8f527c5e | 1349 | { |
d62a17ae | 1350 | struct route_node *rn; |
1351 | struct route_entry *re; | |
8f527c5e FL |
1352 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
1353 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) | |
d7c0a89a QY |
1354 | uint32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
1355 | uint32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; | |
1356 | uint32_t i; | |
1357 | uint32_t is_ibgp; | |
d62a17ae | 1358 | |
1359 | memset(&rib_cnt, 0, sizeof(rib_cnt)); | |
1360 | memset(&fib_cnt, 0, sizeof(fib_cnt)); | |
1361 | for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) | |
a2addae8 | 1362 | RNODE_FOREACH_RE (rn, re) { |
d62a17ae | 1363 | is_ibgp = (re->type == ZEBRA_ROUTE_BGP |
1364 | && CHECK_FLAG(re->flags, ZEBRA_FLAG_IBGP)); | |
1365 | ||
1366 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; | |
1367 | if (is_ibgp) | |
1368 | rib_cnt[ZEBRA_ROUTE_IBGP]++; | |
1369 | else | |
1370 | rib_cnt[re->type]++; | |
1371 | ||
1372 | if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) { | |
1373 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; | |
1374 | ||
1375 | if (is_ibgp) | |
1376 | fib_cnt[ZEBRA_ROUTE_IBGP]++; | |
1377 | else | |
1378 | fib_cnt[re->type]++; | |
1379 | } | |
1380 | } | |
1381 | ||
1382 | vty_out(vty, "%-20s %-20s %s (vrf %s)\n", "Route Source", "Routes", | |
6ca30e9e | 1383 | "FIB", zvrf_name(((rib_table_info_t *)route_table_get_info(table))->zvrf)); |
d62a17ae | 1384 | |
1385 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
9d303b37 DL |
1386 | if ((rib_cnt[i] > 0) || (i == ZEBRA_ROUTE_BGP |
1387 | && rib_cnt[ZEBRA_ROUTE_IBGP] > 0)) { | |
d62a17ae | 1388 | if (i == ZEBRA_ROUTE_BGP) { |
1389 | vty_out(vty, "%-20s %-20d %-20d \n", "ebgp", | |
1390 | rib_cnt[ZEBRA_ROUTE_BGP], | |
1391 | fib_cnt[ZEBRA_ROUTE_BGP]); | |
1392 | vty_out(vty, "%-20s %-20d %-20d \n", "ibgp", | |
1393 | rib_cnt[ZEBRA_ROUTE_IBGP], | |
1394 | fib_cnt[ZEBRA_ROUTE_IBGP]); | |
1395 | } else | |
1396 | vty_out(vty, "%-20s %-20d %-20d \n", | |
1397 | zebra_route_string(i), rib_cnt[i], | |
1398 | fib_cnt[i]); | |
1399 | } | |
1400 | } | |
1401 | ||
1402 | vty_out(vty, "------\n"); | |
1403 | vty_out(vty, "%-20s %-20d %-20d \n", "Totals", | |
1404 | rib_cnt[ZEBRA_ROUTE_TOTAL], fib_cnt[ZEBRA_ROUTE_TOTAL]); | |
1405 | vty_out(vty, "\n"); | |
8f527c5e FL |
1406 | } |
1407 | ||
1408 | /* | |
1409 | * Implementation of the ip route summary prefix command. | |
1410 | * | |
1411 | * This command prints the primary prefixes that have been installed by various | |
1412 | * protocols on the box. | |
1413 | * | |
1414 | */ | |
d62a17ae | 1415 | static void vty_show_ip_route_summary_prefix(struct vty *vty, |
1416 | struct route_table *table) | |
8f527c5e | 1417 | { |
d62a17ae | 1418 | struct route_node *rn; |
1419 | struct route_entry *re; | |
1420 | struct nexthop *nexthop; | |
8f527c5e FL |
1421 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
1422 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) | |
d7c0a89a QY |
1423 | uint32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
1424 | uint32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; | |
1425 | uint32_t i; | |
d62a17ae | 1426 | int cnt; |
1427 | ||
1428 | memset(&rib_cnt, 0, sizeof(rib_cnt)); | |
1429 | memset(&fib_cnt, 0, sizeof(fib_cnt)); | |
1430 | for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) | |
a2addae8 | 1431 | RNODE_FOREACH_RE (rn, re) { |
d62a17ae | 1432 | |
1433 | /* | |
1434 | * In case of ECMP, count only once. | |
1435 | */ | |
1436 | cnt = 0; | |
677c1dd5 DS |
1437 | if (CHECK_FLAG(re->status, ROUTE_ENTRY_INSTALLED)) { |
1438 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; | |
1439 | fib_cnt[re->type]++; | |
1440 | } | |
7ee30f28 | 1441 | for (nexthop = re->ng.nexthop; (!cnt && nexthop); |
d62a17ae | 1442 | nexthop = nexthop->next) { |
1443 | cnt++; | |
1444 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; | |
1445 | rib_cnt[re->type]++; | |
d62a17ae | 1446 | if (re->type == ZEBRA_ROUTE_BGP |
1447 | && CHECK_FLAG(re->flags, ZEBRA_FLAG_IBGP)) { | |
1448 | rib_cnt[ZEBRA_ROUTE_IBGP]++; | |
677c1dd5 DS |
1449 | if (CHECK_FLAG(re->status, |
1450 | ROUTE_ENTRY_INSTALLED)) | |
d62a17ae | 1451 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
1452 | } | |
1453 | } | |
1454 | } | |
1455 | ||
1456 | vty_out(vty, "%-20s %-20s %s (vrf %s)\n", "Route Source", | |
1457 | "Prefix Routes", "FIB", | |
6ca30e9e | 1458 | zvrf_name(((rib_table_info_t *)route_table_get_info(table))->zvrf)); |
d62a17ae | 1459 | |
1460 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
1461 | if (rib_cnt[i] > 0) { | |
1462 | if (i == ZEBRA_ROUTE_BGP) { | |
1463 | vty_out(vty, "%-20s %-20d %-20d \n", "ebgp", | |
1464 | rib_cnt[ZEBRA_ROUTE_BGP] | |
1465 | - rib_cnt[ZEBRA_ROUTE_IBGP], | |
1466 | fib_cnt[ZEBRA_ROUTE_BGP] | |
1467 | - fib_cnt[ZEBRA_ROUTE_IBGP]); | |
1468 | vty_out(vty, "%-20s %-20d %-20d \n", "ibgp", | |
1469 | rib_cnt[ZEBRA_ROUTE_IBGP], | |
1470 | fib_cnt[ZEBRA_ROUTE_IBGP]); | |
1471 | } else | |
1472 | vty_out(vty, "%-20s %-20d %-20d \n", | |
1473 | zebra_route_string(i), rib_cnt[i], | |
1474 | fib_cnt[i]); | |
1475 | } | |
1476 | } | |
1477 | ||
1478 | vty_out(vty, "------\n"); | |
1479 | vty_out(vty, "%-20s %-20d %-20d \n", "Totals", | |
1480 | rib_cnt[ZEBRA_ROUTE_TOTAL], fib_cnt[ZEBRA_ROUTE_TOTAL]); | |
1481 | vty_out(vty, "\n"); | |
9343ce83 DS |
1482 | } |
1483 | ||
cddf391b B |
1484 | /* |
1485 | * Show IPv6 mroute command.Used to dump | |
1486 | * the Multicast routing table. | |
1487 | */ | |
cddf391b B |
1488 | DEFUN (show_ipv6_mroute, |
1489 | show_ipv6_mroute_cmd, | |
9bf96c84 | 1490 | "show ipv6 mroute [vrf NAME]", |
cddf391b B |
1491 | SHOW_STR |
1492 | IP_STR | |
9bf96c84 DW |
1493 | "IPv6 Multicast routing table\n" |
1494 | VRF_CMD_HELP_STR) | |
cddf391b | 1495 | { |
d62a17ae | 1496 | struct route_table *table; |
1497 | struct route_node *rn; | |
1498 | struct route_entry *re; | |
1499 | int first = 1; | |
1500 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1501 | ||
1502 | if (argc == 5) | |
ec1db588 | 1503 | VRF_GET_ID(vrf_id, argv[4]->arg, false); |
d62a17ae | 1504 | |
1505 | table = zebra_vrf_table(AFI_IP6, SAFI_MULTICAST, vrf_id); | |
1506 | if (!table) | |
1507 | return CMD_SUCCESS; | |
1508 | ||
1509 | /* Show all IPv6 route. */ | |
1510 | for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) | |
a2addae8 | 1511 | RNODE_FOREACH_RE (rn, re) { |
d62a17ae | 1512 | if (first) { |
1513 | vty_out(vty, SHOW_ROUTE_V6_HEADER); | |
1514 | first = 0; | |
1515 | } | |
1516 | vty_show_ip_route(vty, rn, re, NULL); | |
1517 | } | |
1518 | return CMD_SUCCESS; | |
cddf391b B |
1519 | } |
1520 | ||
af41b63a FL |
1521 | DEFUN (show_ipv6_mroute_vrf_all, |
1522 | show_ipv6_mroute_vrf_all_cmd, | |
5bebf568 | 1523 | "show ipv6 mroute vrf all", |
af41b63a FL |
1524 | SHOW_STR |
1525 | IP_STR | |
1526 | "IPv6 Multicast routing table\n" | |
1527 | VRF_ALL_CMD_HELP_STR) | |
1528 | { | |
d62a17ae | 1529 | struct route_table *table; |
1530 | struct route_node *rn; | |
1531 | struct route_entry *re; | |
1532 | struct vrf *vrf; | |
1533 | struct zebra_vrf *zvrf; | |
1534 | int first = 1; | |
1535 | ||
a2addae8 | 1536 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
d62a17ae | 1537 | if ((zvrf = vrf->info) == NULL |
1538 | || (table = zvrf->table[AFI_IP6][SAFI_MULTICAST]) == NULL) | |
1539 | continue; | |
1540 | ||
1541 | /* Show all IPv6 route. */ | |
1542 | for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) | |
a2addae8 | 1543 | RNODE_FOREACH_RE (rn, re) { |
d62a17ae | 1544 | if (first) { |
1545 | vty_out(vty, SHOW_ROUTE_V6_HEADER); | |
1546 | first = 0; | |
1547 | } | |
1548 | vty_show_ip_route(vty, rn, re, NULL); | |
1549 | } | |
1550 | } | |
1551 | return CMD_SUCCESS; | |
af41b63a FL |
1552 | } |
1553 | ||
6baf7bb8 DS |
1554 | DEFUN (allow_external_route_update, |
1555 | allow_external_route_update_cmd, | |
1556 | "allow-external-route-update", | |
17d990c1 | 1557 | "Allow FRR routes to be overwritten by external processes\n") |
6baf7bb8 | 1558 | { |
d62a17ae | 1559 | allow_delete = 1; |
6baf7bb8 | 1560 | |
d62a17ae | 1561 | return CMD_SUCCESS; |
6baf7bb8 DS |
1562 | } |
1563 | ||
1564 | DEFUN (no_allow_external_route_update, | |
1565 | no_allow_external_route_update_cmd, | |
1566 | "no allow-external-route-update", | |
17d990c1 DS |
1567 | NO_STR |
1568 | "Allow FRR routes to be overwritten by external processes\n") | |
6baf7bb8 | 1569 | { |
d62a17ae | 1570 | allow_delete = 0; |
6baf7bb8 | 1571 | |
d62a17ae | 1572 | return CMD_SUCCESS; |
6baf7bb8 DS |
1573 | } |
1574 | ||
12f6fb97 DS |
1575 | /* show vrf */ |
1576 | DEFUN (show_vrf, | |
1577 | show_vrf_cmd, | |
1578 | "show vrf", | |
1579 | SHOW_STR | |
1580 | "VRF\n") | |
1581 | { | |
d62a17ae | 1582 | struct vrf *vrf; |
1583 | struct zebra_vrf *zvrf; | |
12f6fb97 | 1584 | |
b73823ef PG |
1585 | if (vrf_is_backend_netns()) |
1586 | vty_out(vty, "netns-based vrfs\n"); | |
1587 | ||
a2addae8 | 1588 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
d62a17ae | 1589 | if (!(zvrf = vrf->info)) |
1590 | continue; | |
90ac32c2 | 1591 | if (zvrf_id(zvrf) == VRF_DEFAULT) |
d62a17ae | 1592 | continue; |
1593 | ||
1594 | vty_out(vty, "vrf %s ", zvrf_name(zvrf)); | |
996c9314 | 1595 | if (zvrf_id(zvrf) == VRF_UNKNOWN || !zvrf_is_active(zvrf)) |
d62a17ae | 1596 | vty_out(vty, "inactive"); |
81c9005f | 1597 | else if (zvrf_ns_name(zvrf)) |
996c9314 LB |
1598 | vty_out(vty, "id %u netns %s", zvrf_id(zvrf), |
1599 | zvrf_ns_name(zvrf)); | |
d62a17ae | 1600 | else |
1601 | vty_out(vty, "id %u table %u", zvrf_id(zvrf), | |
1602 | zvrf->table_id); | |
22bd3e94 | 1603 | if (vrf_is_user_cfged(vrf)) |
1604 | vty_out(vty, " (configured)"); | |
d62a17ae | 1605 | vty_out(vty, "\n"); |
1606 | } | |
12f6fb97 | 1607 | |
d62a17ae | 1608 | return CMD_SUCCESS; |
12f6fb97 DS |
1609 | } |
1610 | ||
62710e2b | 1611 | DEFUN_HIDDEN (default_vrf_vni_mapping, |
e8d26197 | 1612 | default_vrf_vni_mapping_cmd, |
c48d9f5f | 1613 | "vni " CMD_VNI_RANGE "[prefix-routes-only]", |
e8d26197 | 1614 | "VNI corresponding to the DEFAULT VRF\n" |
c48d9f5f MK |
1615 | "VNI-ID\n" |
1616 | "Prefix routes only \n") | |
e8d26197 MK |
1617 | { |
1618 | int ret = 0; | |
1619 | char err[ERR_STR_SZ]; | |
1620 | struct zebra_vrf *zvrf = NULL; | |
1621 | vni_t vni = strtoul(argv[1]->arg, NULL, 10); | |
c48d9f5f | 1622 | int filter = 0; |
e8d26197 MK |
1623 | |
1624 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
1625 | if (!zvrf) | |
1626 | return CMD_WARNING; | |
1627 | ||
c48d9f5f MK |
1628 | if (argc == 3) |
1629 | filter = 1; | |
1630 | ||
1631 | ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, | |
1632 | filter, 1); | |
e8d26197 MK |
1633 | if (ret != 0) { |
1634 | vty_out(vty, "%s\n", err); | |
1635 | return CMD_WARNING; | |
1636 | } | |
1637 | ||
1638 | return CMD_SUCCESS; | |
1639 | } | |
1640 | ||
62710e2b | 1641 | DEFUN_HIDDEN (no_default_vrf_vni_mapping, |
e8d26197 MK |
1642 | no_default_vrf_vni_mapping_cmd, |
1643 | "no vni " CMD_VNI_RANGE, | |
1644 | NO_STR | |
1645 | "VNI corresponding to DEFAULT VRF\n" | |
1646 | "VNI-ID") | |
1647 | { | |
1648 | int ret = 0; | |
1649 | char err[ERR_STR_SZ]; | |
1650 | vni_t vni = strtoul(argv[2]->arg, NULL, 10); | |
1651 | struct zebra_vrf *zvrf = NULL; | |
1652 | ||
1653 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
1654 | if (!zvrf) | |
1655 | return CMD_WARNING; | |
1656 | ||
c48d9f5f | 1657 | ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, 0, 0); |
e8d26197 MK |
1658 | if (ret != 0) { |
1659 | vty_out(vty, "%s\n", err); | |
1660 | return CMD_WARNING; | |
1661 | } | |
1662 | ||
1663 | return CMD_SUCCESS; | |
1664 | } | |
1665 | ||
b7cfce93 MK |
1666 | DEFUN (vrf_vni_mapping, |
1667 | vrf_vni_mapping_cmd, | |
c48d9f5f | 1668 | "vni " CMD_VNI_RANGE "[prefix-routes-only]", |
e8d26197 | 1669 | "VNI corresponding to tenant VRF\n" |
c48d9f5f MK |
1670 | "VNI-ID\n" |
1671 | "prefix-routes-only\n") | |
b7cfce93 MK |
1672 | { |
1673 | int ret = 0; | |
c48d9f5f | 1674 | int filter = 0; |
b7cfce93 MK |
1675 | |
1676 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); | |
1677 | vni_t vni = strtoul(argv[1]->arg, NULL, 10); | |
1678 | char err[ERR_STR_SZ]; | |
1679 | ||
1680 | assert(vrf); | |
1681 | assert(zvrf); | |
1682 | ||
c48d9f5f MK |
1683 | if (argc == 3) |
1684 | filter = 1; | |
1685 | ||
317f1fe0 | 1686 | /* Mark as having FRR configuration */ |
1687 | vrf_set_user_cfged(vrf); | |
c48d9f5f MK |
1688 | ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, |
1689 | filter, 1); | |
b7cfce93 MK |
1690 | if (ret != 0) { |
1691 | vty_out(vty, "%s\n", err); | |
1692 | return CMD_WARNING; | |
1693 | } | |
1694 | ||
1695 | return CMD_SUCCESS; | |
1696 | } | |
1697 | ||
1698 | DEFUN (no_vrf_vni_mapping, | |
1699 | no_vrf_vni_mapping_cmd, | |
cf299714 | 1700 | "no vni " CMD_VNI_RANGE "[prefix-routes-only]", |
b7cfce93 | 1701 | NO_STR |
e8d26197 | 1702 | "VNI corresponding to tenant VRF\n" |
cf299714 MK |
1703 | "VNI-ID\n" |
1704 | "prefix-routes-only\n") | |
b7cfce93 MK |
1705 | { |
1706 | int ret = 0; | |
cf299714 | 1707 | int filter = 0; |
b7cfce93 MK |
1708 | char err[ERR_STR_SZ]; |
1709 | vni_t vni = strtoul(argv[2]->arg, NULL, 10); | |
1710 | ||
1711 | ZEBRA_DECLVAR_CONTEXT(vrf, zvrf); | |
1712 | ||
1713 | assert(vrf); | |
1714 | assert(zvrf); | |
1715 | ||
cf299714 MK |
1716 | if (argc == 4) |
1717 | filter = 1; | |
1718 | ||
1719 | ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, | |
1720 | ERR_STR_SZ, filter, 0); | |
b7cfce93 MK |
1721 | if (ret != 0) { |
1722 | vty_out(vty, "%s\n", err); | |
1723 | return CMD_WARNING; | |
1724 | } | |
1725 | ||
22bd3e94 | 1726 | /* If no other FRR config for this VRF, mark accordingly. */ |
1727 | if (!zebra_vrf_has_config(zvrf)) | |
1728 | vrf_reset_user_cfged(vrf); | |
1729 | ||
b7cfce93 MK |
1730 | return CMD_SUCCESS; |
1731 | } | |
1732 | ||
1733 | /* show vrf */ | |
1734 | DEFUN (show_vrf_vni, | |
1735 | show_vrf_vni_cmd, | |
35be5542 | 1736 | "show vrf vni [json]", |
b7cfce93 MK |
1737 | SHOW_STR |
1738 | "VRF\n" | |
35be5542 MK |
1739 | "VNI\n" |
1740 | JSON_STR) | |
b7cfce93 MK |
1741 | { |
1742 | struct vrf *vrf; | |
1743 | struct zebra_vrf *zvrf; | |
35be5542 MK |
1744 | json_object *json = NULL; |
1745 | json_object *json_vrfs = NULL; | |
9f049418 | 1746 | bool uj = use_json(argc, argv); |
35be5542 MK |
1747 | |
1748 | if (uj) { | |
1749 | json = json_object_new_object(); | |
1750 | json_vrfs = json_object_new_array(); | |
1751 | } | |
b7cfce93 | 1752 | |
4cce389e | 1753 | if (!uj) |
996c9314 LB |
1754 | vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", "VRF", |
1755 | "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac"); | |
4cce389e | 1756 | |
996c9314 | 1757 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
b7cfce93 MK |
1758 | zvrf = vrf->info; |
1759 | if (!zvrf) | |
1760 | continue; | |
1761 | ||
4cce389e | 1762 | zebra_vxlan_print_vrf_vni(vty, zvrf, json_vrfs); |
35be5542 MK |
1763 | } |
1764 | ||
1765 | if (uj) { | |
1766 | json_object_object_add(json, "vrfs", json_vrfs); | |
1767 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
1768 | json, JSON_C_TO_STRING_PRETTY)); | |
1769 | json_object_free(json); | |
b7cfce93 MK |
1770 | } |
1771 | ||
1772 | return CMD_SUCCESS; | |
1773 | } | |
1774 | ||
4cce389e MK |
1775 | DEFUN (show_evpn_global, |
1776 | show_evpn_global_cmd, | |
1777 | "show evpn [json]", | |
1778 | SHOW_STR | |
1779 | "EVPN\n" | |
1780 | JSON_STR) | |
1781 | { | |
9f049418 | 1782 | bool uj = use_json(argc, argv); |
4cce389e MK |
1783 | |
1784 | zebra_vxlan_print_evpn(vty, uj); | |
1785 | return CMD_SUCCESS; | |
1786 | } | |
1787 | ||
cec2e17d | 1788 | DEFUN (show_evpn_vni, |
1789 | show_evpn_vni_cmd, | |
cd233079 | 1790 | "show evpn vni [json]", |
cec2e17d | 1791 | SHOW_STR |
1792 | "EVPN\n" | |
09af6961 | 1793 | "VxLAN Network Identifier\n" |
bd592158 | 1794 | JSON_STR) |
cec2e17d | 1795 | { |
d62a17ae | 1796 | struct zebra_vrf *zvrf; |
9f049418 | 1797 | bool uj = use_json(argc, argv); |
cec2e17d | 1798 | |
d62a17ae | 1799 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
cd233079 | 1800 | zebra_vxlan_print_vnis(vty, zvrf, uj); |
d62a17ae | 1801 | return CMD_SUCCESS; |
cec2e17d | 1802 | } |
1803 | ||
09af6961 NS |
1804 | DEFUN (show_evpn_vni_detail, show_evpn_vni_detail_cmd, |
1805 | "show evpn vni detail [json]", | |
1806 | SHOW_STR | |
1807 | "EVPN\n" | |
1808 | "VxLAN Network Identifier\n" | |
1809 | "Detailed Information On Each VNI\n" | |
1810 | JSON_STR) | |
1811 | { | |
1812 | struct zebra_vrf *zvrf; | |
1813 | bool uj = use_json(argc, argv); | |
1814 | ||
1815 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
1816 | zebra_vxlan_print_vnis_detail(vty, zvrf, uj); | |
1817 | return CMD_SUCCESS; | |
1818 | } | |
1819 | ||
cec2e17d | 1820 | DEFUN (show_evpn_vni_vni, |
1821 | show_evpn_vni_vni_cmd, | |
cd233079 | 1822 | "show evpn vni " CMD_VNI_RANGE "[json]", |
cec2e17d | 1823 | SHOW_STR |
1824 | "EVPN\n" | |
1825 | "VxLAN Network Identifier\n" | |
cd233079 | 1826 | "VNI number\n" |
bd592158 | 1827 | JSON_STR) |
cec2e17d | 1828 | { |
d62a17ae | 1829 | struct zebra_vrf *zvrf; |
1830 | vni_t vni; | |
9f049418 | 1831 | bool uj = use_json(argc, argv); |
cec2e17d | 1832 | |
d62a17ae | 1833 | vni = strtoul(argv[3]->arg, NULL, 10); |
1834 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
cd233079 | 1835 | zebra_vxlan_print_vni(vty, zvrf, vni, uj); |
d62a17ae | 1836 | return CMD_SUCCESS; |
cec2e17d | 1837 | } |
1838 | ||
4cce389e MK |
1839 | DEFUN (show_evpn_rmac_vni_mac, |
1840 | show_evpn_rmac_vni_mac_cmd, | |
1841 | "show evpn rmac vni " CMD_VNI_RANGE " mac WORD [json]", | |
9aa741ea MK |
1842 | SHOW_STR |
1843 | "EVPN\n" | |
1844 | "RMAC\n" | |
4cce389e | 1845 | "L3 VNI\n" |
9aa741ea MK |
1846 | "VNI number\n" |
1847 | "MAC\n" | |
316f4ca4 MK |
1848 | "mac-address (e.g. 0a:0a:0a:0a:0a:0a)\n" |
1849 | JSON_STR) | |
9aa741ea MK |
1850 | { |
1851 | vni_t l3vni = 0; | |
1852 | struct ethaddr mac; | |
9f049418 | 1853 | bool uj = use_json(argc, argv); |
9aa741ea MK |
1854 | |
1855 | l3vni = strtoul(argv[4]->arg, NULL, 10); | |
1856 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1857 | vty_out(vty, "%% Malformed MAC address\n"); | |
1858 | return CMD_WARNING; | |
1859 | } | |
316f4ca4 | 1860 | zebra_vxlan_print_specific_rmac_l3vni(vty, l3vni, &mac, uj); |
9aa741ea MK |
1861 | return CMD_SUCCESS; |
1862 | } | |
1863 | ||
4cce389e MK |
1864 | DEFUN (show_evpn_rmac_vni, |
1865 | show_evpn_rmac_vni_cmd, | |
1866 | "show evpn rmac vni " CMD_VNI_RANGE "[json]", | |
b7cfce93 MK |
1867 | SHOW_STR |
1868 | "EVPN\n" | |
1869 | "RMAC\n" | |
4cce389e | 1870 | "L3 VNI\n" |
b7cfce93 MK |
1871 | "VNI number\n" |
1872 | JSON_STR) | |
1873 | { | |
1874 | vni_t l3vni = 0; | |
9f049418 | 1875 | bool uj = use_json(argc, argv); |
b7cfce93 MK |
1876 | |
1877 | l3vni = strtoul(argv[4]->arg, NULL, 10); | |
1878 | zebra_vxlan_print_rmacs_l3vni(vty, l3vni, uj); | |
1879 | ||
1880 | return CMD_SUCCESS; | |
1881 | } | |
1882 | ||
4cce389e MK |
1883 | DEFUN (show_evpn_rmac_vni_all, |
1884 | show_evpn_rmac_vni_all_cmd, | |
1885 | "show evpn rmac vni all [json]", | |
b7cfce93 MK |
1886 | SHOW_STR |
1887 | "EVPN\n" | |
1888 | "RMAC addresses\n" | |
4cce389e | 1889 | "L3 VNI\n" |
b7cfce93 MK |
1890 | "All VNIs\n" |
1891 | JSON_STR) | |
1892 | { | |
9f049418 | 1893 | bool uj = use_json(argc, argv); |
b7cfce93 MK |
1894 | |
1895 | zebra_vxlan_print_rmacs_all_l3vni(vty, uj); | |
1896 | ||
1897 | return CMD_SUCCESS; | |
1898 | } | |
1899 | ||
4cce389e MK |
1900 | DEFUN (show_evpn_nh_vni_ip, |
1901 | show_evpn_nh_vni_ip_cmd, | |
1902 | "show evpn next-hops vni " CMD_VNI_RANGE " ip WORD [json]", | |
9aa741ea MK |
1903 | SHOW_STR |
1904 | "EVPN\n" | |
1905 | "Remote Vteps\n" | |
4cce389e | 1906 | "L3 VNI\n" |
9aa741ea MK |
1907 | "VNI number\n" |
1908 | "Ip address\n" | |
c0e519d3 MK |
1909 | "Host address (ipv4 or ipv6)\n" |
1910 | JSON_STR) | |
9aa741ea MK |
1911 | { |
1912 | vni_t l3vni; | |
9aa741ea | 1913 | struct ipaddr ip; |
9f049418 | 1914 | bool uj = use_json(argc, argv); |
9aa741ea MK |
1915 | |
1916 | l3vni = strtoul(argv[4]->arg, NULL, 10); | |
1917 | if (str2ipaddr(argv[6]->arg, &ip) != 0) { | |
1918 | if (!uj) | |
1919 | vty_out(vty, "%% Malformed Neighbor address\n"); | |
1920 | return CMD_WARNING; | |
1921 | } | |
c0e519d3 | 1922 | zebra_vxlan_print_specific_nh_l3vni(vty, l3vni, &ip, uj); |
9aa741ea MK |
1923 | |
1924 | return CMD_SUCCESS; | |
1925 | } | |
1926 | ||
4cce389e MK |
1927 | DEFUN (show_evpn_nh_vni, |
1928 | show_evpn_nh_vni_cmd, | |
1929 | "show evpn next-hops vni " CMD_VNI_RANGE "[json]", | |
b7cfce93 MK |
1930 | SHOW_STR |
1931 | "EVPN\n" | |
1932 | "Remote Vteps\n" | |
4cce389e | 1933 | "L3 VNI\n" |
b7cfce93 MK |
1934 | "VNI number\n" |
1935 | JSON_STR) | |
1936 | { | |
1937 | vni_t l3vni; | |
9f049418 | 1938 | bool uj = use_json(argc, argv); |
b7cfce93 MK |
1939 | |
1940 | l3vni = strtoul(argv[4]->arg, NULL, 10); | |
1941 | zebra_vxlan_print_nh_l3vni(vty, l3vni, uj); | |
1942 | ||
1943 | return CMD_SUCCESS; | |
1944 | } | |
1945 | ||
4cce389e MK |
1946 | DEFUN (show_evpn_nh_vni_all, |
1947 | show_evpn_nh_vni_all_cmd, | |
1948 | "show evpn next-hops vni all [json]", | |
b7cfce93 MK |
1949 | SHOW_STR |
1950 | "EVPN\n" | |
1951 | "Remote VTEPs\n" | |
4cce389e | 1952 | "L3 VNI\n" |
b7cfce93 MK |
1953 | "All VNIs\n" |
1954 | JSON_STR) | |
1955 | { | |
9f049418 | 1956 | bool uj = use_json(argc, argv); |
b7cfce93 MK |
1957 | |
1958 | zebra_vxlan_print_nh_all_l3vni(vty, uj); | |
1959 | ||
1960 | return CMD_SUCCESS; | |
1961 | } | |
1962 | ||
cec2e17d | 1963 | DEFUN (show_evpn_mac_vni, |
1964 | show_evpn_mac_vni_cmd, | |
cd233079 | 1965 | "show evpn mac vni " CMD_VNI_RANGE "[json]", |
cec2e17d | 1966 | SHOW_STR |
1967 | "EVPN\n" | |
1968 | "MAC addresses\n" | |
1969 | "VxLAN Network Identifier\n" | |
cd233079 | 1970 | "VNI number\n" |
bd592158 | 1971 | JSON_STR) |
cec2e17d | 1972 | { |
d62a17ae | 1973 | struct zebra_vrf *zvrf; |
1974 | vni_t vni; | |
9f049418 | 1975 | bool uj = use_json(argc, argv); |
cec2e17d | 1976 | |
d62a17ae | 1977 | vni = strtoul(argv[4]->arg, NULL, 10); |
1978 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
cd233079 | 1979 | zebra_vxlan_print_macs_vni(vty, zvrf, vni, uj); |
d62a17ae | 1980 | return CMD_SUCCESS; |
cec2e17d | 1981 | } |
1982 | ||
1983 | DEFUN (show_evpn_mac_vni_all, | |
1984 | show_evpn_mac_vni_all_cmd, | |
cd233079 | 1985 | "show evpn mac vni all [json]", |
cec2e17d | 1986 | SHOW_STR |
1987 | "EVPN\n" | |
1988 | "MAC addresses\n" | |
1989 | "VxLAN Network Identifier\n" | |
cd233079 | 1990 | "All VNIs\n" |
bd592158 | 1991 | JSON_STR) |
cec2e17d | 1992 | { |
d62a17ae | 1993 | struct zebra_vrf *zvrf; |
9f049418 | 1994 | bool uj = use_json(argc, argv); |
cec2e17d | 1995 | |
d62a17ae | 1996 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
1374d4db | 1997 | zebra_vxlan_print_macs_all_vni(vty, zvrf, false, uj); |
d62a17ae | 1998 | return CMD_SUCCESS; |
cec2e17d | 1999 | } |
2000 | ||
cffe7580 NS |
2001 | DEFUN (show_evpn_mac_vni_all_detail, show_evpn_mac_vni_all_detail_cmd, |
2002 | "show evpn mac vni all detail [json]", | |
2003 | SHOW_STR | |
2004 | "EVPN\n" | |
2005 | "MAC addresses\n" | |
2006 | "VxLAN Network Identifier\n" | |
2007 | "All VNIs\n" | |
2008 | "Detailed Information On Each VNI MAC\n" | |
2009 | JSON_STR) | |
2010 | { | |
2011 | struct zebra_vrf *zvrf; | |
2012 | bool uj = use_json(argc, argv); | |
2013 | ||
2014 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2015 | zebra_vxlan_print_macs_all_vni_detail(vty, zvrf, false, uj); | |
2016 | return CMD_SUCCESS; | |
2017 | } | |
2018 | ||
cec2e17d | 2019 | DEFUN (show_evpn_mac_vni_all_vtep, |
2020 | show_evpn_mac_vni_all_vtep_cmd, | |
cd233079 | 2021 | "show evpn mac vni all vtep A.B.C.D [json]", |
cec2e17d | 2022 | SHOW_STR |
2023 | "EVPN\n" | |
2024 | "MAC addresses\n" | |
2025 | "VxLAN Network Identifier\n" | |
2026 | "All VNIs\n" | |
2027 | "Remote VTEP\n" | |
cd233079 | 2028 | "Remote VTEP IP address\n" |
bd592158 | 2029 | JSON_STR) |
cec2e17d | 2030 | { |
d62a17ae | 2031 | struct zebra_vrf *zvrf; |
2032 | struct in_addr vtep_ip; | |
9f049418 | 2033 | bool uj = use_json(argc, argv); |
cec2e17d | 2034 | |
d62a17ae | 2035 | if (!inet_aton(argv[6]->arg, &vtep_ip)) { |
cd233079 CS |
2036 | if (!uj) |
2037 | vty_out(vty, "%% Malformed VTEP IP address\n"); | |
d62a17ae | 2038 | return CMD_WARNING; |
2039 | } | |
2040 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
cd233079 | 2041 | zebra_vxlan_print_macs_all_vni_vtep(vty, zvrf, vtep_ip, uj); |
cec2e17d | 2042 | |
d62a17ae | 2043 | return CMD_SUCCESS; |
cec2e17d | 2044 | } |
2045 | ||
2046 | ||
2047 | DEFUN (show_evpn_mac_vni_mac, | |
2048 | show_evpn_mac_vni_mac_cmd, | |
24cdbd0d | 2049 | "show evpn mac vni " CMD_VNI_RANGE " mac WORD [json]", |
cec2e17d | 2050 | SHOW_STR |
2051 | "EVPN\n" | |
2052 | "MAC addresses\n" | |
2053 | "VxLAN Network Identifier\n" | |
2054 | "VNI number\n" | |
2055 | "MAC\n" | |
24cdbd0d DS |
2056 | "MAC address (e.g., 00:e0:ec:20:12:62)\n" |
2057 | JSON_STR) | |
2058 | ||
cec2e17d | 2059 | { |
d62a17ae | 2060 | struct zebra_vrf *zvrf; |
2061 | vni_t vni; | |
2062 | struct ethaddr mac; | |
24cdbd0d | 2063 | bool uj = use_json(argc, argv); |
cec2e17d | 2064 | |
d62a17ae | 2065 | vni = strtoul(argv[4]->arg, NULL, 10); |
2066 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
2067 | vty_out(vty, "%% Malformed MAC address"); | |
2068 | return CMD_WARNING; | |
2069 | } | |
2070 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
24cdbd0d | 2071 | zebra_vxlan_print_specific_mac_vni(vty, zvrf, vni, &mac, uj); |
d62a17ae | 2072 | return CMD_SUCCESS; |
cec2e17d | 2073 | } |
2074 | ||
2075 | DEFUN (show_evpn_mac_vni_vtep, | |
2076 | show_evpn_mac_vni_vtep_cmd, | |
cd233079 | 2077 | "show evpn mac vni " CMD_VNI_RANGE " vtep A.B.C.D" "[json]", |
cec2e17d | 2078 | SHOW_STR |
2079 | "EVPN\n" | |
2080 | "MAC addresses\n" | |
2081 | "VxLAN Network Identifier\n" | |
2082 | "VNI number\n" | |
2083 | "Remote VTEP\n" | |
cd233079 | 2084 | "Remote VTEP IP address\n" |
bd592158 | 2085 | JSON_STR) |
cec2e17d | 2086 | { |
d62a17ae | 2087 | struct zebra_vrf *zvrf; |
2088 | vni_t vni; | |
2089 | struct in_addr vtep_ip; | |
9f049418 | 2090 | bool uj = use_json(argc, argv); |
cec2e17d | 2091 | |
d62a17ae | 2092 | vni = strtoul(argv[4]->arg, NULL, 10); |
2093 | if (!inet_aton(argv[6]->arg, &vtep_ip)) { | |
cd233079 CS |
2094 | if (!uj) |
2095 | vty_out(vty, "%% Malformed VTEP IP address\n"); | |
d62a17ae | 2096 | return CMD_WARNING; |
2097 | } | |
cec2e17d | 2098 | |
d62a17ae | 2099 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
cd233079 | 2100 | zebra_vxlan_print_macs_vni_vtep(vty, zvrf, vni, vtep_ip, uj); |
d62a17ae | 2101 | return CMD_SUCCESS; |
cec2e17d | 2102 | } |
2103 | ||
1374d4db CS |
2104 | DEFPY (show_evpn_mac_vni_all_dad, |
2105 | show_evpn_mac_vni_all_dad_cmd, | |
2106 | "show evpn mac vni all duplicate [json]", | |
2107 | SHOW_STR | |
2108 | "EVPN\n" | |
2109 | "MAC addresses\n" | |
2110 | "VxLAN Network Identifier\n" | |
2111 | "All VNIs\n" | |
2112 | "Duplicate address list\n" | |
2113 | JSON_STR) | |
2114 | { | |
2115 | struct zebra_vrf *zvrf; | |
2116 | bool uj = use_json(argc, argv); | |
2117 | ||
2118 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2119 | zebra_vxlan_print_macs_all_vni(vty, zvrf, true, uj); | |
2120 | return CMD_SUCCESS; | |
2121 | } | |
2122 | ||
2123 | ||
2124 | DEFPY (show_evpn_mac_vni_dad, | |
2125 | show_evpn_mac_vni_dad_cmd, | |
2126 | "show evpn mac vni " CMD_VNI_RANGE " duplicate" "[json]", | |
2127 | SHOW_STR | |
2128 | "EVPN\n" | |
2129 | "MAC addresses\n" | |
2130 | "VxLAN Network Identifier\n" | |
2131 | "VNI number\n" | |
2132 | "Duplicate address list\n" | |
2133 | JSON_STR) | |
2134 | { | |
2135 | struct zebra_vrf *zvrf; | |
2136 | vni_t vni; | |
2137 | bool uj = use_json(argc, argv); | |
2138 | ||
2139 | vni = strtoul(argv[4]->arg, NULL, 10); | |
2140 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2141 | ||
2142 | zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj); | |
2143 | ||
2144 | return CMD_SUCCESS; | |
2145 | } | |
2146 | ||
2147 | DEFPY (show_evpn_neigh_vni_dad, | |
2148 | show_evpn_neigh_vni_dad_cmd, | |
2149 | "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate" "[json]", | |
2150 | SHOW_STR | |
2151 | "EVPN\n" | |
2152 | "ARP and ND cache\n" | |
2153 | "VxLAN Network Identifier\n" | |
2154 | "VNI number\n" | |
2155 | "Duplicate address list\n" | |
2156 | JSON_STR) | |
2157 | { | |
2158 | struct zebra_vrf *zvrf; | |
2159 | vni_t vni; | |
2160 | bool uj = use_json(argc, argv); | |
2161 | ||
2162 | vni = strtoul(argv[4]->arg, NULL, 10); | |
2163 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2164 | zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj); | |
2165 | return CMD_SUCCESS; | |
2166 | } | |
2167 | ||
2168 | DEFPY (show_evpn_neigh_vni_all_dad, | |
2169 | show_evpn_neigh_vni_all_dad_cmd, | |
2170 | "show evpn arp-cache vni all duplicate [json]", | |
2171 | SHOW_STR | |
2172 | "EVPN\n" | |
2173 | "ARP and ND cache\n" | |
2174 | "VxLAN Network Identifier\n" | |
2175 | "All VNIs\n" | |
2176 | "Duplicate address list\n" | |
2177 | JSON_STR) | |
2178 | { | |
2179 | struct zebra_vrf *zvrf; | |
2180 | bool uj = use_json(argc, argv); | |
2181 | ||
2182 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2183 | zebra_vxlan_print_neigh_all_vni(vty, zvrf, true, uj); | |
2184 | return CMD_SUCCESS; | |
2185 | } | |
2186 | ||
2187 | ||
cec2e17d | 2188 | DEFUN (show_evpn_neigh_vni, |
2189 | show_evpn_neigh_vni_cmd, | |
cd233079 | 2190 | "show evpn arp-cache vni " CMD_VNI_RANGE "[json]", |
cec2e17d | 2191 | SHOW_STR |
2192 | "EVPN\n" | |
2193 | "ARP and ND cache\n" | |
2194 | "VxLAN Network Identifier\n" | |
cd233079 | 2195 | "VNI number\n" |
bd592158 | 2196 | JSON_STR) |
cec2e17d | 2197 | { |
d62a17ae | 2198 | struct zebra_vrf *zvrf; |
2199 | vni_t vni; | |
9f049418 | 2200 | bool uj = use_json(argc, argv); |
cec2e17d | 2201 | |
d62a17ae | 2202 | vni = strtoul(argv[4]->arg, NULL, 10); |
2203 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
cd233079 | 2204 | zebra_vxlan_print_neigh_vni(vty, zvrf, vni, uj); |
d62a17ae | 2205 | return CMD_SUCCESS; |
cec2e17d | 2206 | } |
2207 | ||
2208 | DEFUN (show_evpn_neigh_vni_all, | |
2209 | show_evpn_neigh_vni_all_cmd, | |
cd233079 | 2210 | "show evpn arp-cache vni all [json]", |
cec2e17d | 2211 | SHOW_STR |
2212 | "EVPN\n" | |
2213 | "ARP and ND cache\n" | |
2214 | "VxLAN Network Identifier\n" | |
cd233079 | 2215 | "All VNIs\n" |
bd592158 | 2216 | JSON_STR) |
cec2e17d | 2217 | { |
d62a17ae | 2218 | struct zebra_vrf *zvrf; |
9f049418 | 2219 | bool uj = use_json(argc, argv); |
cec2e17d | 2220 | |
d62a17ae | 2221 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
1374d4db | 2222 | zebra_vxlan_print_neigh_all_vni(vty, zvrf, false, uj); |
d62a17ae | 2223 | return CMD_SUCCESS; |
cec2e17d | 2224 | } |
2225 | ||
e3fac919 NS |
2226 | DEFUN (show_evpn_neigh_vni_all_detail, show_evpn_neigh_vni_all_detail_cmd, |
2227 | "show evpn arp-cache vni all detail [json]", | |
2228 | SHOW_STR | |
2229 | "EVPN\n" | |
2230 | "ARP and ND cache\n" | |
2231 | "VxLAN Network Identifier\n" | |
2232 | "All VNIs\n" | |
2233 | "Neighbor details for all vnis in detail\n" JSON_STR) | |
2234 | { | |
2235 | struct zebra_vrf *zvrf; | |
2236 | bool uj = use_json(argc, argv); | |
2237 | ||
2238 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2239 | zebra_vxlan_print_neigh_all_vni_detail(vty, zvrf, false, uj); | |
2240 | return CMD_SUCCESS; | |
2241 | } | |
2242 | ||
cec2e17d | 2243 | DEFUN (show_evpn_neigh_vni_neigh, |
2244 | show_evpn_neigh_vni_neigh_cmd, | |
cd233079 | 2245 | "show evpn arp-cache vni " CMD_VNI_RANGE " ip WORD [json]", |
cec2e17d | 2246 | SHOW_STR |
2247 | "EVPN\n" | |
2248 | "ARP and ND cache\n" | |
2249 | "VxLAN Network Identifier\n" | |
2250 | "VNI number\n" | |
2251 | "Neighbor\n" | |
cd233079 | 2252 | "Neighbor address (IPv4 or IPv6 address)\n" |
bd592158 | 2253 | JSON_STR) |
cec2e17d | 2254 | { |
d62a17ae | 2255 | struct zebra_vrf *zvrf; |
2256 | vni_t vni; | |
2257 | struct ipaddr ip; | |
9f049418 | 2258 | bool uj = use_json(argc, argv); |
cec2e17d | 2259 | |
d62a17ae | 2260 | vni = strtoul(argv[4]->arg, NULL, 10); |
2261 | if (str2ipaddr(argv[6]->arg, &ip) != 0) { | |
cd233079 CS |
2262 | if (!uj) |
2263 | vty_out(vty, "%% Malformed Neighbor address\n"); | |
d62a17ae | 2264 | return CMD_WARNING; |
2265 | } | |
2266 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
cd233079 | 2267 | zebra_vxlan_print_specific_neigh_vni(vty, zvrf, vni, &ip, uj); |
d62a17ae | 2268 | return CMD_SUCCESS; |
cec2e17d | 2269 | } |
2270 | ||
2271 | DEFUN (show_evpn_neigh_vni_vtep, | |
2272 | show_evpn_neigh_vni_vtep_cmd, | |
cd233079 | 2273 | "show evpn arp-cache vni " CMD_VNI_RANGE " vtep A.B.C.D [json]", |
cec2e17d | 2274 | SHOW_STR |
2275 | "EVPN\n" | |
2276 | "ARP and ND cache\n" | |
2277 | "VxLAN Network Identifier\n" | |
2278 | "VNI number\n" | |
2279 | "Remote VTEP\n" | |
cd233079 | 2280 | "Remote VTEP IP address\n" |
bd592158 | 2281 | JSON_STR) |
cec2e17d | 2282 | { |
d62a17ae | 2283 | struct zebra_vrf *zvrf; |
2284 | vni_t vni; | |
2285 | struct in_addr vtep_ip; | |
9f049418 | 2286 | bool uj = use_json(argc, argv); |
cec2e17d | 2287 | |
d62a17ae | 2288 | vni = strtoul(argv[4]->arg, NULL, 10); |
2289 | if (!inet_aton(argv[6]->arg, &vtep_ip)) { | |
cd233079 CS |
2290 | if (!uj) |
2291 | vty_out(vty, "%% Malformed VTEP IP address\n"); | |
d62a17ae | 2292 | return CMD_WARNING; |
2293 | } | |
cec2e17d | 2294 | |
d62a17ae | 2295 | zvrf = vrf_info_lookup(VRF_DEFAULT); |
cd233079 | 2296 | zebra_vxlan_print_neigh_vni_vtep(vty, zvrf, vni, vtep_ip, uj); |
d62a17ae | 2297 | return CMD_SUCCESS; |
cec2e17d | 2298 | } |
2299 | ||
586f4ccf PG |
2300 | /* policy routing contexts */ |
2301 | DEFUN (show_pbr_ipset, | |
2302 | show_pbr_ipset_cmd, | |
2303 | "show pbr ipset [WORD]", | |
2304 | SHOW_STR | |
2305 | "Policy-Based Routing\n" | |
2306 | "IPset Context information\n" | |
2307 | "IPset Name information\n") | |
2308 | { | |
2309 | int idx = 0; | |
2310 | int found = 0; | |
2311 | found = argv_find(argv, argc, "WORD", &idx); | |
2312 | if (!found) | |
2313 | zebra_pbr_show_ipset_list(vty, NULL); | |
2314 | else | |
2315 | zebra_pbr_show_ipset_list(vty, argv[idx]->arg); | |
2316 | return CMD_SUCCESS; | |
2317 | } | |
2318 | ||
2319 | /* policy routing contexts */ | |
2320 | DEFUN (show_pbr_iptable, | |
2321 | show_pbr_iptable_cmd, | |
7929821a | 2322 | "show pbr iptable [WORD]", |
586f4ccf PG |
2323 | SHOW_STR |
2324 | "Policy-Based Routing\n" | |
7929821a PG |
2325 | "IPtable Context information\n" |
2326 | "IPtable Name information\n") | |
586f4ccf | 2327 | { |
7929821a PG |
2328 | int idx = 0; |
2329 | int found = 0; | |
2330 | ||
2331 | found = argv_find(argv, argc, "WORD", &idx); | |
2332 | if (!found) | |
2333 | zebra_pbr_show_iptable(vty, NULL); | |
2334 | else | |
2335 | zebra_pbr_show_iptable(vty, argv[idx]->arg); | |
586f4ccf PG |
2336 | return CMD_SUCCESS; |
2337 | } | |
2338 | ||
09de9258 CS |
2339 | DEFPY (clear_evpn_dup_addr, |
2340 | clear_evpn_dup_addr_cmd, | |
2341 | "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni_val [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>", | |
2342 | CLEAR_STR | |
2343 | "EVPN\n" | |
2344 | "Duplicate address \n" | |
2345 | "VxLAN Network Identifier\n" | |
2346 | "VNI number\n" | |
2347 | "All VNIs\n" | |
2348 | "MAC\n" | |
2349 | "MAC address (e.g., 00:e0:ec:20:12:62)\n" | |
2350 | "IP\n" | |
2351 | "IPv4 address\n" | |
2352 | "IPv6 address\n") | |
2353 | { | |
2354 | struct zebra_vrf *zvrf; | |
2355 | vni_t vni = 0; | |
2356 | struct ipaddr host_ip = {.ipa_type = IPADDR_NONE }; | |
2357 | struct ethaddr mac_addr; | |
1883de66 | 2358 | int ret = CMD_SUCCESS; |
09de9258 CS |
2359 | |
2360 | zvrf = vrf_info_lookup(VRF_DEFAULT); | |
2361 | if (vni_val) { | |
2362 | vni = strtoul(vni_val, NULL, 10); | |
2363 | ||
2364 | if (mac_val) { | |
2365 | prefix_str2mac(mac_val, &mac_addr); | |
1883de66 CS |
2366 | ret = zebra_vxlan_clear_dup_detect_vni_mac(vty, zvrf, |
2367 | vni, | |
2368 | &mac_addr); | |
2369 | } else if (ip) { | |
09de9258 CS |
2370 | if (sockunion_family(ip) == AF_INET) { |
2371 | host_ip.ipa_type = IPADDR_V4; | |
2372 | host_ip.ipaddr_v4.s_addr = sockunion2ip(ip); | |
2373 | } else { | |
2374 | host_ip.ipa_type = IPADDR_V6; | |
2375 | memcpy(&host_ip.ipaddr_v6, &ip->sin6.sin6_addr, | |
2376 | sizeof(struct in6_addr)); | |
2377 | } | |
1883de66 CS |
2378 | ret = zebra_vxlan_clear_dup_detect_vni_ip(vty, zvrf, |
2379 | vni, | |
2380 | &host_ip); | |
09de9258 | 2381 | } else |
1883de66 | 2382 | ret = zebra_vxlan_clear_dup_detect_vni(vty, zvrf, vni); |
09de9258 CS |
2383 | |
2384 | } else { | |
1883de66 | 2385 | ret = zebra_vxlan_clear_dup_detect_vni_all(vty, zvrf); |
09de9258 CS |
2386 | } |
2387 | ||
1883de66 | 2388 | return ret; |
09de9258 CS |
2389 | } |
2390 | ||
718e3744 | 2391 | /* Static ip route configuration write function. */ |
d62a17ae | 2392 | static int zebra_ip_config(struct vty *vty) |
718e3744 | 2393 | { |
d62a17ae | 2394 | int write = 0; |
718e3744 | 2395 | |
d62a17ae | 2396 | write += zebra_import_table_config(vty); |
37728041 | 2397 | |
d62a17ae | 2398 | return write; |
718e3744 | 2399 | } |
2400 | ||
7a4bb9c5 DS |
2401 | DEFUN (ip_zebra_import_table_distance, |
2402 | ip_zebra_import_table_distance_cmd, | |
12dcf78e | 2403 | "ip import-table (1-252) [distance (1-255)] [route-map WORD]", |
8902474b DS |
2404 | IP_STR |
2405 | "import routes from non-main kernel table\n" | |
2406 | "kernel routing table id\n" | |
2407 | "Distance for imported routes\n" | |
2408 | "Default distance value\n" | |
2409 | "route-map for filtering\n" | |
2410 | "route-map name\n") | |
2411 | { | |
d7c0a89a | 2412 | uint32_t table_id = 0; |
8902474b | 2413 | |
d62a17ae | 2414 | table_id = strtoul(argv[2]->arg, NULL, 10); |
2415 | int distance = ZEBRA_TABLE_DISTANCE_DEFAULT; | |
2416 | char *rmap = | |
2417 | strmatch(argv[argc - 2]->text, "route-map") | |
2418 | ? XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[argc - 1]->arg) | |
2419 | : NULL; | |
2420 | int ret; | |
d722f26e | 2421 | |
d62a17ae | 2422 | if (argc == 7 || (argc == 5 && !rmap)) |
2423 | distance = strtoul(argv[4]->arg, NULL, 10); | |
8902474b | 2424 | |
d62a17ae | 2425 | if (!is_zebra_valid_kernel_table(table_id)) { |
2426 | vty_out(vty, | |
2427 | "Invalid routing table ID, %d. Must be in range 1-252\n", | |
2428 | table_id); | |
0af35d90 RW |
2429 | if (rmap) |
2430 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap); | |
d62a17ae | 2431 | return CMD_WARNING; |
2432 | } | |
8902474b | 2433 | |
d62a17ae | 2434 | if (is_zebra_main_routing_table(table_id)) { |
2435 | vty_out(vty, | |
2436 | "Invalid routing table ID, %d. Must be non-default table\n", | |
2437 | table_id); | |
0af35d90 RW |
2438 | if (rmap) |
2439 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap); | |
d62a17ae | 2440 | return CMD_WARNING; |
2441 | } | |
8902474b | 2442 | |
d62a17ae | 2443 | ret = zebra_import_table(AFI_IP, table_id, distance, rmap, 1); |
2444 | if (rmap) | |
2445 | XFREE(MTYPE_ROUTE_MAP_NAME, rmap); | |
d722f26e | 2446 | |
d62a17ae | 2447 | return ret; |
8902474b DS |
2448 | } |
2449 | ||
62d52ded DS |
2450 | DEFUN_HIDDEN (zebra_packet_process, |
2451 | zebra_packet_process_cmd, | |
2452 | "zebra zapi-packets (1-10000)", | |
2453 | ZEBRA_STR | |
2454 | "Zapi Protocol\n" | |
2455 | "Number of packets to process before relinquishing thread\n") | |
2456 | { | |
2457 | uint32_t packets = strtoul(argv[2]->arg, NULL, 10); | |
2458 | ||
ccd51bd2 QY |
2459 | atomic_store_explicit(&zebrad.packets_to_process, packets, |
2460 | memory_order_relaxed); | |
62d52ded DS |
2461 | |
2462 | return CMD_SUCCESS; | |
2463 | } | |
2464 | ||
2465 | DEFUN_HIDDEN (no_zebra_packet_process, | |
2466 | no_zebra_packet_process_cmd, | |
2467 | "no zebra zapi-packets [(1-10000)]", | |
2468 | NO_STR | |
2469 | ZEBRA_STR | |
2470 | "Zapi Protocol\n" | |
2471 | "Number of packets to process before relinquishing thread\n") | |
2472 | { | |
ccd51bd2 QY |
2473 | atomic_store_explicit(&zebrad.packets_to_process, |
2474 | ZEBRA_ZAPI_PACKETS_TO_PROCESS, | |
2475 | memory_order_relaxed); | |
62d52ded DS |
2476 | |
2477 | return CMD_SUCCESS; | |
2478 | } | |
2479 | ||
3a30f50f DS |
2480 | DEFUN_HIDDEN (zebra_workqueue_timer, |
2481 | zebra_workqueue_timer_cmd, | |
2482 | "zebra work-queue (0-10000)", | |
2483 | ZEBRA_STR | |
2484 | "Work Queue\n" | |
2485 | "Time in milliseconds\n") | |
2486 | { | |
996c9314 | 2487 | uint32_t timer = strtoul(argv[2]->arg, NULL, 10); |
489a9614 | 2488 | zrouter.ribq->spec.hold = timer; |
3a30f50f | 2489 | |
996c9314 | 2490 | return CMD_SUCCESS; |
3a30f50f DS |
2491 | } |
2492 | ||
2493 | DEFUN_HIDDEN (no_zebra_workqueue_timer, | |
2494 | no_zebra_workqueue_timer_cmd, | |
2495 | "no zebra work-queue [(0-10000)]", | |
2496 | NO_STR | |
2497 | ZEBRA_STR | |
2498 | "Work Queue\n" | |
2499 | "Time in milliseconds\n") | |
2500 | { | |
489a9614 | 2501 | zrouter.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; |
3a30f50f | 2502 | |
996c9314 | 2503 | return CMD_SUCCESS; |
3a30f50f DS |
2504 | } |
2505 | ||
7a4bb9c5 DS |
2506 | DEFUN (no_ip_zebra_import_table, |
2507 | no_ip_zebra_import_table_cmd, | |
b62ecea5 | 2508 | "no ip import-table (1-252) [distance (1-255)] [route-map NAME]", |
7a4bb9c5 DS |
2509 | NO_STR |
2510 | IP_STR | |
2511 | "import routes from non-main kernel table\n" | |
3a2d747c QY |
2512 | "kernel routing table id\n" |
2513 | "Distance for imported routes\n" | |
2514 | "Default distance value\n" | |
2515 | "route-map for filtering\n" | |
2516 | "route-map name\n") | |
7a4bb9c5 | 2517 | { |
d7c0a89a | 2518 | uint32_t table_id = 0; |
d62a17ae | 2519 | table_id = strtoul(argv[3]->arg, NULL, 10); |
7a4bb9c5 | 2520 | |
d62a17ae | 2521 | if (!is_zebra_valid_kernel_table(table_id)) { |
2522 | vty_out(vty, | |
2523 | "Invalid routing table ID. Must be in range 1-252\n"); | |
2524 | return CMD_WARNING; | |
2525 | } | |
7a4bb9c5 | 2526 | |
d62a17ae | 2527 | if (is_zebra_main_routing_table(table_id)) { |
2528 | vty_out(vty, | |
2529 | "Invalid routing table ID, %d. Must be non-default table\n", | |
2530 | table_id); | |
2531 | return CMD_WARNING; | |
2532 | } | |
7a4bb9c5 | 2533 | |
d62a17ae | 2534 | if (!is_zebra_import_table_enabled(AFI_IP, table_id)) |
2535 | return CMD_SUCCESS; | |
7a4bb9c5 | 2536 | |
d62a17ae | 2537 | return (zebra_import_table(AFI_IP, table_id, 0, NULL, 0)); |
7a4bb9c5 DS |
2538 | } |
2539 | ||
d62a17ae | 2540 | static int config_write_protocol(struct vty *vty) |
6baf7bb8 | 2541 | { |
d62a17ae | 2542 | if (allow_delete) |
2543 | vty_out(vty, "allow-external-route-update\n"); | |
6baf7bb8 | 2544 | |
d62a17ae | 2545 | if (zebra_rnh_ip_default_route) |
2546 | vty_out(vty, "ip nht resolve-via-default\n"); | |
6baf7bb8 | 2547 | |
d62a17ae | 2548 | if (zebra_rnh_ipv6_default_route) |
2549 | vty_out(vty, "ipv6 nht resolve-via-default\n"); | |
6baf7bb8 | 2550 | |
489a9614 DS |
2551 | if (zrouter.ribq->spec.hold != ZEBRA_RIB_PROCESS_HOLD_TIME) |
2552 | vty_out(vty, "zebra work-queue %u\n", zrouter.ribq->spec.hold); | |
3a30f50f | 2553 | |
62d52ded | 2554 | if (zebrad.packets_to_process != ZEBRA_ZAPI_PACKETS_TO_PROCESS) |
996c9314 LB |
2555 | vty_out(vty, "zebra zapi-packets %u\n", |
2556 | zebrad.packets_to_process); | |
62d52ded | 2557 | |
d62a17ae | 2558 | enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get(); |
4623d897 | 2559 | |
d62a17ae | 2560 | if (ipv4_multicast_mode != MCAST_NO_CONFIG) |
2561 | vty_out(vty, "ip multicast rpf-lookup-mode %s\n", | |
2562 | ipv4_multicast_mode == MCAST_URIB_ONLY | |
2563 | ? "urib-only" | |
2564 | : ipv4_multicast_mode == MCAST_MRIB_ONLY | |
2565 | ? "mrib-only" | |
2566 | : ipv4_multicast_mode | |
2567 | == MCAST_MIX_MRIB_FIRST | |
2568 | ? "mrib-then-urib" | |
2569 | : ipv4_multicast_mode | |
2570 | == MCAST_MIX_DISTANCE | |
2571 | ? "lower-distance" | |
2572 | : "longer-prefix"); | |
d62a17ae | 2573 | return 1; |
6baf7bb8 DS |
2574 | } |
2575 | ||
c0d136ae DS |
2576 | #ifdef HAVE_NETLINK |
2577 | /* Display default rtm_table for all clients. */ | |
2578 | DEFUN (show_table, | |
2579 | show_table_cmd, | |
2580 | "show table", | |
2581 | SHOW_STR | |
2582 | "default routing table to use for all clients\n") | |
2583 | { | |
b3d43ff4 | 2584 | vty_out(vty, "table %d\n", zrouter.rtm_table_default); |
c0d136ae DS |
2585 | return CMD_SUCCESS; |
2586 | } | |
2587 | ||
2588 | DEFUN (config_table, | |
2589 | config_table_cmd, | |
2590 | "table TABLENO", | |
2591 | "Configure target kernel routing table\n" | |
2592 | "TABLE integer\n") | |
2593 | { | |
b3d43ff4 | 2594 | zrouter.rtm_table_default = strtol(argv[1]->arg, (char **)0, 10); |
c0d136ae DS |
2595 | return CMD_SUCCESS; |
2596 | } | |
2597 | ||
2598 | DEFUN (no_config_table, | |
2599 | no_config_table_cmd, | |
2600 | "no table [TABLENO]", | |
2601 | NO_STR | |
2602 | "Configure target kernel routing table\n" | |
2603 | "TABLE integer\n") | |
2604 | { | |
b3d43ff4 | 2605 | zrouter.rtm_table_default = 0; |
c0d136ae DS |
2606 | return CMD_SUCCESS; |
2607 | } | |
2608 | #endif | |
2609 | ||
2610 | DEFUN (show_zebra, | |
2611 | show_zebra_cmd, | |
2612 | "show zebra", | |
2613 | SHOW_STR | |
2614 | ZEBRA_STR) | |
2615 | { | |
2616 | struct vrf *vrf; | |
2617 | ||
2618 | vty_out(vty, | |
2619 | " Route Route Neighbor LSP LSP\n"); | |
2620 | vty_out(vty, | |
2621 | "VRF Installs Removals Updates Installs Removals\n"); | |
2622 | ||
996c9314 | 2623 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
c0d136ae DS |
2624 | struct zebra_vrf *zvrf = vrf->info; |
2625 | ||
2626 | vty_out(vty, "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64 | |
2627 | " %10" PRIu64 " %10" PRIu64 "\n", | |
2628 | vrf->name, zvrf->installs, zvrf->removals, | |
2629 | zvrf->neigh_updates, zvrf->lsp_installs, | |
2630 | zvrf->lsp_removals); | |
2631 | } | |
2632 | ||
2633 | return CMD_SUCCESS; | |
2634 | } | |
2635 | ||
2636 | DEFUN (ip_forwarding, | |
2637 | ip_forwarding_cmd, | |
2638 | "ip forwarding", | |
2639 | IP_STR | |
2640 | "Turn on IP forwarding\n") | |
2641 | { | |
2642 | int ret; | |
2643 | ||
2644 | ret = ipforward(); | |
2645 | if (ret == 0) | |
2646 | ret = ipforward_on(); | |
2647 | ||
2648 | if (ret == 0) { | |
2649 | vty_out(vty, "Can't turn on IP forwarding\n"); | |
2650 | return CMD_WARNING_CONFIG_FAILED; | |
2651 | } | |
2652 | ||
2653 | return CMD_SUCCESS; | |
2654 | } | |
2655 | ||
2656 | DEFUN (no_ip_forwarding, | |
2657 | no_ip_forwarding_cmd, | |
2658 | "no ip forwarding", | |
2659 | NO_STR | |
2660 | IP_STR | |
2661 | "Turn off IP forwarding\n") | |
2662 | { | |
2663 | int ret; | |
2664 | ||
2665 | ret = ipforward(); | |
2666 | if (ret != 0) | |
2667 | ret = ipforward_off(); | |
2668 | ||
2669 | if (ret != 0) { | |
2670 | vty_out(vty, "Can't turn off IP forwarding\n"); | |
2671 | return CMD_WARNING_CONFIG_FAILED; | |
2672 | } | |
2673 | ||
2674 | return CMD_SUCCESS; | |
2675 | } | |
2676 | ||
2677 | /* Only display ip forwarding is enabled or not. */ | |
2678 | DEFUN (show_ip_forwarding, | |
2679 | show_ip_forwarding_cmd, | |
2680 | "show ip forwarding", | |
2681 | SHOW_STR | |
2682 | IP_STR | |
2683 | "IP forwarding status\n") | |
2684 | { | |
2685 | int ret; | |
2686 | ||
2687 | ret = ipforward(); | |
2688 | ||
2689 | if (ret == 0) | |
2690 | vty_out(vty, "IP forwarding is off\n"); | |
2691 | else | |
2692 | vty_out(vty, "IP forwarding is on\n"); | |
2693 | return CMD_SUCCESS; | |
2694 | } | |
2695 | ||
2696 | /* Only display ipv6 forwarding is enabled or not. */ | |
2697 | DEFUN (show_ipv6_forwarding, | |
2698 | show_ipv6_forwarding_cmd, | |
2699 | "show ipv6 forwarding", | |
2700 | SHOW_STR | |
2701 | "IPv6 information\n" | |
2702 | "Forwarding status\n") | |
2703 | { | |
2704 | int ret; | |
2705 | ||
2706 | ret = ipforward_ipv6(); | |
2707 | ||
2708 | switch (ret) { | |
2709 | case -1: | |
2710 | vty_out(vty, "ipv6 forwarding is unknown\n"); | |
2711 | break; | |
2712 | case 0: | |
2713 | vty_out(vty, "ipv6 forwarding is %s\n", "off"); | |
2714 | break; | |
2715 | case 1: | |
2716 | vty_out(vty, "ipv6 forwarding is %s\n", "on"); | |
2717 | break; | |
2718 | default: | |
2719 | vty_out(vty, "ipv6 forwarding is %s\n", "off"); | |
2720 | break; | |
2721 | } | |
2722 | return CMD_SUCCESS; | |
2723 | } | |
2724 | ||
2725 | DEFUN (ipv6_forwarding, | |
2726 | ipv6_forwarding_cmd, | |
2727 | "ipv6 forwarding", | |
2728 | IPV6_STR | |
2729 | "Turn on IPv6 forwarding\n") | |
2730 | { | |
2731 | int ret; | |
2732 | ||
2733 | ret = ipforward_ipv6(); | |
2734 | if (ret == 0) | |
2735 | ret = ipforward_ipv6_on(); | |
2736 | ||
2737 | if (ret == 0) { | |
2738 | vty_out(vty, "Can't turn on IPv6 forwarding\n"); | |
2739 | return CMD_WARNING_CONFIG_FAILED; | |
2740 | } | |
2741 | ||
2742 | return CMD_SUCCESS; | |
2743 | } | |
2744 | ||
2745 | DEFUN (no_ipv6_forwarding, | |
2746 | no_ipv6_forwarding_cmd, | |
2747 | "no ipv6 forwarding", | |
2748 | NO_STR | |
2749 | IPV6_STR | |
2750 | "Turn off IPv6 forwarding\n") | |
2751 | { | |
2752 | int ret; | |
2753 | ||
2754 | ret = ipforward_ipv6(); | |
2755 | if (ret != 0) | |
2756 | ret = ipforward_ipv6_off(); | |
2757 | ||
2758 | if (ret != 0) { | |
2759 | vty_out(vty, "Can't turn off IPv6 forwarding\n"); | |
2760 | return CMD_WARNING_CONFIG_FAILED; | |
2761 | } | |
2762 | ||
2763 | return CMD_SUCCESS; | |
2764 | } | |
2765 | ||
1d11b21f MS |
2766 | /* Display dataplane info */ |
2767 | DEFUN (show_dataplane, | |
2768 | show_dataplane_cmd, | |
2769 | "show zebra dplane [detailed]", | |
2770 | SHOW_STR | |
2771 | ZEBRA_STR | |
2772 | "Zebra dataplane information\n" | |
2773 | "Detailed output\n") | |
2774 | { | |
2775 | int idx = 0; | |
2776 | bool detailed = false; | |
2777 | ||
2778 | if (argv_find(argv, argc, "detailed", &idx)) | |
2779 | detailed = true; | |
2780 | ||
2781 | return dplane_show_helper(vty, detailed); | |
2782 | } | |
2783 | ||
2784 | /* Display dataplane providers info */ | |
2785 | DEFUN (show_dataplane_providers, | |
2786 | show_dataplane_providers_cmd, | |
2787 | "show zebra dplane providers [detailed]", | |
2788 | SHOW_STR | |
2789 | ZEBRA_STR | |
2790 | "Zebra dataplane information\n" | |
2791 | "Zebra dataplane provider information\n" | |
2792 | "Detailed output\n") | |
2793 | { | |
2794 | int idx = 0; | |
2795 | bool detailed = false; | |
2796 | ||
2797 | if (argv_find(argv, argc, "detailed", &idx)) | |
2798 | detailed = true; | |
2799 | ||
2800 | return dplane_show_provs_helper(vty, detailed); | |
2801 | } | |
2802 | ||
91f16812 MS |
2803 | /* Configure dataplane incoming queue limit */ |
2804 | DEFUN (zebra_dplane_queue_limit, | |
2805 | zebra_dplane_queue_limit_cmd, | |
2806 | "zebra dplane limit (0-10000)", | |
2807 | ZEBRA_STR | |
2808 | "Zebra dataplane\n" | |
2809 | "Limit incoming queued updates\n" | |
2810 | "Number of queued updates\n") | |
2811 | { | |
2812 | uint32_t limit = 0; | |
2813 | ||
2814 | limit = strtoul(argv[3]->arg, NULL, 10); | |
2815 | ||
2816 | dplane_set_in_queue_limit(limit, true); | |
2817 | ||
2818 | return CMD_SUCCESS; | |
2819 | } | |
2820 | ||
2821 | /* Reset dataplane queue limit to default value */ | |
2822 | DEFUN (no_zebra_dplane_queue_limit, | |
2823 | no_zebra_dplane_queue_limit_cmd, | |
2824 | "no zebra dplane limit [(0-10000)]", | |
2825 | NO_STR | |
2826 | ZEBRA_STR | |
2827 | "Zebra dataplane\n" | |
2828 | "Limit incoming queued updates\n" | |
2829 | "Number of queued updates\n") | |
2830 | { | |
2831 | dplane_set_in_queue_limit(0, false); | |
2832 | ||
2833 | return CMD_SUCCESS; | |
2834 | } | |
1d11b21f | 2835 | |
ac5aa23f DS |
2836 | DEFUN (zebra_show_routing_tables_summary, |
2837 | zebra_show_routing_tables_summary_cmd, | |
2838 | "show zebra router table summary", | |
2839 | SHOW_STR | |
2840 | ZEBRA_STR | |
2841 | "The Zebra Router Information\n" | |
2842 | "Table Information about this Zebra Router\n" | |
2843 | "Summary Information\n") | |
2844 | { | |
2845 | zebra_router_show_table_summary(vty); | |
2846 | ||
2847 | return CMD_SUCCESS; | |
2848 | } | |
2849 | ||
c0d136ae DS |
2850 | /* Table configuration write function. */ |
2851 | static int config_write_table(struct vty *vty) | |
2852 | { | |
b3d43ff4 DS |
2853 | if (zrouter.rtm_table_default) |
2854 | vty_out(vty, "table %d\n", zrouter.rtm_table_default); | |
c0d136ae DS |
2855 | return 0; |
2856 | } | |
2857 | ||
2858 | /* IPForwarding configuration write function. */ | |
2859 | static int config_write_forwarding(struct vty *vty) | |
2860 | { | |
2861 | /* FIXME: Find better place for that. */ | |
2862 | router_id_write(vty); | |
2863 | ||
2864 | if (!ipforward()) | |
2865 | vty_out(vty, "no ip forwarding\n"); | |
2866 | if (!ipforward_ipv6()) | |
2867 | vty_out(vty, "no ipv6 forwarding\n"); | |
2868 | vty_out(vty, "!\n"); | |
2869 | return 0; | |
2870 | } | |
2871 | ||
718e3744 | 2872 | /* IP node for static routes. */ |
d62a17ae | 2873 | static struct cmd_node ip_node = {IP_NODE, "", 1}; |
2874 | static struct cmd_node protocol_node = {PROTOCOL_NODE, "", 1}; | |
c0d136ae DS |
2875 | /* table node for routing tables. */ |
2876 | static struct cmd_node table_node = {TABLE_NODE, | |
2877 | "", /* This node has no interface. */ | |
2878 | 1}; | |
2879 | static struct cmd_node forwarding_node = {FORWARDING_NODE, | |
2880 | "", /* This node has no interface. */ | |
2881 | 1}; | |
718e3744 | 2882 | |
2883 | /* Route VTY. */ | |
d62a17ae | 2884 | void zebra_vty_init(void) |
2885 | { | |
c0d136ae DS |
2886 | /* Install configuration write function. */ |
2887 | install_node(&table_node, config_write_table); | |
2888 | install_node(&forwarding_node, config_write_forwarding); | |
2889 | ||
2890 | install_element(VIEW_NODE, &show_ip_forwarding_cmd); | |
2891 | install_element(CONFIG_NODE, &ip_forwarding_cmd); | |
2892 | install_element(CONFIG_NODE, &no_ip_forwarding_cmd); | |
2893 | install_element(ENABLE_NODE, &show_zebra_cmd); | |
2894 | ||
2895 | #ifdef HAVE_NETLINK | |
2896 | install_element(VIEW_NODE, &show_table_cmd); | |
2897 | install_element(CONFIG_NODE, &config_table_cmd); | |
2898 | install_element(CONFIG_NODE, &no_config_table_cmd); | |
2899 | #endif /* HAVE_NETLINK */ | |
2900 | ||
2901 | install_element(VIEW_NODE, &show_ipv6_forwarding_cmd); | |
2902 | install_element(CONFIG_NODE, &ipv6_forwarding_cmd); | |
2903 | install_element(CONFIG_NODE, &no_ipv6_forwarding_cmd); | |
2904 | ||
2905 | /* Route-map */ | |
2906 | zebra_route_map_init(); | |
2907 | ||
d62a17ae | 2908 | install_node(&ip_node, zebra_ip_config); |
2909 | install_node(&protocol_node, config_write_protocol); | |
2910 | ||
2911 | install_element(CONFIG_NODE, &allow_external_route_update_cmd); | |
2912 | install_element(CONFIG_NODE, &no_allow_external_route_update_cmd); | |
7e24fdf3 | 2913 | |
d62a17ae | 2914 | install_element(CONFIG_NODE, &ip_multicast_mode_cmd); |
2915 | install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd); | |
b3b08602 | 2916 | |
d62a17ae | 2917 | install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd); |
2918 | install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd); | |
3a30f50f DS |
2919 | install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd); |
2920 | install_element(CONFIG_NODE, &no_zebra_workqueue_timer_cmd); | |
62d52ded DS |
2921 | install_element(CONFIG_NODE, &zebra_packet_process_cmd); |
2922 | install_element(CONFIG_NODE, &no_zebra_packet_process_cmd); | |
d62a17ae | 2923 | |
2924 | install_element(VIEW_NODE, &show_vrf_cmd); | |
b7cfce93 | 2925 | install_element(VIEW_NODE, &show_vrf_vni_cmd); |
ecffa493 | 2926 | install_element(VIEW_NODE, &show_route_cmd); |
ae825b8b | 2927 | install_element(VIEW_NODE, &show_route_table_cmd); |
87d6ac7a PG |
2928 | if (vrf_is_backend_netns()) |
2929 | install_element(VIEW_NODE, &show_route_table_vrf_cmd); | |
5ce91022 RW |
2930 | install_element(VIEW_NODE, &show_route_detail_cmd); |
2931 | install_element(VIEW_NODE, &show_route_summary_cmd); | |
d62a17ae | 2932 | install_element(VIEW_NODE, &show_ip_nht_cmd); |
b85c8275 | 2933 | install_element(VIEW_NODE, &show_ip_import_check_cmd); |
d62a17ae | 2934 | |
2935 | install_element(VIEW_NODE, &show_ip_rpf_cmd); | |
2936 | install_element(VIEW_NODE, &show_ip_rpf_addr_cmd); | |
2937 | ||
d62a17ae | 2938 | install_element(CONFIG_NODE, &ip_nht_default_route_cmd); |
2939 | install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd); | |
2940 | install_element(CONFIG_NODE, &ipv6_nht_default_route_cmd); | |
2941 | install_element(CONFIG_NODE, &no_ipv6_nht_default_route_cmd); | |
214e5c26 | 2942 | install_element(VRF_NODE, &ip_nht_default_route_cmd); |
2943 | install_element(VRF_NODE, &no_ip_nht_default_route_cmd); | |
2944 | install_element(VRF_NODE, &ipv6_nht_default_route_cmd); | |
2945 | install_element(VRF_NODE, &no_ipv6_nht_default_route_cmd); | |
d62a17ae | 2946 | install_element(VIEW_NODE, &show_ipv6_mroute_cmd); |
2947 | ||
2948 | /* Commands for VRF */ | |
d62a17ae | 2949 | install_element(VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd); |
2950 | ||
4cce389e | 2951 | install_element(VIEW_NODE, &show_evpn_global_cmd); |
d62a17ae | 2952 | install_element(VIEW_NODE, &show_evpn_vni_cmd); |
09af6961 | 2953 | install_element(VIEW_NODE, &show_evpn_vni_detail_cmd); |
d62a17ae | 2954 | install_element(VIEW_NODE, &show_evpn_vni_vni_cmd); |
4cce389e MK |
2955 | install_element(VIEW_NODE, &show_evpn_rmac_vni_mac_cmd); |
2956 | install_element(VIEW_NODE, &show_evpn_rmac_vni_cmd); | |
2957 | install_element(VIEW_NODE, &show_evpn_rmac_vni_all_cmd); | |
2958 | install_element(VIEW_NODE, &show_evpn_nh_vni_ip_cmd); | |
2959 | install_element(VIEW_NODE, &show_evpn_nh_vni_cmd); | |
2960 | install_element(VIEW_NODE, &show_evpn_nh_vni_all_cmd); | |
d62a17ae | 2961 | install_element(VIEW_NODE, &show_evpn_mac_vni_cmd); |
2962 | install_element(VIEW_NODE, &show_evpn_mac_vni_all_cmd); | |
cffe7580 | 2963 | install_element(VIEW_NODE, &show_evpn_mac_vni_all_detail_cmd); |
d62a17ae | 2964 | install_element(VIEW_NODE, &show_evpn_mac_vni_all_vtep_cmd); |
2965 | install_element(VIEW_NODE, &show_evpn_mac_vni_mac_cmd); | |
2966 | install_element(VIEW_NODE, &show_evpn_mac_vni_vtep_cmd); | |
1374d4db CS |
2967 | install_element(VIEW_NODE, &show_evpn_mac_vni_dad_cmd); |
2968 | install_element(VIEW_NODE, &show_evpn_mac_vni_all_dad_cmd); | |
d62a17ae | 2969 | install_element(VIEW_NODE, &show_evpn_neigh_vni_cmd); |
2970 | install_element(VIEW_NODE, &show_evpn_neigh_vni_all_cmd); | |
e3fac919 | 2971 | install_element(VIEW_NODE, &show_evpn_neigh_vni_all_detail_cmd); |
d62a17ae | 2972 | install_element(VIEW_NODE, &show_evpn_neigh_vni_neigh_cmd); |
2973 | install_element(VIEW_NODE, &show_evpn_neigh_vni_vtep_cmd); | |
1374d4db CS |
2974 | install_element(VIEW_NODE, &show_evpn_neigh_vni_dad_cmd); |
2975 | install_element(VIEW_NODE, &show_evpn_neigh_vni_all_dad_cmd); | |
09de9258 | 2976 | install_element(ENABLE_NODE, &clear_evpn_dup_addr_cmd); |
b7cfce93 | 2977 | |
586f4ccf PG |
2978 | install_element(VIEW_NODE, &show_pbr_ipset_cmd); |
2979 | install_element(VIEW_NODE, &show_pbr_iptable_cmd); | |
2980 | ||
e8d26197 MK |
2981 | install_element(CONFIG_NODE, &default_vrf_vni_mapping_cmd); |
2982 | install_element(CONFIG_NODE, &no_default_vrf_vni_mapping_cmd); | |
b7cfce93 MK |
2983 | install_element(VRF_NODE, &vrf_vni_mapping_cmd); |
2984 | install_element(VRF_NODE, &no_vrf_vni_mapping_cmd); | |
4060008b | 2985 | |
1d11b21f MS |
2986 | install_element(VIEW_NODE, &show_dataplane_cmd); |
2987 | install_element(VIEW_NODE, &show_dataplane_providers_cmd); | |
91f16812 MS |
2988 | install_element(CONFIG_NODE, &zebra_dplane_queue_limit_cmd); |
2989 | install_element(CONFIG_NODE, &no_zebra_dplane_queue_limit_cmd); | |
ac5aa23f DS |
2990 | |
2991 | install_element(VIEW_NODE, &zebra_show_routing_tables_summary_cmd); | |
718e3744 | 2992 | } |