blob: 08144cb8d78216fc82f4c8099a7c4c8edcd8c97a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
Paul Jakma7514fb72007-05-02 16:05:35 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
Feng Lu41f44a22015-05-22 11:39:56 +020030#include "vrf.h"
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -050031#include "nexthop.h"
paul718e3742002-12-13 20:15:29 +000032
paula1ac18c2005-06-28 17:17:12 +000033#include "zebra/zserv.h"
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -050034#include "zebra/zebra_rnh.h"
paula1ac18c2005-06-28 17:17:12 +000035
Feng Lu4364ee52015-05-22 11:40:03 +020036static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
David Lamparter3b02fe82015-01-22 19:12:35 +010037static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
38 int mcast);
Feng Lu4364ee52015-05-22 11:40:03 +020039static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
40 struct rib *rib);
Everton Marques33d86db2014-07-14 11:19:00 -030041
42/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000043static int
Everton Marques33d86db2014-07-14 11:19:00 -030044zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
45 const char *dest_str, const char *mask_str,
46 const char *gate_str, const char *flag_str,
Piotr Chytłade24f822007-06-28 00:09:28 +020047 const char *tag_str, const char *distance_str,
48 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +000049{
50 int ret;
51 u_char distance;
52 struct prefix p;
53 struct in_addr gate;
54 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000055 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000056 u_char flag = 0;
Piotr Chytłade24f822007-06-28 00:09:28 +020057 u_short tag = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +020058 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +000059
60 ret = str2prefix (dest_str, &p);
61 if (ret <= 0)
62 {
63 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
64 return CMD_WARNING;
65 }
66
67 /* Cisco like mask notation. */
68 if (mask_str)
69 {
70 ret = inet_aton (mask_str, &mask);
71 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000072 {
73 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
74 return CMD_WARNING;
75 }
paul718e3742002-12-13 20:15:29 +000076 p.prefixlen = ip_masklen (mask);
77 }
78
79 /* Apply mask for given prefix. */
80 apply_mask (&p);
81
paul595db7f2003-05-25 21:35:06 +000082 /* Administrative distance. */
83 if (distance_str)
84 distance = atoi (distance_str);
85 else
86 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
87
Piotr Chytłade24f822007-06-28 00:09:28 +020088 /* tag */
89 if (tag_str)
90 tag = atoi (tag_str);
91
Feng Lu7aaf4ea2015-05-22 11:40:06 +020092 /* VRF id */
93 if (vrf_id_str)
94 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
95
paul595db7f2003-05-25 21:35:06 +000096 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000097 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000098 {
99 if (flag_str)
100 {
101 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
102 return CMD_WARNING;
103 }
104 if (add_cmd)
Piotr Chytłade24f822007-06-28 00:09:28 +0200105 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000106 else
Piotr Chytłade24f822007-06-28 00:09:28 +0200107 static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000108 return CMD_SUCCESS;
109 }
110
hasso81dfcaa2003-05-25 19:21:25 +0000111 /* Route flags */
112 if (flag_str) {
113 switch(flag_str[0]) {
114 case 'r':
115 case 'R': /* XXX */
116 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
117 break;
118 case 'b':
119 case 'B': /* XXX */
120 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
121 break;
122 default:
123 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000124 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000125 }
126 }
127
hasso457ef552003-05-28 12:02:15 +0000128 if (gate_str == NULL)
129 {
130 if (add_cmd)
Piotr Chytłade24f822007-06-28 00:09:28 +0200131 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, tag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000132 else
Piotr Chytłade24f822007-06-28 00:09:28 +0200133 static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000134
135 return CMD_SUCCESS;
136 }
137
paul718e3742002-12-13 20:15:29 +0000138 /* When gateway is A.B.C.D format, gate is treated as nexthop
139 address other case gate is treated as interface name. */
140 ret = inet_aton (gate_str, &gate);
141 if (ret)
142 ifname = NULL;
143 else
144 ifname = gate_str;
145
146 if (add_cmd)
Piotr Chytłade24f822007-06-28 00:09:28 +0200147 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, tag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000148 else
Piotr Chytłade24f822007-06-28 00:09:28 +0200149 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, tag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000150
151 return CMD_SUCCESS;
152}
153
Everton Marques33d86db2014-07-14 11:19:00 -0300154/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100155DEFUN (ip_mroute_dist,
156 ip_mroute_dist_cmd,
157 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300158 IP_STR
159 "Configure static unicast route into MRIB for multicast RPF lookup\n"
160 "IP destination prefix (e.g. 10.0.0.0/8)\n"
161 "Nexthop address\n"
162 "Nexthop interface name\n"
163 "Distance\n")
164{
David Lamparter863f20c2015-01-27 20:24:15 +0100165 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100166 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Piotr Chytłade24f822007-06-28 00:09:28 +0200167 NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300168}
169
David Lampartera76681b2015-01-22 19:03:53 +0100170ALIAS (ip_mroute_dist,
171 ip_mroute_cmd,
172 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
173 IP_STR
174 "Configure static unicast route into MRIB for multicast RPF lookup\n"
175 "IP destination prefix (e.g. 10.0.0.0/8)\n"
176 "Nexthop address\n"
177 "Nexthop interface name\n")
178
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200179DEFUN (ip_mroute_dist_vrf,
180 ip_mroute_dist_vrf_cmd,
181 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
182 IP_STR
183 "Configure static unicast route into MRIB for multicast RPF lookup\n"
184 "IP destination prefix (e.g. 10.0.0.0/8)\n"
185 "Nexthop address\n"
186 "Nexthop interface name\n"
187 "Distance\n"
188 VRF_CMD_HELP_STR)
189{
190 VTY_WARN_EXPERIMENTAL();
191 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Piotr Chytłade24f822007-06-28 00:09:28 +0200192 NULL, NULL, argc > 3 ? argv[2] : NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200193 argc > 3 ? argv[3] : argv[2]);
194}
195
196ALIAS (ip_mroute_dist_vrf,
197 ip_mroute_vrf_cmd,
198 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
199 IP_STR
200 "Configure static unicast route into MRIB for multicast RPF lookup\n"
201 "IP destination prefix (e.g. 10.0.0.0/8)\n"
202 "Nexthop address\n"
203 "Nexthop interface name\n"
204 VRF_CMD_HELP_STR)
205
David Lampartera76681b2015-01-22 19:03:53 +0100206DEFUN (no_ip_mroute_dist,
207 no_ip_mroute_dist_cmd,
208 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300209 IP_STR
210 "Configure static unicast route into MRIB for multicast RPF lookup\n"
211 "IP destination prefix (e.g. 10.0.0.0/8)\n"
212 "Nexthop address\n"
213 "Nexthop interface name\n"
214 "Distance\n")
215{
David Lamparter863f20c2015-01-27 20:24:15 +0100216 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100217 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Piotr Chytłade24f822007-06-28 00:09:28 +0200218 NULL, NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300219}
220
David Lampartera76681b2015-01-22 19:03:53 +0100221ALIAS (no_ip_mroute_dist,
222 no_ip_mroute_cmd,
223 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
224 NO_STR
225 IP_STR
226 "Configure static unicast route into MRIB for multicast RPF lookup\n"
227 "IP destination prefix (e.g. 10.0.0.0/8)\n"
228 "Nexthop address\n"
229 "Nexthop interface name\n")
230
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200231DEFUN (no_ip_mroute_dist_vrf,
232 no_ip_mroute_dist_vrf_cmd,
233 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
234 IP_STR
235 "Configure static unicast route into MRIB for multicast RPF lookup\n"
236 "IP destination prefix (e.g. 10.0.0.0/8)\n"
237 "Nexthop address\n"
238 "Nexthop interface name\n"
239 "Distance\n"
240 VRF_CMD_HELP_STR)
241{
242 VTY_WARN_EXPERIMENTAL();
243 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Piotr Chytłade24f822007-06-28 00:09:28 +0200244 NULL, NULL, argc > 3 ? argv[2] : NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200245 argc > 3 ? argv[3] : argv[2]);
246}
247
248ALIAS (no_ip_mroute_dist_vrf,
249 no_ip_mroute_vrf_cmd,
250 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
251 NO_STR
252 IP_STR
253 "Configure static unicast route into MRIB for multicast RPF lookup\n"
254 "IP destination prefix (e.g. 10.0.0.0/8)\n"
255 "Nexthop address\n"
256 "Nexthop interface name\n"
257 VRF_CMD_HELP_STR)
258
David Lamparterbd078122015-01-06 19:53:24 +0100259DEFUN (ip_multicast_mode,
260 ip_multicast_mode_cmd,
261 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
262 IP_STR
263 "Multicast options\n"
264 "RPF lookup behavior\n"
265 "Lookup in unicast RIB only\n"
266 "Lookup in multicast RIB only\n"
267 "Try multicast RIB first, fall back to unicast RIB\n"
268 "Lookup both, use entry with lower distance\n"
269 "Lookup both, use entry with longer prefix\n")
270{
David Lamparter863f20c2015-01-27 20:24:15 +0100271 VTY_WARN_EXPERIMENTAL();
272
David Lamparterbd078122015-01-06 19:53:24 +0100273 if (!strncmp (argv[0], "u", 1))
274 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
275 else if (!strncmp (argv[0], "mrib-o", 6))
276 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
277 else if (!strncmp (argv[0], "mrib-t", 6))
278 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
279 else if (!strncmp (argv[0], "low", 3))
280 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
281 else if (!strncmp (argv[0], "lon", 3))
282 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
283 else
284 {
285 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
286 return CMD_WARNING;
287 }
288
289 return CMD_SUCCESS;
290}
291
292DEFUN (no_ip_multicast_mode,
293 no_ip_multicast_mode_cmd,
294 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
295 NO_STR
296 IP_STR
297 "Multicast options\n"
298 "RPF lookup behavior\n"
299 "Lookup in unicast RIB only\n"
300 "Lookup in multicast RIB only\n"
301 "Try multicast RIB first, fall back to unicast RIB\n"
302 "Lookup both, use entry with lower distance\n"
303 "Lookup both, use entry with longer prefix\n")
304{
305 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
306 return CMD_SUCCESS;
307}
308
309ALIAS (no_ip_multicast_mode,
310 no_ip_multicast_mode_noarg_cmd,
311 "no ip multicast rpf-lookup-mode",
312 NO_STR
313 IP_STR
314 "Multicast options\n"
315 "RPF lookup behavior\n")
316
Everton Marques33d86db2014-07-14 11:19:00 -0300317DEFUN (show_ip_rpf,
318 show_ip_rpf_cmd,
319 "show ip rpf",
320 SHOW_STR
321 IP_STR
322 "Display RPF information for multicast source\n")
323{
Feng Lu4364ee52015-05-22 11:40:03 +0200324 vrf_id_t vrf_id = VRF_DEFAULT;
325
326 if (argc > 0)
327 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
328
David Lamparter863f20c2015-01-27 20:24:15 +0100329 VTY_WARN_EXPERIMENTAL();
Feng Lu4364ee52015-05-22 11:40:03 +0200330 return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -0300331}
332
Feng Lu4364ee52015-05-22 11:40:03 +0200333ALIAS (show_ip_rpf,
334 show_ip_rpf_vrf_cmd,
335 "show ip rpf " VRF_CMD_STR,
336 SHOW_STR
337 IP_STR
338 "Display RPF information for multicast source\n"
339 VRF_CMD_HELP_STR)
340
David Lamparter3b02fe82015-01-22 19:12:35 +0100341DEFUN (show_ip_rpf_addr,
342 show_ip_rpf_addr_cmd,
343 "show ip rpf A.B.C.D",
344 SHOW_STR
345 IP_STR
346 "Display RPF information for multicast source\n"
347 "IP multicast source address (e.g. 10.0.0.0)\n")
348{
349 struct in_addr addr;
350 struct route_node *rn;
351 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +0200352 vrf_id_t vrf_id = VRF_DEFAULT;
353 int ret;
354
355 if (argc > 1)
356 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
357
358 VTY_WARN_EXPERIMENTAL();
359
360 ret = inet_aton (argv[0], &addr);
361 if (ret == 0)
362 {
363 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
364 return CMD_WARNING;
365 }
366
367 rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
368
369 if (rib)
370 vty_show_ip_route_detail (vty, rn, 1);
371 else
372 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
373
374 return CMD_SUCCESS;
375}
376
377ALIAS (show_ip_rpf_addr,
378 show_ip_rpf_addr_vrf_cmd,
379 "show ip rpf A.B.C.D " VRF_CMD_STR,
380 SHOW_STR
381 IP_STR
382 "Display RPF information for multicast source\n"
383 "IP multicast source address (e.g. 10.0.0.0)\n"
384 VRF_CMD_HELP_STR)
385
386DEFUN (show_ip_rpf_vrf_all,
387 show_ip_rpf_vrf_all_cmd,
388 "show ip rpf " VRF_ALL_CMD_STR,
389 SHOW_STR
390 IP_STR
391 "Display RPF information for multicast source\n"
392 VRF_ALL_CMD_HELP_STR)
393{
394 struct zebra_vrf *zvrf;
395 struct route_table *table;
396 struct route_node *rn;
397 struct rib *rib;
398 vrf_iter_t iter;
399 int first = 1;
400
401 VTY_WARN_EXPERIMENTAL();
402
403 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
404 {
405 if ((zvrf = vrf_iter2info (iter)) == NULL ||
406 (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
407 continue;
408
409 /* Show all IPv4 routes. */
410 for (rn = route_top (table); rn; rn = route_next (rn))
411 RNODE_FOREACH_RIB (rn, rib)
412 {
413 if (first)
414 {
415 vty_out (vty, SHOW_ROUTE_V4_HEADER);
416 first = 0;
417 }
418 vty_show_ip_route (vty, rn, rib);
419 }
420 }
421
422 return CMD_SUCCESS;
423}
424
425DEFUN (show_ip_rpf_addr_vrf_all,
426 show_ip_rpf_addr_vrf_all_cmd,
427 "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
428 SHOW_STR
429 IP_STR
430 "Display RPF information for multicast source\n"
431 "IP multicast source address (e.g. 10.0.0.0)\n"
432 VRF_ALL_CMD_HELP_STR)
433{
434 struct in_addr addr;
435 struct route_node *rn;
436 vrf_iter_t iter;
David Lamparter3b02fe82015-01-22 19:12:35 +0100437 int ret;
438
David Lamparter863f20c2015-01-27 20:24:15 +0100439 VTY_WARN_EXPERIMENTAL();
440
David Lamparter3b02fe82015-01-22 19:12:35 +0100441 ret = inet_aton (argv[0], &addr);
442 if (ret == 0)
443 {
444 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
445 return CMD_WARNING;
446 }
447
Feng Lu4364ee52015-05-22 11:40:03 +0200448 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
449 {
450 if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
451 vty_show_ip_route_detail (vty, rn, 1);
452 }
David Lamparter3b02fe82015-01-22 19:12:35 +0100453
454 return CMD_SUCCESS;
455}
456
paul718e3742002-12-13 20:15:29 +0000457/* Static route configuration. */
458DEFUN (ip_route,
459 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000460 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000461 IP_STR
462 "Establish static routes\n"
463 "IP destination prefix (e.g. 10.0.0.0/8)\n"
464 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000465 "IP gateway interface name\n"
466 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000467{
Piotr Chytłade24f822007-06-28 00:09:28 +0200468 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
469 NULL, NULL, NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000470}
471
472DEFUN (ip_route_flags,
473 ip_route_flags_cmd,
474 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000475 IP_STR
476 "Establish static routes\n"
477 "IP destination prefix (e.g. 10.0.0.0/8)\n"
478 "IP gateway address\n"
479 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000480 "Emit an ICMP unreachable when matched\n"
481 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000482{
Piotr Chytłade24f822007-06-28 00:09:28 +0200483 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
484 argv[2], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +0000485}
486
hasso457ef552003-05-28 12:02:15 +0000487DEFUN (ip_route_flags2,
488 ip_route_flags2_cmd,
489 "ip route A.B.C.D/M (reject|blackhole)",
490 IP_STR
491 "Establish static routes\n"
492 "IP destination prefix (e.g. 10.0.0.0/8)\n"
493 "Emit an ICMP unreachable when matched\n"
494 "Silently discard pkts when matched\n")
495{
Piotr Chytłade24f822007-06-28 00:09:28 +0200496 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
497 NULL, argv[1], NULL, NULL, NULL);
hasso457ef552003-05-28 12:02:15 +0000498}
499
paul718e3742002-12-13 20:15:29 +0000500/* Mask as A.B.C.D format. */
501DEFUN (ip_route_mask,
502 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000503 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000504 IP_STR
505 "Establish static routes\n"
506 "IP destination prefix\n"
507 "IP destination prefix mask\n"
508 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000509 "IP gateway interface name\n"
510 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000511{
Piotr Chytłade24f822007-06-28 00:09:28 +0200512 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
513 argv[2], NULL, NULL, NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000514}
515
516DEFUN (ip_route_mask_flags,
517 ip_route_mask_flags_cmd,
518 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000519 IP_STR
520 "Establish static routes\n"
521 "IP destination prefix\n"
522 "IP destination prefix mask\n"
523 "IP gateway address\n"
524 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000525 "Emit an ICMP unreachable when matched\n"
526 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000527{
Piotr Chytłade24f822007-06-28 00:09:28 +0200528 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
529 argv[2], argv[3], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +0000530}
531
hasso457ef552003-05-28 12:02:15 +0000532DEFUN (ip_route_mask_flags2,
533 ip_route_mask_flags2_cmd,
534 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
535 IP_STR
536 "Establish static routes\n"
537 "IP destination prefix\n"
538 "IP destination prefix mask\n"
539 "Emit an ICMP unreachable when matched\n"
540 "Silently discard pkts when matched\n")
541{
Piotr Chytłade24f822007-06-28 00:09:28 +0200542 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
543 NULL, argv[2], NULL, NULL, NULL);
hasso457ef552003-05-28 12:02:15 +0000544}
545
paul718e3742002-12-13 20:15:29 +0000546/* Distance option value. */
547DEFUN (ip_route_distance,
548 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000549 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000550 IP_STR
551 "Establish static routes\n"
552 "IP destination prefix (e.g. 10.0.0.0/8)\n"
553 "IP gateway address\n"
554 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000555 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000556 "Distance value for this route\n")
557{
Piotr Chytłade24f822007-06-28 00:09:28 +0200558 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
559 argv[1], NULL, NULL, argv[2], NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000560}
561
562DEFUN (ip_route_flags_distance,
563 ip_route_flags_distance_cmd,
564 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
565 IP_STR
566 "Establish static routes\n"
567 "IP destination prefix (e.g. 10.0.0.0/8)\n"
568 "IP gateway address\n"
569 "IP gateway interface name\n"
570 "Emit an ICMP unreachable when matched\n"
571 "Silently discard pkts when matched\n"
572 "Distance value for this route\n")
573{
Piotr Chytłade24f822007-06-28 00:09:28 +0200574 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1],
575 argv[2], NULL, argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000576}
577
hasso457ef552003-05-28 12:02:15 +0000578DEFUN (ip_route_flags_distance2,
579 ip_route_flags_distance2_cmd,
580 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
581 IP_STR
582 "Establish static routes\n"
583 "IP destination prefix (e.g. 10.0.0.0/8)\n"
584 "Emit an ICMP unreachable when matched\n"
585 "Silently discard pkts when matched\n"
586 "Distance value for this route\n")
587{
Piotr Chytłade24f822007-06-28 00:09:28 +0200588 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
589 NULL, argv[1], NULL, argv[2], NULL);
hasso457ef552003-05-28 12:02:15 +0000590}
591
paul718e3742002-12-13 20:15:29 +0000592DEFUN (ip_route_mask_distance,
593 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000594 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000595 IP_STR
596 "Establish static routes\n"
597 "IP destination prefix\n"
598 "IP destination prefix mask\n"
599 "IP gateway address\n"
600 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000601 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000602 "Distance value for this route\n")
603{
Piotr Chytłade24f822007-06-28 00:09:28 +0200604 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
605 NULL, NULL, argv[3], NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000606}
607
608DEFUN (ip_route_mask_flags_distance,
609 ip_route_mask_flags_distance_cmd,
610 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
611 IP_STR
612 "Establish static routes\n"
613 "IP destination prefix\n"
614 "IP destination prefix mask\n"
615 "IP gateway address\n"
616 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000617 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000618 "Silently discard pkts when matched\n"
619 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000620{
Piotr Chytłade24f822007-06-28 00:09:28 +0200621 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2],
622 argv[3], NULL, argv[4], NULL);
paul718e3742002-12-13 20:15:29 +0000623}
624
hasso457ef552003-05-28 12:02:15 +0000625DEFUN (ip_route_mask_flags_distance2,
626 ip_route_mask_flags_distance2_cmd,
627 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
628 IP_STR
629 "Establish static routes\n"
630 "IP destination prefix\n"
631 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000632 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000633 "Silently discard pkts when matched\n"
634 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000635{
Piotr Chytłade24f822007-06-28 00:09:28 +0200636 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
637 NULL, argv[2], NULL, argv[3], NULL);
hasso457ef552003-05-28 12:02:15 +0000638}
639
paul718e3742002-12-13 20:15:29 +0000640DEFUN (no_ip_route,
641 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000642 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000643 NO_STR
644 IP_STR
645 "Establish static routes\n"
646 "IP destination prefix (e.g. 10.0.0.0/8)\n"
647 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000648 "IP gateway interface name\n"
649 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000650{
Piotr Chytłade24f822007-06-28 00:09:28 +0200651 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
652 argv[1], NULL, NULL, NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000653}
654
655ALIAS (no_ip_route,
656 no_ip_route_flags_cmd,
657 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000658 NO_STR
659 IP_STR
660 "Establish static routes\n"
661 "IP destination prefix (e.g. 10.0.0.0/8)\n"
662 "IP gateway address\n"
663 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000664 "Emit an ICMP unreachable when matched\n"
665 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000666
hasso457ef552003-05-28 12:02:15 +0000667DEFUN (no_ip_route_flags2,
668 no_ip_route_flags2_cmd,
669 "no ip route A.B.C.D/M (reject|blackhole)",
670 NO_STR
671 IP_STR
672 "Establish static routes\n"
673 "IP destination prefix (e.g. 10.0.0.0/8)\n"
674 "Emit an ICMP unreachable when matched\n"
675 "Silently discard pkts when matched\n")
676{
Piotr Chytłade24f822007-06-28 00:09:28 +0200677 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
678 NULL, NULL, NULL, NULL, NULL);
hasso457ef552003-05-28 12:02:15 +0000679}
680
paul718e3742002-12-13 20:15:29 +0000681DEFUN (no_ip_route_mask,
682 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000683 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000684 NO_STR
685 IP_STR
686 "Establish static routes\n"
687 "IP destination prefix\n"
688 "IP destination prefix mask\n"
689 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000690 "IP gateway interface name\n"
691 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000692{
Piotr Chytłade24f822007-06-28 00:09:28 +0200693 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
694 argv[2], NULL, NULL, NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000695}
696
697ALIAS (no_ip_route_mask,
698 no_ip_route_mask_flags_cmd,
699 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000700 NO_STR
701 IP_STR
702 "Establish static routes\n"
703 "IP destination prefix\n"
704 "IP destination prefix mask\n"
705 "IP gateway address\n"
706 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000707 "Emit an ICMP unreachable when matched\n"
708 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000709
hasso457ef552003-05-28 12:02:15 +0000710DEFUN (no_ip_route_mask_flags2,
711 no_ip_route_mask_flags2_cmd,
712 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
713 NO_STR
714 IP_STR
715 "Establish static routes\n"
716 "IP destination prefix\n"
717 "IP destination prefix mask\n"
718 "Emit an ICMP unreachable when matched\n"
719 "Silently discard pkts when matched\n")
720{
Piotr Chytłade24f822007-06-28 00:09:28 +0200721 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
722 NULL, NULL, NULL, NULL, NULL);
hasso457ef552003-05-28 12:02:15 +0000723}
724
paul718e3742002-12-13 20:15:29 +0000725DEFUN (no_ip_route_distance,
726 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000727 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000728 NO_STR
729 IP_STR
730 "Establish static routes\n"
731 "IP destination prefix (e.g. 10.0.0.0/8)\n"
732 "IP gateway address\n"
733 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000734 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000735 "Distance value for this route\n")
736{
Piotr Chytłade24f822007-06-28 00:09:28 +0200737 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
738 argv[1], NULL, NULL, argv[2], NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000739}
740
741DEFUN (no_ip_route_flags_distance,
742 no_ip_route_flags_distance_cmd,
743 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
744 NO_STR
745 IP_STR
746 "Establish static routes\n"
747 "IP destination prefix (e.g. 10.0.0.0/8)\n"
748 "IP gateway address\n"
749 "IP gateway interface name\n"
750 "Emit an ICMP unreachable when matched\n"
751 "Silently discard pkts when matched\n"
752 "Distance value for this route\n")
753{
Piotr Chytłade24f822007-06-28 00:09:28 +0200754 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
755 argv[1], argv[2], NULL, argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000756}
757
hasso457ef552003-05-28 12:02:15 +0000758DEFUN (no_ip_route_flags_distance2,
759 no_ip_route_flags_distance2_cmd,
760 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
761 NO_STR
762 IP_STR
763 "Establish static routes\n"
764 "IP destination prefix (e.g. 10.0.0.0/8)\n"
765 "Emit an ICMP unreachable when matched\n"
766 "Silently discard pkts when matched\n"
767 "Distance value for this route\n")
768{
Piotr Chytłade24f822007-06-28 00:09:28 +0200769 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
770 argv[1], NULL, argv[2], NULL);
hasso457ef552003-05-28 12:02:15 +0000771}
772
paul718e3742002-12-13 20:15:29 +0000773DEFUN (no_ip_route_mask_distance,
774 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000775 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000776 NO_STR
777 IP_STR
778 "Establish static routes\n"
779 "IP destination prefix\n"
780 "IP destination prefix mask\n"
781 "IP gateway address\n"
782 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000783 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000784 "Distance value for this route\n")
785{
Piotr Chytłade24f822007-06-28 00:09:28 +0200786 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
787 argv[2], NULL, NULL, argv[3], NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000788}
789
790DEFUN (no_ip_route_mask_flags_distance,
791 no_ip_route_mask_flags_distance_cmd,
792 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
793 NO_STR
794 IP_STR
795 "Establish static routes\n"
796 "IP destination prefix\n"
797 "IP destination prefix mask\n"
798 "IP gateway address\n"
799 "IP gateway interface name\n"
800 "Emit an ICMP unreachable when matched\n"
801 "Silently discard pkts when matched\n"
802 "Distance value for this route\n")
803{
Piotr Chytłade24f822007-06-28 00:09:28 +0200804 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
805 argv[2], argv[3], NULL, argv[4], NULL);
paul718e3742002-12-13 20:15:29 +0000806}
807
hasso457ef552003-05-28 12:02:15 +0000808DEFUN (no_ip_route_mask_flags_distance2,
809 no_ip_route_mask_flags_distance2_cmd,
810 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
811 NO_STR
812 IP_STR
813 "Establish static routes\n"
814 "IP destination prefix\n"
815 "IP destination prefix mask\n"
816 "Emit an ICMP unreachable when matched\n"
817 "Silently discard pkts when matched\n"
818 "Distance value for this route\n")
819{
Piotr Chytłade24f822007-06-28 00:09:28 +0200820 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
821 NULL, argv[2], NULL, argv[3], NULL);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200822}
823
824DEFUN (ip_route_vrf,
825 ip_route_vrf_cmd,
826 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
827 IP_STR
828 "Establish static routes\n"
829 "IP destination prefix (e.g. 10.0.0.0/8)\n"
830 "IP gateway address\n"
831 "IP gateway interface name\n"
832 "Null interface\n"
833 VRF_CMD_HELP_STR)
834{
Piotr Chytłade24f822007-06-28 00:09:28 +0200835 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
836 argv[1], NULL, NULL, NULL, argv[2]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200837}
838
839DEFUN (ip_route_flags_vrf,
840 ip_route_flags_vrf_cmd,
841 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
842 IP_STR
843 "Establish static routes\n"
844 "IP destination prefix (e.g. 10.0.0.0/8)\n"
845 "IP gateway address\n"
846 "IP gateway interface name\n"
847 "Emit an ICMP unreachable when matched\n"
848 "Silently discard pkts when matched\n"
849 VRF_CMD_HELP_STR)
850{
Piotr Chytłade24f822007-06-28 00:09:28 +0200851 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
852 argv[1], argv[2], NULL, NULL, argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200853}
854
855DEFUN (ip_route_flags2_vrf,
856 ip_route_flags2_vrf_cmd,
857 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
858 IP_STR
859 "Establish static routes\n"
860 "IP destination prefix (e.g. 10.0.0.0/8)\n"
861 "Emit an ICMP unreachable when matched\n"
862 "Silently discard pkts when matched\n"
863 VRF_CMD_HELP_STR)
864{
Piotr Chytłade24f822007-06-28 00:09:28 +0200865 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
866 NULL, argv[1], NULL, NULL, argv[2]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200867}
868
869/* Mask as A.B.C.D format. */
870DEFUN (ip_route_mask_vrf,
871 ip_route_mask_vrf_cmd,
872 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
873 IP_STR
874 "Establish static routes\n"
875 "IP destination prefix\n"
876 "IP destination prefix mask\n"
877 "IP gateway address\n"
878 "IP gateway interface name\n"
879 "Null interface\n"
880 VRF_CMD_HELP_STR)
881{
Piotr Chytłade24f822007-06-28 00:09:28 +0200882 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
883 argv[2], NULL, NULL, NULL, argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200884}
885
886DEFUN (ip_route_mask_flags_vrf,
887 ip_route_mask_flags_vrf_cmd,
888 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
889 IP_STR
890 "Establish static routes\n"
891 "IP destination prefix\n"
892 "IP destination prefix mask\n"
893 "IP gateway address\n"
894 "IP gateway interface name\n"
895 "Emit an ICMP unreachable when matched\n"
896 "Silently discard pkts when matched\n"
897 VRF_CMD_HELP_STR)
898{
Piotr Chytłade24f822007-06-28 00:09:28 +0200899 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
900 argv[2], argv[3], NULL, NULL, argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200901}
902
903DEFUN (ip_route_mask_flags2_vrf,
904 ip_route_mask_flags2_vrf_cmd,
905 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
906 IP_STR
907 "Establish static routes\n"
908 "IP destination prefix\n"
909 "IP destination prefix mask\n"
910 "Emit an ICMP unreachable when matched\n"
911 "Silently discard pkts when matched\n"
912 VRF_CMD_HELP_STR)
913{
Piotr Chytłade24f822007-06-28 00:09:28 +0200914 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
915 NULL, argv[2], NULL, NULL, argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200916}
917
918/* Distance option value. */
919DEFUN (ip_route_distance_vrf,
920 ip_route_distance_vrf_cmd,
921 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
922 IP_STR
923 "Establish static routes\n"
924 "IP destination prefix (e.g. 10.0.0.0/8)\n"
925 "IP gateway address\n"
926 "IP gateway interface name\n"
927 "Null interface\n"
928 "Distance value for this route\n"
929 VRF_CMD_HELP_STR)
930{
Piotr Chytłade24f822007-06-28 00:09:28 +0200931 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
932 argv[1], NULL, NULL, argv[2], argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200933}
934
935DEFUN (ip_route_flags_distance_vrf,
936 ip_route_flags_distance_vrf_cmd,
937 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
938 IP_STR
939 "Establish static routes\n"
940 "IP destination prefix (e.g. 10.0.0.0/8)\n"
941 "IP gateway address\n"
942 "IP gateway interface name\n"
943 "Emit an ICMP unreachable when matched\n"
944 "Silently discard pkts when matched\n"
945 "Distance value for this route\n"
946 VRF_CMD_HELP_STR)
947{
Piotr Chytłade24f822007-06-28 00:09:28 +0200948 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
949 argv[1], argv[2], NULL, argv[3], argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200950}
951
952DEFUN (ip_route_flags_distance2_vrf,
953 ip_route_flags_distance2_vrf_cmd,
954 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
955 IP_STR
956 "Establish static routes\n"
957 "IP destination prefix (e.g. 10.0.0.0/8)\n"
958 "Emit an ICMP unreachable when matched\n"
959 "Silently discard pkts when matched\n"
960 "Distance value for this route\n"
961 VRF_CMD_HELP_STR)
962{
Piotr Chytłade24f822007-06-28 00:09:28 +0200963 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL,
964 NULL, argv[1], NULL, argv[2], argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200965}
966
967DEFUN (ip_route_mask_distance_vrf,
968 ip_route_mask_distance_vrf_cmd,
969 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
970 IP_STR
971 "Establish static routes\n"
972 "IP destination prefix\n"
973 "IP destination prefix mask\n"
974 "IP gateway address\n"
975 "IP gateway interface name\n"
976 "Null interface\n"
977 "Distance value for this route\n"
978 VRF_CMD_HELP_STR)
979{
Piotr Chytłade24f822007-06-28 00:09:28 +0200980 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
981 argv[2], NULL, NULL, argv[3], argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200982}
983
984DEFUN (ip_route_mask_flags_distance_vrf,
985 ip_route_mask_flags_distance_vrf_cmd,
986 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
987 IP_STR
988 "Establish static routes\n"
989 "IP destination prefix\n"
990 "IP destination prefix mask\n"
991 "IP gateway address\n"
992 "IP gateway interface name\n"
993 "Emit an ICMP unreachable when matched\n"
994 "Silently discard pkts when matched\n"
995 "Distance value for this route\n"
996 VRF_CMD_HELP_STR)
997{
Piotr Chytłade24f822007-06-28 00:09:28 +0200998 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
999 argv[2], argv[3], NULL, argv[4], argv[5]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001000}
1001
1002DEFUN (ip_route_mask_flags_distance2_vrf,
1003 ip_route_mask_flags_distance2_vrf_cmd,
1004 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1005 IP_STR
1006 "Establish static routes\n"
1007 "IP destination prefix\n"
1008 "IP destination prefix mask\n"
1009 "Emit an ICMP unreachable when matched\n"
1010 "Silently discard pkts when matched\n"
1011 "Distance value for this route\n"
1012 VRF_CMD_HELP_STR)
1013{
Piotr Chytłade24f822007-06-28 00:09:28 +02001014 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1],
1015 NULL, argv[2], NULL, argv[3], argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001016}
1017
1018DEFUN (no_ip_route_vrf,
1019 no_ip_route_vrf_cmd,
1020 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1021 NO_STR
1022 IP_STR
1023 "Establish static routes\n"
1024 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1025 "IP gateway address\n"
1026 "IP gateway interface name\n"
1027 "Null interface\n"
1028 VRF_CMD_HELP_STR)
1029{
Piotr Chytłade24f822007-06-28 00:09:28 +02001030 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0],
1031 NULL, argv[1], NULL, NULL, NULL,
1032 (argc > 3) ? argv[3] : argv[2]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001033}
1034
1035ALIAS (no_ip_route_vrf,
1036 no_ip_route_flags_vrf_cmd,
1037 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1038 NO_STR
1039 IP_STR
1040 "Establish static routes\n"
1041 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1042 "IP gateway address\n"
1043 "IP gateway interface name\n"
1044 "Emit an ICMP unreachable when matched\n"
1045 "Silently discard pkts when matched\n"
1046 VRF_CMD_HELP_STR)
1047
1048DEFUN (no_ip_route_flags2_vrf,
1049 no_ip_route_flags2_vrf_cmd,
1050 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1051 NO_STR
1052 IP_STR
1053 "Establish static routes\n"
1054 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1055 "Emit an ICMP unreachable when matched\n"
1056 "Silently discard pkts when matched\n"
1057 VRF_CMD_HELP_STR)
1058{
Piotr Chytłade24f822007-06-28 00:09:28 +02001059 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0],
1060 NULL, NULL, NULL, NULL, NULL, argv[2]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001061}
1062
1063DEFUN (no_ip_route_mask_vrf,
1064 no_ip_route_mask_vrf_cmd,
1065 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1066 NO_STR
1067 IP_STR
1068 "Establish static routes\n"
1069 "IP destination prefix\n"
1070 "IP destination prefix mask\n"
1071 "IP gateway address\n"
1072 "IP gateway interface name\n"
1073 "Null interface\n"
1074 VRF_CMD_HELP_STR)
1075{
Piotr Chytłade24f822007-06-28 00:09:28 +02001076 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1077 argv[2], NULL, NULL, NULL,
1078 (argc > 4) ? argv[4] : argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001079}
1080
1081ALIAS (no_ip_route_mask_vrf,
1082 no_ip_route_mask_flags_vrf_cmd,
1083 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1084 NO_STR
1085 IP_STR
1086 "Establish static routes\n"
1087 "IP destination prefix\n"
1088 "IP destination prefix mask\n"
1089 "IP gateway address\n"
1090 "IP gateway interface name\n"
1091 "Emit an ICMP unreachable when matched\n"
1092 "Silently discard pkts when matched\n"
1093 VRF_CMD_HELP_STR)
1094
1095DEFUN (no_ip_route_mask_flags2_vrf,
1096 no_ip_route_mask_flags2_vrf_cmd,
1097 "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1098 NO_STR
1099 IP_STR
1100 "Establish static routes\n"
1101 "IP destination prefix\n"
1102 "IP destination prefix mask\n"
1103 "Emit an ICMP unreachable when matched\n"
1104 "Silently discard pkts when matched\n"
1105 VRF_CMD_HELP_STR)
1106{
Piotr Chytłade24f822007-06-28 00:09:28 +02001107 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1108 NULL, NULL, NULL, NULL, argv[2]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001109}
1110
1111DEFUN (no_ip_route_distance_vrf,
1112 no_ip_route_distance_vrf_cmd,
1113 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1114 NO_STR
1115 IP_STR
1116 "Establish static routes\n"
1117 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1118 "IP gateway address\n"
1119 "IP gateway interface name\n"
1120 "Null interface\n"
1121 "Distance value for this route\n"
1122 VRF_CMD_HELP_STR)
1123{
Piotr Chytłade24f822007-06-28 00:09:28 +02001124 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL,
1125 argv[1], NULL, NULL, argv[2], argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001126}
1127
1128DEFUN (no_ip_route_flags_distance_vrf,
1129 no_ip_route_flags_distance_vrf_cmd,
1130 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1131 NO_STR
1132 IP_STR
1133 "Establish static routes\n"
1134 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1135 "IP gateway address\n"
1136 "IP gateway interface name\n"
1137 "Emit an ICMP unreachable when matched\n"
1138 "Silently discard pkts when matched\n"
1139 "Distance value for this route\n"
1140 VRF_CMD_HELP_STR)
1141{
Piotr Chytłade24f822007-06-28 00:09:28 +02001142 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1],
1143 argv[2], NULL, argv[3], argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001144}
1145
1146DEFUN (no_ip_route_flags_distance2_vrf,
1147 no_ip_route_flags_distance2_vrf_cmd,
1148 "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1149 NO_STR
1150 IP_STR
1151 "Establish static routes\n"
1152 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1153 "Emit an ICMP unreachable when matched\n"
1154 "Silently discard pkts when matched\n"
1155 "Distance value for this route\n"
1156 VRF_CMD_HELP_STR)
1157{
Piotr Chytłade24f822007-06-28 00:09:28 +02001158 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL,
1159 argv[1], NULL, argv[2], argv[3]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001160}
1161
1162DEFUN (no_ip_route_mask_distance_vrf,
1163 no_ip_route_mask_distance_vrf_cmd,
1164 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1165 NO_STR
1166 IP_STR
1167 "Establish static routes\n"
1168 "IP destination prefix\n"
1169 "IP destination prefix mask\n"
1170 "IP gateway address\n"
1171 "IP gateway interface name\n"
1172 "Null interface\n"
1173 "Distance value for this route\n"
1174 VRF_CMD_HELP_STR)
1175{
Piotr Chytłade24f822007-06-28 00:09:28 +02001176 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1],
1177 argv[2], NULL, NULL, argv[3], argv[4]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001178}
1179
1180DEFUN (no_ip_route_mask_flags_distance_vrf,
1181 no_ip_route_mask_flags_distance_vrf_cmd,
1182 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1183 NO_STR
1184 IP_STR
1185 "Establish static routes\n"
1186 "IP destination prefix\n"
1187 "IP destination prefix mask\n"
1188 "IP gateway address\n"
1189 "IP gateway interface name\n"
1190 "Emit an ICMP unreachable when matched\n"
1191 "Silently discard pkts when matched\n"
1192 "Distance value for this route\n"
1193 VRF_CMD_HELP_STR)
1194{
Piotr Chytłade24f822007-06-28 00:09:28 +02001195 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2],
1196 argv[3], NULL, argv[4], argv[5]);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02001197}
1198
1199DEFUN (no_ip_route_mask_flags_distance2_vrf,
1200 no_ip_route_mask_flags_distance2_vrf_cmd,
1201 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1202 NO_STR
1203 IP_STR
1204 "Establish static routes\n"
1205 "IP destination prefix\n"
1206 "IP destination prefix mask\n"
1207 "Emit an ICMP unreachable when matched\n"
1208 "Silently discard pkts when matched\n"
1209 "Distance value for this route\n"
1210 VRF_CMD_HELP_STR)
1211{
Piotr Chytłade24f822007-06-28 00:09:28 +02001212 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL,
1213 argv[2], NULL, argv[3], argv[4]);
hasso457ef552003-05-28 12:02:15 +00001214}
1215
Paul Jakma7514fb72007-05-02 16:05:35 +00001216char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
1217
1218DEFUN (ip_protocol,
1219 ip_protocol_cmd,
1220 "ip protocol PROTO route-map ROUTE-MAP",
1221 NO_STR
1222 "Apply route map to PROTO\n"
1223 "Protocol name\n"
1224 "Route map name\n")
1225{
1226 int i;
1227
1228 if (strcasecmp(argv[0], "any") == 0)
1229 i = ZEBRA_ROUTE_MAX;
1230 else
1231 i = proto_name2num(argv[0]);
1232 if (i < 0)
1233 {
1234 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1235 VTY_NEWLINE);
1236 return CMD_WARNING;
1237 }
1238 if (proto_rm[AFI_IP][i])
1239 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1240 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
1241 return CMD_SUCCESS;
1242}
1243
1244DEFUN (no_ip_protocol,
1245 no_ip_protocol_cmd,
1246 "no ip protocol PROTO",
1247 NO_STR
1248 "Remove route map from PROTO\n"
1249 "Protocol name\n")
1250{
1251 int i;
1252
1253 if (strcasecmp(argv[0], "any") == 0)
1254 i = ZEBRA_ROUTE_MAX;
1255 else
1256 i = proto_name2num(argv[0]);
1257 if (i < 0)
1258 {
1259 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1260 VTY_NEWLINE);
1261 return CMD_WARNING;
1262 }
1263 if (proto_rm[AFI_IP][i])
1264 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1265 proto_rm[AFI_IP][i] = NULL;
1266 return CMD_SUCCESS;
1267}
1268
paul718e3742002-12-13 20:15:29 +00001269/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +00001270static void
David Lamparter3b02fe82015-01-22 19:12:35 +01001271vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +00001272{
1273 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001274 struct nexthop *nexthop, *tnexthop;
1275 int recursing;
Timo Teräs53a5c392015-05-23 11:08:40 +03001276 char buf[PREFIX_STRLEN];
paul718e3742002-12-13 20:15:29 +00001277
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001278 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001279 {
David Lamparterb7cce952015-03-07 08:40:48 +01001280 const char *mcast_info = "";
David Lamparter3b02fe82015-01-22 19:12:35 +01001281 if (mcast)
1282 {
1283 rib_table_info_t *info = rn->table->info;
1284 mcast_info = (info->safi == SAFI_MULTICAST)
1285 ? " using Multicast RIB"
1286 : " using Unicast RIB";
1287 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001288 vty_out (vty, "Routing entry for %s%s%s",
1289 prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
1290 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001291 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001292 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
Timo Teräsb11f3b52015-11-02 16:50:07 +02001293 if (rib->mtu)
1294 vty_out (vty, ", mtu %u", rib->mtu);
Piotr Chytłade24f822007-06-28 00:09:28 +02001295 vty_out (vty, ", tag %d", rib->tag);
Feng Lu4364ee52015-05-22 11:40:03 +02001296 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001297 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001298 vty_out (vty, ", best");
Timo Teräs325823a2016-01-15 17:36:31 +02001299 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE))
1300 vty_out (vty, ", fib-override");
1301 if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
1302 vty_out (vty, ", fib");
paul718e3742002-12-13 20:15:29 +00001303 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001304 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001305 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1306 vty_out (vty, ", blackhole");
1307 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1308 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001309 vty_out (vty, "%s", VTY_NEWLINE);
1310
1311#define ONE_DAY_SECOND 60*60*24
1312#define ONE_WEEK_SECOND 60*60*24*7
1313 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001314 || rib->type == ZEBRA_ROUTE_RIPNG
1315 || rib->type == ZEBRA_ROUTE_OSPF
1316 || rib->type == ZEBRA_ROUTE_OSPF6
1317 || rib->type == ZEBRA_ROUTE_BABEL
1318 || rib->type == ZEBRA_ROUTE_ISIS
1319 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001320 {
1321 time_t uptime;
1322 struct tm *tm;
1323
1324 uptime = time (NULL);
1325 uptime -= rib->uptime;
1326 tm = gmtime (&uptime);
1327
1328 vty_out (vty, " Last update ");
1329
1330 if (uptime < ONE_DAY_SECOND)
1331 vty_out (vty, "%02d:%02d:%02d",
1332 tm->tm_hour, tm->tm_min, tm->tm_sec);
1333 else if (uptime < ONE_WEEK_SECOND)
1334 vty_out (vty, "%dd%02dh%02dm",
1335 tm->tm_yday, tm->tm_hour, tm->tm_min);
1336 else
1337 vty_out (vty, "%02dw%dd%02dh",
1338 tm->tm_yday/7,
1339 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1340 vty_out (vty, " ago%s", VTY_NEWLINE);
1341 }
1342
Christian Frankefa713d92013-07-05 15:35:37 +00001343 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001344 {
Timo Teräs7e73eb72016-04-09 17:22:32 +03001345 vty_out (vty, " %c%c%s",
1346 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? '>' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001347 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1348 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001349
Timo Teräs53a5c392015-05-23 11:08:40 +03001350 switch (nexthop->type)
1351 {
1352 case NEXTHOP_TYPE_IPV4:
1353 case NEXTHOP_TYPE_IPV4_IFINDEX:
1354 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1355 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001356 vty_out (vty, ", via %s",
1357 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001358 break;
1359 case NEXTHOP_TYPE_IPV6:
1360 case NEXTHOP_TYPE_IPV6_IFINDEX:
1361 case NEXTHOP_TYPE_IPV6_IFNAME:
1362 vty_out (vty, " %s",
1363 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1364 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1365 vty_out (vty, ", %s", nexthop->ifname);
1366 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001367 vty_out (vty, ", via %s",
1368 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001369 break;
1370 case NEXTHOP_TYPE_IFINDEX:
1371 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001372 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001373 break;
1374 case NEXTHOP_TYPE_IFNAME:
1375 vty_out (vty, " directly connected, %s", nexthop->ifname);
1376 break;
1377 case NEXTHOP_TYPE_BLACKHOLE:
1378 vty_out (vty, " directly connected, Null0");
1379 break;
1380 default:
1381 break;
1382 }
1383 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1384 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001385
Timo Teräs53a5c392015-05-23 11:08:40 +03001386 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1387 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001388
Timo Teräs53a5c392015-05-23 11:08:40 +03001389 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1390 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001391
Timo Teräs53a5c392015-05-23 11:08:40 +03001392 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001393 {
1394 case NEXTHOP_TYPE_IPV4:
1395 case NEXTHOP_TYPE_IPV4_IFINDEX:
1396 case NEXTHOP_TYPE_IPV4_IFNAME:
1397 if (nexthop->src.ipv4.s_addr)
1398 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001399 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1400 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001401 }
1402 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001403#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001404 case NEXTHOP_TYPE_IPV6:
1405 case NEXTHOP_TYPE_IPV6_IFINDEX:
1406 case NEXTHOP_TYPE_IPV6_IFNAME:
1407 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1408 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001409 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1410 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001411 }
1412 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001413#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001414 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001415 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001416 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001417 vty_out (vty, "%s", VTY_NEWLINE);
1418 }
paul718e3742002-12-13 20:15:29 +00001419 vty_out (vty, "%s", VTY_NEWLINE);
1420 }
1421}
1422
paula1ac18c2005-06-28 17:17:12 +00001423static void
paul718e3742002-12-13 20:15:29 +00001424vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1425{
Christian Frankefa713d92013-07-05 15:35:37 +00001426 struct nexthop *nexthop, *tnexthop;
1427 int recursing;
paul718e3742002-12-13 20:15:29 +00001428 int len = 0;
1429 char buf[BUFSIZ];
1430
1431 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001432 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001433 {
1434 if (nexthop == rib->nexthop)
1435 {
1436 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001437 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001438 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001439 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1440 ? '>' : ' ',
1441 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1442 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001443 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001444
1445 /* Distance and metric display. */
1446 if (rib->type != ZEBRA_ROUTE_CONNECT
1447 && rib->type != ZEBRA_ROUTE_KERNEL)
1448 len += vty_out (vty, " [%d/%d]", rib->distance,
1449 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001450
1451 if (rib->vrf_id != VRF_DEFAULT)
1452 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001453 }
1454 else
1455 vty_out (vty, " %c%*c",
1456 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1457 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001458 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001459
1460 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001461 {
1462 case NEXTHOP_TYPE_IPV4:
1463 case NEXTHOP_TYPE_IPV4_IFINDEX:
1464 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1465 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001466 vty_out (vty, ", %s",
1467 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001468 break;
1469 case NEXTHOP_TYPE_IPV6:
1470 case NEXTHOP_TYPE_IPV6_IFINDEX:
1471 case NEXTHOP_TYPE_IPV6_IFNAME:
1472 vty_out (vty, " via %s",
1473 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1474 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1475 vty_out (vty, ", %s", nexthop->ifname);
1476 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001477 vty_out (vty, ", %s",
1478 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001479 break;
1480 case NEXTHOP_TYPE_IFINDEX:
1481 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001482 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001483 break;
1484 case NEXTHOP_TYPE_IFNAME:
1485 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1486 break;
1487 case NEXTHOP_TYPE_BLACKHOLE:
1488 vty_out (vty, " is directly connected, Null0");
1489 break;
1490 default:
1491 break;
1492 }
paul718e3742002-12-13 20:15:29 +00001493 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001494 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001495
Christian Frankee8d3d292013-07-05 15:35:39 +00001496 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001497 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001498
paul718e3742002-12-13 20:15:29 +00001499 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001500 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001501
Paul Jakma7514fb72007-05-02 16:05:35 +00001502 switch (nexthop->type)
1503 {
1504 case NEXTHOP_TYPE_IPV4:
1505 case NEXTHOP_TYPE_IPV4_IFINDEX:
1506 case NEXTHOP_TYPE_IPV4_IFNAME:
1507 if (nexthop->src.ipv4.s_addr)
1508 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001509 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001510 vty_out (vty, ", src %s", buf);
1511 }
1512 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001513#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001514 case NEXTHOP_TYPE_IPV6:
1515 case NEXTHOP_TYPE_IPV6_IFINDEX:
1516 case NEXTHOP_TYPE_IPV6_IFNAME:
1517 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1518 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001519 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001520 vty_out (vty, ", src %s", buf);
1521 }
1522 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001523#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001524 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001525 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001526 }
paul718e3742002-12-13 20:15:29 +00001527
hasso81dfcaa2003-05-25 19:21:25 +00001528 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1529 vty_out (vty, ", bh");
1530 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1531 vty_out (vty, ", rej");
1532
paul718e3742002-12-13 20:15:29 +00001533 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001534 || rib->type == ZEBRA_ROUTE_RIPNG
1535 || rib->type == ZEBRA_ROUTE_OSPF
1536 || rib->type == ZEBRA_ROUTE_OSPF6
1537 || rib->type == ZEBRA_ROUTE_BABEL
1538 || rib->type == ZEBRA_ROUTE_ISIS
1539 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001540 {
1541 time_t uptime;
1542 struct tm *tm;
1543
1544 uptime = time (NULL);
1545 uptime -= rib->uptime;
1546 tm = gmtime (&uptime);
1547
1548#define ONE_DAY_SECOND 60*60*24
1549#define ONE_WEEK_SECOND 60*60*24*7
1550
1551 if (uptime < ONE_DAY_SECOND)
1552 vty_out (vty, ", %02d:%02d:%02d",
1553 tm->tm_hour, tm->tm_min, tm->tm_sec);
1554 else if (uptime < ONE_WEEK_SECOND)
1555 vty_out (vty, ", %dd%02dh%02dm",
1556 tm->tm_yday, tm->tm_hour, tm->tm_min);
1557 else
1558 vty_out (vty, ", %02dw%dd%02dh",
1559 tm->tm_yday/7,
1560 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1561 }
1562 vty_out (vty, "%s", VTY_NEWLINE);
1563 }
1564}
1565
paul718e3742002-12-13 20:15:29 +00001566DEFUN (show_ip_route,
1567 show_ip_route_cmd,
1568 "show ip route",
1569 SHOW_STR
1570 IP_STR
1571 "IP routing table\n")
1572{
Feng Lu4364ee52015-05-22 11:40:03 +02001573 vrf_id_t vrf_id = VRF_DEFAULT;
1574
1575 if (argc > 0)
1576 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1577
1578 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001579}
1580
Feng Lu4364ee52015-05-22 11:40:03 +02001581static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1582{
paul718e3742002-12-13 20:15:29 +00001583 struct route_table *table;
1584 struct route_node *rn;
1585 struct rib *rib;
1586 int first = 1;
1587
Feng Lu4364ee52015-05-22 11:40:03 +02001588 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001589 if (! table)
1590 return CMD_SUCCESS;
1591
1592 /* Show all IPv4 routes. */
1593 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001594 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001595 {
1596 if (first)
1597 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001598 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001599 first = 0;
1600 }
1601 vty_show_ip_route (vty, rn, rib);
1602 }
1603 return CMD_SUCCESS;
1604}
1605
Feng Lu4364ee52015-05-22 11:40:03 +02001606ALIAS (show_ip_route,
1607 show_ip_route_vrf_cmd,
1608 "show ip route " VRF_CMD_STR,
1609 SHOW_STR
1610 IP_STR
1611 "IP routing table\n"
1612 VRF_CMD_HELP_STR)
1613
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05001614DEFUN (show_ip_nht,
1615 show_ip_nht_cmd,
1616 "show ip nht",
1617 SHOW_STR
1618 IP_STR
1619 "IP nexthop tracking table\n")
1620{
1621 zebra_print_rnh_table(0, AF_INET, vty);
1622 return CMD_SUCCESS;
1623}
1624
1625DEFUN (show_ipv6_nht,
1626 show_ipv6_nht_cmd,
1627 "show ipv6 nht",
1628 SHOW_STR
1629 IP_STR
1630 "IPv6 nexthop tracking table\n")
1631{
1632 zebra_print_rnh_table(0, AF_INET6, vty);
1633 return CMD_SUCCESS;
1634}
1635
paul718e3742002-12-13 20:15:29 +00001636DEFUN (show_ip_route_prefix_longer,
1637 show_ip_route_prefix_longer_cmd,
1638 "show ip route A.B.C.D/M longer-prefixes",
1639 SHOW_STR
1640 IP_STR
1641 "IP routing table\n"
1642 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1643 "Show route matching the specified Network/Mask pair only\n")
1644{
1645 struct route_table *table;
1646 struct route_node *rn;
1647 struct rib *rib;
1648 struct prefix p;
1649 int ret;
1650 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001651 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001652
1653 ret = str2prefix (argv[0], &p);
1654 if (! ret)
1655 {
1656 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1657 return CMD_WARNING;
1658 }
Feng Lu4364ee52015-05-22 11:40:03 +02001659
1660 if (argc > 1)
1661 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1662
1663 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001664 if (! table)
1665 return CMD_SUCCESS;
1666
1667 /* Show matched type IPv4 routes. */
1668 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001669 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001670 if (prefix_match (&p, &rn->p))
1671 {
1672 if (first)
1673 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001674 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001675 first = 0;
1676 }
1677 vty_show_ip_route (vty, rn, rib);
1678 }
1679 return CMD_SUCCESS;
1680}
1681
Feng Lu4364ee52015-05-22 11:40:03 +02001682ALIAS (show_ip_route_prefix_longer,
1683 show_ip_route_prefix_longer_vrf_cmd,
1684 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1685 SHOW_STR
1686 IP_STR
1687 "IP routing table\n"
1688 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1689 "Show route matching the specified Network/Mask pair only\n"
1690 VRF_CMD_HELP_STR)
1691
paul718e3742002-12-13 20:15:29 +00001692DEFUN (show_ip_route_supernets,
1693 show_ip_route_supernets_cmd,
1694 "show ip route supernets-only",
1695 SHOW_STR
1696 IP_STR
1697 "IP routing table\n"
1698 "Show supernet entries only\n")
1699{
1700 struct route_table *table;
1701 struct route_node *rn;
1702 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001703 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001704 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001705 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001706
Feng Lu4364ee52015-05-22 11:40:03 +02001707 if (argc > 0)
1708 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1709
1710 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001711 if (! table)
1712 return CMD_SUCCESS;
1713
1714 /* Show matched type IPv4 routes. */
1715 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001716 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001717 {
1718 addr = ntohl (rn->p.u.prefix4.s_addr);
1719
1720 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1721 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001722 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001723 {
1724 if (first)
1725 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001726 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001727 first = 0;
1728 }
1729 vty_show_ip_route (vty, rn, rib);
1730 }
1731 }
1732 return CMD_SUCCESS;
1733}
1734
Feng Lu4364ee52015-05-22 11:40:03 +02001735ALIAS (show_ip_route_supernets,
1736 show_ip_route_supernets_vrf_cmd,
1737 "show ip route supernets-only " VRF_CMD_STR,
1738 SHOW_STR
1739 IP_STR
1740 "IP routing table\n"
1741 "Show supernet entries only\n"
1742 VRF_CMD_HELP_STR)
1743
paul718e3742002-12-13 20:15:29 +00001744DEFUN (show_ip_route_protocol,
1745 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001746 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001747 SHOW_STR
1748 IP_STR
1749 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001750 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001751{
1752 int type;
1753 struct route_table *table;
1754 struct route_node *rn;
1755 struct rib *rib;
1756 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001757 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001758
David Lampartere0ca5fd2009-09-16 01:52:42 +02001759 type = proto_redistnum (AFI_IP, argv[0]);
1760 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001761 {
1762 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1763 return CMD_WARNING;
1764 }
Feng Lu4364ee52015-05-22 11:40:03 +02001765
1766 if (argc > 1)
1767 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1768
1769 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001770 if (! table)
1771 return CMD_SUCCESS;
1772
1773 /* Show matched type IPv4 routes. */
1774 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001775 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001776 if (rib->type == type)
1777 {
1778 if (first)
1779 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001780 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001781 first = 0;
1782 }
1783 vty_show_ip_route (vty, rn, rib);
1784 }
1785 return CMD_SUCCESS;
1786}
1787
Feng Lu4364ee52015-05-22 11:40:03 +02001788ALIAS (show_ip_route_protocol,
1789 show_ip_route_protocol_vrf_cmd,
1790 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1791 SHOW_STR
1792 IP_STR
1793 "IP routing table\n"
1794 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1795 VRF_CMD_HELP_STR)
1796
paul718e3742002-12-13 20:15:29 +00001797DEFUN (show_ip_route_addr,
1798 show_ip_route_addr_cmd,
1799 "show ip route A.B.C.D",
1800 SHOW_STR
1801 IP_STR
1802 "IP routing table\n"
1803 "Network in the IP routing table to display\n")
1804{
1805 int ret;
1806 struct prefix_ipv4 p;
1807 struct route_table *table;
1808 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001809 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001810
1811 ret = str2prefix_ipv4 (argv[0], &p);
1812 if (ret <= 0)
1813 {
1814 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1815 return CMD_WARNING;
1816 }
1817
Feng Lu4364ee52015-05-22 11:40:03 +02001818 if (argc > 1)
1819 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1820
1821 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001822 if (! table)
1823 return CMD_SUCCESS;
1824
1825 rn = route_node_match (table, (struct prefix *) &p);
1826 if (! rn)
1827 {
1828 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1829 return CMD_WARNING;
1830 }
1831
David Lamparter3b02fe82015-01-22 19:12:35 +01001832 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001833
1834 route_unlock_node (rn);
1835
1836 return CMD_SUCCESS;
1837}
1838
Feng Lu4364ee52015-05-22 11:40:03 +02001839ALIAS (show_ip_route_addr,
1840 show_ip_route_addr_vrf_cmd,
1841 "show ip route A.B.C.D " VRF_CMD_STR,
1842 SHOW_STR
1843 IP_STR
1844 "IP routing table\n"
1845 "Network in the IP routing table to display\n"
1846 VRF_CMD_HELP_STR)
1847
paul718e3742002-12-13 20:15:29 +00001848DEFUN (show_ip_route_prefix,
1849 show_ip_route_prefix_cmd,
1850 "show ip route A.B.C.D/M",
1851 SHOW_STR
1852 IP_STR
1853 "IP routing table\n"
1854 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1855{
1856 int ret;
1857 struct prefix_ipv4 p;
1858 struct route_table *table;
1859 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001860 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001861
1862 ret = str2prefix_ipv4 (argv[0], &p);
1863 if (ret <= 0)
1864 {
1865 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1866 return CMD_WARNING;
1867 }
1868
Feng Lu4364ee52015-05-22 11:40:03 +02001869 if (argc > 1)
1870 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1871
1872 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001873 if (! table)
1874 return CMD_SUCCESS;
1875
1876 rn = route_node_match (table, (struct prefix *) &p);
1877 if (! rn || rn->p.prefixlen != p.prefixlen)
1878 {
1879 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001880 if (rn)
1881 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001882 return CMD_WARNING;
1883 }
1884
David Lamparter3b02fe82015-01-22 19:12:35 +01001885 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001886
1887 route_unlock_node (rn);
1888
1889 return CMD_SUCCESS;
1890}
1891
Feng Lu4364ee52015-05-22 11:40:03 +02001892ALIAS (show_ip_route_prefix,
1893 show_ip_route_prefix_vrf_cmd,
1894 "show ip route A.B.C.D/M " VRF_CMD_STR,
1895 SHOW_STR
1896 IP_STR
1897 "IP routing table\n"
1898 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1899 VRF_CMD_HELP_STR)
1900
paula1ac18c2005-06-28 17:17:12 +00001901static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001902vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001903{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001904 struct route_node *rn;
1905 struct rib *rib;
1906 struct nexthop *nexthop;
1907#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1908#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1909 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1910 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1911 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001912
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001913 memset (&rib_cnt, 0, sizeof(rib_cnt));
1914 memset (&fib_cnt, 0, sizeof(fib_cnt));
1915 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001916 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001917 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1918 {
1919 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1920 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001921 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1922 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001923 {
1924 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1925 fib_cnt[rib->type]++;
1926 }
1927 if (rib->type == ZEBRA_ROUTE_BGP &&
1928 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1929 {
1930 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001931 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1932 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001933 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1934 }
1935 }
paul718e3742002-12-13 20:15:29 +00001936
Feng Lu4364ee52015-05-22 11:40:03 +02001937 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1938 "Route Source", "Routes", "FIB",
1939 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1940 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001941
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001942 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1943 {
1944 if (rib_cnt[i] > 0)
1945 {
1946 if (i == ZEBRA_ROUTE_BGP)
1947 {
1948 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1949 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1950 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1951 VTY_NEWLINE);
1952 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1953 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1954 VTY_NEWLINE);
1955 }
1956 else
1957 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1958 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1959 }
1960 }
paul718e3742002-12-13 20:15:29 +00001961
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001962 vty_out (vty, "------%s", VTY_NEWLINE);
1963 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1964 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001965 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001966}
1967
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001968/*
1969 * Implementation of the ip route summary prefix command.
1970 *
1971 * This command prints the primary prefixes that have been installed by various
1972 * protocols on the box.
1973 *
1974 */
1975static void
1976vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1977{
1978 struct route_node *rn;
1979 struct rib *rib;
1980 struct nexthop *nexthop;
1981#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1982#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1983 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1984 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1985 u_int32_t i;
1986 int cnt;
1987
1988 memset (&rib_cnt, 0, sizeof(rib_cnt));
1989 memset (&fib_cnt, 0, sizeof(fib_cnt));
1990 for (rn = route_top (table); rn; rn = route_next (rn))
1991 RNODE_FOREACH_RIB (rn, rib)
1992 {
1993
1994 /*
1995 * In case of ECMP, count only once.
1996 */
1997 cnt = 0;
1998 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1999 {
2000 cnt++;
2001 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
2002 rib_cnt[rib->type]++;
2003 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2004 {
2005 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
2006 fib_cnt[rib->type]++;
2007 }
2008 if (rib->type == ZEBRA_ROUTE_BGP &&
2009 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
2010 {
2011 rib_cnt[ZEBRA_ROUTE_IBGP]++;
2012 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2013 fib_cnt[ZEBRA_ROUTE_IBGP]++;
2014 }
2015 }
2016 }
2017
Feng Lu4364ee52015-05-22 11:40:03 +02002018 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
2019 "Route Source", "Prefix Routes", "FIB",
2020 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
2021 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002022
2023 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2024 {
2025 if (rib_cnt[i] > 0)
2026 {
2027 if (i == ZEBRA_ROUTE_BGP)
2028 {
2029 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2030 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2031 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2032 VTY_NEWLINE);
2033 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2034 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2035 VTY_NEWLINE);
2036 }
2037 else
2038 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2039 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2040 }
2041 }
2042
2043 vty_out (vty, "------%s", VTY_NEWLINE);
2044 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2045 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002046 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002047}
2048
paul718e3742002-12-13 20:15:29 +00002049/* Show route summary. */
2050DEFUN (show_ip_route_summary,
2051 show_ip_route_summary_cmd,
2052 "show ip route summary",
2053 SHOW_STR
2054 IP_STR
2055 "IP routing table\n"
2056 "Summary of all routes\n")
2057{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002058 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002059 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002060
Feng Lu4364ee52015-05-22 11:40:03 +02002061 if (argc > 0)
2062 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2063
2064 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002065 if (! table)
2066 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002067
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002068 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002069
2070 return CMD_SUCCESS;
2071}
2072
Feng Lu4364ee52015-05-22 11:40:03 +02002073ALIAS (show_ip_route_summary,
2074 show_ip_route_summary_vrf_cmd,
2075 "show ip route summary " VRF_CMD_STR,
2076 SHOW_STR
2077 IP_STR
2078 "IP routing table\n"
2079 "Summary of all routes\n"
2080 VRF_CMD_HELP_STR)
2081
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002082/* Show route summary prefix. */
2083DEFUN (show_ip_route_summary_prefix,
2084 show_ip_route_summary_prefix_cmd,
2085 "show ip route summary prefix",
2086 SHOW_STR
2087 IP_STR
2088 "IP routing table\n"
2089 "Summary of all routes\n"
2090 "Prefix routes\n")
2091{
2092 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002093 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002094
Feng Lu4364ee52015-05-22 11:40:03 +02002095 if (argc > 0)
2096 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2097
2098 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002099 if (! table)
2100 return CMD_SUCCESS;
2101
2102 vty_show_ip_route_summary_prefix (vty, table);
2103
2104 return CMD_SUCCESS;
2105}
2106
Feng Lu4364ee52015-05-22 11:40:03 +02002107ALIAS (show_ip_route_summary_prefix,
2108 show_ip_route_summary_prefix_vrf_cmd,
2109 "show ip route summary prefix " VRF_CMD_STR,
2110 SHOW_STR
2111 IP_STR
2112 "IP routing table\n"
2113 "Summary of all routes\n"
2114 "Prefix routes\n"
2115 VRF_CMD_HELP_STR)
2116
2117DEFUN (show_ip_route_vrf_all,
2118 show_ip_route_vrf_all_cmd,
2119 "show ip route " VRF_ALL_CMD_STR,
2120 SHOW_STR
2121 IP_STR
2122 "IP routing table\n"
2123 VRF_ALL_CMD_HELP_STR)
2124{
2125 struct route_table *table;
2126 struct route_node *rn;
2127 struct rib *rib;
2128 struct zebra_vrf *zvrf;
2129 vrf_iter_t iter;
2130 int first = 1;
2131
2132 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2133 {
2134 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2135 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2136 continue;
2137
2138 /* Show all IPv4 routes. */
2139 for (rn = route_top (table); rn; rn = route_next (rn))
2140 RNODE_FOREACH_RIB (rn, rib)
2141 {
2142 if (first)
2143 {
2144 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2145 first = 0;
2146 }
2147 vty_show_ip_route (vty, rn, rib);
2148 }
2149 }
2150
2151 return CMD_SUCCESS;
2152}
2153
2154DEFUN (show_ip_route_prefix_longer_vrf_all,
2155 show_ip_route_prefix_longer_vrf_all_cmd,
2156 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2157 SHOW_STR
2158 IP_STR
2159 "IP routing table\n"
2160 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2161 "Show route matching the specified Network/Mask pair only\n"
2162 VRF_ALL_CMD_HELP_STR)
2163{
2164 struct route_table *table;
2165 struct route_node *rn;
2166 struct rib *rib;
2167 struct prefix p;
2168 struct zebra_vrf *zvrf;
2169 vrf_iter_t iter;
2170 int ret;
2171 int first = 1;
2172
2173 ret = str2prefix (argv[0], &p);
2174 if (! ret)
2175 {
2176 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2177 return CMD_WARNING;
2178 }
2179
2180 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2181 {
2182 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2183 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2184 continue;
2185
2186 /* Show matched type IPv4 routes. */
2187 for (rn = route_top (table); rn; rn = route_next (rn))
2188 RNODE_FOREACH_RIB (rn, rib)
2189 if (prefix_match (&p, &rn->p))
2190 {
2191 if (first)
2192 {
2193 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2194 first = 0;
2195 }
2196 vty_show_ip_route (vty, rn, rib);
2197 }
2198 }
2199
2200 return CMD_SUCCESS;
2201}
2202
2203DEFUN (show_ip_route_supernets_vrf_all,
2204 show_ip_route_supernets_vrf_all_cmd,
2205 "show ip route supernets-only " VRF_ALL_CMD_STR,
2206 SHOW_STR
2207 IP_STR
2208 "IP routing table\n"
2209 "Show supernet entries only\n"
2210 VRF_ALL_CMD_HELP_STR)
2211{
2212 struct route_table *table;
2213 struct route_node *rn;
2214 struct rib *rib;
2215 struct zebra_vrf *zvrf;
2216 vrf_iter_t iter;
2217 u_int32_t addr;
2218 int first = 1;
2219
2220 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2221 {
2222 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2223 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2224 continue;
2225
2226 /* Show matched type IPv4 routes. */
2227 for (rn = route_top (table); rn; rn = route_next (rn))
2228 RNODE_FOREACH_RIB (rn, rib)
2229 {
2230 addr = ntohl (rn->p.u.prefix4.s_addr);
2231
2232 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2233 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2234 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2235 {
2236 if (first)
2237 {
2238 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2239 first = 0;
2240 }
2241 vty_show_ip_route (vty, rn, rib);
2242 }
2243 }
2244 }
2245
2246 return CMD_SUCCESS;
2247}
2248
2249DEFUN (show_ip_route_protocol_vrf_all,
2250 show_ip_route_protocol_vrf_all_cmd,
2251 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2252 SHOW_STR
2253 IP_STR
2254 "IP routing table\n"
2255 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2256 VRF_ALL_CMD_HELP_STR)
2257{
2258 int type;
2259 struct route_table *table;
2260 struct route_node *rn;
2261 struct rib *rib;
2262 struct zebra_vrf *zvrf;
2263 vrf_iter_t iter;
2264 int first = 1;
2265
2266 type = proto_redistnum (AFI_IP, argv[0]);
2267 if (type < 0)
2268 {
2269 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2270 return CMD_WARNING;
2271 }
2272
2273 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2274 {
2275 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2276 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2277 continue;
2278
2279 /* Show matched type IPv4 routes. */
2280 for (rn = route_top (table); rn; rn = route_next (rn))
2281 RNODE_FOREACH_RIB (rn, rib)
2282 if (rib->type == type)
2283 {
2284 if (first)
2285 {
2286 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2287 first = 0;
2288 }
2289 vty_show_ip_route (vty, rn, rib);
2290 }
2291 }
2292
2293 return CMD_SUCCESS;
2294}
2295
2296DEFUN (show_ip_route_addr_vrf_all,
2297 show_ip_route_addr_vrf_all_cmd,
2298 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2299 SHOW_STR
2300 IP_STR
2301 "IP routing table\n"
2302 "Network in the IP routing table to display\n"
2303 VRF_ALL_CMD_HELP_STR)
2304{
2305 int ret;
2306 struct prefix_ipv4 p;
2307 struct route_table *table;
2308 struct route_node *rn;
2309 struct zebra_vrf *zvrf;
2310 vrf_iter_t iter;
2311
2312 ret = str2prefix_ipv4 (argv[0], &p);
2313 if (ret <= 0)
2314 {
2315 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2316 return CMD_WARNING;
2317 }
2318
2319 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2320 {
2321 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2322 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2323 continue;
2324
2325 rn = route_node_match (table, (struct prefix *) &p);
2326 if (! rn)
2327 continue;
2328
2329 vty_show_ip_route_detail (vty, rn, 0);
2330
2331 route_unlock_node (rn);
2332 }
2333
2334 return CMD_SUCCESS;
2335}
2336
2337DEFUN (show_ip_route_prefix_vrf_all,
2338 show_ip_route_prefix_vrf_all_cmd,
2339 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2340 SHOW_STR
2341 IP_STR
2342 "IP routing table\n"
2343 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2344 VRF_ALL_CMD_HELP_STR)
2345{
2346 int ret;
2347 struct prefix_ipv4 p;
2348 struct route_table *table;
2349 struct route_node *rn;
2350 struct zebra_vrf *zvrf;
2351 vrf_iter_t iter;
2352
2353 ret = str2prefix_ipv4 (argv[0], &p);
2354 if (ret <= 0)
2355 {
2356 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2357 return CMD_WARNING;
2358 }
2359
2360 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2361 {
2362 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2363 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2364 continue;
2365
2366 rn = route_node_match (table, (struct prefix *) &p);
2367 if (! rn)
2368 continue;
2369 if (rn->p.prefixlen != p.prefixlen)
2370 {
2371 route_unlock_node (rn);
2372 continue;
2373 }
2374
2375 vty_show_ip_route_detail (vty, rn, 0);
2376
2377 route_unlock_node (rn);
2378 }
2379
2380 return CMD_SUCCESS;
2381}
2382
2383DEFUN (show_ip_route_summary_vrf_all,
2384 show_ip_route_summary_vrf_all_cmd,
2385 "show ip route summary " VRF_ALL_CMD_STR,
2386 SHOW_STR
2387 IP_STR
2388 "IP routing table\n"
2389 "Summary of all routes\n"
2390 VRF_ALL_CMD_HELP_STR)
2391{
2392 struct zebra_vrf *zvrf;
2393 vrf_iter_t iter;
2394
2395 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2396 if ((zvrf = vrf_iter2info (iter)) != NULL)
2397 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2398
2399 return CMD_SUCCESS;
2400}
2401
2402DEFUN (show_ip_route_summary_prefix_vrf_all,
2403 show_ip_route_summary_prefix_vrf_all_cmd,
2404 "show ip route summary prefix " VRF_ALL_CMD_STR,
2405 SHOW_STR
2406 IP_STR
2407 "IP routing table\n"
2408 "Summary of all routes\n"
2409 "Prefix routes\n"
2410 VRF_ALL_CMD_HELP_STR)
2411{
2412 struct zebra_vrf *zvrf;
2413 vrf_iter_t iter;
2414
2415 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2416 if ((zvrf = vrf_iter2info (iter)) != NULL)
2417 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2418
2419 return CMD_SUCCESS;
2420}
2421
paul718e3742002-12-13 20:15:29 +00002422/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002423static int
Everton Marques33d86db2014-07-14 11:19:00 -03002424static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002425{
2426 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05002427 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00002428 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002429 struct zebra_vrf *zvrf;
2430 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002431 int write;
2432
2433 write = 0;
2434
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002435 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2436 {
2437 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2438 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2439 continue;
paul718e3742002-12-13 20:15:29 +00002440
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002441 for (rn = route_top (stable); rn; rn = route_next (rn))
2442 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002443 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002444 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2445 rn->p.prefixlen);
2446
2447 switch (si->type)
2448 {
2449 case STATIC_IPV4_GATEWAY:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002450 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002451 break;
2452 case STATIC_IPV4_IFNAME:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002453 vty_out (vty, " %s", si->ifname);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002454 break;
2455 case STATIC_IPV4_BLACKHOLE:
2456 vty_out (vty, " Null0");
2457 break;
2458 }
2459
2460 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2461 if (si->type != STATIC_IPV4_BLACKHOLE)
2462 {
2463 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2464 vty_out (vty, " %s", "reject");
2465
2466 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2467 vty_out (vty, " %s", "blackhole");
2468 }
2469
Piotr Chytłade24f822007-06-28 00:09:28 +02002470 if (si->tag)
2471 vty_out (vty, " tag %d", si->tag);
2472
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002473 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2474 vty_out (vty, " %d", si->distance);
2475
2476 if (si->vrf_id != VRF_DEFAULT)
2477 vty_out (vty, " vrf %u", si->vrf_id);
2478
2479 vty_out (vty, "%s", VTY_NEWLINE);
2480
2481 write = 1;
paul7021c422003-07-15 12:52:22 +00002482 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002483 }
paul718e3742002-12-13 20:15:29 +00002484 return write;
2485}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002486
2487DEFUN (show_ip_protocol,
2488 show_ip_protocol_cmd,
2489 "show ip protocol",
2490 SHOW_STR
2491 IP_STR
2492 "IP protocol filtering status\n")
2493{
2494 int i;
2495
2496 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2497 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2498 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2499 {
2500 if (proto_rm[AFI_IP][i])
2501 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2502 proto_rm[AFI_IP][i],
2503 VTY_NEWLINE);
2504 else
2505 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2506 }
2507 if (proto_rm[AFI_IP][i])
2508 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2509 VTY_NEWLINE);
2510 else
2511 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2512
2513 return CMD_SUCCESS;
2514}
2515
paul718e3742002-12-13 20:15:29 +00002516/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002517static int
hasso39db97e2004-10-12 20:50:58 +00002518static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2519 const char *gate_str, const char *ifname,
Piotr Chytłade24f822007-06-28 00:09:28 +02002520 const char *flag_str, const char *tag_str,
2521 const char *distance_str, const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002522{
2523 int ret;
2524 u_char distance;
2525 struct prefix p;
2526 struct in6_addr *gate = NULL;
2527 struct in6_addr gate_addr;
2528 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002529 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002530 u_char flag = 0;
Piotr Chytłade24f822007-06-28 00:09:28 +02002531 u_short tag = 0;
paul718e3742002-12-13 20:15:29 +00002532
2533 ret = str2prefix (dest_str, &p);
2534 if (ret <= 0)
2535 {
2536 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2537 return CMD_WARNING;
2538 }
2539
2540 /* Apply mask for given prefix. */
2541 apply_mask (&p);
2542
hasso81dfcaa2003-05-25 19:21:25 +00002543 /* Route flags */
2544 if (flag_str) {
2545 switch(flag_str[0]) {
2546 case 'r':
2547 case 'R': /* XXX */
2548 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2549 break;
2550 case 'b':
2551 case 'B': /* XXX */
2552 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2553 break;
2554 default:
2555 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002556 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002557 }
2558 }
2559
paul718e3742002-12-13 20:15:29 +00002560 /* Administrative distance. */
2561 if (distance_str)
2562 distance = atoi (distance_str);
2563 else
2564 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2565
Piotr Chytłade24f822007-06-28 00:09:28 +02002566 /* tag */
2567 if (tag_str)
2568 tag = atoi (tag_str);
2569
paul718e3742002-12-13 20:15:29 +00002570 /* When gateway is valid IPv6 addrees, then gate is treated as
2571 nexthop address other case gate is treated as interface name. */
2572 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2573
2574 if (ifname)
2575 {
2576 /* When ifname is specified. It must be come with gateway
2577 address. */
2578 if (ret != 1)
2579 {
2580 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2581 return CMD_WARNING;
2582 }
2583 type = STATIC_IPV6_GATEWAY_IFNAME;
2584 gate = &gate_addr;
2585 }
2586 else
2587 {
2588 if (ret == 1)
2589 {
2590 type = STATIC_IPV6_GATEWAY;
2591 gate = &gate_addr;
2592 }
2593 else
2594 {
2595 type = STATIC_IPV6_IFNAME;
2596 ifname = gate_str;
2597 }
2598 }
2599
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002600 /* VRF id */
2601 if (vrf_id_str)
2602 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2603
paul718e3742002-12-13 20:15:29 +00002604 if (add_cmd)
Piotr Chytłade24f822007-06-28 00:09:28 +02002605 static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002606 else
Piotr Chytłade24f822007-06-28 00:09:28 +02002607 static_delete_ipv6 (&p, type, gate, ifname, tag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002608
2609 return CMD_SUCCESS;
2610}
2611
2612DEFUN (ipv6_route,
2613 ipv6_route_cmd,
2614 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2615 IP_STR
2616 "Establish static routes\n"
2617 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2618 "IPv6 gateway address\n"
2619 "IPv6 gateway interface name\n")
2620{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002621 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
Piotr Chytłade24f822007-06-28 00:09:28 +02002622 NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002623}
2624
2625DEFUN (ipv6_route_flags,
2626 ipv6_route_flags_cmd,
2627 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2628 IP_STR
2629 "Establish static routes\n"
2630 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2631 "IPv6 gateway address\n"
2632 "IPv6 gateway interface name\n"
2633 "Emit an ICMP unreachable when matched\n"
2634 "Silently discard pkts when matched\n")
2635{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002636 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
Piotr Chytłade24f822007-06-28 00:09:28 +02002637 NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002638}
2639
2640DEFUN (ipv6_route_ifname,
2641 ipv6_route_ifname_cmd,
2642 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2643 IP_STR
2644 "Establish static routes\n"
2645 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2646 "IPv6 gateway address\n"
2647 "IPv6 gateway interface name\n")
2648{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002649 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
Piotr Chytłade24f822007-06-28 00:09:28 +02002650 NULL, NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002651}
2652
2653DEFUN (ipv6_route_ifname_flags,
2654 ipv6_route_ifname_flags_cmd,
2655 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2656 IP_STR
2657 "Establish static routes\n"
2658 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2659 "IPv6 gateway address\n"
2660 "IPv6 gateway interface name\n"
2661 "Emit an ICMP unreachable when matched\n"
2662 "Silently discard pkts when matched\n")
2663{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002664 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
Piotr Chytłade24f822007-06-28 00:09:28 +02002665 NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002666}
2667
2668DEFUN (ipv6_route_pref,
2669 ipv6_route_pref_cmd,
2670 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2671 IP_STR
2672 "Establish static routes\n"
2673 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2674 "IPv6 gateway address\n"
2675 "IPv6 gateway interface name\n"
2676 "Distance value for this prefix\n")
2677{
Piotr Chytłade24f822007-06-28 00:09:28 +02002678 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002679 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002680}
2681
2682DEFUN (ipv6_route_flags_pref,
2683 ipv6_route_flags_pref_cmd,
2684 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2685 IP_STR
2686 "Establish static routes\n"
2687 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2688 "IPv6 gateway address\n"
2689 "IPv6 gateway interface name\n"
2690 "Emit an ICMP unreachable when matched\n"
2691 "Silently discard pkts when matched\n"
2692 "Distance value for this prefix\n")
2693{
Piotr Chytłade24f822007-06-28 00:09:28 +02002694 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002695 NULL);
paul718e3742002-12-13 20:15:29 +00002696}
2697
2698DEFUN (ipv6_route_ifname_pref,
2699 ipv6_route_ifname_pref_cmd,
2700 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2701 IP_STR
2702 "Establish static routes\n"
2703 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2704 "IPv6 gateway address\n"
2705 "IPv6 gateway interface name\n"
2706 "Distance value for this prefix\n")
2707{
Piotr Chytłade24f822007-06-28 00:09:28 +02002708 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002709 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002710}
2711
2712DEFUN (ipv6_route_ifname_flags_pref,
2713 ipv6_route_ifname_flags_pref_cmd,
2714 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2715 IP_STR
2716 "Establish static routes\n"
2717 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2718 "IPv6 gateway address\n"
2719 "IPv6 gateway interface name\n"
2720 "Emit an ICMP unreachable when matched\n"
2721 "Silently discard pkts when matched\n"
2722 "Distance value for this prefix\n")
2723{
Piotr Chytłade24f822007-06-28 00:09:28 +02002724 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002725 NULL);
paul718e3742002-12-13 20:15:29 +00002726}
2727
2728DEFUN (no_ipv6_route,
2729 no_ipv6_route_cmd,
2730 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2731 NO_STR
2732 IP_STR
2733 "Establish static routes\n"
2734 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2735 "IPv6 gateway address\n"
2736 "IPv6 gateway interface name\n")
2737{
Piotr Chytłade24f822007-06-28 00:09:28 +02002738 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002739 NULL);
paul718e3742002-12-13 20:15:29 +00002740}
2741
hasso81dfcaa2003-05-25 19:21:25 +00002742ALIAS (no_ipv6_route,
2743 no_ipv6_route_flags_cmd,
2744 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2745 NO_STR
2746 IP_STR
2747 "Establish static routes\n"
2748 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2749 "IPv6 gateway address\n"
2750 "IPv6 gateway interface name\n"
2751 "Emit an ICMP unreachable when matched\n"
2752 "Silently discard pkts when matched\n")
2753
paul718e3742002-12-13 20:15:29 +00002754DEFUN (no_ipv6_route_ifname,
2755 no_ipv6_route_ifname_cmd,
2756 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2757 NO_STR
2758 IP_STR
2759 "Establish static routes\n"
2760 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2761 "IPv6 gateway address\n"
2762 "IPv6 gateway interface name\n")
2763{
Piotr Chytłade24f822007-06-28 00:09:28 +02002764 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002765 NULL);
paul718e3742002-12-13 20:15:29 +00002766}
2767
hasso81dfcaa2003-05-25 19:21:25 +00002768ALIAS (no_ipv6_route_ifname,
2769 no_ipv6_route_ifname_flags_cmd,
2770 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2771 NO_STR
2772 IP_STR
2773 "Establish static routes\n"
2774 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2775 "IPv6 gateway address\n"
2776 "IPv6 gateway interface name\n"
2777 "Emit an ICMP unreachable when matched\n"
2778 "Silently discard pkts when matched\n")
2779
paul718e3742002-12-13 20:15:29 +00002780DEFUN (no_ipv6_route_pref,
2781 no_ipv6_route_pref_cmd,
2782 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2783 NO_STR
2784 IP_STR
2785 "Establish static routes\n"
2786 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2787 "IPv6 gateway address\n"
2788 "IPv6 gateway interface name\n"
2789 "Distance value for this prefix\n")
2790{
Piotr Chytłade24f822007-06-28 00:09:28 +02002791 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002792 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002793}
2794
2795DEFUN (no_ipv6_route_flags_pref,
2796 no_ipv6_route_flags_pref_cmd,
2797 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2798 NO_STR
2799 IP_STR
2800 "Establish static routes\n"
2801 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2802 "IPv6 gateway address\n"
2803 "IPv6 gateway interface name\n"
2804 "Emit an ICMP unreachable when matched\n"
2805 "Silently discard pkts when matched\n"
2806 "Distance value for this prefix\n")
2807{
2808 /* We do not care about argv[2] */
Piotr Chytłade24f822007-06-28 00:09:28 +02002809 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002810 NULL);
paul718e3742002-12-13 20:15:29 +00002811}
2812
2813DEFUN (no_ipv6_route_ifname_pref,
2814 no_ipv6_route_ifname_pref_cmd,
2815 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2816 NO_STR
2817 IP_STR
2818 "Establish static routes\n"
2819 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2820 "IPv6 gateway address\n"
2821 "IPv6 gateway interface name\n"
2822 "Distance value for this prefix\n")
2823{
Piotr Chytłade24f822007-06-28 00:09:28 +02002824 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002825 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002826}
2827
2828DEFUN (no_ipv6_route_ifname_flags_pref,
2829 no_ipv6_route_ifname_flags_pref_cmd,
2830 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2831 NO_STR
2832 IP_STR
2833 "Establish static routes\n"
2834 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2835 "IPv6 gateway address\n"
2836 "IPv6 gateway interface name\n"
2837 "Emit an ICMP unreachable when matched\n"
2838 "Silently discard pkts when matched\n"
2839 "Distance value for this prefix\n")
2840{
Piotr Chytłade24f822007-06-28 00:09:28 +02002841 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002842 NULL);
2843}
2844
2845DEFUN (ipv6_route_vrf,
2846 ipv6_route_vrf_cmd,
2847 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2848 IP_STR
2849 "Establish static routes\n"
2850 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2851 "IPv6 gateway address\n"
2852 "IPv6 gateway interface name\n"
2853 VRF_CMD_HELP_STR)
2854{
Piotr Chytłade24f822007-06-28 00:09:28 +02002855 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002856 argv[2]);
2857}
2858
2859DEFUN (ipv6_route_flags_vrf,
2860 ipv6_route_flags_vrf_cmd,
2861 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2862 IP_STR
2863 "Establish static routes\n"
2864 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2865 "IPv6 gateway address\n"
2866 "IPv6 gateway interface name\n"
2867 "Emit an ICMP unreachable when matched\n"
2868 "Silently discard pkts when matched\n"
2869 VRF_CMD_HELP_STR)
2870{
Piotr Chytłade24f822007-06-28 00:09:28 +02002871 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002872 argv[3]);
2873}
2874
2875DEFUN (ipv6_route_ifname_vrf,
2876 ipv6_route_ifname_vrf_cmd,
2877 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2878 IP_STR
2879 "Establish static routes\n"
2880 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2881 "IPv6 gateway address\n"
2882 "IPv6 gateway interface name\n"
2883 VRF_CMD_HELP_STR)
2884{
Piotr Chytłade24f822007-06-28 00:09:28 +02002885 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002886 argv[3]);
2887}
2888
2889DEFUN (ipv6_route_ifname_flags_vrf,
2890 ipv6_route_ifname_flags_vrf_cmd,
2891 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2892 IP_STR
2893 "Establish static routes\n"
2894 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2895 "IPv6 gateway address\n"
2896 "IPv6 gateway interface name\n"
2897 "Emit an ICMP unreachable when matched\n"
2898 "Silently discard pkts when matched\n"
2899 VRF_CMD_HELP_STR)
2900{
Piotr Chytłade24f822007-06-28 00:09:28 +02002901 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002902 argv[4]);
2903}
2904
2905DEFUN (ipv6_route_pref_vrf,
2906 ipv6_route_pref_vrf_cmd,
2907 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2908 IP_STR
2909 "Establish static routes\n"
2910 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2911 "IPv6 gateway address\n"
2912 "IPv6 gateway interface name\n"
2913 "Distance value for this prefix\n"
2914 VRF_CMD_HELP_STR)
2915{
Piotr Chytłade24f822007-06-28 00:09:28 +02002916 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002917 argv[3]);
2918}
2919
2920DEFUN (ipv6_route_flags_pref_vrf,
2921 ipv6_route_flags_pref_vrf_cmd,
2922 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2923 IP_STR
2924 "Establish static routes\n"
2925 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2926 "IPv6 gateway address\n"
2927 "IPv6 gateway interface name\n"
2928 "Emit an ICMP unreachable when matched\n"
2929 "Silently discard pkts when matched\n"
2930 "Distance value for this prefix\n"
2931 VRF_CMD_HELP_STR)
2932{
Piotr Chytłade24f822007-06-28 00:09:28 +02002933 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002934 argv[4]);
2935}
2936
2937DEFUN (ipv6_route_ifname_pref_vrf,
2938 ipv6_route_ifname_pref_vrf_cmd,
2939 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2940 IP_STR
2941 "Establish static routes\n"
2942 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2943 "IPv6 gateway address\n"
2944 "IPv6 gateway interface name\n"
2945 "Distance value for this prefix\n"
2946 VRF_CMD_HELP_STR)
2947{
Piotr Chytłade24f822007-06-28 00:09:28 +02002948 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002949 argv[4]);
2950}
2951
2952DEFUN (ipv6_route_ifname_flags_pref_vrf,
2953 ipv6_route_ifname_flags_pref_vrf_cmd,
2954 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
2955 IP_STR
2956 "Establish static routes\n"
2957 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2958 "IPv6 gateway address\n"
2959 "IPv6 gateway interface name\n"
2960 "Emit an ICMP unreachable when matched\n"
2961 "Silently discard pkts when matched\n"
2962 "Distance value for this prefix\n"
2963 VRF_CMD_HELP_STR)
2964{
Piotr Chytłade24f822007-06-28 00:09:28 +02002965 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002966 argv[5]);
2967}
2968
2969DEFUN (no_ipv6_route_vrf,
2970 no_ipv6_route_vrf_cmd,
2971 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2972 NO_STR
2973 IP_STR
2974 "Establish static routes\n"
2975 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2976 "IPv6 gateway address\n"
2977 "IPv6 gateway interface name\n"
2978 VRF_CMD_HELP_STR)
2979{
Piotr Chytłade24f822007-06-28 00:09:28 +02002980 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002981 (argc > 3) ? argv[3] : argv[2]);
2982}
2983
2984ALIAS (no_ipv6_route_vrf,
2985 no_ipv6_route_flags_vrf_cmd,
2986 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2987 NO_STR
2988 IP_STR
2989 "Establish static routes\n"
2990 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2991 "IPv6 gateway address\n"
2992 "IPv6 gateway interface name\n"
2993 "Emit an ICMP unreachable when matched\n"
2994 "Silently discard pkts when matched\n"
2995 VRF_CMD_HELP_STR)
2996
2997DEFUN (no_ipv6_route_ifname_vrf,
2998 no_ipv6_route_ifname_vrf_cmd,
2999 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
3000 NO_STR
3001 IP_STR
3002 "Establish static routes\n"
3003 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3004 "IPv6 gateway address\n"
3005 "IPv6 gateway interface name\n"
3006 VRF_CMD_HELP_STR)
3007{
Piotr Chytłade24f822007-06-28 00:09:28 +02003008 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003009 (argc > 4) ? argv[4] : argv[3]);
3010}
3011
3012ALIAS (no_ipv6_route_ifname_vrf,
3013 no_ipv6_route_ifname_flags_vrf_cmd,
3014 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
3015 NO_STR
3016 IP_STR
3017 "Establish static routes\n"
3018 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3019 "IPv6 gateway address\n"
3020 "IPv6 gateway interface name\n"
3021 "Emit an ICMP unreachable when matched\n"
3022 "Silently discard pkts when matched\n"
3023 VRF_CMD_HELP_STR)
3024
3025DEFUN (no_ipv6_route_pref_vrf,
3026 no_ipv6_route_pref_vrf_cmd,
3027 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
3028 NO_STR
3029 IP_STR
3030 "Establish static routes\n"
3031 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3032 "IPv6 gateway address\n"
3033 "IPv6 gateway interface name\n"
3034 "Distance value for this prefix\n"
3035 VRF_CMD_HELP_STR)
3036{
Piotr Chytłade24f822007-06-28 00:09:28 +02003037 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003038 argv[3]);
3039}
3040
3041DEFUN (no_ipv6_route_flags_pref_vrf,
3042 no_ipv6_route_flags_pref_vrf_cmd,
3043 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3044 NO_STR
3045 IP_STR
3046 "Establish static routes\n"
3047 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3048 "IPv6 gateway address\n"
3049 "IPv6 gateway interface name\n"
3050 "Emit an ICMP unreachable when matched\n"
3051 "Silently discard pkts when matched\n"
3052 "Distance value for this prefix\n"
3053 VRF_CMD_HELP_STR)
3054{
3055 /* We do not care about argv[2] */
Piotr Chytłade24f822007-06-28 00:09:28 +02003056 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003057 argv[4]);
3058}
3059
3060DEFUN (no_ipv6_route_ifname_pref_vrf,
3061 no_ipv6_route_ifname_pref_vrf_cmd,
3062 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3063 NO_STR
3064 IP_STR
3065 "Establish static routes\n"
3066 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3067 "IPv6 gateway address\n"
3068 "IPv6 gateway interface name\n"
3069 "Distance value for this prefix\n"
3070 VRF_CMD_HELP_STR)
3071{
Piotr Chytłade24f822007-06-28 00:09:28 +02003072 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003073 argv[4]);
3074}
3075
3076DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3077 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3078 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3079 NO_STR
3080 IP_STR
3081 "Establish static routes\n"
3082 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3083 "IPv6 gateway address\n"
3084 "IPv6 gateway interface name\n"
3085 "Emit an ICMP unreachable when matched\n"
3086 "Silently discard pkts when matched\n"
3087 "Distance value for this prefix\n"
3088 VRF_CMD_HELP_STR)
3089{
Piotr Chytłade24f822007-06-28 00:09:28 +02003090 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4],
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003091 argv[5]);
paul718e3742002-12-13 20:15:29 +00003092}
3093
paul718e3742002-12-13 20:15:29 +00003094DEFUN (show_ipv6_route,
3095 show_ipv6_route_cmd,
3096 "show ipv6 route",
3097 SHOW_STR
3098 IP_STR
3099 "IPv6 routing table\n")
3100{
3101 struct route_table *table;
3102 struct route_node *rn;
3103 struct rib *rib;
3104 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003105 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003106
Feng Lu4364ee52015-05-22 11:40:03 +02003107 if (argc > 0)
3108 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3109
3110 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003111 if (! table)
3112 return CMD_SUCCESS;
3113
3114 /* Show all IPv6 route. */
3115 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003116 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003117 {
3118 if (first)
3119 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003120 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003121 first = 0;
3122 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003123 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003124 }
3125 return CMD_SUCCESS;
3126}
3127
Feng Lu4364ee52015-05-22 11:40:03 +02003128ALIAS (show_ipv6_route,
3129 show_ipv6_route_vrf_cmd,
3130 "show ipv6 route " VRF_CMD_STR,
3131 SHOW_STR
3132 IP_STR
3133 "IPv6 routing table\n"
3134 VRF_CMD_HELP_STR)
3135
paul718e3742002-12-13 20:15:29 +00003136DEFUN (show_ipv6_route_prefix_longer,
3137 show_ipv6_route_prefix_longer_cmd,
3138 "show ipv6 route X:X::X:X/M longer-prefixes",
3139 SHOW_STR
3140 IP_STR
3141 "IPv6 routing table\n"
3142 "IPv6 prefix\n"
3143 "Show route matching the specified Network/Mask pair only\n")
3144{
3145 struct route_table *table;
3146 struct route_node *rn;
3147 struct rib *rib;
3148 struct prefix p;
3149 int ret;
3150 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003151 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003152
3153 ret = str2prefix (argv[0], &p);
3154 if (! ret)
3155 {
3156 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3157 return CMD_WARNING;
3158 }
3159
Feng Lu4364ee52015-05-22 11:40:03 +02003160 if (argc > 1)
3161 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3162
3163 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3164 if (! table)
3165 return CMD_SUCCESS;
3166
paul718e3742002-12-13 20:15:29 +00003167 /* Show matched type IPv6 routes. */
3168 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003169 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003170 if (prefix_match (&p, &rn->p))
3171 {
3172 if (first)
3173 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003174 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003175 first = 0;
3176 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003177 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003178 }
3179 return CMD_SUCCESS;
3180}
3181
Feng Lu4364ee52015-05-22 11:40:03 +02003182ALIAS (show_ipv6_route_prefix_longer,
3183 show_ipv6_route_prefix_longer_vrf_cmd,
3184 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3185 SHOW_STR
3186 IP_STR
3187 "IPv6 routing table\n"
3188 "IPv6 prefix\n"
3189 "Show route matching the specified Network/Mask pair only\n"
3190 VRF_CMD_HELP_STR)
3191
paul718e3742002-12-13 20:15:29 +00003192DEFUN (show_ipv6_route_protocol,
3193 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003194 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003195 SHOW_STR
3196 IP_STR
3197 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003198 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003199{
3200 int type;
3201 struct route_table *table;
3202 struct route_node *rn;
3203 struct rib *rib;
3204 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003205 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003206
David Lampartere0ca5fd2009-09-16 01:52:42 +02003207 type = proto_redistnum (AFI_IP6, argv[0]);
3208 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003209 {
3210 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3211 return CMD_WARNING;
3212 }
Feng Lu4364ee52015-05-22 11:40:03 +02003213
3214 if (argc > 1)
3215 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3216
3217 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003218 if (! table)
3219 return CMD_SUCCESS;
3220
3221 /* Show matched type IPv6 routes. */
3222 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003223 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003224 if (rib->type == type)
3225 {
3226 if (first)
3227 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003228 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003229 first = 0;
3230 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003231 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003232 }
3233 return CMD_SUCCESS;
3234}
3235
Feng Lu4364ee52015-05-22 11:40:03 +02003236ALIAS (show_ipv6_route_protocol,
3237 show_ipv6_route_protocol_vrf_cmd,
3238 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3239 SHOW_STR
3240 IP_STR
3241 "IP routing table\n"
3242 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3243 VRF_CMD_HELP_STR)
3244
paul718e3742002-12-13 20:15:29 +00003245DEFUN (show_ipv6_route_addr,
3246 show_ipv6_route_addr_cmd,
3247 "show ipv6 route X:X::X:X",
3248 SHOW_STR
3249 IP_STR
3250 "IPv6 routing table\n"
3251 "IPv6 Address\n")
3252{
3253 int ret;
3254 struct prefix_ipv6 p;
3255 struct route_table *table;
3256 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003257 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003258
3259 ret = str2prefix_ipv6 (argv[0], &p);
3260 if (ret <= 0)
3261 {
3262 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3263 return CMD_WARNING;
3264 }
3265
Feng Lu4364ee52015-05-22 11:40:03 +02003266 if (argc > 1)
3267 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3268
3269 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003270 if (! table)
3271 return CMD_SUCCESS;
3272
3273 rn = route_node_match (table, (struct prefix *) &p);
3274 if (! rn)
3275 {
3276 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3277 return CMD_WARNING;
3278 }
3279
Timo Teräs53a5c392015-05-23 11:08:40 +03003280 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003281
3282 route_unlock_node (rn);
3283
3284 return CMD_SUCCESS;
3285}
3286
Feng Lu4364ee52015-05-22 11:40:03 +02003287ALIAS (show_ipv6_route_addr,
3288 show_ipv6_route_addr_vrf_cmd,
3289 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3290 SHOW_STR
3291 IP_STR
3292 "IPv6 routing table\n"
3293 "IPv6 Address\n"
3294 VRF_CMD_HELP_STR)
3295
paul718e3742002-12-13 20:15:29 +00003296DEFUN (show_ipv6_route_prefix,
3297 show_ipv6_route_prefix_cmd,
3298 "show ipv6 route X:X::X:X/M",
3299 SHOW_STR
3300 IP_STR
3301 "IPv6 routing table\n"
3302 "IPv6 prefix\n")
3303{
3304 int ret;
3305 struct prefix_ipv6 p;
3306 struct route_table *table;
3307 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003308 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003309
3310 ret = str2prefix_ipv6 (argv[0], &p);
3311 if (ret <= 0)
3312 {
3313 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3314 return CMD_WARNING;
3315 }
3316
Feng Lu4364ee52015-05-22 11:40:03 +02003317 if (argc > 1)
3318 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3319
3320 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003321 if (! table)
3322 return CMD_SUCCESS;
3323
3324 rn = route_node_match (table, (struct prefix *) &p);
3325 if (! rn || rn->p.prefixlen != p.prefixlen)
3326 {
3327 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003328 if (rn)
3329 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003330 return CMD_WARNING;
3331 }
3332
Timo Teräs53a5c392015-05-23 11:08:40 +03003333 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003334
3335 route_unlock_node (rn);
3336
3337 return CMD_SUCCESS;
3338}
3339
Feng Lu4364ee52015-05-22 11:40:03 +02003340ALIAS (show_ipv6_route_prefix,
3341 show_ipv6_route_prefix_vrf_cmd,
3342 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3343 SHOW_STR
3344 IP_STR
3345 "IPv6 routing table\n"
3346 "IPv6 prefix\n"
3347 VRF_CMD_HELP_STR)
3348
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003349/* Show route summary. */
3350DEFUN (show_ipv6_route_summary,
3351 show_ipv6_route_summary_cmd,
3352 "show ipv6 route summary",
3353 SHOW_STR
3354 IP_STR
3355 "IPv6 routing table\n"
3356 "Summary of all IPv6 routes\n")
3357{
3358 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003359 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003360
Feng Lu4364ee52015-05-22 11:40:03 +02003361 if (argc > 0)
3362 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3363
3364 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003365 if (! table)
3366 return CMD_SUCCESS;
3367
3368 vty_show_ip_route_summary (vty, table);
3369
3370 return CMD_SUCCESS;
3371}
3372
Feng Lu4364ee52015-05-22 11:40:03 +02003373ALIAS (show_ipv6_route_summary,
3374 show_ipv6_route_summary_vrf_cmd,
3375 "show ipv6 route summary " VRF_CMD_STR,
3376 SHOW_STR
3377 IP_STR
3378 "IPv6 routing table\n"
3379 "Summary of all IPv6 routes\n"
3380 VRF_CMD_HELP_STR)
3381
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003382/* Show ipv6 route summary prefix. */
3383DEFUN (show_ipv6_route_summary_prefix,
3384 show_ipv6_route_summary_prefix_cmd,
3385 "show ipv6 route summary prefix",
3386 SHOW_STR
3387 IP_STR
3388 "IPv6 routing table\n"
3389 "Summary of all IPv6 routes\n"
3390 "Prefix routes\n")
3391{
3392 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003393 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003394
Feng Lu4364ee52015-05-22 11:40:03 +02003395 if (argc > 0)
3396 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3397
3398 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003399 if (! table)
3400 return CMD_SUCCESS;
3401
3402 vty_show_ip_route_summary_prefix (vty, table);
3403
3404 return CMD_SUCCESS;
3405}
3406
Feng Lu4364ee52015-05-22 11:40:03 +02003407ALIAS (show_ipv6_route_summary_prefix,
3408 show_ipv6_route_summary_prefix_vrf_cmd,
3409 "show ipv6 route summary prefix " VRF_CMD_STR,
3410 SHOW_STR
3411 IP_STR
3412 "IPv6 routing table\n"
3413 "Summary of all IPv6 routes\n"
3414 "Prefix routes\n"
3415 VRF_CMD_HELP_STR)
3416
G.Balajicddf3912011-11-26 21:59:32 +04003417/*
G.Balajicddf3912011-11-26 21:59:32 +04003418 * Show IPv6 mroute command.Used to dump
3419 * the Multicast routing table.
3420 */
3421
3422DEFUN (show_ipv6_mroute,
3423 show_ipv6_mroute_cmd,
3424 "show ipv6 mroute",
3425 SHOW_STR
3426 IP_STR
3427 "IPv6 Multicast routing table\n")
3428{
3429 struct route_table *table;
3430 struct route_node *rn;
3431 struct rib *rib;
3432 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003433 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003434
Feng Lu4364ee52015-05-22 11:40:03 +02003435 if (argc > 0)
3436 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3437
3438 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003439 if (! table)
3440 return CMD_SUCCESS;
3441
3442 /* Show all IPv6 route. */
3443 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003444 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003445 {
3446 if (first)
3447 {
G.Balajicb32fd62011-11-27 20:09:40 +05303448 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003449 first = 0;
3450 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003451 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003452 }
3453 return CMD_SUCCESS;
3454}
3455
Feng Lu4364ee52015-05-22 11:40:03 +02003456ALIAS (show_ipv6_mroute,
3457 show_ipv6_mroute_vrf_cmd,
3458 "show ipv6 mroute " VRF_CMD_STR,
3459 SHOW_STR
3460 IP_STR
3461 "IPv6 Multicast routing table\n"
3462 VRF_CMD_HELP_STR)
3463
3464DEFUN (show_ipv6_route_vrf_all,
3465 show_ipv6_route_vrf_all_cmd,
3466 "show ipv6 route " VRF_ALL_CMD_STR,
3467 SHOW_STR
3468 IP_STR
3469 "IPv6 routing table\n"
3470 VRF_ALL_CMD_HELP_STR)
3471{
3472 struct route_table *table;
3473 struct route_node *rn;
3474 struct rib *rib;
3475 struct zebra_vrf *zvrf;
3476 vrf_iter_t iter;
3477 int first = 1;
3478
3479 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3480 {
3481 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3482 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3483 continue;
3484
3485 /* Show all IPv6 route. */
3486 for (rn = route_top (table); rn; rn = route_next (rn))
3487 RNODE_FOREACH_RIB (rn, rib)
3488 {
3489 if (first)
3490 {
3491 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3492 first = 0;
3493 }
3494 vty_show_ip_route (vty, rn, rib);
3495 }
3496 }
3497
3498 return CMD_SUCCESS;
3499}
3500
3501DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3502 show_ipv6_route_prefix_longer_vrf_all_cmd,
3503 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3504 SHOW_STR
3505 IP_STR
3506 "IPv6 routing table\n"
3507 "IPv6 prefix\n"
3508 "Show route matching the specified Network/Mask pair only\n"
3509 VRF_ALL_CMD_HELP_STR)
3510{
3511 struct route_table *table;
3512 struct route_node *rn;
3513 struct rib *rib;
3514 struct prefix p;
3515 struct zebra_vrf *zvrf;
3516 vrf_iter_t iter;
3517 int ret;
3518 int first = 1;
3519
3520 ret = str2prefix (argv[0], &p);
3521 if (! ret)
3522 {
3523 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3524 return CMD_WARNING;
3525 }
3526
3527 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3528 {
3529 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3530 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3531 continue;
3532
3533 /* Show matched type IPv6 routes. */
3534 for (rn = route_top (table); rn; rn = route_next (rn))
3535 RNODE_FOREACH_RIB (rn, rib)
3536 if (prefix_match (&p, &rn->p))
3537 {
3538 if (first)
3539 {
3540 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3541 first = 0;
3542 }
3543 vty_show_ip_route (vty, rn, rib);
3544 }
3545 }
3546
3547 return CMD_SUCCESS;
3548}
3549
3550DEFUN (show_ipv6_route_protocol_vrf_all,
3551 show_ipv6_route_protocol_vrf_all_cmd,
3552 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3553 SHOW_STR
3554 IP_STR
3555 "IP routing table\n"
3556 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3557 VRF_ALL_CMD_HELP_STR)
3558{
3559 int type;
3560 struct route_table *table;
3561 struct route_node *rn;
3562 struct rib *rib;
3563 struct zebra_vrf *zvrf;
3564 vrf_iter_t iter;
3565 int first = 1;
3566
3567 type = proto_redistnum (AFI_IP6, argv[0]);
3568 if (type < 0)
3569 {
3570 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3571 return CMD_WARNING;
3572 }
3573
3574 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3575 {
3576 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3577 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3578 continue;
3579
3580 /* Show matched type IPv6 routes. */
3581 for (rn = route_top (table); rn; rn = route_next (rn))
3582 RNODE_FOREACH_RIB (rn, rib)
3583 if (rib->type == type)
3584 {
3585 if (first)
3586 {
3587 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3588 first = 0;
3589 }
3590 vty_show_ip_route (vty, rn, rib);
3591 }
3592 }
3593
3594 return CMD_SUCCESS;
3595}
3596
3597DEFUN (show_ipv6_route_addr_vrf_all,
3598 show_ipv6_route_addr_vrf_all_cmd,
3599 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3600 SHOW_STR
3601 IP_STR
3602 "IPv6 routing table\n"
3603 "IPv6 Address\n"
3604 VRF_ALL_CMD_HELP_STR)
3605{
3606 int ret;
3607 struct prefix_ipv6 p;
3608 struct route_table *table;
3609 struct route_node *rn;
3610 struct zebra_vrf *zvrf;
3611 vrf_iter_t iter;
3612
3613 ret = str2prefix_ipv6 (argv[0], &p);
3614 if (ret <= 0)
3615 {
3616 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3617 return CMD_WARNING;
3618 }
3619
3620 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3621 {
3622 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3623 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3624 continue;
3625
3626 rn = route_node_match (table, (struct prefix *) &p);
3627 if (! rn)
3628 continue;
3629
3630 vty_show_ip_route_detail (vty, rn, 0);
3631
3632 route_unlock_node (rn);
3633 }
3634
3635 return CMD_SUCCESS;
3636}
3637
3638DEFUN (show_ipv6_route_prefix_vrf_all,
3639 show_ipv6_route_prefix_vrf_all_cmd,
3640 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3641 SHOW_STR
3642 IP_STR
3643 "IPv6 routing table\n"
3644 "IPv6 prefix\n"
3645 VRF_ALL_CMD_HELP_STR)
3646{
3647 int ret;
3648 struct prefix_ipv6 p;
3649 struct route_table *table;
3650 struct route_node *rn;
3651 struct zebra_vrf *zvrf;
3652 vrf_iter_t iter;
3653
3654 ret = str2prefix_ipv6 (argv[0], &p);
3655 if (ret <= 0)
3656 {
3657 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3658 return CMD_WARNING;
3659 }
3660
3661 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3662 {
3663 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3664 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3665 continue;
3666
3667 rn = route_node_match (table, (struct prefix *) &p);
3668 if (! rn)
3669 continue;
3670 if (rn->p.prefixlen != p.prefixlen)
3671 {
3672 route_unlock_node (rn);
3673 continue;
3674 }
3675
3676 vty_show_ip_route_detail (vty, rn, 0);
3677
3678 route_unlock_node (rn);
3679 }
3680
3681 return CMD_SUCCESS;
3682}
3683
3684/* Show route summary. */
3685DEFUN (show_ipv6_route_summary_vrf_all,
3686 show_ipv6_route_summary_vrf_all_cmd,
3687 "show ipv6 route summary " VRF_ALL_CMD_STR,
3688 SHOW_STR
3689 IP_STR
3690 "IPv6 routing table\n"
3691 "Summary of all IPv6 routes\n"
3692 VRF_ALL_CMD_HELP_STR)
3693{
3694 struct zebra_vrf *zvrf;
3695 vrf_iter_t iter;
3696
3697 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3698 if ((zvrf = vrf_iter2info (iter)) != NULL)
3699 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3700
3701 return CMD_SUCCESS;
3702}
3703
3704DEFUN (show_ipv6_mroute_vrf_all,
3705 show_ipv6_mroute_vrf_all_cmd,
3706 "show ipv6 mroute " VRF_ALL_CMD_STR,
3707 SHOW_STR
3708 IP_STR
3709 "IPv6 Multicast routing table\n"
3710 VRF_ALL_CMD_HELP_STR)
3711{
3712 struct route_table *table;
3713 struct route_node *rn;
3714 struct rib *rib;
3715 struct zebra_vrf *zvrf;
3716 vrf_iter_t iter;
3717 int first = 1;
3718
3719 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3720 {
3721 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3722 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3723 continue;
3724
3725 /* Show all IPv6 route. */
3726 for (rn = route_top (table); rn; rn = route_next (rn))
3727 RNODE_FOREACH_RIB (rn, rib)
3728 {
3729 if (first)
3730 {
3731 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3732 first = 0;
3733 }
3734 vty_show_ip_route (vty, rn, rib);
3735 }
3736 }
3737 return CMD_SUCCESS;
3738}
3739
3740DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3741 show_ipv6_route_summary_prefix_vrf_all_cmd,
3742 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3743 SHOW_STR
3744 IP_STR
3745 "IPv6 routing table\n"
3746 "Summary of all IPv6 routes\n"
3747 "Prefix routes\n"
3748 VRF_ALL_CMD_HELP_STR)
3749{
3750 struct zebra_vrf *zvrf;
3751 vrf_iter_t iter;
3752
3753 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3754 if ((zvrf = vrf_iter2info (iter)) != NULL)
3755 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3756
3757 return CMD_SUCCESS;
3758}
3759
paul718e3742002-12-13 20:15:29 +00003760/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003761static int
paul718e3742002-12-13 20:15:29 +00003762static_config_ipv6 (struct vty *vty)
3763{
3764 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05003765 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00003766 int write;
3767 char buf[BUFSIZ];
3768 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003769 struct zebra_vrf *zvrf;
3770 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003771
3772 write = 0;
3773
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003774 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3775 {
3776 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3777 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3778 continue;
paul718e3742002-12-13 20:15:29 +00003779
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003780 for (rn = route_top (stable); rn; rn = route_next (rn))
3781 for (si = rn->info; si; si = si->next)
3782 {
3783 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003784
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003785 switch (si->type)
3786 {
3787 case STATIC_IPV6_GATEWAY:
3788 vty_out (vty, " %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003789 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003790 break;
3791 case STATIC_IPV6_IFNAME:
3792 vty_out (vty, " %s", si->ifname);
3793 break;
3794 case STATIC_IPV6_GATEWAY_IFNAME:
3795 vty_out (vty, " %s %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003796 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003797 si->ifname);
3798 break;
3799 }
paul718e3742002-12-13 20:15:29 +00003800
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003801 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3802 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003803
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003804 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3805 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003806
Piotr Chytłade24f822007-06-28 00:09:28 +02003807 if (si->tag)
3808 vty_out (vty, " tag %d", si->tag);
3809
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003810 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3811 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003812
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003813 if (si->vrf_id != VRF_DEFAULT)
3814 vty_out (vty, " vrf %u", si->vrf_id);
3815
3816 vty_out (vty, "%s", VTY_NEWLINE);
3817
3818 write = 1;
3819 }
3820 }
paul718e3742002-12-13 20:15:29 +00003821 return write;
3822}
paul718e3742002-12-13 20:15:29 +00003823
3824/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003825static int
paul718e3742002-12-13 20:15:29 +00003826zebra_ip_config (struct vty *vty)
3827{
3828 int write = 0;
3829
Everton Marques33d86db2014-07-14 11:19:00 -03003830 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3831 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003832#ifdef HAVE_IPV6
3833 write += static_config_ipv6 (vty);
3834#endif /* HAVE_IPV6 */
3835
3836 return write;
3837}
3838
David Lamparterbd078122015-01-06 19:53:24 +01003839static int config_write_vty(struct vty *vty)
3840{
Paul Jakma7514fb72007-05-02 16:05:35 +00003841 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003842 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3843
3844 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3845 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3846 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3847 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3848 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3849 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3850 "longer-prefix",
3851 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003852
3853 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3854 {
3855 if (proto_rm[AFI_IP][i])
3856 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3857 proto_rm[AFI_IP][i], VTY_NEWLINE);
3858 }
3859 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3860 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3861 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3862
3863 return 1;
3864}
3865
3866/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003867static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003868
paul718e3742002-12-13 20:15:29 +00003869/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003870static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003871
3872/* Route VTY. */
3873void
paula1ac18c2005-06-28 17:17:12 +00003874zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003875{
3876 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003877 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003878
Everton Marques33d86db2014-07-14 11:19:00 -03003879 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003880 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003881 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003882 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003883 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3884 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3885 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003886 install_element (CONFIG_NODE, &ip_protocol_cmd);
3887 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3888 install_element (VIEW_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003889 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003890 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003891 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003892 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003893 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003894 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003895 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003896 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003897 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003898 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003899 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003900 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003901 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003902 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003903 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003904 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003905 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003906 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003907 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003908 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003909 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003910 install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003911 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003912 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003913
3914 install_element (VIEW_NODE, &show_ip_route_cmd);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003915 install_element (VIEW_NODE, &show_ip_nht_cmd);
3916 install_element (VIEW_NODE, &show_ipv6_nht_cmd);
paul718e3742002-12-13 20:15:29 +00003917 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3918 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3919 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3920 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3921 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003922 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003923 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003924
Everton Marques33d86db2014-07-14 11:19:00 -03003925 install_element (VIEW_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003926 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003927
Feng Lu4364ee52015-05-22 11:40:03 +02003928 /* Commands for VRF */
3929
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003930 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3931 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3932 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3933 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3934
3935 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3936 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3937 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3938 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3939 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3940 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3941 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3942 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3943 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3944 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
3945 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
3946 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
3947 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
3948 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
3949 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
3950 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
3951 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
3952 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
3953 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
3954 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
3955 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003956 install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003957 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
3958 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
3959
Feng Lu4364ee52015-05-22 11:40:03 +02003960 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
3961 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
3962 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
3963 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3964 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
3965 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
3966 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
3967 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003968
3969 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
3970 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
3971 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
3972 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3973 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
3974 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
3975 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
3976 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003977
Feng Lu4364ee52015-05-22 11:40:03 +02003978 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
3979 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
3980 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
3981 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003982
paul718e3742002-12-13 20:15:29 +00003983 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003984 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003985 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003986 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003987 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003988 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003989 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003990 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003991 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003992 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003993 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003994 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003995 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003996 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003997 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003998 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003999 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004000 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004001 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00004002 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
4003 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
4004 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
4005 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04004006
4007 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004008
4009 /* Commands for VRF */
4010
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004011 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4012 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4013 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4014 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4015 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4016 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4017 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4018 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4019 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4020 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4021 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4022 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4023 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4024 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4025 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4026 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4027
Feng Lu4364ee52015-05-22 11:40:03 +02004028 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4029 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4030 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4031 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4032 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4033 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4034 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004035
4036 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4037 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4038 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4039 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4040 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4041 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4042 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004043
4044 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004045
4046 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
Piotr Chytłade24f822007-06-28 00:09:28 +02004047 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004048}