blob: dd7df5c96c997ffea449d8540c1126604fc8c40d [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"
paul718e3742002-12-13 20:15:29 +000031
paula1ac18c2005-06-28 17:17:12 +000032#include "zebra/zserv.h"
33
Feng Lu4364ee52015-05-22 11:40:03 +020034static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
David Lamparter3b02fe82015-01-22 19:12:35 +010035static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
36 int mcast);
Feng Lu4364ee52015-05-22 11:40:03 +020037static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
38 struct rib *rib);
Everton Marques33d86db2014-07-14 11:19:00 -030039
40/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000041static int
Everton Marques33d86db2014-07-14 11:19:00 -030042zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
43 const char *dest_str, const char *mask_str,
44 const char *gate_str, const char *flag_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +020045 const char *distance_str, const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +000046{
47 int ret;
48 u_char distance;
49 struct prefix p;
50 struct in_addr gate;
51 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000052 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000053 u_char flag = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +020054 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +000055
56 ret = str2prefix (dest_str, &p);
57 if (ret <= 0)
58 {
59 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
60 return CMD_WARNING;
61 }
62
63 /* Cisco like mask notation. */
64 if (mask_str)
65 {
66 ret = inet_aton (mask_str, &mask);
67 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000068 {
69 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
70 return CMD_WARNING;
71 }
paul718e3742002-12-13 20:15:29 +000072 p.prefixlen = ip_masklen (mask);
73 }
74
75 /* Apply mask for given prefix. */
76 apply_mask (&p);
77
paul595db7f2003-05-25 21:35:06 +000078 /* Administrative distance. */
79 if (distance_str)
80 distance = atoi (distance_str);
81 else
82 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
83
Feng Lu7aaf4ea2015-05-22 11:40:06 +020084 /* VRF id */
85 if (vrf_id_str)
86 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
87
paul595db7f2003-05-25 21:35:06 +000088 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000089 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000090 {
91 if (flag_str)
92 {
93 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
94 return CMD_WARNING;
95 }
96 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +020097 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +000098 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +020099 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000100 return CMD_SUCCESS;
101 }
102
hasso81dfcaa2003-05-25 19:21:25 +0000103 /* Route flags */
104 if (flag_str) {
105 switch(flag_str[0]) {
106 case 'r':
107 case 'R': /* XXX */
108 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
109 break;
110 case 'b':
111 case 'B': /* XXX */
112 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
113 break;
114 default:
115 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000116 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000117 }
118 }
119
hasso457ef552003-05-28 12:02:15 +0000120 if (gate_str == NULL)
121 {
122 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200123 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000124 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200125 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000126
127 return CMD_SUCCESS;
128 }
129
paul718e3742002-12-13 20:15:29 +0000130 /* When gateway is A.B.C.D format, gate is treated as nexthop
131 address other case gate is treated as interface name. */
132 ret = inet_aton (gate_str, &gate);
133 if (ret)
134 ifname = NULL;
135 else
136 ifname = gate_str;
137
138 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200139 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000140 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200141 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000142
143 return CMD_SUCCESS;
144}
145
Everton Marques33d86db2014-07-14 11:19:00 -0300146static int
147zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
148 const char *mask_str, const char *gate_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200149 const char *flag_str, const char *distance_str,
150 const char *vrf_id_str)
Everton Marques33d86db2014-07-14 11:19:00 -0300151{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200152 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str,
153 gate_str, flag_str, distance_str, vrf_id_str);
Everton Marques33d86db2014-07-14 11:19:00 -0300154}
155
156/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100157DEFUN (ip_mroute_dist,
158 ip_mroute_dist_cmd,
159 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300160 IP_STR
161 "Configure static unicast route into MRIB for multicast RPF lookup\n"
162 "IP destination prefix (e.g. 10.0.0.0/8)\n"
163 "Nexthop address\n"
164 "Nexthop interface name\n"
165 "Distance\n")
166{
David Lamparter863f20c2015-01-27 20:24:15 +0100167 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100168 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200169 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300170}
171
David Lampartera76681b2015-01-22 19:03:53 +0100172ALIAS (ip_mroute_dist,
173 ip_mroute_cmd,
174 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
175 IP_STR
176 "Configure static unicast route into MRIB for multicast RPF lookup\n"
177 "IP destination prefix (e.g. 10.0.0.0/8)\n"
178 "Nexthop address\n"
179 "Nexthop interface name\n")
180
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200181DEFUN (ip_mroute_dist_vrf,
182 ip_mroute_dist_vrf_cmd,
183 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
184 IP_STR
185 "Configure static unicast route into MRIB for multicast RPF lookup\n"
186 "IP destination prefix (e.g. 10.0.0.0/8)\n"
187 "Nexthop address\n"
188 "Nexthop interface name\n"
189 "Distance\n"
190 VRF_CMD_HELP_STR)
191{
192 VTY_WARN_EXPERIMENTAL();
193 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
194 NULL, argc > 3 ? argv[2] : NULL,
195 argc > 3 ? argv[3] : argv[2]);
196}
197
198ALIAS (ip_mroute_dist_vrf,
199 ip_mroute_vrf_cmd,
200 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
201 IP_STR
202 "Configure static unicast route into MRIB for multicast RPF lookup\n"
203 "IP destination prefix (e.g. 10.0.0.0/8)\n"
204 "Nexthop address\n"
205 "Nexthop interface name\n"
206 VRF_CMD_HELP_STR)
207
David Lampartera76681b2015-01-22 19:03:53 +0100208DEFUN (no_ip_mroute_dist,
209 no_ip_mroute_dist_cmd,
210 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300211 IP_STR
212 "Configure static unicast route into MRIB for multicast RPF lookup\n"
213 "IP destination prefix (e.g. 10.0.0.0/8)\n"
214 "Nexthop address\n"
215 "Nexthop interface name\n"
216 "Distance\n")
217{
David Lamparter863f20c2015-01-27 20:24:15 +0100218 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100219 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200220 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300221}
222
David Lampartera76681b2015-01-22 19:03:53 +0100223ALIAS (no_ip_mroute_dist,
224 no_ip_mroute_cmd,
225 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
226 NO_STR
227 IP_STR
228 "Configure static unicast route into MRIB for multicast RPF lookup\n"
229 "IP destination prefix (e.g. 10.0.0.0/8)\n"
230 "Nexthop address\n"
231 "Nexthop interface name\n")
232
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200233DEFUN (no_ip_mroute_dist_vrf,
234 no_ip_mroute_dist_vrf_cmd,
235 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
236 IP_STR
237 "Configure static unicast route into MRIB for multicast RPF lookup\n"
238 "IP destination prefix (e.g. 10.0.0.0/8)\n"
239 "Nexthop address\n"
240 "Nexthop interface name\n"
241 "Distance\n"
242 VRF_CMD_HELP_STR)
243{
244 VTY_WARN_EXPERIMENTAL();
245 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
246 NULL, argc > 3 ? argv[2] : NULL,
247 argc > 3 ? argv[3] : argv[2]);
248}
249
250ALIAS (no_ip_mroute_dist_vrf,
251 no_ip_mroute_vrf_cmd,
252 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
253 NO_STR
254 IP_STR
255 "Configure static unicast route into MRIB for multicast RPF lookup\n"
256 "IP destination prefix (e.g. 10.0.0.0/8)\n"
257 "Nexthop address\n"
258 "Nexthop interface name\n"
259 VRF_CMD_HELP_STR)
260
David Lamparterbd078122015-01-06 19:53:24 +0100261DEFUN (ip_multicast_mode,
262 ip_multicast_mode_cmd,
263 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
264 IP_STR
265 "Multicast options\n"
266 "RPF lookup behavior\n"
267 "Lookup in unicast RIB only\n"
268 "Lookup in multicast RIB only\n"
269 "Try multicast RIB first, fall back to unicast RIB\n"
270 "Lookup both, use entry with lower distance\n"
271 "Lookup both, use entry with longer prefix\n")
272{
David Lamparter863f20c2015-01-27 20:24:15 +0100273 VTY_WARN_EXPERIMENTAL();
274
David Lamparterbd078122015-01-06 19:53:24 +0100275 if (!strncmp (argv[0], "u", 1))
276 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
277 else if (!strncmp (argv[0], "mrib-o", 6))
278 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
279 else if (!strncmp (argv[0], "mrib-t", 6))
280 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
281 else if (!strncmp (argv[0], "low", 3))
282 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
283 else if (!strncmp (argv[0], "lon", 3))
284 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
285 else
286 {
287 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
288 return CMD_WARNING;
289 }
290
291 return CMD_SUCCESS;
292}
293
294DEFUN (no_ip_multicast_mode,
295 no_ip_multicast_mode_cmd,
296 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
297 NO_STR
298 IP_STR
299 "Multicast options\n"
300 "RPF lookup behavior\n"
301 "Lookup in unicast RIB only\n"
302 "Lookup in multicast RIB only\n"
303 "Try multicast RIB first, fall back to unicast RIB\n"
304 "Lookup both, use entry with lower distance\n"
305 "Lookup both, use entry with longer prefix\n")
306{
307 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
308 return CMD_SUCCESS;
309}
310
311ALIAS (no_ip_multicast_mode,
312 no_ip_multicast_mode_noarg_cmd,
313 "no ip multicast rpf-lookup-mode",
314 NO_STR
315 IP_STR
316 "Multicast options\n"
317 "RPF lookup behavior\n")
318
Everton Marques33d86db2014-07-14 11:19:00 -0300319DEFUN (show_ip_rpf,
320 show_ip_rpf_cmd,
321 "show ip rpf",
322 SHOW_STR
323 IP_STR
324 "Display RPF information for multicast source\n")
325{
Feng Lu4364ee52015-05-22 11:40:03 +0200326 vrf_id_t vrf_id = VRF_DEFAULT;
327
328 if (argc > 0)
329 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
330
David Lamparter863f20c2015-01-27 20:24:15 +0100331 VTY_WARN_EXPERIMENTAL();
Feng Lu4364ee52015-05-22 11:40:03 +0200332 return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -0300333}
334
Feng Lu4364ee52015-05-22 11:40:03 +0200335ALIAS (show_ip_rpf,
336 show_ip_rpf_vrf_cmd,
337 "show ip rpf " VRF_CMD_STR,
338 SHOW_STR
339 IP_STR
340 "Display RPF information for multicast source\n"
341 VRF_CMD_HELP_STR)
342
David Lamparter3b02fe82015-01-22 19:12:35 +0100343DEFUN (show_ip_rpf_addr,
344 show_ip_rpf_addr_cmd,
345 "show ip rpf A.B.C.D",
346 SHOW_STR
347 IP_STR
348 "Display RPF information for multicast source\n"
349 "IP multicast source address (e.g. 10.0.0.0)\n")
350{
351 struct in_addr addr;
352 struct route_node *rn;
353 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +0200354 vrf_id_t vrf_id = VRF_DEFAULT;
355 int ret;
356
357 if (argc > 1)
358 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
359
360 VTY_WARN_EXPERIMENTAL();
361
362 ret = inet_aton (argv[0], &addr);
363 if (ret == 0)
364 {
365 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
366 return CMD_WARNING;
367 }
368
369 rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
370
371 if (rib)
372 vty_show_ip_route_detail (vty, rn, 1);
373 else
374 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
375
376 return CMD_SUCCESS;
377}
378
379ALIAS (show_ip_rpf_addr,
380 show_ip_rpf_addr_vrf_cmd,
381 "show ip rpf A.B.C.D " VRF_CMD_STR,
382 SHOW_STR
383 IP_STR
384 "Display RPF information for multicast source\n"
385 "IP multicast source address (e.g. 10.0.0.0)\n"
386 VRF_CMD_HELP_STR)
387
388DEFUN (show_ip_rpf_vrf_all,
389 show_ip_rpf_vrf_all_cmd,
390 "show ip rpf " VRF_ALL_CMD_STR,
391 SHOW_STR
392 IP_STR
393 "Display RPF information for multicast source\n"
394 VRF_ALL_CMD_HELP_STR)
395{
396 struct zebra_vrf *zvrf;
397 struct route_table *table;
398 struct route_node *rn;
399 struct rib *rib;
400 vrf_iter_t iter;
401 int first = 1;
402
403 VTY_WARN_EXPERIMENTAL();
404
405 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
406 {
407 if ((zvrf = vrf_iter2info (iter)) == NULL ||
408 (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
409 continue;
410
411 /* Show all IPv4 routes. */
412 for (rn = route_top (table); rn; rn = route_next (rn))
413 RNODE_FOREACH_RIB (rn, rib)
414 {
415 if (first)
416 {
417 vty_out (vty, SHOW_ROUTE_V4_HEADER);
418 first = 0;
419 }
420 vty_show_ip_route (vty, rn, rib);
421 }
422 }
423
424 return CMD_SUCCESS;
425}
426
427DEFUN (show_ip_rpf_addr_vrf_all,
428 show_ip_rpf_addr_vrf_all_cmd,
429 "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
430 SHOW_STR
431 IP_STR
432 "Display RPF information for multicast source\n"
433 "IP multicast source address (e.g. 10.0.0.0)\n"
434 VRF_ALL_CMD_HELP_STR)
435{
436 struct in_addr addr;
437 struct route_node *rn;
438 vrf_iter_t iter;
David Lamparter3b02fe82015-01-22 19:12:35 +0100439 int ret;
440
David Lamparter863f20c2015-01-27 20:24:15 +0100441 VTY_WARN_EXPERIMENTAL();
442
David Lamparter3b02fe82015-01-22 19:12:35 +0100443 ret = inet_aton (argv[0], &addr);
444 if (ret == 0)
445 {
446 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
Feng Lu4364ee52015-05-22 11:40:03 +0200450 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
451 {
452 if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
453 vty_show_ip_route_detail (vty, rn, 1);
454 }
David Lamparter3b02fe82015-01-22 19:12:35 +0100455
456 return CMD_SUCCESS;
457}
458
paul718e3742002-12-13 20:15:29 +0000459/* Static route configuration. */
460DEFUN (ip_route,
461 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000462 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000463 IP_STR
464 "Establish static routes\n"
465 "IP destination prefix (e.g. 10.0.0.0/8)\n"
466 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000467 "IP gateway interface name\n"
468 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000469{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200470 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
471 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000472}
473
474DEFUN (ip_route_flags,
475 ip_route_flags_cmd,
476 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000477 IP_STR
478 "Establish static routes\n"
479 "IP destination prefix (e.g. 10.0.0.0/8)\n"
480 "IP gateway address\n"
481 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000482 "Emit an ICMP unreachable when matched\n"
483 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000484{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200485 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
486 NULL);
paul718e3742002-12-13 20:15:29 +0000487}
488
hasso457ef552003-05-28 12:02:15 +0000489DEFUN (ip_route_flags2,
490 ip_route_flags2_cmd,
491 "ip route A.B.C.D/M (reject|blackhole)",
492 IP_STR
493 "Establish static routes\n"
494 "IP destination prefix (e.g. 10.0.0.0/8)\n"
495 "Emit an ICMP unreachable when matched\n"
496 "Silently discard pkts when matched\n")
497{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200498 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
499 NULL);
hasso457ef552003-05-28 12:02:15 +0000500}
501
paul718e3742002-12-13 20:15:29 +0000502/* Mask as A.B.C.D format. */
503DEFUN (ip_route_mask,
504 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000505 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000506 IP_STR
507 "Establish static routes\n"
508 "IP destination prefix\n"
509 "IP destination prefix mask\n"
510 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000511 "IP gateway interface name\n"
512 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000513{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200514 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
515 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000516}
517
518DEFUN (ip_route_mask_flags,
519 ip_route_mask_flags_cmd,
520 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000521 IP_STR
522 "Establish static routes\n"
523 "IP destination prefix\n"
524 "IP destination prefix mask\n"
525 "IP gateway address\n"
526 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000527 "Emit an ICMP unreachable when matched\n"
528 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000529{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200530 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
531 NULL);
paul718e3742002-12-13 20:15:29 +0000532}
533
hasso457ef552003-05-28 12:02:15 +0000534DEFUN (ip_route_mask_flags2,
535 ip_route_mask_flags2_cmd,
536 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
537 IP_STR
538 "Establish static routes\n"
539 "IP destination prefix\n"
540 "IP destination prefix mask\n"
541 "Emit an ICMP unreachable when matched\n"
542 "Silently discard pkts when matched\n")
543{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200544 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
545 NULL);
hasso457ef552003-05-28 12:02:15 +0000546}
547
paul718e3742002-12-13 20:15:29 +0000548/* Distance option value. */
549DEFUN (ip_route_distance,
550 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000551 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000552 IP_STR
553 "Establish static routes\n"
554 "IP destination prefix (e.g. 10.0.0.0/8)\n"
555 "IP gateway address\n"
556 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000557 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000558 "Distance value for this route\n")
559{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200560 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
561 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000562}
563
564DEFUN (ip_route_flags_distance,
565 ip_route_flags_distance_cmd,
566 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
567 IP_STR
568 "Establish static routes\n"
569 "IP destination prefix (e.g. 10.0.0.0/8)\n"
570 "IP gateway address\n"
571 "IP gateway interface name\n"
572 "Emit an ICMP unreachable when matched\n"
573 "Silently discard pkts when matched\n"
574 "Distance value for this route\n")
575{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200576 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
577 NULL);
paul718e3742002-12-13 20:15:29 +0000578}
579
hasso457ef552003-05-28 12:02:15 +0000580DEFUN (ip_route_flags_distance2,
581 ip_route_flags_distance2_cmd,
582 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
583 IP_STR
584 "Establish static routes\n"
585 "IP destination prefix (e.g. 10.0.0.0/8)\n"
586 "Emit an ICMP unreachable when matched\n"
587 "Silently discard pkts when matched\n"
588 "Distance value for this route\n")
589{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200590 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
591 NULL);
hasso457ef552003-05-28 12:02:15 +0000592}
593
paul718e3742002-12-13 20:15:29 +0000594DEFUN (ip_route_mask_distance,
595 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000596 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000597 IP_STR
598 "Establish static routes\n"
599 "IP destination prefix\n"
600 "IP destination prefix mask\n"
601 "IP gateway address\n"
602 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000603 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000604 "Distance value for this route\n")
605{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200606 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
607 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000608}
609
610DEFUN (ip_route_mask_flags_distance,
611 ip_route_mask_flags_distance_cmd,
612 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
613 IP_STR
614 "Establish static routes\n"
615 "IP destination prefix\n"
616 "IP destination prefix mask\n"
617 "IP gateway address\n"
618 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000619 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000620 "Silently discard pkts when matched\n"
621 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000622{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200623 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
624 NULL);
paul718e3742002-12-13 20:15:29 +0000625}
626
hasso457ef552003-05-28 12:02:15 +0000627DEFUN (ip_route_mask_flags_distance2,
628 ip_route_mask_flags_distance2_cmd,
629 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
630 IP_STR
631 "Establish static routes\n"
632 "IP destination prefix\n"
633 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000634 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000635 "Silently discard pkts when matched\n"
636 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000637{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200638 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
639 NULL);
hasso457ef552003-05-28 12:02:15 +0000640}
641
paul718e3742002-12-13 20:15:29 +0000642DEFUN (no_ip_route,
643 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000644 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000645 NO_STR
646 IP_STR
647 "Establish static routes\n"
648 "IP destination prefix (e.g. 10.0.0.0/8)\n"
649 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000650 "IP gateway interface name\n"
651 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000652{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200653 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
654 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000655}
656
657ALIAS (no_ip_route,
658 no_ip_route_flags_cmd,
659 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000660 NO_STR
661 IP_STR
662 "Establish static routes\n"
663 "IP destination prefix (e.g. 10.0.0.0/8)\n"
664 "IP gateway address\n"
665 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000666 "Emit an ICMP unreachable when matched\n"
667 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000668
hasso457ef552003-05-28 12:02:15 +0000669DEFUN (no_ip_route_flags2,
670 no_ip_route_flags2_cmd,
671 "no ip route A.B.C.D/M (reject|blackhole)",
672 NO_STR
673 IP_STR
674 "Establish static routes\n"
675 "IP destination prefix (e.g. 10.0.0.0/8)\n"
676 "Emit an ICMP unreachable when matched\n"
677 "Silently discard pkts when matched\n")
678{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200679 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
680 NULL);
hasso457ef552003-05-28 12:02:15 +0000681}
682
paul718e3742002-12-13 20:15:29 +0000683DEFUN (no_ip_route_mask,
684 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000685 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000686 NO_STR
687 IP_STR
688 "Establish static routes\n"
689 "IP destination prefix\n"
690 "IP destination prefix mask\n"
691 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000692 "IP gateway interface name\n"
693 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000694{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200695 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
696 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000697}
698
699ALIAS (no_ip_route_mask,
700 no_ip_route_mask_flags_cmd,
701 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000702 NO_STR
703 IP_STR
704 "Establish static routes\n"
705 "IP destination prefix\n"
706 "IP destination prefix mask\n"
707 "IP gateway address\n"
708 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000709 "Emit an ICMP unreachable when matched\n"
710 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000711
hasso457ef552003-05-28 12:02:15 +0000712DEFUN (no_ip_route_mask_flags2,
713 no_ip_route_mask_flags2_cmd,
714 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
715 NO_STR
716 IP_STR
717 "Establish static routes\n"
718 "IP destination prefix\n"
719 "IP destination prefix mask\n"
720 "Emit an ICMP unreachable when matched\n"
721 "Silently discard pkts when matched\n")
722{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200723 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
724 NULL);
hasso457ef552003-05-28 12:02:15 +0000725}
726
paul718e3742002-12-13 20:15:29 +0000727DEFUN (no_ip_route_distance,
728 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000729 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000730 NO_STR
731 IP_STR
732 "Establish static routes\n"
733 "IP destination prefix (e.g. 10.0.0.0/8)\n"
734 "IP gateway address\n"
735 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000736 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000737 "Distance value for this route\n")
738{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200739 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
740 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000741}
742
743DEFUN (no_ip_route_flags_distance,
744 no_ip_route_flags_distance_cmd,
745 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
746 NO_STR
747 IP_STR
748 "Establish static routes\n"
749 "IP destination prefix (e.g. 10.0.0.0/8)\n"
750 "IP gateway address\n"
751 "IP gateway interface name\n"
752 "Emit an ICMP unreachable when matched\n"
753 "Silently discard pkts when matched\n"
754 "Distance value for this route\n")
755{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200756 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
757 NULL);
paul718e3742002-12-13 20:15:29 +0000758}
759
hasso457ef552003-05-28 12:02:15 +0000760DEFUN (no_ip_route_flags_distance2,
761 no_ip_route_flags_distance2_cmd,
762 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
763 NO_STR
764 IP_STR
765 "Establish static routes\n"
766 "IP destination prefix (e.g. 10.0.0.0/8)\n"
767 "Emit an ICMP unreachable when matched\n"
768 "Silently discard pkts when matched\n"
769 "Distance value for this route\n")
770{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200771 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
772 NULL);
hasso457ef552003-05-28 12:02:15 +0000773}
774
paul718e3742002-12-13 20:15:29 +0000775DEFUN (no_ip_route_mask_distance,
776 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000777 "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 +0000778 NO_STR
779 IP_STR
780 "Establish static routes\n"
781 "IP destination prefix\n"
782 "IP destination prefix mask\n"
783 "IP gateway address\n"
784 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000785 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000786 "Distance value for this route\n")
787{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200788 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
789 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000790}
791
792DEFUN (no_ip_route_mask_flags_distance,
793 no_ip_route_mask_flags_distance_cmd,
794 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
795 NO_STR
796 IP_STR
797 "Establish static routes\n"
798 "IP destination prefix\n"
799 "IP destination prefix mask\n"
800 "IP gateway address\n"
801 "IP gateway interface name\n"
802 "Emit an ICMP unreachable when matched\n"
803 "Silently discard pkts when matched\n"
804 "Distance value for this route\n")
805{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200806 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
807 NULL);
paul718e3742002-12-13 20:15:29 +0000808}
809
hasso457ef552003-05-28 12:02:15 +0000810DEFUN (no_ip_route_mask_flags_distance2,
811 no_ip_route_mask_flags_distance2_cmd,
812 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
813 NO_STR
814 IP_STR
815 "Establish static routes\n"
816 "IP destination prefix\n"
817 "IP destination prefix mask\n"
818 "Emit an ICMP unreachable when matched\n"
819 "Silently discard pkts when matched\n"
820 "Distance value for this route\n")
821{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200822 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
823 NULL);
824}
825
826DEFUN (ip_route_vrf,
827 ip_route_vrf_cmd,
828 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
829 IP_STR
830 "Establish static routes\n"
831 "IP destination prefix (e.g. 10.0.0.0/8)\n"
832 "IP gateway address\n"
833 "IP gateway interface name\n"
834 "Null interface\n"
835 VRF_CMD_HELP_STR)
836{
837 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
838 argv[2]);
839}
840
841DEFUN (ip_route_flags_vrf,
842 ip_route_flags_vrf_cmd,
843 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
844 IP_STR
845 "Establish static routes\n"
846 "IP destination prefix (e.g. 10.0.0.0/8)\n"
847 "IP gateway address\n"
848 "IP gateway interface name\n"
849 "Emit an ICMP unreachable when matched\n"
850 "Silently discard pkts when matched\n"
851 VRF_CMD_HELP_STR)
852{
853 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
854 argv[3]);
855}
856
857DEFUN (ip_route_flags2_vrf,
858 ip_route_flags2_vrf_cmd,
859 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
860 IP_STR
861 "Establish static routes\n"
862 "IP destination prefix (e.g. 10.0.0.0/8)\n"
863 "Emit an ICMP unreachable when matched\n"
864 "Silently discard pkts when matched\n"
865 VRF_CMD_HELP_STR)
866{
867 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
868 argv[2]);
869}
870
871/* Mask as A.B.C.D format. */
872DEFUN (ip_route_mask_vrf,
873 ip_route_mask_vrf_cmd,
874 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
875 IP_STR
876 "Establish static routes\n"
877 "IP destination prefix\n"
878 "IP destination prefix mask\n"
879 "IP gateway address\n"
880 "IP gateway interface name\n"
881 "Null interface\n"
882 VRF_CMD_HELP_STR)
883{
884 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
885 argv[3]);
886}
887
888DEFUN (ip_route_mask_flags_vrf,
889 ip_route_mask_flags_vrf_cmd,
890 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
891 IP_STR
892 "Establish static routes\n"
893 "IP destination prefix\n"
894 "IP destination prefix mask\n"
895 "IP gateway address\n"
896 "IP gateway interface name\n"
897 "Emit an ICMP unreachable when matched\n"
898 "Silently discard pkts when matched\n"
899 VRF_CMD_HELP_STR)
900{
901 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
902 argv[4]);
903}
904
905DEFUN (ip_route_mask_flags2_vrf,
906 ip_route_mask_flags2_vrf_cmd,
907 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
908 IP_STR
909 "Establish static routes\n"
910 "IP destination prefix\n"
911 "IP destination prefix mask\n"
912 "Emit an ICMP unreachable when matched\n"
913 "Silently discard pkts when matched\n"
914 VRF_CMD_HELP_STR)
915{
916 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
917 argv[3]);
918}
919
920/* Distance option value. */
921DEFUN (ip_route_distance_vrf,
922 ip_route_distance_vrf_cmd,
923 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
924 IP_STR
925 "Establish static routes\n"
926 "IP destination prefix (e.g. 10.0.0.0/8)\n"
927 "IP gateway address\n"
928 "IP gateway interface name\n"
929 "Null interface\n"
930 "Distance value for this route\n"
931 VRF_CMD_HELP_STR)
932{
933 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
934 argv[3]);
935}
936
937DEFUN (ip_route_flags_distance_vrf,
938 ip_route_flags_distance_vrf_cmd,
939 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
940 IP_STR
941 "Establish static routes\n"
942 "IP destination prefix (e.g. 10.0.0.0/8)\n"
943 "IP gateway address\n"
944 "IP gateway interface name\n"
945 "Emit an ICMP unreachable when matched\n"
946 "Silently discard pkts when matched\n"
947 "Distance value for this route\n"
948 VRF_CMD_HELP_STR)
949{
950 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
951 argv[4]);
952}
953
954DEFUN (ip_route_flags_distance2_vrf,
955 ip_route_flags_distance2_vrf_cmd,
956 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
957 IP_STR
958 "Establish static routes\n"
959 "IP destination prefix (e.g. 10.0.0.0/8)\n"
960 "Emit an ICMP unreachable when matched\n"
961 "Silently discard pkts when matched\n"
962 "Distance value for this route\n"
963 VRF_CMD_HELP_STR)
964{
965 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
966 argv[3]);
967}
968
969DEFUN (ip_route_mask_distance_vrf,
970 ip_route_mask_distance_vrf_cmd,
971 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
972 IP_STR
973 "Establish static routes\n"
974 "IP destination prefix\n"
975 "IP destination prefix mask\n"
976 "IP gateway address\n"
977 "IP gateway interface name\n"
978 "Null interface\n"
979 "Distance value for this route\n"
980 VRF_CMD_HELP_STR)
981{
982 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
983 argv[4]);
984}
985
986DEFUN (ip_route_mask_flags_distance_vrf,
987 ip_route_mask_flags_distance_vrf_cmd,
988 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
989 IP_STR
990 "Establish static routes\n"
991 "IP destination prefix\n"
992 "IP destination prefix mask\n"
993 "IP gateway address\n"
994 "IP gateway interface name\n"
995 "Emit an ICMP unreachable when matched\n"
996 "Silently discard pkts when matched\n"
997 "Distance value for this route\n"
998 VRF_CMD_HELP_STR)
999{
1000 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
1001 argv[5]);
1002}
1003
1004DEFUN (ip_route_mask_flags_distance2_vrf,
1005 ip_route_mask_flags_distance2_vrf_cmd,
1006 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1007 IP_STR
1008 "Establish static routes\n"
1009 "IP destination prefix\n"
1010 "IP destination prefix mask\n"
1011 "Emit an ICMP unreachable when matched\n"
1012 "Silently discard pkts when matched\n"
1013 "Distance value for this route\n"
1014 VRF_CMD_HELP_STR)
1015{
1016 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
1017 argv[4]);
1018}
1019
1020DEFUN (no_ip_route_vrf,
1021 no_ip_route_vrf_cmd,
1022 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1023 NO_STR
1024 IP_STR
1025 "Establish static routes\n"
1026 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1027 "IP gateway address\n"
1028 "IP gateway interface name\n"
1029 "Null interface\n"
1030 VRF_CMD_HELP_STR)
1031{
1032 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
1033 (argc > 3) ? argv[3] : argv[2]);
1034}
1035
1036ALIAS (no_ip_route_vrf,
1037 no_ip_route_flags_vrf_cmd,
1038 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1039 NO_STR
1040 IP_STR
1041 "Establish static routes\n"
1042 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1043 "IP gateway address\n"
1044 "IP gateway interface name\n"
1045 "Emit an ICMP unreachable when matched\n"
1046 "Silently discard pkts when matched\n"
1047 VRF_CMD_HELP_STR)
1048
1049DEFUN (no_ip_route_flags2_vrf,
1050 no_ip_route_flags2_vrf_cmd,
1051 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1052 NO_STR
1053 IP_STR
1054 "Establish static routes\n"
1055 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1056 "Emit an ICMP unreachable when matched\n"
1057 "Silently discard pkts when matched\n"
1058 VRF_CMD_HELP_STR)
1059{
1060 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
1061 argv[2]);
1062}
1063
1064DEFUN (no_ip_route_mask_vrf,
1065 no_ip_route_mask_vrf_cmd,
1066 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1067 NO_STR
1068 IP_STR
1069 "Establish static routes\n"
1070 "IP destination prefix\n"
1071 "IP destination prefix mask\n"
1072 "IP gateway address\n"
1073 "IP gateway interface name\n"
1074 "Null interface\n"
1075 VRF_CMD_HELP_STR)
1076{
1077 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
1078 (argc > 4) ? argv[4] : argv[3]);
1079}
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{
1107 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
1108 argv[2]);
1109}
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{
1124 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
1125 argv[3]);
1126}
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{
1142 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
1143 argv[4]);
1144}
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{
1158 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
1159 argv[3]);
1160}
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{
1176 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
1177 argv[4]);
1178}
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{
1195 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
1196 argv[5]);
1197}
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{
1212 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
1213 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);
Feng Lu4364ee52015-05-22 11:40:03 +02001293 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001294 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001295 vty_out (vty, ", best");
paul718e3742002-12-13 20:15:29 +00001296 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001297 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1299 vty_out (vty, ", blackhole");
1300 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1301 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001302 vty_out (vty, "%s", VTY_NEWLINE);
1303
1304#define ONE_DAY_SECOND 60*60*24
1305#define ONE_WEEK_SECOND 60*60*24*7
1306 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001307 || rib->type == ZEBRA_ROUTE_RIPNG
1308 || rib->type == ZEBRA_ROUTE_OSPF
1309 || rib->type == ZEBRA_ROUTE_OSPF6
1310 || rib->type == ZEBRA_ROUTE_BABEL
1311 || rib->type == ZEBRA_ROUTE_ISIS
1312 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001313 {
1314 time_t uptime;
1315 struct tm *tm;
1316
1317 uptime = time (NULL);
1318 uptime -= rib->uptime;
1319 tm = gmtime (&uptime);
1320
1321 vty_out (vty, " Last update ");
1322
1323 if (uptime < ONE_DAY_SECOND)
1324 vty_out (vty, "%02d:%02d:%02d",
1325 tm->tm_hour, tm->tm_min, tm->tm_sec);
1326 else if (uptime < ONE_WEEK_SECOND)
1327 vty_out (vty, "%dd%02dh%02dm",
1328 tm->tm_yday, tm->tm_hour, tm->tm_min);
1329 else
1330 vty_out (vty, "%02dw%dd%02dh",
1331 tm->tm_yday/7,
1332 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1333 vty_out (vty, " ago%s", VTY_NEWLINE);
1334 }
1335
Christian Frankefa713d92013-07-05 15:35:37 +00001336 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001337 {
1338 vty_out (vty, " %c%s",
1339 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1340 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001341
Timo Teräs53a5c392015-05-23 11:08:40 +03001342 switch (nexthop->type)
1343 {
1344 case NEXTHOP_TYPE_IPV4:
1345 case NEXTHOP_TYPE_IPV4_IFINDEX:
1346 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1347 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001348 vty_out (vty, ", via %s",
1349 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001350 break;
1351 case NEXTHOP_TYPE_IPV6:
1352 case NEXTHOP_TYPE_IPV6_IFINDEX:
1353 case NEXTHOP_TYPE_IPV6_IFNAME:
1354 vty_out (vty, " %s",
1355 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1356 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1357 vty_out (vty, ", %s", nexthop->ifname);
1358 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001359 vty_out (vty, ", via %s",
1360 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001361 break;
1362 case NEXTHOP_TYPE_IFINDEX:
1363 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001364 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001365 break;
1366 case NEXTHOP_TYPE_IFNAME:
1367 vty_out (vty, " directly connected, %s", nexthop->ifname);
1368 break;
1369 case NEXTHOP_TYPE_BLACKHOLE:
1370 vty_out (vty, " directly connected, Null0");
1371 break;
1372 default:
1373 break;
1374 }
1375 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1376 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001377
Timo Teräs53a5c392015-05-23 11:08:40 +03001378 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1379 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001380
Timo Teräs53a5c392015-05-23 11:08:40 +03001381 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1382 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001383
Timo Teräs53a5c392015-05-23 11:08:40 +03001384 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001385 {
1386 case NEXTHOP_TYPE_IPV4:
1387 case NEXTHOP_TYPE_IPV4_IFINDEX:
1388 case NEXTHOP_TYPE_IPV4_IFNAME:
1389 if (nexthop->src.ipv4.s_addr)
1390 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001391 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1392 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001393 }
1394 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001395#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001396 case NEXTHOP_TYPE_IPV6:
1397 case NEXTHOP_TYPE_IPV6_IFINDEX:
1398 case NEXTHOP_TYPE_IPV6_IFNAME:
1399 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1400 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001401 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1402 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001403 }
1404 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001405#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001406 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001407 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001408 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001409 vty_out (vty, "%s", VTY_NEWLINE);
1410 }
paul718e3742002-12-13 20:15:29 +00001411 vty_out (vty, "%s", VTY_NEWLINE);
1412 }
1413}
1414
paula1ac18c2005-06-28 17:17:12 +00001415static void
paul718e3742002-12-13 20:15:29 +00001416vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1417{
Christian Frankefa713d92013-07-05 15:35:37 +00001418 struct nexthop *nexthop, *tnexthop;
1419 int recursing;
paul718e3742002-12-13 20:15:29 +00001420 int len = 0;
1421 char buf[BUFSIZ];
1422
1423 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001424 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001425 {
1426 if (nexthop == rib->nexthop)
1427 {
1428 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001429 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001430 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001431 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1432 ? '>' : ' ',
1433 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1434 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001435 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001436
1437 /* Distance and metric display. */
1438 if (rib->type != ZEBRA_ROUTE_CONNECT
1439 && rib->type != ZEBRA_ROUTE_KERNEL)
1440 len += vty_out (vty, " [%d/%d]", rib->distance,
1441 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001442
1443 if (rib->vrf_id != VRF_DEFAULT)
1444 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001445 }
1446 else
1447 vty_out (vty, " %c%*c",
1448 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1449 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001450 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001451
1452 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001453 {
1454 case NEXTHOP_TYPE_IPV4:
1455 case NEXTHOP_TYPE_IPV4_IFINDEX:
1456 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1457 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001458 vty_out (vty, ", %s",
1459 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001460 break;
1461 case NEXTHOP_TYPE_IPV6:
1462 case NEXTHOP_TYPE_IPV6_IFINDEX:
1463 case NEXTHOP_TYPE_IPV6_IFNAME:
1464 vty_out (vty, " via %s",
1465 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1466 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1467 vty_out (vty, ", %s", nexthop->ifname);
1468 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001469 vty_out (vty, ", %s",
1470 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001471 break;
1472 case NEXTHOP_TYPE_IFINDEX:
1473 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001474 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001475 break;
1476 case NEXTHOP_TYPE_IFNAME:
1477 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1478 break;
1479 case NEXTHOP_TYPE_BLACKHOLE:
1480 vty_out (vty, " is directly connected, Null0");
1481 break;
1482 default:
1483 break;
1484 }
paul718e3742002-12-13 20:15:29 +00001485 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001486 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001487
Christian Frankee8d3d292013-07-05 15:35:39 +00001488 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001489 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001490
paul718e3742002-12-13 20:15:29 +00001491 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001492 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001493
Paul Jakma7514fb72007-05-02 16:05:35 +00001494 switch (nexthop->type)
1495 {
1496 case NEXTHOP_TYPE_IPV4:
1497 case NEXTHOP_TYPE_IPV4_IFINDEX:
1498 case NEXTHOP_TYPE_IPV4_IFNAME:
1499 if (nexthop->src.ipv4.s_addr)
1500 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001501 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001502 vty_out (vty, ", src %s", buf);
1503 }
1504 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001505#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001506 case NEXTHOP_TYPE_IPV6:
1507 case NEXTHOP_TYPE_IPV6_IFINDEX:
1508 case NEXTHOP_TYPE_IPV6_IFNAME:
1509 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1510 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001511 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001512 vty_out (vty, ", src %s", buf);
1513 }
1514 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001515#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001516 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001517 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001518 }
paul718e3742002-12-13 20:15:29 +00001519
hasso81dfcaa2003-05-25 19:21:25 +00001520 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1521 vty_out (vty, ", bh");
1522 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1523 vty_out (vty, ", rej");
1524
paul718e3742002-12-13 20:15:29 +00001525 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001526 || rib->type == ZEBRA_ROUTE_RIPNG
1527 || rib->type == ZEBRA_ROUTE_OSPF
1528 || rib->type == ZEBRA_ROUTE_OSPF6
1529 || rib->type == ZEBRA_ROUTE_BABEL
1530 || rib->type == ZEBRA_ROUTE_ISIS
1531 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001532 {
1533 time_t uptime;
1534 struct tm *tm;
1535
1536 uptime = time (NULL);
1537 uptime -= rib->uptime;
1538 tm = gmtime (&uptime);
1539
1540#define ONE_DAY_SECOND 60*60*24
1541#define ONE_WEEK_SECOND 60*60*24*7
1542
1543 if (uptime < ONE_DAY_SECOND)
1544 vty_out (vty, ", %02d:%02d:%02d",
1545 tm->tm_hour, tm->tm_min, tm->tm_sec);
1546 else if (uptime < ONE_WEEK_SECOND)
1547 vty_out (vty, ", %dd%02dh%02dm",
1548 tm->tm_yday, tm->tm_hour, tm->tm_min);
1549 else
1550 vty_out (vty, ", %02dw%dd%02dh",
1551 tm->tm_yday/7,
1552 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1553 }
1554 vty_out (vty, "%s", VTY_NEWLINE);
1555 }
1556}
1557
paul718e3742002-12-13 20:15:29 +00001558DEFUN (show_ip_route,
1559 show_ip_route_cmd,
1560 "show ip route",
1561 SHOW_STR
1562 IP_STR
1563 "IP routing table\n")
1564{
Feng Lu4364ee52015-05-22 11:40:03 +02001565 vrf_id_t vrf_id = VRF_DEFAULT;
1566
1567 if (argc > 0)
1568 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1569
1570 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001571}
1572
Feng Lu4364ee52015-05-22 11:40:03 +02001573static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1574{
paul718e3742002-12-13 20:15:29 +00001575 struct route_table *table;
1576 struct route_node *rn;
1577 struct rib *rib;
1578 int first = 1;
1579
Feng Lu4364ee52015-05-22 11:40:03 +02001580 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001581 if (! table)
1582 return CMD_SUCCESS;
1583
1584 /* Show all IPv4 routes. */
1585 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001586 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001587 {
1588 if (first)
1589 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001590 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001591 first = 0;
1592 }
1593 vty_show_ip_route (vty, rn, rib);
1594 }
1595 return CMD_SUCCESS;
1596}
1597
Feng Lu4364ee52015-05-22 11:40:03 +02001598ALIAS (show_ip_route,
1599 show_ip_route_vrf_cmd,
1600 "show ip route " VRF_CMD_STR,
1601 SHOW_STR
1602 IP_STR
1603 "IP routing table\n"
1604 VRF_CMD_HELP_STR)
1605
paul718e3742002-12-13 20:15:29 +00001606DEFUN (show_ip_route_prefix_longer,
1607 show_ip_route_prefix_longer_cmd,
1608 "show ip route A.B.C.D/M longer-prefixes",
1609 SHOW_STR
1610 IP_STR
1611 "IP routing table\n"
1612 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1613 "Show route matching the specified Network/Mask pair only\n")
1614{
1615 struct route_table *table;
1616 struct route_node *rn;
1617 struct rib *rib;
1618 struct prefix p;
1619 int ret;
1620 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001621 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001622
1623 ret = str2prefix (argv[0], &p);
1624 if (! ret)
1625 {
1626 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1627 return CMD_WARNING;
1628 }
Feng Lu4364ee52015-05-22 11:40:03 +02001629
1630 if (argc > 1)
1631 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1632
1633 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001634 if (! table)
1635 return CMD_SUCCESS;
1636
1637 /* Show matched type IPv4 routes. */
1638 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001639 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001640 if (prefix_match (&p, &rn->p))
1641 {
1642 if (first)
1643 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001644 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001645 first = 0;
1646 }
1647 vty_show_ip_route (vty, rn, rib);
1648 }
1649 return CMD_SUCCESS;
1650}
1651
Feng Lu4364ee52015-05-22 11:40:03 +02001652ALIAS (show_ip_route_prefix_longer,
1653 show_ip_route_prefix_longer_vrf_cmd,
1654 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1655 SHOW_STR
1656 IP_STR
1657 "IP routing table\n"
1658 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1659 "Show route matching the specified Network/Mask pair only\n"
1660 VRF_CMD_HELP_STR)
1661
paul718e3742002-12-13 20:15:29 +00001662DEFUN (show_ip_route_supernets,
1663 show_ip_route_supernets_cmd,
1664 "show ip route supernets-only",
1665 SHOW_STR
1666 IP_STR
1667 "IP routing table\n"
1668 "Show supernet entries only\n")
1669{
1670 struct route_table *table;
1671 struct route_node *rn;
1672 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001673 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001674 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001675 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001676
Feng Lu4364ee52015-05-22 11:40:03 +02001677 if (argc > 0)
1678 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1679
1680 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001681 if (! table)
1682 return CMD_SUCCESS;
1683
1684 /* Show matched type IPv4 routes. */
1685 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001686 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001687 {
1688 addr = ntohl (rn->p.u.prefix4.s_addr);
1689
1690 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1691 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001692 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001693 {
1694 if (first)
1695 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001696 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001697 first = 0;
1698 }
1699 vty_show_ip_route (vty, rn, rib);
1700 }
1701 }
1702 return CMD_SUCCESS;
1703}
1704
Feng Lu4364ee52015-05-22 11:40:03 +02001705ALIAS (show_ip_route_supernets,
1706 show_ip_route_supernets_vrf_cmd,
1707 "show ip route supernets-only " VRF_CMD_STR,
1708 SHOW_STR
1709 IP_STR
1710 "IP routing table\n"
1711 "Show supernet entries only\n"
1712 VRF_CMD_HELP_STR)
1713
paul718e3742002-12-13 20:15:29 +00001714DEFUN (show_ip_route_protocol,
1715 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001716 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001717 SHOW_STR
1718 IP_STR
1719 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001720 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001721{
1722 int type;
1723 struct route_table *table;
1724 struct route_node *rn;
1725 struct rib *rib;
1726 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001727 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001728
David Lampartere0ca5fd2009-09-16 01:52:42 +02001729 type = proto_redistnum (AFI_IP, argv[0]);
1730 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001731 {
1732 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1733 return CMD_WARNING;
1734 }
Feng Lu4364ee52015-05-22 11:40:03 +02001735
1736 if (argc > 1)
1737 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1738
1739 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001740 if (! table)
1741 return CMD_SUCCESS;
1742
1743 /* Show matched type IPv4 routes. */
1744 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001745 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001746 if (rib->type == type)
1747 {
1748 if (first)
1749 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001750 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001751 first = 0;
1752 }
1753 vty_show_ip_route (vty, rn, rib);
1754 }
1755 return CMD_SUCCESS;
1756}
1757
Feng Lu4364ee52015-05-22 11:40:03 +02001758ALIAS (show_ip_route_protocol,
1759 show_ip_route_protocol_vrf_cmd,
1760 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1761 SHOW_STR
1762 IP_STR
1763 "IP routing table\n"
1764 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1765 VRF_CMD_HELP_STR)
1766
paul718e3742002-12-13 20:15:29 +00001767DEFUN (show_ip_route_addr,
1768 show_ip_route_addr_cmd,
1769 "show ip route A.B.C.D",
1770 SHOW_STR
1771 IP_STR
1772 "IP routing table\n"
1773 "Network in the IP routing table to display\n")
1774{
1775 int ret;
1776 struct prefix_ipv4 p;
1777 struct route_table *table;
1778 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001779 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001780
1781 ret = str2prefix_ipv4 (argv[0], &p);
1782 if (ret <= 0)
1783 {
1784 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1785 return CMD_WARNING;
1786 }
1787
Feng Lu4364ee52015-05-22 11:40:03 +02001788 if (argc > 1)
1789 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1790
1791 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001792 if (! table)
1793 return CMD_SUCCESS;
1794
1795 rn = route_node_match (table, (struct prefix *) &p);
1796 if (! rn)
1797 {
1798 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1799 return CMD_WARNING;
1800 }
1801
David Lamparter3b02fe82015-01-22 19:12:35 +01001802 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001803
1804 route_unlock_node (rn);
1805
1806 return CMD_SUCCESS;
1807}
1808
Feng Lu4364ee52015-05-22 11:40:03 +02001809ALIAS (show_ip_route_addr,
1810 show_ip_route_addr_vrf_cmd,
1811 "show ip route A.B.C.D " VRF_CMD_STR,
1812 SHOW_STR
1813 IP_STR
1814 "IP routing table\n"
1815 "Network in the IP routing table to display\n"
1816 VRF_CMD_HELP_STR)
1817
paul718e3742002-12-13 20:15:29 +00001818DEFUN (show_ip_route_prefix,
1819 show_ip_route_prefix_cmd,
1820 "show ip route A.B.C.D/M",
1821 SHOW_STR
1822 IP_STR
1823 "IP routing table\n"
1824 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1825{
1826 int ret;
1827 struct prefix_ipv4 p;
1828 struct route_table *table;
1829 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001830 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001831
1832 ret = str2prefix_ipv4 (argv[0], &p);
1833 if (ret <= 0)
1834 {
1835 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1836 return CMD_WARNING;
1837 }
1838
Feng Lu4364ee52015-05-22 11:40:03 +02001839 if (argc > 1)
1840 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1841
1842 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001843 if (! table)
1844 return CMD_SUCCESS;
1845
1846 rn = route_node_match (table, (struct prefix *) &p);
1847 if (! rn || rn->p.prefixlen != p.prefixlen)
1848 {
1849 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001850 if (rn)
1851 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001852 return CMD_WARNING;
1853 }
1854
David Lamparter3b02fe82015-01-22 19:12:35 +01001855 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001856
1857 route_unlock_node (rn);
1858
1859 return CMD_SUCCESS;
1860}
1861
Feng Lu4364ee52015-05-22 11:40:03 +02001862ALIAS (show_ip_route_prefix,
1863 show_ip_route_prefix_vrf_cmd,
1864 "show ip route A.B.C.D/M " VRF_CMD_STR,
1865 SHOW_STR
1866 IP_STR
1867 "IP routing table\n"
1868 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1869 VRF_CMD_HELP_STR)
1870
paula1ac18c2005-06-28 17:17:12 +00001871static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001872vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001873{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001874 struct route_node *rn;
1875 struct rib *rib;
1876 struct nexthop *nexthop;
1877#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1878#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1879 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1880 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1881 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001882
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001883 memset (&rib_cnt, 0, sizeof(rib_cnt));
1884 memset (&fib_cnt, 0, sizeof(fib_cnt));
1885 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001886 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001887 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1888 {
1889 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1890 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001891 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1892 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001893 {
1894 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1895 fib_cnt[rib->type]++;
1896 }
1897 if (rib->type == ZEBRA_ROUTE_BGP &&
1898 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1899 {
1900 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001901 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1902 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001903 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1904 }
1905 }
paul718e3742002-12-13 20:15:29 +00001906
Feng Lu4364ee52015-05-22 11:40:03 +02001907 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1908 "Route Source", "Routes", "FIB",
1909 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1910 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001911
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001912 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1913 {
1914 if (rib_cnt[i] > 0)
1915 {
1916 if (i == ZEBRA_ROUTE_BGP)
1917 {
1918 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1919 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1920 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1921 VTY_NEWLINE);
1922 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1923 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1924 VTY_NEWLINE);
1925 }
1926 else
1927 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1928 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1929 }
1930 }
paul718e3742002-12-13 20:15:29 +00001931
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001932 vty_out (vty, "------%s", VTY_NEWLINE);
1933 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1934 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001935 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001936}
1937
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001938/*
1939 * Implementation of the ip route summary prefix command.
1940 *
1941 * This command prints the primary prefixes that have been installed by various
1942 * protocols on the box.
1943 *
1944 */
1945static void
1946vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1947{
1948 struct route_node *rn;
1949 struct rib *rib;
1950 struct nexthop *nexthop;
1951#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1952#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1953 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1954 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1955 u_int32_t i;
1956 int cnt;
1957
1958 memset (&rib_cnt, 0, sizeof(rib_cnt));
1959 memset (&fib_cnt, 0, sizeof(fib_cnt));
1960 for (rn = route_top (table); rn; rn = route_next (rn))
1961 RNODE_FOREACH_RIB (rn, rib)
1962 {
1963
1964 /*
1965 * In case of ECMP, count only once.
1966 */
1967 cnt = 0;
1968 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1969 {
1970 cnt++;
1971 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1972 rib_cnt[rib->type]++;
1973 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1974 {
1975 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1976 fib_cnt[rib->type]++;
1977 }
1978 if (rib->type == ZEBRA_ROUTE_BGP &&
1979 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1980 {
1981 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1982 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1983 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1984 }
1985 }
1986 }
1987
Feng Lu4364ee52015-05-22 11:40:03 +02001988 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1989 "Route Source", "Prefix Routes", "FIB",
1990 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1991 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001992
1993 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1994 {
1995 if (rib_cnt[i] > 0)
1996 {
1997 if (i == ZEBRA_ROUTE_BGP)
1998 {
1999 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2000 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2001 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2002 VTY_NEWLINE);
2003 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2004 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2005 VTY_NEWLINE);
2006 }
2007 else
2008 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2009 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2010 }
2011 }
2012
2013 vty_out (vty, "------%s", VTY_NEWLINE);
2014 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2015 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002016 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002017}
2018
paul718e3742002-12-13 20:15:29 +00002019/* Show route summary. */
2020DEFUN (show_ip_route_summary,
2021 show_ip_route_summary_cmd,
2022 "show ip route summary",
2023 SHOW_STR
2024 IP_STR
2025 "IP routing table\n"
2026 "Summary of all routes\n")
2027{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002028 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002029 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002030
Feng Lu4364ee52015-05-22 11:40:03 +02002031 if (argc > 0)
2032 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2033
2034 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002035 if (! table)
2036 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002037
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002038 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002039
2040 return CMD_SUCCESS;
2041}
2042
Feng Lu4364ee52015-05-22 11:40:03 +02002043ALIAS (show_ip_route_summary,
2044 show_ip_route_summary_vrf_cmd,
2045 "show ip route summary " VRF_CMD_STR,
2046 SHOW_STR
2047 IP_STR
2048 "IP routing table\n"
2049 "Summary of all routes\n"
2050 VRF_CMD_HELP_STR)
2051
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002052/* Show route summary prefix. */
2053DEFUN (show_ip_route_summary_prefix,
2054 show_ip_route_summary_prefix_cmd,
2055 "show ip route summary prefix",
2056 SHOW_STR
2057 IP_STR
2058 "IP routing table\n"
2059 "Summary of all routes\n"
2060 "Prefix routes\n")
2061{
2062 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002063 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002064
Feng Lu4364ee52015-05-22 11:40:03 +02002065 if (argc > 0)
2066 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2067
2068 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002069 if (! table)
2070 return CMD_SUCCESS;
2071
2072 vty_show_ip_route_summary_prefix (vty, table);
2073
2074 return CMD_SUCCESS;
2075}
2076
Feng Lu4364ee52015-05-22 11:40:03 +02002077ALIAS (show_ip_route_summary_prefix,
2078 show_ip_route_summary_prefix_vrf_cmd,
2079 "show ip route summary prefix " VRF_CMD_STR,
2080 SHOW_STR
2081 IP_STR
2082 "IP routing table\n"
2083 "Summary of all routes\n"
2084 "Prefix routes\n"
2085 VRF_CMD_HELP_STR)
2086
2087DEFUN (show_ip_route_vrf_all,
2088 show_ip_route_vrf_all_cmd,
2089 "show ip route " VRF_ALL_CMD_STR,
2090 SHOW_STR
2091 IP_STR
2092 "IP routing table\n"
2093 VRF_ALL_CMD_HELP_STR)
2094{
2095 struct route_table *table;
2096 struct route_node *rn;
2097 struct rib *rib;
2098 struct zebra_vrf *zvrf;
2099 vrf_iter_t iter;
2100 int first = 1;
2101
2102 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2103 {
2104 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2105 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2106 continue;
2107
2108 /* Show all IPv4 routes. */
2109 for (rn = route_top (table); rn; rn = route_next (rn))
2110 RNODE_FOREACH_RIB (rn, rib)
2111 {
2112 if (first)
2113 {
2114 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2115 first = 0;
2116 }
2117 vty_show_ip_route (vty, rn, rib);
2118 }
2119 }
2120
2121 return CMD_SUCCESS;
2122}
2123
2124DEFUN (show_ip_route_prefix_longer_vrf_all,
2125 show_ip_route_prefix_longer_vrf_all_cmd,
2126 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2127 SHOW_STR
2128 IP_STR
2129 "IP routing table\n"
2130 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2131 "Show route matching the specified Network/Mask pair only\n"
2132 VRF_ALL_CMD_HELP_STR)
2133{
2134 struct route_table *table;
2135 struct route_node *rn;
2136 struct rib *rib;
2137 struct prefix p;
2138 struct zebra_vrf *zvrf;
2139 vrf_iter_t iter;
2140 int ret;
2141 int first = 1;
2142
2143 ret = str2prefix (argv[0], &p);
2144 if (! ret)
2145 {
2146 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2147 return CMD_WARNING;
2148 }
2149
2150 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2151 {
2152 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2153 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2154 continue;
2155
2156 /* Show matched type IPv4 routes. */
2157 for (rn = route_top (table); rn; rn = route_next (rn))
2158 RNODE_FOREACH_RIB (rn, rib)
2159 if (prefix_match (&p, &rn->p))
2160 {
2161 if (first)
2162 {
2163 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2164 first = 0;
2165 }
2166 vty_show_ip_route (vty, rn, rib);
2167 }
2168 }
2169
2170 return CMD_SUCCESS;
2171}
2172
2173DEFUN (show_ip_route_supernets_vrf_all,
2174 show_ip_route_supernets_vrf_all_cmd,
2175 "show ip route supernets-only " VRF_ALL_CMD_STR,
2176 SHOW_STR
2177 IP_STR
2178 "IP routing table\n"
2179 "Show supernet entries only\n"
2180 VRF_ALL_CMD_HELP_STR)
2181{
2182 struct route_table *table;
2183 struct route_node *rn;
2184 struct rib *rib;
2185 struct zebra_vrf *zvrf;
2186 vrf_iter_t iter;
2187 u_int32_t addr;
2188 int first = 1;
2189
2190 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2191 {
2192 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2193 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2194 continue;
2195
2196 /* Show matched type IPv4 routes. */
2197 for (rn = route_top (table); rn; rn = route_next (rn))
2198 RNODE_FOREACH_RIB (rn, rib)
2199 {
2200 addr = ntohl (rn->p.u.prefix4.s_addr);
2201
2202 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2203 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2204 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2205 {
2206 if (first)
2207 {
2208 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2209 first = 0;
2210 }
2211 vty_show_ip_route (vty, rn, rib);
2212 }
2213 }
2214 }
2215
2216 return CMD_SUCCESS;
2217}
2218
2219DEFUN (show_ip_route_protocol_vrf_all,
2220 show_ip_route_protocol_vrf_all_cmd,
2221 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2222 SHOW_STR
2223 IP_STR
2224 "IP routing table\n"
2225 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2226 VRF_ALL_CMD_HELP_STR)
2227{
2228 int type;
2229 struct route_table *table;
2230 struct route_node *rn;
2231 struct rib *rib;
2232 struct zebra_vrf *zvrf;
2233 vrf_iter_t iter;
2234 int first = 1;
2235
2236 type = proto_redistnum (AFI_IP, argv[0]);
2237 if (type < 0)
2238 {
2239 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2240 return CMD_WARNING;
2241 }
2242
2243 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2244 {
2245 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2246 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2247 continue;
2248
2249 /* Show matched type IPv4 routes. */
2250 for (rn = route_top (table); rn; rn = route_next (rn))
2251 RNODE_FOREACH_RIB (rn, rib)
2252 if (rib->type == type)
2253 {
2254 if (first)
2255 {
2256 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2257 first = 0;
2258 }
2259 vty_show_ip_route (vty, rn, rib);
2260 }
2261 }
2262
2263 return CMD_SUCCESS;
2264}
2265
2266DEFUN (show_ip_route_addr_vrf_all,
2267 show_ip_route_addr_vrf_all_cmd,
2268 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2269 SHOW_STR
2270 IP_STR
2271 "IP routing table\n"
2272 "Network in the IP routing table to display\n"
2273 VRF_ALL_CMD_HELP_STR)
2274{
2275 int ret;
2276 struct prefix_ipv4 p;
2277 struct route_table *table;
2278 struct route_node *rn;
2279 struct zebra_vrf *zvrf;
2280 vrf_iter_t iter;
2281
2282 ret = str2prefix_ipv4 (argv[0], &p);
2283 if (ret <= 0)
2284 {
2285 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2286 return CMD_WARNING;
2287 }
2288
2289 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2290 {
2291 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2292 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2293 continue;
2294
2295 rn = route_node_match (table, (struct prefix *) &p);
2296 if (! rn)
2297 continue;
2298
2299 vty_show_ip_route_detail (vty, rn, 0);
2300
2301 route_unlock_node (rn);
2302 }
2303
2304 return CMD_SUCCESS;
2305}
2306
2307DEFUN (show_ip_route_prefix_vrf_all,
2308 show_ip_route_prefix_vrf_all_cmd,
2309 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2310 SHOW_STR
2311 IP_STR
2312 "IP routing table\n"
2313 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2314 VRF_ALL_CMD_HELP_STR)
2315{
2316 int ret;
2317 struct prefix_ipv4 p;
2318 struct route_table *table;
2319 struct route_node *rn;
2320 struct zebra_vrf *zvrf;
2321 vrf_iter_t iter;
2322
2323 ret = str2prefix_ipv4 (argv[0], &p);
2324 if (ret <= 0)
2325 {
2326 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2327 return CMD_WARNING;
2328 }
2329
2330 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2331 {
2332 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2333 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2334 continue;
2335
2336 rn = route_node_match (table, (struct prefix *) &p);
2337 if (! rn)
2338 continue;
2339 if (rn->p.prefixlen != p.prefixlen)
2340 {
2341 route_unlock_node (rn);
2342 continue;
2343 }
2344
2345 vty_show_ip_route_detail (vty, rn, 0);
2346
2347 route_unlock_node (rn);
2348 }
2349
2350 return CMD_SUCCESS;
2351}
2352
2353DEFUN (show_ip_route_summary_vrf_all,
2354 show_ip_route_summary_vrf_all_cmd,
2355 "show ip route summary " VRF_ALL_CMD_STR,
2356 SHOW_STR
2357 IP_STR
2358 "IP routing table\n"
2359 "Summary of all routes\n"
2360 VRF_ALL_CMD_HELP_STR)
2361{
2362 struct zebra_vrf *zvrf;
2363 vrf_iter_t iter;
2364
2365 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2366 if ((zvrf = vrf_iter2info (iter)) != NULL)
2367 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2368
2369 return CMD_SUCCESS;
2370}
2371
2372DEFUN (show_ip_route_summary_prefix_vrf_all,
2373 show_ip_route_summary_prefix_vrf_all_cmd,
2374 "show ip route summary prefix " VRF_ALL_CMD_STR,
2375 SHOW_STR
2376 IP_STR
2377 "IP routing table\n"
2378 "Summary of all routes\n"
2379 "Prefix routes\n"
2380 VRF_ALL_CMD_HELP_STR)
2381{
2382 struct zebra_vrf *zvrf;
2383 vrf_iter_t iter;
2384
2385 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2386 if ((zvrf = vrf_iter2info (iter)) != NULL)
2387 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2388
2389 return CMD_SUCCESS;
2390}
2391
paul718e3742002-12-13 20:15:29 +00002392/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002393static int
Everton Marques33d86db2014-07-14 11:19:00 -03002394static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002395{
2396 struct route_node *rn;
2397 struct static_ipv4 *si;
2398 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002399 struct zebra_vrf *zvrf;
2400 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002401 int write;
2402
2403 write = 0;
2404
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002405 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2406 {
2407 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2408 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2409 continue;
paul718e3742002-12-13 20:15:29 +00002410
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002411 for (rn = route_top (stable); rn; rn = route_next (rn))
2412 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002413 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002414 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2415 rn->p.prefixlen);
2416
2417 switch (si->type)
2418 {
2419 case STATIC_IPV4_GATEWAY:
2420 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
2421 break;
2422 case STATIC_IPV4_IFNAME:
2423 vty_out (vty, " %s", si->gate.ifname);
2424 break;
2425 case STATIC_IPV4_BLACKHOLE:
2426 vty_out (vty, " Null0");
2427 break;
2428 }
2429
2430 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2431 if (si->type != STATIC_IPV4_BLACKHOLE)
2432 {
2433 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2434 vty_out (vty, " %s", "reject");
2435
2436 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2437 vty_out (vty, " %s", "blackhole");
2438 }
2439
2440 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2441 vty_out (vty, " %d", si->distance);
2442
2443 if (si->vrf_id != VRF_DEFAULT)
2444 vty_out (vty, " vrf %u", si->vrf_id);
2445
2446 vty_out (vty, "%s", VTY_NEWLINE);
2447
2448 write = 1;
paul7021c422003-07-15 12:52:22 +00002449 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002450 }
paul718e3742002-12-13 20:15:29 +00002451 return write;
2452}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002453
2454DEFUN (show_ip_protocol,
2455 show_ip_protocol_cmd,
2456 "show ip protocol",
2457 SHOW_STR
2458 IP_STR
2459 "IP protocol filtering status\n")
2460{
2461 int i;
2462
2463 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2464 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2465 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2466 {
2467 if (proto_rm[AFI_IP][i])
2468 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2469 proto_rm[AFI_IP][i],
2470 VTY_NEWLINE);
2471 else
2472 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2473 }
2474 if (proto_rm[AFI_IP][i])
2475 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2476 VTY_NEWLINE);
2477 else
2478 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2479
2480 return CMD_SUCCESS;
2481}
2482
Joachim Nilsson36735ed2012-05-09 13:38:36 +02002483/*
2484 * Show IP mroute command to dump the BGP Multicast
2485 * routing table
2486 */
2487DEFUN (show_ip_mroute,
2488 show_ip_mroute_cmd,
2489 "show ip mroute",
2490 SHOW_STR
2491 IP_STR
2492 "IP Multicast routing table\n")
2493{
2494 struct route_table *table;
2495 struct route_node *rn;
2496 struct rib *rib;
2497 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02002498 vrf_id_t vrf_id = VRF_DEFAULT;
Joachim Nilsson36735ed2012-05-09 13:38:36 +02002499
Feng Lu4364ee52015-05-22 11:40:03 +02002500 if (argc > 0)
2501 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2502
2503 table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, vrf_id);
Joachim Nilsson36735ed2012-05-09 13:38:36 +02002504 if (! table)
2505 return CMD_SUCCESS;
2506
2507 /* Show all IPv4 routes. */
2508 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002509 RNODE_FOREACH_RIB (rn, rib)
Joachim Nilsson36735ed2012-05-09 13:38:36 +02002510 {
2511 if (first)
2512 {
2513 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2514 first = 0;
2515 }
2516 vty_show_ip_route (vty, rn, rib);
2517 }
2518 return CMD_SUCCESS;
2519}
2520
Feng Lu4364ee52015-05-22 11:40:03 +02002521ALIAS (show_ip_mroute,
2522 show_ip_mroute_vrf_cmd,
2523 "show ip mroute " VRF_CMD_STR,
2524 SHOW_STR
2525 IP_STR
2526 "IP Multicast routing table\n"
2527 VRF_CMD_HELP_STR)
2528
2529DEFUN (show_ip_mroute_vrf_all,
2530 show_ip_mroute_vrf_all_cmd,
2531 "show ip mroute " VRF_ALL_CMD_STR,
2532 SHOW_STR
2533 IP_STR
2534 "IP Multicast routing table\n"
2535 VRF_ALL_CMD_HELP_STR)
2536{
2537 struct route_table *table;
2538 struct route_node *rn;
2539 struct rib *rib;
2540 struct zebra_vrf *zvrf;
2541 vrf_iter_t iter;
2542 int first = 1;
2543
2544 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2545 {
2546 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2547 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2548 continue;
2549
2550 /* Show all IPv4 routes. */
2551 for (rn = route_top (table); rn; rn = route_next (rn))
2552 RNODE_FOREACH_RIB (rn, rib)
2553 {
2554 if (first)
2555 {
2556 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2557 first = 0;
2558 }
2559 vty_show_ip_route (vty, rn, rib);
2560 }
2561 }
2562
2563 return CMD_SUCCESS;
2564}
David Lamparter6b0655a2014-06-04 06:53:35 +02002565
paul718e3742002-12-13 20:15:29 +00002566#ifdef HAVE_IPV6
2567/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002568static int
hasso39db97e2004-10-12 20:50:58 +00002569static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2570 const char *gate_str, const char *ifname,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002571 const char *flag_str, const char *distance_str,
2572 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002573{
2574 int ret;
2575 u_char distance;
2576 struct prefix p;
2577 struct in6_addr *gate = NULL;
2578 struct in6_addr gate_addr;
2579 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002580 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002581 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00002582
2583 ret = str2prefix (dest_str, &p);
2584 if (ret <= 0)
2585 {
2586 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2587 return CMD_WARNING;
2588 }
2589
2590 /* Apply mask for given prefix. */
2591 apply_mask (&p);
2592
hasso81dfcaa2003-05-25 19:21:25 +00002593 /* Route flags */
2594 if (flag_str) {
2595 switch(flag_str[0]) {
2596 case 'r':
2597 case 'R': /* XXX */
2598 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2599 break;
2600 case 'b':
2601 case 'B': /* XXX */
2602 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2603 break;
2604 default:
2605 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002606 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002607 }
2608 }
2609
paul718e3742002-12-13 20:15:29 +00002610 /* Administrative distance. */
2611 if (distance_str)
2612 distance = atoi (distance_str);
2613 else
2614 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2615
2616 /* When gateway is valid IPv6 addrees, then gate is treated as
2617 nexthop address other case gate is treated as interface name. */
2618 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2619
2620 if (ifname)
2621 {
2622 /* When ifname is specified. It must be come with gateway
2623 address. */
2624 if (ret != 1)
2625 {
2626 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2627 return CMD_WARNING;
2628 }
2629 type = STATIC_IPV6_GATEWAY_IFNAME;
2630 gate = &gate_addr;
2631 }
2632 else
2633 {
2634 if (ret == 1)
2635 {
2636 type = STATIC_IPV6_GATEWAY;
2637 gate = &gate_addr;
2638 }
2639 else
2640 {
2641 type = STATIC_IPV6_IFNAME;
2642 ifname = gate_str;
2643 }
2644 }
2645
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002646 /* VRF id */
2647 if (vrf_id_str)
2648 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2649
paul718e3742002-12-13 20:15:29 +00002650 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002651 static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002652 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002653 static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002654
2655 return CMD_SUCCESS;
2656}
2657
2658DEFUN (ipv6_route,
2659 ipv6_route_cmd,
2660 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2661 IP_STR
2662 "Establish static routes\n"
2663 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2664 "IPv6 gateway address\n"
2665 "IPv6 gateway interface name\n")
2666{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002667 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2668 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002669}
2670
2671DEFUN (ipv6_route_flags,
2672 ipv6_route_flags_cmd,
2673 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2674 IP_STR
2675 "Establish static routes\n"
2676 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2677 "IPv6 gateway address\n"
2678 "IPv6 gateway interface name\n"
2679 "Emit an ICMP unreachable when matched\n"
2680 "Silently discard pkts when matched\n")
2681{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002682 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2683 NULL);
paul718e3742002-12-13 20:15:29 +00002684}
2685
2686DEFUN (ipv6_route_ifname,
2687 ipv6_route_ifname_cmd,
2688 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2689 IP_STR
2690 "Establish static routes\n"
2691 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2692 "IPv6 gateway address\n"
2693 "IPv6 gateway interface name\n")
2694{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002695 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2696 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002697}
2698
2699DEFUN (ipv6_route_ifname_flags,
2700 ipv6_route_ifname_flags_cmd,
2701 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2702 IP_STR
2703 "Establish static routes\n"
2704 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2705 "IPv6 gateway address\n"
2706 "IPv6 gateway interface name\n"
2707 "Emit an ICMP unreachable when matched\n"
2708 "Silently discard pkts when matched\n")
2709{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002710 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2711 NULL);
paul718e3742002-12-13 20:15:29 +00002712}
2713
2714DEFUN (ipv6_route_pref,
2715 ipv6_route_pref_cmd,
2716 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2717 IP_STR
2718 "Establish static routes\n"
2719 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2720 "IPv6 gateway address\n"
2721 "IPv6 gateway interface name\n"
2722 "Distance value for this prefix\n")
2723{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002724 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2725 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002726}
2727
2728DEFUN (ipv6_route_flags_pref,
2729 ipv6_route_flags_pref_cmd,
2730 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2731 IP_STR
2732 "Establish static routes\n"
2733 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2734 "IPv6 gateway address\n"
2735 "IPv6 gateway interface name\n"
2736 "Emit an ICMP unreachable when matched\n"
2737 "Silently discard pkts when matched\n"
2738 "Distance value for this prefix\n")
2739{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002740 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2741 NULL);
paul718e3742002-12-13 20:15:29 +00002742}
2743
2744DEFUN (ipv6_route_ifname_pref,
2745 ipv6_route_ifname_pref_cmd,
2746 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2747 IP_STR
2748 "Establish static routes\n"
2749 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2750 "IPv6 gateway address\n"
2751 "IPv6 gateway interface name\n"
2752 "Distance value for this prefix\n")
2753{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002754 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2755 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002756}
2757
2758DEFUN (ipv6_route_ifname_flags_pref,
2759 ipv6_route_ifname_flags_pref_cmd,
2760 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2761 IP_STR
2762 "Establish static routes\n"
2763 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2764 "IPv6 gateway address\n"
2765 "IPv6 gateway interface name\n"
2766 "Emit an ICMP unreachable when matched\n"
2767 "Silently discard pkts when matched\n"
2768 "Distance value for this prefix\n")
2769{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002770 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2771 NULL);
paul718e3742002-12-13 20:15:29 +00002772}
2773
2774DEFUN (no_ipv6_route,
2775 no_ipv6_route_cmd,
2776 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2777 NO_STR
2778 IP_STR
2779 "Establish static routes\n"
2780 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2781 "IPv6 gateway address\n"
2782 "IPv6 gateway interface name\n")
2783{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002784 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2785 NULL);
paul718e3742002-12-13 20:15:29 +00002786}
2787
hasso81dfcaa2003-05-25 19:21:25 +00002788ALIAS (no_ipv6_route,
2789 no_ipv6_route_flags_cmd,
2790 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2791 NO_STR
2792 IP_STR
2793 "Establish static routes\n"
2794 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2795 "IPv6 gateway address\n"
2796 "IPv6 gateway interface name\n"
2797 "Emit an ICMP unreachable when matched\n"
2798 "Silently discard pkts when matched\n")
2799
paul718e3742002-12-13 20:15:29 +00002800DEFUN (no_ipv6_route_ifname,
2801 no_ipv6_route_ifname_cmd,
2802 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2803 NO_STR
2804 IP_STR
2805 "Establish static routes\n"
2806 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2807 "IPv6 gateway address\n"
2808 "IPv6 gateway interface name\n")
2809{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002810 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2811 NULL);
paul718e3742002-12-13 20:15:29 +00002812}
2813
hasso81dfcaa2003-05-25 19:21:25 +00002814ALIAS (no_ipv6_route_ifname,
2815 no_ipv6_route_ifname_flags_cmd,
2816 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2817 NO_STR
2818 IP_STR
2819 "Establish static routes\n"
2820 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2821 "IPv6 gateway address\n"
2822 "IPv6 gateway interface name\n"
2823 "Emit an ICMP unreachable when matched\n"
2824 "Silently discard pkts when matched\n")
2825
paul718e3742002-12-13 20:15:29 +00002826DEFUN (no_ipv6_route_pref,
2827 no_ipv6_route_pref_cmd,
2828 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2829 NO_STR
2830 IP_STR
2831 "Establish static routes\n"
2832 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2833 "IPv6 gateway address\n"
2834 "IPv6 gateway interface name\n"
2835 "Distance value for this prefix\n")
2836{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002837 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
2838 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002839}
2840
2841DEFUN (no_ipv6_route_flags_pref,
2842 no_ipv6_route_flags_pref_cmd,
2843 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2844 NO_STR
2845 IP_STR
2846 "Establish static routes\n"
2847 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2848 "IPv6 gateway address\n"
2849 "IPv6 gateway interface name\n"
2850 "Emit an ICMP unreachable when matched\n"
2851 "Silently discard pkts when matched\n"
2852 "Distance value for this prefix\n")
2853{
2854 /* We do not care about argv[2] */
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002855 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
2856 NULL);
paul718e3742002-12-13 20:15:29 +00002857}
2858
2859DEFUN (no_ipv6_route_ifname_pref,
2860 no_ipv6_route_ifname_pref_cmd,
2861 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2862 NO_STR
2863 IP_STR
2864 "Establish static routes\n"
2865 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2866 "IPv6 gateway address\n"
2867 "IPv6 gateway interface name\n"
2868 "Distance value for this prefix\n")
2869{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002870 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
2871 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002872}
2873
2874DEFUN (no_ipv6_route_ifname_flags_pref,
2875 no_ipv6_route_ifname_flags_pref_cmd,
2876 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2877 NO_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 "Emit an ICMP unreachable when matched\n"
2884 "Silently discard pkts when matched\n"
2885 "Distance value for this prefix\n")
2886{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002887 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
2888 NULL);
2889}
2890
2891DEFUN (ipv6_route_vrf,
2892 ipv6_route_vrf_cmd,
2893 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2894 IP_STR
2895 "Establish static routes\n"
2896 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2897 "IPv6 gateway address\n"
2898 "IPv6 gateway interface name\n"
2899 VRF_CMD_HELP_STR)
2900{
2901 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2902 argv[2]);
2903}
2904
2905DEFUN (ipv6_route_flags_vrf,
2906 ipv6_route_flags_vrf_cmd,
2907 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " 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 "Emit an ICMP unreachable when matched\n"
2914 "Silently discard pkts when matched\n"
2915 VRF_CMD_HELP_STR)
2916{
2917 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2918 argv[3]);
2919}
2920
2921DEFUN (ipv6_route_ifname_vrf,
2922 ipv6_route_ifname_vrf_cmd,
2923 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2924 IP_STR
2925 "Establish static routes\n"
2926 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2927 "IPv6 gateway address\n"
2928 "IPv6 gateway interface name\n"
2929 VRF_CMD_HELP_STR)
2930{
2931 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2932 argv[3]);
2933}
2934
2935DEFUN (ipv6_route_ifname_flags_vrf,
2936 ipv6_route_ifname_flags_vrf_cmd,
2937 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2938 IP_STR
2939 "Establish static routes\n"
2940 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2941 "IPv6 gateway address\n"
2942 "IPv6 gateway interface name\n"
2943 "Emit an ICMP unreachable when matched\n"
2944 "Silently discard pkts when matched\n"
2945 VRF_CMD_HELP_STR)
2946{
2947 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2948 argv[4]);
2949}
2950
2951DEFUN (ipv6_route_pref_vrf,
2952 ipv6_route_pref_vrf_cmd,
2953 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2954 IP_STR
2955 "Establish static routes\n"
2956 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2957 "IPv6 gateway address\n"
2958 "IPv6 gateway interface name\n"
2959 "Distance value for this prefix\n"
2960 VRF_CMD_HELP_STR)
2961{
2962 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2963 argv[3]);
2964}
2965
2966DEFUN (ipv6_route_flags_pref_vrf,
2967 ipv6_route_flags_pref_vrf_cmd,
2968 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2969 IP_STR
2970 "Establish static routes\n"
2971 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2972 "IPv6 gateway address\n"
2973 "IPv6 gateway interface name\n"
2974 "Emit an ICMP unreachable when matched\n"
2975 "Silently discard pkts when matched\n"
2976 "Distance value for this prefix\n"
2977 VRF_CMD_HELP_STR)
2978{
2979 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2980 argv[4]);
2981}
2982
2983DEFUN (ipv6_route_ifname_pref_vrf,
2984 ipv6_route_ifname_pref_vrf_cmd,
2985 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2986 IP_STR
2987 "Establish static routes\n"
2988 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2989 "IPv6 gateway address\n"
2990 "IPv6 gateway interface name\n"
2991 "Distance value for this prefix\n"
2992 VRF_CMD_HELP_STR)
2993{
2994 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2995 argv[4]);
2996}
2997
2998DEFUN (ipv6_route_ifname_flags_pref_vrf,
2999 ipv6_route_ifname_flags_pref_vrf_cmd,
3000 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_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 "Emit an ICMP unreachable when matched\n"
3007 "Silently discard pkts when matched\n"
3008 "Distance value for this prefix\n"
3009 VRF_CMD_HELP_STR)
3010{
3011 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
3012 argv[5]);
3013}
3014
3015DEFUN (no_ipv6_route_vrf,
3016 no_ipv6_route_vrf_cmd,
3017 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
3018 NO_STR
3019 IP_STR
3020 "Establish static routes\n"
3021 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3022 "IPv6 gateway address\n"
3023 "IPv6 gateway interface name\n"
3024 VRF_CMD_HELP_STR)
3025{
3026 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
3027 (argc > 3) ? argv[3] : argv[2]);
3028}
3029
3030ALIAS (no_ipv6_route_vrf,
3031 no_ipv6_route_flags_vrf_cmd,
3032 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
3033 NO_STR
3034 IP_STR
3035 "Establish static routes\n"
3036 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3037 "IPv6 gateway address\n"
3038 "IPv6 gateway interface name\n"
3039 "Emit an ICMP unreachable when matched\n"
3040 "Silently discard pkts when matched\n"
3041 VRF_CMD_HELP_STR)
3042
3043DEFUN (no_ipv6_route_ifname_vrf,
3044 no_ipv6_route_ifname_vrf_cmd,
3045 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
3046 NO_STR
3047 IP_STR
3048 "Establish static routes\n"
3049 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3050 "IPv6 gateway address\n"
3051 "IPv6 gateway interface name\n"
3052 VRF_CMD_HELP_STR)
3053{
3054 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
3055 (argc > 4) ? argv[4] : argv[3]);
3056}
3057
3058ALIAS (no_ipv6_route_ifname_vrf,
3059 no_ipv6_route_ifname_flags_vrf_cmd,
3060 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
3061 NO_STR
3062 IP_STR
3063 "Establish static routes\n"
3064 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3065 "IPv6 gateway address\n"
3066 "IPv6 gateway interface name\n"
3067 "Emit an ICMP unreachable when matched\n"
3068 "Silently discard pkts when matched\n"
3069 VRF_CMD_HELP_STR)
3070
3071DEFUN (no_ipv6_route_pref_vrf,
3072 no_ipv6_route_pref_vrf_cmd,
3073 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
3074 NO_STR
3075 IP_STR
3076 "Establish static routes\n"
3077 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3078 "IPv6 gateway address\n"
3079 "IPv6 gateway interface name\n"
3080 "Distance value for this prefix\n"
3081 VRF_CMD_HELP_STR)
3082{
3083 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
3084 argv[3]);
3085}
3086
3087DEFUN (no_ipv6_route_flags_pref_vrf,
3088 no_ipv6_route_flags_pref_vrf_cmd,
3089 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3090 NO_STR
3091 IP_STR
3092 "Establish static routes\n"
3093 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3094 "IPv6 gateway address\n"
3095 "IPv6 gateway interface name\n"
3096 "Emit an ICMP unreachable when matched\n"
3097 "Silently discard pkts when matched\n"
3098 "Distance value for this prefix\n"
3099 VRF_CMD_HELP_STR)
3100{
3101 /* We do not care about argv[2] */
3102 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
3103 argv[4]);
3104}
3105
3106DEFUN (no_ipv6_route_ifname_pref_vrf,
3107 no_ipv6_route_ifname_pref_vrf_cmd,
3108 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3109 NO_STR
3110 IP_STR
3111 "Establish static routes\n"
3112 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3113 "IPv6 gateway address\n"
3114 "IPv6 gateway interface name\n"
3115 "Distance value for this prefix\n"
3116 VRF_CMD_HELP_STR)
3117{
3118 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
3119 argv[4]);
3120}
3121
3122DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3123 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3124 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3125 NO_STR
3126 IP_STR
3127 "Establish static routes\n"
3128 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3129 "IPv6 gateway address\n"
3130 "IPv6 gateway interface name\n"
3131 "Emit an ICMP unreachable when matched\n"
3132 "Silently discard pkts when matched\n"
3133 "Distance value for this prefix\n"
3134 VRF_CMD_HELP_STR)
3135{
3136 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
3137 argv[5]);
paul718e3742002-12-13 20:15:29 +00003138}
3139
paul718e3742002-12-13 20:15:29 +00003140DEFUN (show_ipv6_route,
3141 show_ipv6_route_cmd,
3142 "show ipv6 route",
3143 SHOW_STR
3144 IP_STR
3145 "IPv6 routing table\n")
3146{
3147 struct route_table *table;
3148 struct route_node *rn;
3149 struct rib *rib;
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
Feng Lu4364ee52015-05-22 11:40:03 +02003153 if (argc > 0)
3154 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3155
3156 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003157 if (! table)
3158 return CMD_SUCCESS;
3159
3160 /* Show all IPv6 route. */
3161 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003162 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003163 {
3164 if (first)
3165 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003166 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003167 first = 0;
3168 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003169 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003170 }
3171 return CMD_SUCCESS;
3172}
3173
Feng Lu4364ee52015-05-22 11:40:03 +02003174ALIAS (show_ipv6_route,
3175 show_ipv6_route_vrf_cmd,
3176 "show ipv6 route " VRF_CMD_STR,
3177 SHOW_STR
3178 IP_STR
3179 "IPv6 routing table\n"
3180 VRF_CMD_HELP_STR)
3181
paul718e3742002-12-13 20:15:29 +00003182DEFUN (show_ipv6_route_prefix_longer,
3183 show_ipv6_route_prefix_longer_cmd,
3184 "show ipv6 route X:X::X:X/M longer-prefixes",
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{
3191 struct route_table *table;
3192 struct route_node *rn;
3193 struct rib *rib;
3194 struct prefix p;
3195 int ret;
3196 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003197 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003198
3199 ret = str2prefix (argv[0], &p);
3200 if (! ret)
3201 {
3202 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3203 return CMD_WARNING;
3204 }
3205
Feng Lu4364ee52015-05-22 11:40:03 +02003206 if (argc > 1)
3207 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3208
3209 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3210 if (! table)
3211 return CMD_SUCCESS;
3212
paul718e3742002-12-13 20:15:29 +00003213 /* Show matched type IPv6 routes. */
3214 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003215 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003216 if (prefix_match (&p, &rn->p))
3217 {
3218 if (first)
3219 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003220 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003221 first = 0;
3222 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003223 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003224 }
3225 return CMD_SUCCESS;
3226}
3227
Feng Lu4364ee52015-05-22 11:40:03 +02003228ALIAS (show_ipv6_route_prefix_longer,
3229 show_ipv6_route_prefix_longer_vrf_cmd,
3230 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3231 SHOW_STR
3232 IP_STR
3233 "IPv6 routing table\n"
3234 "IPv6 prefix\n"
3235 "Show route matching the specified Network/Mask pair only\n"
3236 VRF_CMD_HELP_STR)
3237
paul718e3742002-12-13 20:15:29 +00003238DEFUN (show_ipv6_route_protocol,
3239 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003240 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003241 SHOW_STR
3242 IP_STR
3243 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003244 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003245{
3246 int type;
3247 struct route_table *table;
3248 struct route_node *rn;
3249 struct rib *rib;
3250 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003251 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003252
David Lampartere0ca5fd2009-09-16 01:52:42 +02003253 type = proto_redistnum (AFI_IP6, argv[0]);
3254 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003255 {
3256 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3257 return CMD_WARNING;
3258 }
Feng Lu4364ee52015-05-22 11:40:03 +02003259
3260 if (argc > 1)
3261 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3262
3263 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003264 if (! table)
3265 return CMD_SUCCESS;
3266
3267 /* Show matched type IPv6 routes. */
3268 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003269 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003270 if (rib->type == type)
3271 {
3272 if (first)
3273 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003274 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003275 first = 0;
3276 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003277 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003278 }
3279 return CMD_SUCCESS;
3280}
3281
Feng Lu4364ee52015-05-22 11:40:03 +02003282ALIAS (show_ipv6_route_protocol,
3283 show_ipv6_route_protocol_vrf_cmd,
3284 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3285 SHOW_STR
3286 IP_STR
3287 "IP routing table\n"
3288 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3289 VRF_CMD_HELP_STR)
3290
paul718e3742002-12-13 20:15:29 +00003291DEFUN (show_ipv6_route_addr,
3292 show_ipv6_route_addr_cmd,
3293 "show ipv6 route X:X::X:X",
3294 SHOW_STR
3295 IP_STR
3296 "IPv6 routing table\n"
3297 "IPv6 Address\n")
3298{
3299 int ret;
3300 struct prefix_ipv6 p;
3301 struct route_table *table;
3302 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003303 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003304
3305 ret = str2prefix_ipv6 (argv[0], &p);
3306 if (ret <= 0)
3307 {
3308 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3309 return CMD_WARNING;
3310 }
3311
Feng Lu4364ee52015-05-22 11:40:03 +02003312 if (argc > 1)
3313 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3314
3315 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003316 if (! table)
3317 return CMD_SUCCESS;
3318
3319 rn = route_node_match (table, (struct prefix *) &p);
3320 if (! rn)
3321 {
3322 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3323 return CMD_WARNING;
3324 }
3325
Timo Teräs53a5c392015-05-23 11:08:40 +03003326 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003327
3328 route_unlock_node (rn);
3329
3330 return CMD_SUCCESS;
3331}
3332
Feng Lu4364ee52015-05-22 11:40:03 +02003333ALIAS (show_ipv6_route_addr,
3334 show_ipv6_route_addr_vrf_cmd,
3335 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3336 SHOW_STR
3337 IP_STR
3338 "IPv6 routing table\n"
3339 "IPv6 Address\n"
3340 VRF_CMD_HELP_STR)
3341
paul718e3742002-12-13 20:15:29 +00003342DEFUN (show_ipv6_route_prefix,
3343 show_ipv6_route_prefix_cmd,
3344 "show ipv6 route X:X::X:X/M",
3345 SHOW_STR
3346 IP_STR
3347 "IPv6 routing table\n"
3348 "IPv6 prefix\n")
3349{
3350 int ret;
3351 struct prefix_ipv6 p;
3352 struct route_table *table;
3353 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003354 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003355
3356 ret = str2prefix_ipv6 (argv[0], &p);
3357 if (ret <= 0)
3358 {
3359 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3360 return CMD_WARNING;
3361 }
3362
Feng Lu4364ee52015-05-22 11:40:03 +02003363 if (argc > 1)
3364 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3365
3366 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003367 if (! table)
3368 return CMD_SUCCESS;
3369
3370 rn = route_node_match (table, (struct prefix *) &p);
3371 if (! rn || rn->p.prefixlen != p.prefixlen)
3372 {
3373 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003374 if (rn)
3375 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003376 return CMD_WARNING;
3377 }
3378
Timo Teräs53a5c392015-05-23 11:08:40 +03003379 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003380
3381 route_unlock_node (rn);
3382
3383 return CMD_SUCCESS;
3384}
3385
Feng Lu4364ee52015-05-22 11:40:03 +02003386ALIAS (show_ipv6_route_prefix,
3387 show_ipv6_route_prefix_vrf_cmd,
3388 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3389 SHOW_STR
3390 IP_STR
3391 "IPv6 routing table\n"
3392 "IPv6 prefix\n"
3393 VRF_CMD_HELP_STR)
3394
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003395/* Show route summary. */
3396DEFUN (show_ipv6_route_summary,
3397 show_ipv6_route_summary_cmd,
3398 "show ipv6 route summary",
3399 SHOW_STR
3400 IP_STR
3401 "IPv6 routing table\n"
3402 "Summary of all IPv6 routes\n")
3403{
3404 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003405 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003406
Feng Lu4364ee52015-05-22 11:40:03 +02003407 if (argc > 0)
3408 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3409
3410 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003411 if (! table)
3412 return CMD_SUCCESS;
3413
3414 vty_show_ip_route_summary (vty, table);
3415
3416 return CMD_SUCCESS;
3417}
3418
Feng Lu4364ee52015-05-22 11:40:03 +02003419ALIAS (show_ipv6_route_summary,
3420 show_ipv6_route_summary_vrf_cmd,
3421 "show ipv6 route summary " VRF_CMD_STR,
3422 SHOW_STR
3423 IP_STR
3424 "IPv6 routing table\n"
3425 "Summary of all IPv6 routes\n"
3426 VRF_CMD_HELP_STR)
3427
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003428/* Show ipv6 route summary prefix. */
3429DEFUN (show_ipv6_route_summary_prefix,
3430 show_ipv6_route_summary_prefix_cmd,
3431 "show ipv6 route summary prefix",
3432 SHOW_STR
3433 IP_STR
3434 "IPv6 routing table\n"
3435 "Summary of all IPv6 routes\n"
3436 "Prefix routes\n")
3437{
3438 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003439 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003440
Feng Lu4364ee52015-05-22 11:40:03 +02003441 if (argc > 0)
3442 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3443
3444 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003445 if (! table)
3446 return CMD_SUCCESS;
3447
3448 vty_show_ip_route_summary_prefix (vty, table);
3449
3450 return CMD_SUCCESS;
3451}
3452
Feng Lu4364ee52015-05-22 11:40:03 +02003453ALIAS (show_ipv6_route_summary_prefix,
3454 show_ipv6_route_summary_prefix_vrf_cmd,
3455 "show ipv6 route summary prefix " VRF_CMD_STR,
3456 SHOW_STR
3457 IP_STR
3458 "IPv6 routing table\n"
3459 "Summary of all IPv6 routes\n"
3460 "Prefix routes\n"
3461 VRF_CMD_HELP_STR)
3462
G.Balajicddf3912011-11-26 21:59:32 +04003463/*
G.Balajicddf3912011-11-26 21:59:32 +04003464 * Show IPv6 mroute command.Used to dump
3465 * the Multicast routing table.
3466 */
3467
3468DEFUN (show_ipv6_mroute,
3469 show_ipv6_mroute_cmd,
3470 "show ipv6 mroute",
3471 SHOW_STR
3472 IP_STR
3473 "IPv6 Multicast routing table\n")
3474{
3475 struct route_table *table;
3476 struct route_node *rn;
3477 struct rib *rib;
3478 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003479 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003480
Feng Lu4364ee52015-05-22 11:40:03 +02003481 if (argc > 0)
3482 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3483
3484 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003485 if (! table)
3486 return CMD_SUCCESS;
3487
3488 /* Show all IPv6 route. */
3489 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003490 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003491 {
3492 if (first)
3493 {
G.Balajicb32fd62011-11-27 20:09:40 +05303494 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003495 first = 0;
3496 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003497 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003498 }
3499 return CMD_SUCCESS;
3500}
3501
Feng Lu4364ee52015-05-22 11:40:03 +02003502ALIAS (show_ipv6_mroute,
3503 show_ipv6_mroute_vrf_cmd,
3504 "show ipv6 mroute " VRF_CMD_STR,
3505 SHOW_STR
3506 IP_STR
3507 "IPv6 Multicast routing table\n"
3508 VRF_CMD_HELP_STR)
3509
3510DEFUN (show_ipv6_route_vrf_all,
3511 show_ipv6_route_vrf_all_cmd,
3512 "show ipv6 route " VRF_ALL_CMD_STR,
3513 SHOW_STR
3514 IP_STR
3515 "IPv6 routing table\n"
3516 VRF_ALL_CMD_HELP_STR)
3517{
3518 struct route_table *table;
3519 struct route_node *rn;
3520 struct rib *rib;
3521 struct zebra_vrf *zvrf;
3522 vrf_iter_t iter;
3523 int first = 1;
3524
3525 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3526 {
3527 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3528 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3529 continue;
3530
3531 /* Show all IPv6 route. */
3532 for (rn = route_top (table); rn; rn = route_next (rn))
3533 RNODE_FOREACH_RIB (rn, rib)
3534 {
3535 if (first)
3536 {
3537 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3538 first = 0;
3539 }
3540 vty_show_ip_route (vty, rn, rib);
3541 }
3542 }
3543
3544 return CMD_SUCCESS;
3545}
3546
3547DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3548 show_ipv6_route_prefix_longer_vrf_all_cmd,
3549 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3550 SHOW_STR
3551 IP_STR
3552 "IPv6 routing table\n"
3553 "IPv6 prefix\n"
3554 "Show route matching the specified Network/Mask pair only\n"
3555 VRF_ALL_CMD_HELP_STR)
3556{
3557 struct route_table *table;
3558 struct route_node *rn;
3559 struct rib *rib;
3560 struct prefix p;
3561 struct zebra_vrf *zvrf;
3562 vrf_iter_t iter;
3563 int ret;
3564 int first = 1;
3565
3566 ret = str2prefix (argv[0], &p);
3567 if (! ret)
3568 {
3569 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3570 return CMD_WARNING;
3571 }
3572
3573 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3574 {
3575 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3576 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3577 continue;
3578
3579 /* Show matched type IPv6 routes. */
3580 for (rn = route_top (table); rn; rn = route_next (rn))
3581 RNODE_FOREACH_RIB (rn, rib)
3582 if (prefix_match (&p, &rn->p))
3583 {
3584 if (first)
3585 {
3586 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3587 first = 0;
3588 }
3589 vty_show_ip_route (vty, rn, rib);
3590 }
3591 }
3592
3593 return CMD_SUCCESS;
3594}
3595
3596DEFUN (show_ipv6_route_protocol_vrf_all,
3597 show_ipv6_route_protocol_vrf_all_cmd,
3598 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3599 SHOW_STR
3600 IP_STR
3601 "IP routing table\n"
3602 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3603 VRF_ALL_CMD_HELP_STR)
3604{
3605 int type;
3606 struct route_table *table;
3607 struct route_node *rn;
3608 struct rib *rib;
3609 struct zebra_vrf *zvrf;
3610 vrf_iter_t iter;
3611 int first = 1;
3612
3613 type = proto_redistnum (AFI_IP6, argv[0]);
3614 if (type < 0)
3615 {
3616 vty_out (vty, "Unknown route type%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 /* Show matched type IPv6 routes. */
3627 for (rn = route_top (table); rn; rn = route_next (rn))
3628 RNODE_FOREACH_RIB (rn, rib)
3629 if (rib->type == type)
3630 {
3631 if (first)
3632 {
3633 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3634 first = 0;
3635 }
3636 vty_show_ip_route (vty, rn, rib);
3637 }
3638 }
3639
3640 return CMD_SUCCESS;
3641}
3642
3643DEFUN (show_ipv6_route_addr_vrf_all,
3644 show_ipv6_route_addr_vrf_all_cmd,
3645 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3646 SHOW_STR
3647 IP_STR
3648 "IPv6 routing table\n"
3649 "IPv6 Address\n"
3650 VRF_ALL_CMD_HELP_STR)
3651{
3652 int ret;
3653 struct prefix_ipv6 p;
3654 struct route_table *table;
3655 struct route_node *rn;
3656 struct zebra_vrf *zvrf;
3657 vrf_iter_t iter;
3658
3659 ret = str2prefix_ipv6 (argv[0], &p);
3660 if (ret <= 0)
3661 {
3662 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3663 return CMD_WARNING;
3664 }
3665
3666 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3667 {
3668 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3669 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3670 continue;
3671
3672 rn = route_node_match (table, (struct prefix *) &p);
3673 if (! rn)
3674 continue;
3675
3676 vty_show_ip_route_detail (vty, rn, 0);
3677
3678 route_unlock_node (rn);
3679 }
3680
3681 return CMD_SUCCESS;
3682}
3683
3684DEFUN (show_ipv6_route_prefix_vrf_all,
3685 show_ipv6_route_prefix_vrf_all_cmd,
3686 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3687 SHOW_STR
3688 IP_STR
3689 "IPv6 routing table\n"
3690 "IPv6 prefix\n"
3691 VRF_ALL_CMD_HELP_STR)
3692{
3693 int ret;
3694 struct prefix_ipv6 p;
3695 struct route_table *table;
3696 struct route_node *rn;
3697 struct zebra_vrf *zvrf;
3698 vrf_iter_t iter;
3699
3700 ret = str2prefix_ipv6 (argv[0], &p);
3701 if (ret <= 0)
3702 {
3703 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3704 return CMD_WARNING;
3705 }
3706
3707 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3708 {
3709 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3710 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3711 continue;
3712
3713 rn = route_node_match (table, (struct prefix *) &p);
3714 if (! rn)
3715 continue;
3716 if (rn->p.prefixlen != p.prefixlen)
3717 {
3718 route_unlock_node (rn);
3719 continue;
3720 }
3721
3722 vty_show_ip_route_detail (vty, rn, 0);
3723
3724 route_unlock_node (rn);
3725 }
3726
3727 return CMD_SUCCESS;
3728}
3729
3730/* Show route summary. */
3731DEFUN (show_ipv6_route_summary_vrf_all,
3732 show_ipv6_route_summary_vrf_all_cmd,
3733 "show ipv6 route summary " VRF_ALL_CMD_STR,
3734 SHOW_STR
3735 IP_STR
3736 "IPv6 routing table\n"
3737 "Summary of all IPv6 routes\n"
3738 VRF_ALL_CMD_HELP_STR)
3739{
3740 struct zebra_vrf *zvrf;
3741 vrf_iter_t iter;
3742
3743 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3744 if ((zvrf = vrf_iter2info (iter)) != NULL)
3745 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3746
3747 return CMD_SUCCESS;
3748}
3749
3750DEFUN (show_ipv6_mroute_vrf_all,
3751 show_ipv6_mroute_vrf_all_cmd,
3752 "show ipv6 mroute " VRF_ALL_CMD_STR,
3753 SHOW_STR
3754 IP_STR
3755 "IPv6 Multicast routing table\n"
3756 VRF_ALL_CMD_HELP_STR)
3757{
3758 struct route_table *table;
3759 struct route_node *rn;
3760 struct rib *rib;
3761 struct zebra_vrf *zvrf;
3762 vrf_iter_t iter;
3763 int first = 1;
3764
3765 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3766 {
3767 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3768 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3769 continue;
3770
3771 /* Show all IPv6 route. */
3772 for (rn = route_top (table); rn; rn = route_next (rn))
3773 RNODE_FOREACH_RIB (rn, rib)
3774 {
3775 if (first)
3776 {
3777 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3778 first = 0;
3779 }
3780 vty_show_ip_route (vty, rn, rib);
3781 }
3782 }
3783 return CMD_SUCCESS;
3784}
3785
3786DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3787 show_ipv6_route_summary_prefix_vrf_all_cmd,
3788 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3789 SHOW_STR
3790 IP_STR
3791 "IPv6 routing table\n"
3792 "Summary of all IPv6 routes\n"
3793 "Prefix routes\n"
3794 VRF_ALL_CMD_HELP_STR)
3795{
3796 struct zebra_vrf *zvrf;
3797 vrf_iter_t iter;
3798
3799 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3800 if ((zvrf = vrf_iter2info (iter)) != NULL)
3801 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3802
3803 return CMD_SUCCESS;
3804}
3805
paul718e3742002-12-13 20:15:29 +00003806/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003807static int
paul718e3742002-12-13 20:15:29 +00003808static_config_ipv6 (struct vty *vty)
3809{
3810 struct route_node *rn;
3811 struct static_ipv6 *si;
3812 int write;
3813 char buf[BUFSIZ];
3814 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003815 struct zebra_vrf *zvrf;
3816 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003817
3818 write = 0;
3819
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003820 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3821 {
3822 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3823 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3824 continue;
paul718e3742002-12-13 20:15:29 +00003825
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003826 for (rn = route_top (stable); rn; rn = route_next (rn))
3827 for (si = rn->info; si; si = si->next)
3828 {
3829 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003830
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003831 switch (si->type)
3832 {
3833 case STATIC_IPV6_GATEWAY:
3834 vty_out (vty, " %s",
3835 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
3836 break;
3837 case STATIC_IPV6_IFNAME:
3838 vty_out (vty, " %s", si->ifname);
3839 break;
3840 case STATIC_IPV6_GATEWAY_IFNAME:
3841 vty_out (vty, " %s %s",
3842 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ),
3843 si->ifname);
3844 break;
3845 }
paul718e3742002-12-13 20:15:29 +00003846
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003847 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3848 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003849
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003850 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3851 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003852
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003853 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3854 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003855
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003856 if (si->vrf_id != VRF_DEFAULT)
3857 vty_out (vty, " vrf %u", si->vrf_id);
3858
3859 vty_out (vty, "%s", VTY_NEWLINE);
3860
3861 write = 1;
3862 }
3863 }
paul718e3742002-12-13 20:15:29 +00003864 return write;
3865}
3866#endif /* HAVE_IPV6 */
3867
3868/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003869static int
paul718e3742002-12-13 20:15:29 +00003870zebra_ip_config (struct vty *vty)
3871{
3872 int write = 0;
3873
Everton Marques33d86db2014-07-14 11:19:00 -03003874 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3875 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003876#ifdef HAVE_IPV6
3877 write += static_config_ipv6 (vty);
3878#endif /* HAVE_IPV6 */
3879
3880 return write;
3881}
3882
David Lamparterbd078122015-01-06 19:53:24 +01003883static int config_write_vty(struct vty *vty)
3884{
Paul Jakma7514fb72007-05-02 16:05:35 +00003885 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003886 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3887
3888 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3889 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3890 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3891 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3892 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3893 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3894 "longer-prefix",
3895 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003896
3897 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3898 {
3899 if (proto_rm[AFI_IP][i])
3900 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3901 proto_rm[AFI_IP][i], VTY_NEWLINE);
3902 }
3903 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3904 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3905 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3906
3907 return 1;
3908}
3909
3910/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003911static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003912
paul718e3742002-12-13 20:15:29 +00003913/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003914static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003915
3916/* Route VTY. */
3917void
paula1ac18c2005-06-28 17:17:12 +00003918zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003919{
3920 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003921 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003922
Everton Marques33d86db2014-07-14 11:19:00 -03003923 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003924 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003925 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003926 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003927 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3928 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3929 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003930 install_element (CONFIG_NODE, &ip_protocol_cmd);
3931 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3932 install_element (VIEW_NODE, &show_ip_protocol_cmd);
3933 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003934 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003935 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003936 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003937 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003938 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003939 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003940 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003941 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003942 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003943 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003944 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003945 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003946 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003947 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003948 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003949 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003950 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003951 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003952 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003953 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003954 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003955 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003956 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003957
3958 install_element (VIEW_NODE, &show_ip_route_cmd);
3959 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3960 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3961 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3962 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3963 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003964 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003965 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003966 install_element (ENABLE_NODE, &show_ip_route_cmd);
3967 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
3968 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
3969 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
3970 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
3971 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00003972 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003973 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003974
G.Balajicddf3912011-11-26 21:59:32 +04003975 install_element (VIEW_NODE, &show_ip_mroute_cmd);
3976 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
3977
Everton Marques33d86db2014-07-14 11:19:00 -03003978 install_element (VIEW_NODE, &show_ip_rpf_cmd);
3979 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003980 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
3981 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003982
Feng Lu4364ee52015-05-22 11:40:03 +02003983 /* Commands for VRF */
3984
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003985 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3986 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3987 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3988 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3989
3990 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3991 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3992 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3993 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3994 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3995 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3996 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3997 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3998 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3999 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
4000 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
4001 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
4002 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
4003 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
4004 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
4005 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
4006 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
4007 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
4008 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
4009 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
4010 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
4011 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
4012 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
4013
Feng Lu4364ee52015-05-22 11:40:03 +02004014 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
4015 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
4016 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
4017 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
4018 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
4019 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
4020 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
4021 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
4022 install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
4023 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd);
4024 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd);
4025 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd);
4026 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd);
4027 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd);
4028 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd);
4029 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd);
4030
4031 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
4032 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
4033 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
4034 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
4035 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
4036 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
4037 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
4038 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
4039 install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
4040 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd);
4041 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd);
4042 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
4043 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd);
4044 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd);
4045 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd);
4046 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
4047
4048 install_element (VIEW_NODE, &show_ip_mroute_vrf_cmd);
4049 install_element (ENABLE_NODE, &show_ip_mroute_vrf_cmd);
4050
4051 install_element (VIEW_NODE, &show_ip_mroute_vrf_all_cmd);
4052 install_element (ENABLE_NODE, &show_ip_mroute_vrf_all_cmd);
4053
4054 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
4055 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
4056 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
4057 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
4058 install_element (ENABLE_NODE, &show_ip_rpf_vrf_cmd);
4059 install_element (ENABLE_NODE, &show_ip_rpf_vrf_all_cmd);
4060 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_cmd);
4061 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_all_cmd);
4062
paul718e3742002-12-13 20:15:29 +00004063#ifdef HAVE_IPV6
4064 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004065 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00004066 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004067 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00004068 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004069 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00004070 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004071 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00004072 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004073 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00004074 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004075 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00004076 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004077 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00004078 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00004079 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00004080 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004081 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004082 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00004083 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
4084 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
4085 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
4086 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
4087 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
4088 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
4089 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
4090 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
4091 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004092 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004093 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04004094
4095 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
4096 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004097
4098 /* Commands for VRF */
4099
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004100 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4101 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4102 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4103 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4104 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4105 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4106 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4107 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4108 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4109 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4110 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4111 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4112 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4113 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4114 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4115 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4116
Feng Lu4364ee52015-05-22 11:40:03 +02004117 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4118 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4119 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4120 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4121 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4122 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4123 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4124 install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
4125 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd);
4126 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd);
4127 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd);
4128 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4129 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd);
4130 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4131
4132 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4133 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4134 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4135 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4136 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4137 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4138 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4139 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
4140 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4141 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4142 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4143 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4144 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4145 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4146
4147 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
4148 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
4149
4150 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
4151 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004152#endif /* HAVE_IPV6 */
4153}