blob: 21b92ea9e3819d97512dba75f4d461569ab13ea5 [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);
Timo Teräsb11f3b52015-11-02 16:50:07 +02001293 if (rib->mtu)
1294 vty_out (vty, ", mtu %u", rib->mtu);
Feng Lu4364ee52015-05-22 11:40:03 +02001295 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001296 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001297 vty_out (vty, ", best");
Timo Teräs325823a2016-01-15 17:36:31 +02001298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE))
1299 vty_out (vty, ", fib-override");
1300 if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
1301 vty_out (vty, ", fib");
paul718e3742002-12-13 20:15:29 +00001302 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001303 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001304 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1305 vty_out (vty, ", blackhole");
1306 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1307 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001308 vty_out (vty, "%s", VTY_NEWLINE);
1309
1310#define ONE_DAY_SECOND 60*60*24
1311#define ONE_WEEK_SECOND 60*60*24*7
1312 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001313 || rib->type == ZEBRA_ROUTE_RIPNG
1314 || rib->type == ZEBRA_ROUTE_OSPF
1315 || rib->type == ZEBRA_ROUTE_OSPF6
1316 || rib->type == ZEBRA_ROUTE_BABEL
1317 || rib->type == ZEBRA_ROUTE_ISIS
1318 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001319 {
1320 time_t uptime;
1321 struct tm *tm;
1322
1323 uptime = time (NULL);
1324 uptime -= rib->uptime;
1325 tm = gmtime (&uptime);
1326
1327 vty_out (vty, " Last update ");
1328
1329 if (uptime < ONE_DAY_SECOND)
1330 vty_out (vty, "%02d:%02d:%02d",
1331 tm->tm_hour, tm->tm_min, tm->tm_sec);
1332 else if (uptime < ONE_WEEK_SECOND)
1333 vty_out (vty, "%dd%02dh%02dm",
1334 tm->tm_yday, tm->tm_hour, tm->tm_min);
1335 else
1336 vty_out (vty, "%02dw%dd%02dh",
1337 tm->tm_yday/7,
1338 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1339 vty_out (vty, " ago%s", VTY_NEWLINE);
1340 }
1341
Christian Frankefa713d92013-07-05 15:35:37 +00001342 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001343 {
1344 vty_out (vty, " %c%s",
1345 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1346 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001347
Timo Teräs53a5c392015-05-23 11:08:40 +03001348 switch (nexthop->type)
1349 {
1350 case NEXTHOP_TYPE_IPV4:
1351 case NEXTHOP_TYPE_IPV4_IFINDEX:
1352 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1353 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001354 vty_out (vty, ", via %s",
1355 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001356 break;
1357 case NEXTHOP_TYPE_IPV6:
1358 case NEXTHOP_TYPE_IPV6_IFINDEX:
1359 case NEXTHOP_TYPE_IPV6_IFNAME:
1360 vty_out (vty, " %s",
1361 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1362 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1363 vty_out (vty, ", %s", nexthop->ifname);
1364 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001365 vty_out (vty, ", via %s",
1366 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001367 break;
1368 case NEXTHOP_TYPE_IFINDEX:
1369 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001370 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001371 break;
1372 case NEXTHOP_TYPE_IFNAME:
1373 vty_out (vty, " directly connected, %s", nexthop->ifname);
1374 break;
1375 case NEXTHOP_TYPE_BLACKHOLE:
1376 vty_out (vty, " directly connected, Null0");
1377 break;
1378 default:
1379 break;
1380 }
1381 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1382 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001383
Timo Teräs53a5c392015-05-23 11:08:40 +03001384 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1385 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001386
Timo Teräs53a5c392015-05-23 11:08:40 +03001387 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1388 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001389
Timo Teräs53a5c392015-05-23 11:08:40 +03001390 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001391 {
1392 case NEXTHOP_TYPE_IPV4:
1393 case NEXTHOP_TYPE_IPV4_IFINDEX:
1394 case NEXTHOP_TYPE_IPV4_IFNAME:
1395 if (nexthop->src.ipv4.s_addr)
1396 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001397 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1398 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001399 }
1400 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001401#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001402 case NEXTHOP_TYPE_IPV6:
1403 case NEXTHOP_TYPE_IPV6_IFINDEX:
1404 case NEXTHOP_TYPE_IPV6_IFNAME:
1405 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1406 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001407 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1408 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001409 }
1410 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001411#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001412 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001413 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001414 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001415 vty_out (vty, "%s", VTY_NEWLINE);
1416 }
paul718e3742002-12-13 20:15:29 +00001417 vty_out (vty, "%s", VTY_NEWLINE);
1418 }
1419}
1420
paula1ac18c2005-06-28 17:17:12 +00001421static void
paul718e3742002-12-13 20:15:29 +00001422vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1423{
Christian Frankefa713d92013-07-05 15:35:37 +00001424 struct nexthop *nexthop, *tnexthop;
1425 int recursing;
paul718e3742002-12-13 20:15:29 +00001426 int len = 0;
1427 char buf[BUFSIZ];
1428
1429 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001430 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001431 {
1432 if (nexthop == rib->nexthop)
1433 {
1434 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001435 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001436 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001437 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1438 ? '>' : ' ',
1439 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1440 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001441 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001442
1443 /* Distance and metric display. */
1444 if (rib->type != ZEBRA_ROUTE_CONNECT
1445 && rib->type != ZEBRA_ROUTE_KERNEL)
1446 len += vty_out (vty, " [%d/%d]", rib->distance,
1447 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001448
1449 if (rib->vrf_id != VRF_DEFAULT)
1450 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001451 }
1452 else
1453 vty_out (vty, " %c%*c",
1454 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1455 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001456 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001457
1458 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001459 {
1460 case NEXTHOP_TYPE_IPV4:
1461 case NEXTHOP_TYPE_IPV4_IFINDEX:
1462 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1463 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001464 vty_out (vty, ", %s",
1465 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001466 break;
1467 case NEXTHOP_TYPE_IPV6:
1468 case NEXTHOP_TYPE_IPV6_IFINDEX:
1469 case NEXTHOP_TYPE_IPV6_IFNAME:
1470 vty_out (vty, " via %s",
1471 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1472 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1473 vty_out (vty, ", %s", nexthop->ifname);
1474 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001475 vty_out (vty, ", %s",
1476 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001477 break;
1478 case NEXTHOP_TYPE_IFINDEX:
1479 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001480 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001481 break;
1482 case NEXTHOP_TYPE_IFNAME:
1483 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1484 break;
1485 case NEXTHOP_TYPE_BLACKHOLE:
1486 vty_out (vty, " is directly connected, Null0");
1487 break;
1488 default:
1489 break;
1490 }
paul718e3742002-12-13 20:15:29 +00001491 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001492 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001493
Christian Frankee8d3d292013-07-05 15:35:39 +00001494 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001495 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001496
paul718e3742002-12-13 20:15:29 +00001497 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001498 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001499
Paul Jakma7514fb72007-05-02 16:05:35 +00001500 switch (nexthop->type)
1501 {
1502 case NEXTHOP_TYPE_IPV4:
1503 case NEXTHOP_TYPE_IPV4_IFINDEX:
1504 case NEXTHOP_TYPE_IPV4_IFNAME:
1505 if (nexthop->src.ipv4.s_addr)
1506 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001507 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001508 vty_out (vty, ", src %s", buf);
1509 }
1510 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001511#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001512 case NEXTHOP_TYPE_IPV6:
1513 case NEXTHOP_TYPE_IPV6_IFINDEX:
1514 case NEXTHOP_TYPE_IPV6_IFNAME:
1515 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1516 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001517 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001518 vty_out (vty, ", src %s", buf);
1519 }
1520 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001521#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001522 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001523 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001524 }
paul718e3742002-12-13 20:15:29 +00001525
hasso81dfcaa2003-05-25 19:21:25 +00001526 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1527 vty_out (vty, ", bh");
1528 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1529 vty_out (vty, ", rej");
1530
paul718e3742002-12-13 20:15:29 +00001531 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001532 || rib->type == ZEBRA_ROUTE_RIPNG
1533 || rib->type == ZEBRA_ROUTE_OSPF
1534 || rib->type == ZEBRA_ROUTE_OSPF6
1535 || rib->type == ZEBRA_ROUTE_BABEL
1536 || rib->type == ZEBRA_ROUTE_ISIS
1537 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001538 {
1539 time_t uptime;
1540 struct tm *tm;
1541
1542 uptime = time (NULL);
1543 uptime -= rib->uptime;
1544 tm = gmtime (&uptime);
1545
1546#define ONE_DAY_SECOND 60*60*24
1547#define ONE_WEEK_SECOND 60*60*24*7
1548
1549 if (uptime < ONE_DAY_SECOND)
1550 vty_out (vty, ", %02d:%02d:%02d",
1551 tm->tm_hour, tm->tm_min, tm->tm_sec);
1552 else if (uptime < ONE_WEEK_SECOND)
1553 vty_out (vty, ", %dd%02dh%02dm",
1554 tm->tm_yday, tm->tm_hour, tm->tm_min);
1555 else
1556 vty_out (vty, ", %02dw%dd%02dh",
1557 tm->tm_yday/7,
1558 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1559 }
1560 vty_out (vty, "%s", VTY_NEWLINE);
1561 }
1562}
1563
paul718e3742002-12-13 20:15:29 +00001564DEFUN (show_ip_route,
1565 show_ip_route_cmd,
1566 "show ip route",
1567 SHOW_STR
1568 IP_STR
1569 "IP routing table\n")
1570{
Feng Lu4364ee52015-05-22 11:40:03 +02001571 vrf_id_t vrf_id = VRF_DEFAULT;
1572
1573 if (argc > 0)
1574 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1575
1576 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001577}
1578
Feng Lu4364ee52015-05-22 11:40:03 +02001579static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1580{
paul718e3742002-12-13 20:15:29 +00001581 struct route_table *table;
1582 struct route_node *rn;
1583 struct rib *rib;
1584 int first = 1;
1585
Feng Lu4364ee52015-05-22 11:40:03 +02001586 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001587 if (! table)
1588 return CMD_SUCCESS;
1589
1590 /* Show all IPv4 routes. */
1591 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001592 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001593 {
1594 if (first)
1595 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001596 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001597 first = 0;
1598 }
1599 vty_show_ip_route (vty, rn, rib);
1600 }
1601 return CMD_SUCCESS;
1602}
1603
Feng Lu4364ee52015-05-22 11:40:03 +02001604ALIAS (show_ip_route,
1605 show_ip_route_vrf_cmd,
1606 "show ip route " VRF_CMD_STR,
1607 SHOW_STR
1608 IP_STR
1609 "IP routing table\n"
1610 VRF_CMD_HELP_STR)
1611
paul718e3742002-12-13 20:15:29 +00001612DEFUN (show_ip_route_prefix_longer,
1613 show_ip_route_prefix_longer_cmd,
1614 "show ip route A.B.C.D/M longer-prefixes",
1615 SHOW_STR
1616 IP_STR
1617 "IP routing table\n"
1618 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1619 "Show route matching the specified Network/Mask pair only\n")
1620{
1621 struct route_table *table;
1622 struct route_node *rn;
1623 struct rib *rib;
1624 struct prefix p;
1625 int ret;
1626 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001627 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001628
1629 ret = str2prefix (argv[0], &p);
1630 if (! ret)
1631 {
1632 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1633 return CMD_WARNING;
1634 }
Feng Lu4364ee52015-05-22 11:40:03 +02001635
1636 if (argc > 1)
1637 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1638
1639 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001640 if (! table)
1641 return CMD_SUCCESS;
1642
1643 /* Show matched type IPv4 routes. */
1644 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001645 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001646 if (prefix_match (&p, &rn->p))
1647 {
1648 if (first)
1649 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001650 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001651 first = 0;
1652 }
1653 vty_show_ip_route (vty, rn, rib);
1654 }
1655 return CMD_SUCCESS;
1656}
1657
Feng Lu4364ee52015-05-22 11:40:03 +02001658ALIAS (show_ip_route_prefix_longer,
1659 show_ip_route_prefix_longer_vrf_cmd,
1660 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1661 SHOW_STR
1662 IP_STR
1663 "IP routing table\n"
1664 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1665 "Show route matching the specified Network/Mask pair only\n"
1666 VRF_CMD_HELP_STR)
1667
paul718e3742002-12-13 20:15:29 +00001668DEFUN (show_ip_route_supernets,
1669 show_ip_route_supernets_cmd,
1670 "show ip route supernets-only",
1671 SHOW_STR
1672 IP_STR
1673 "IP routing table\n"
1674 "Show supernet entries only\n")
1675{
1676 struct route_table *table;
1677 struct route_node *rn;
1678 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001679 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001680 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001681 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001682
Feng Lu4364ee52015-05-22 11:40:03 +02001683 if (argc > 0)
1684 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1685
1686 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001687 if (! table)
1688 return CMD_SUCCESS;
1689
1690 /* Show matched type IPv4 routes. */
1691 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001692 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001693 {
1694 addr = ntohl (rn->p.u.prefix4.s_addr);
1695
1696 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1697 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001698 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001699 {
1700 if (first)
1701 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001702 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001703 first = 0;
1704 }
1705 vty_show_ip_route (vty, rn, rib);
1706 }
1707 }
1708 return CMD_SUCCESS;
1709}
1710
Feng Lu4364ee52015-05-22 11:40:03 +02001711ALIAS (show_ip_route_supernets,
1712 show_ip_route_supernets_vrf_cmd,
1713 "show ip route supernets-only " VRF_CMD_STR,
1714 SHOW_STR
1715 IP_STR
1716 "IP routing table\n"
1717 "Show supernet entries only\n"
1718 VRF_CMD_HELP_STR)
1719
paul718e3742002-12-13 20:15:29 +00001720DEFUN (show_ip_route_protocol,
1721 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001722 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001723 SHOW_STR
1724 IP_STR
1725 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001726 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001727{
1728 int type;
1729 struct route_table *table;
1730 struct route_node *rn;
1731 struct rib *rib;
1732 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001733 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001734
David Lampartere0ca5fd2009-09-16 01:52:42 +02001735 type = proto_redistnum (AFI_IP, argv[0]);
1736 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001737 {
1738 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1739 return CMD_WARNING;
1740 }
Feng Lu4364ee52015-05-22 11:40:03 +02001741
1742 if (argc > 1)
1743 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1744
1745 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001746 if (! table)
1747 return CMD_SUCCESS;
1748
1749 /* Show matched type IPv4 routes. */
1750 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001751 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001752 if (rib->type == type)
1753 {
1754 if (first)
1755 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001756 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001757 first = 0;
1758 }
1759 vty_show_ip_route (vty, rn, rib);
1760 }
1761 return CMD_SUCCESS;
1762}
1763
Feng Lu4364ee52015-05-22 11:40:03 +02001764ALIAS (show_ip_route_protocol,
1765 show_ip_route_protocol_vrf_cmd,
1766 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1767 SHOW_STR
1768 IP_STR
1769 "IP routing table\n"
1770 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1771 VRF_CMD_HELP_STR)
1772
paul718e3742002-12-13 20:15:29 +00001773DEFUN (show_ip_route_addr,
1774 show_ip_route_addr_cmd,
1775 "show ip route A.B.C.D",
1776 SHOW_STR
1777 IP_STR
1778 "IP routing table\n"
1779 "Network in the IP routing table to display\n")
1780{
1781 int ret;
1782 struct prefix_ipv4 p;
1783 struct route_table *table;
1784 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001785 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001786
1787 ret = str2prefix_ipv4 (argv[0], &p);
1788 if (ret <= 0)
1789 {
1790 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1791 return CMD_WARNING;
1792 }
1793
Feng Lu4364ee52015-05-22 11:40:03 +02001794 if (argc > 1)
1795 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1796
1797 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001798 if (! table)
1799 return CMD_SUCCESS;
1800
1801 rn = route_node_match (table, (struct prefix *) &p);
1802 if (! rn)
1803 {
1804 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1805 return CMD_WARNING;
1806 }
1807
David Lamparter3b02fe82015-01-22 19:12:35 +01001808 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001809
1810 route_unlock_node (rn);
1811
1812 return CMD_SUCCESS;
1813}
1814
Feng Lu4364ee52015-05-22 11:40:03 +02001815ALIAS (show_ip_route_addr,
1816 show_ip_route_addr_vrf_cmd,
1817 "show ip route A.B.C.D " VRF_CMD_STR,
1818 SHOW_STR
1819 IP_STR
1820 "IP routing table\n"
1821 "Network in the IP routing table to display\n"
1822 VRF_CMD_HELP_STR)
1823
paul718e3742002-12-13 20:15:29 +00001824DEFUN (show_ip_route_prefix,
1825 show_ip_route_prefix_cmd,
1826 "show ip route A.B.C.D/M",
1827 SHOW_STR
1828 IP_STR
1829 "IP routing table\n"
1830 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1831{
1832 int ret;
1833 struct prefix_ipv4 p;
1834 struct route_table *table;
1835 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001836 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001837
1838 ret = str2prefix_ipv4 (argv[0], &p);
1839 if (ret <= 0)
1840 {
1841 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1842 return CMD_WARNING;
1843 }
1844
Feng Lu4364ee52015-05-22 11:40:03 +02001845 if (argc > 1)
1846 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1847
1848 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001849 if (! table)
1850 return CMD_SUCCESS;
1851
1852 rn = route_node_match (table, (struct prefix *) &p);
1853 if (! rn || rn->p.prefixlen != p.prefixlen)
1854 {
1855 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001856 if (rn)
1857 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001858 return CMD_WARNING;
1859 }
1860
David Lamparter3b02fe82015-01-22 19:12:35 +01001861 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001862
1863 route_unlock_node (rn);
1864
1865 return CMD_SUCCESS;
1866}
1867
Feng Lu4364ee52015-05-22 11:40:03 +02001868ALIAS (show_ip_route_prefix,
1869 show_ip_route_prefix_vrf_cmd,
1870 "show ip route A.B.C.D/M " VRF_CMD_STR,
1871 SHOW_STR
1872 IP_STR
1873 "IP routing table\n"
1874 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1875 VRF_CMD_HELP_STR)
1876
paula1ac18c2005-06-28 17:17:12 +00001877static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001878vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001879{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001880 struct route_node *rn;
1881 struct rib *rib;
1882 struct nexthop *nexthop;
1883#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1884#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1885 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1886 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1887 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001888
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001889 memset (&rib_cnt, 0, sizeof(rib_cnt));
1890 memset (&fib_cnt, 0, sizeof(fib_cnt));
1891 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001892 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001893 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1894 {
1895 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1896 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001897 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1898 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001899 {
1900 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1901 fib_cnt[rib->type]++;
1902 }
1903 if (rib->type == ZEBRA_ROUTE_BGP &&
1904 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1905 {
1906 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001907 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1908 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001909 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1910 }
1911 }
paul718e3742002-12-13 20:15:29 +00001912
Feng Lu4364ee52015-05-22 11:40:03 +02001913 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1914 "Route Source", "Routes", "FIB",
1915 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1916 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001917
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001918 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1919 {
1920 if (rib_cnt[i] > 0)
1921 {
1922 if (i == ZEBRA_ROUTE_BGP)
1923 {
1924 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1925 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1926 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1927 VTY_NEWLINE);
1928 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1929 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1930 VTY_NEWLINE);
1931 }
1932 else
1933 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1934 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1935 }
1936 }
paul718e3742002-12-13 20:15:29 +00001937
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001938 vty_out (vty, "------%s", VTY_NEWLINE);
1939 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1940 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001941 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001942}
1943
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001944/*
1945 * Implementation of the ip route summary prefix command.
1946 *
1947 * This command prints the primary prefixes that have been installed by various
1948 * protocols on the box.
1949 *
1950 */
1951static void
1952vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1953{
1954 struct route_node *rn;
1955 struct rib *rib;
1956 struct nexthop *nexthop;
1957#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1958#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1959 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1960 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1961 u_int32_t i;
1962 int cnt;
1963
1964 memset (&rib_cnt, 0, sizeof(rib_cnt));
1965 memset (&fib_cnt, 0, sizeof(fib_cnt));
1966 for (rn = route_top (table); rn; rn = route_next (rn))
1967 RNODE_FOREACH_RIB (rn, rib)
1968 {
1969
1970 /*
1971 * In case of ECMP, count only once.
1972 */
1973 cnt = 0;
1974 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1975 {
1976 cnt++;
1977 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1978 rib_cnt[rib->type]++;
1979 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1980 {
1981 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1982 fib_cnt[rib->type]++;
1983 }
1984 if (rib->type == ZEBRA_ROUTE_BGP &&
1985 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1986 {
1987 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1988 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1989 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1990 }
1991 }
1992 }
1993
Feng Lu4364ee52015-05-22 11:40:03 +02001994 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1995 "Route Source", "Prefix Routes", "FIB",
1996 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1997 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001998
1999 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2000 {
2001 if (rib_cnt[i] > 0)
2002 {
2003 if (i == ZEBRA_ROUTE_BGP)
2004 {
2005 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2006 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2007 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2008 VTY_NEWLINE);
2009 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2010 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2011 VTY_NEWLINE);
2012 }
2013 else
2014 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2015 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2016 }
2017 }
2018
2019 vty_out (vty, "------%s", VTY_NEWLINE);
2020 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2021 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002022 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002023}
2024
paul718e3742002-12-13 20:15:29 +00002025/* Show route summary. */
2026DEFUN (show_ip_route_summary,
2027 show_ip_route_summary_cmd,
2028 "show ip route summary",
2029 SHOW_STR
2030 IP_STR
2031 "IP routing table\n"
2032 "Summary of all routes\n")
2033{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002034 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002035 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002036
Feng Lu4364ee52015-05-22 11:40:03 +02002037 if (argc > 0)
2038 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2039
2040 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002041 if (! table)
2042 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002043
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002044 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002045
2046 return CMD_SUCCESS;
2047}
2048
Feng Lu4364ee52015-05-22 11:40:03 +02002049ALIAS (show_ip_route_summary,
2050 show_ip_route_summary_vrf_cmd,
2051 "show ip route summary " VRF_CMD_STR,
2052 SHOW_STR
2053 IP_STR
2054 "IP routing table\n"
2055 "Summary of all routes\n"
2056 VRF_CMD_HELP_STR)
2057
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002058/* Show route summary prefix. */
2059DEFUN (show_ip_route_summary_prefix,
2060 show_ip_route_summary_prefix_cmd,
2061 "show ip route summary prefix",
2062 SHOW_STR
2063 IP_STR
2064 "IP routing table\n"
2065 "Summary of all routes\n"
2066 "Prefix routes\n")
2067{
2068 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002069 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002070
Feng Lu4364ee52015-05-22 11:40:03 +02002071 if (argc > 0)
2072 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2073
2074 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002075 if (! table)
2076 return CMD_SUCCESS;
2077
2078 vty_show_ip_route_summary_prefix (vty, table);
2079
2080 return CMD_SUCCESS;
2081}
2082
Feng Lu4364ee52015-05-22 11:40:03 +02002083ALIAS (show_ip_route_summary_prefix,
2084 show_ip_route_summary_prefix_vrf_cmd,
2085 "show ip route summary prefix " VRF_CMD_STR,
2086 SHOW_STR
2087 IP_STR
2088 "IP routing table\n"
2089 "Summary of all routes\n"
2090 "Prefix routes\n"
2091 VRF_CMD_HELP_STR)
2092
2093DEFUN (show_ip_route_vrf_all,
2094 show_ip_route_vrf_all_cmd,
2095 "show ip route " VRF_ALL_CMD_STR,
2096 SHOW_STR
2097 IP_STR
2098 "IP routing table\n"
2099 VRF_ALL_CMD_HELP_STR)
2100{
2101 struct route_table *table;
2102 struct route_node *rn;
2103 struct rib *rib;
2104 struct zebra_vrf *zvrf;
2105 vrf_iter_t iter;
2106 int first = 1;
2107
2108 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2109 {
2110 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2111 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2112 continue;
2113
2114 /* Show all IPv4 routes. */
2115 for (rn = route_top (table); rn; rn = route_next (rn))
2116 RNODE_FOREACH_RIB (rn, rib)
2117 {
2118 if (first)
2119 {
2120 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2121 first = 0;
2122 }
2123 vty_show_ip_route (vty, rn, rib);
2124 }
2125 }
2126
2127 return CMD_SUCCESS;
2128}
2129
2130DEFUN (show_ip_route_prefix_longer_vrf_all,
2131 show_ip_route_prefix_longer_vrf_all_cmd,
2132 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2133 SHOW_STR
2134 IP_STR
2135 "IP routing table\n"
2136 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2137 "Show route matching the specified Network/Mask pair only\n"
2138 VRF_ALL_CMD_HELP_STR)
2139{
2140 struct route_table *table;
2141 struct route_node *rn;
2142 struct rib *rib;
2143 struct prefix p;
2144 struct zebra_vrf *zvrf;
2145 vrf_iter_t iter;
2146 int ret;
2147 int first = 1;
2148
2149 ret = str2prefix (argv[0], &p);
2150 if (! ret)
2151 {
2152 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2153 return CMD_WARNING;
2154 }
2155
2156 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2157 {
2158 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2159 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2160 continue;
2161
2162 /* Show matched type IPv4 routes. */
2163 for (rn = route_top (table); rn; rn = route_next (rn))
2164 RNODE_FOREACH_RIB (rn, rib)
2165 if (prefix_match (&p, &rn->p))
2166 {
2167 if (first)
2168 {
2169 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2170 first = 0;
2171 }
2172 vty_show_ip_route (vty, rn, rib);
2173 }
2174 }
2175
2176 return CMD_SUCCESS;
2177}
2178
2179DEFUN (show_ip_route_supernets_vrf_all,
2180 show_ip_route_supernets_vrf_all_cmd,
2181 "show ip route supernets-only " VRF_ALL_CMD_STR,
2182 SHOW_STR
2183 IP_STR
2184 "IP routing table\n"
2185 "Show supernet entries only\n"
2186 VRF_ALL_CMD_HELP_STR)
2187{
2188 struct route_table *table;
2189 struct route_node *rn;
2190 struct rib *rib;
2191 struct zebra_vrf *zvrf;
2192 vrf_iter_t iter;
2193 u_int32_t addr;
2194 int first = 1;
2195
2196 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2197 {
2198 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2199 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2200 continue;
2201
2202 /* Show matched type IPv4 routes. */
2203 for (rn = route_top (table); rn; rn = route_next (rn))
2204 RNODE_FOREACH_RIB (rn, rib)
2205 {
2206 addr = ntohl (rn->p.u.prefix4.s_addr);
2207
2208 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2209 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2210 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2211 {
2212 if (first)
2213 {
2214 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2215 first = 0;
2216 }
2217 vty_show_ip_route (vty, rn, rib);
2218 }
2219 }
2220 }
2221
2222 return CMD_SUCCESS;
2223}
2224
2225DEFUN (show_ip_route_protocol_vrf_all,
2226 show_ip_route_protocol_vrf_all_cmd,
2227 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2228 SHOW_STR
2229 IP_STR
2230 "IP routing table\n"
2231 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2232 VRF_ALL_CMD_HELP_STR)
2233{
2234 int type;
2235 struct route_table *table;
2236 struct route_node *rn;
2237 struct rib *rib;
2238 struct zebra_vrf *zvrf;
2239 vrf_iter_t iter;
2240 int first = 1;
2241
2242 type = proto_redistnum (AFI_IP, argv[0]);
2243 if (type < 0)
2244 {
2245 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2246 return CMD_WARNING;
2247 }
2248
2249 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2250 {
2251 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2252 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2253 continue;
2254
2255 /* Show matched type IPv4 routes. */
2256 for (rn = route_top (table); rn; rn = route_next (rn))
2257 RNODE_FOREACH_RIB (rn, rib)
2258 if (rib->type == type)
2259 {
2260 if (first)
2261 {
2262 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2263 first = 0;
2264 }
2265 vty_show_ip_route (vty, rn, rib);
2266 }
2267 }
2268
2269 return CMD_SUCCESS;
2270}
2271
2272DEFUN (show_ip_route_addr_vrf_all,
2273 show_ip_route_addr_vrf_all_cmd,
2274 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2275 SHOW_STR
2276 IP_STR
2277 "IP routing table\n"
2278 "Network in the IP routing table to display\n"
2279 VRF_ALL_CMD_HELP_STR)
2280{
2281 int ret;
2282 struct prefix_ipv4 p;
2283 struct route_table *table;
2284 struct route_node *rn;
2285 struct zebra_vrf *zvrf;
2286 vrf_iter_t iter;
2287
2288 ret = str2prefix_ipv4 (argv[0], &p);
2289 if (ret <= 0)
2290 {
2291 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2292 return CMD_WARNING;
2293 }
2294
2295 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2296 {
2297 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2298 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2299 continue;
2300
2301 rn = route_node_match (table, (struct prefix *) &p);
2302 if (! rn)
2303 continue;
2304
2305 vty_show_ip_route_detail (vty, rn, 0);
2306
2307 route_unlock_node (rn);
2308 }
2309
2310 return CMD_SUCCESS;
2311}
2312
2313DEFUN (show_ip_route_prefix_vrf_all,
2314 show_ip_route_prefix_vrf_all_cmd,
2315 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2316 SHOW_STR
2317 IP_STR
2318 "IP routing table\n"
2319 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2320 VRF_ALL_CMD_HELP_STR)
2321{
2322 int ret;
2323 struct prefix_ipv4 p;
2324 struct route_table *table;
2325 struct route_node *rn;
2326 struct zebra_vrf *zvrf;
2327 vrf_iter_t iter;
2328
2329 ret = str2prefix_ipv4 (argv[0], &p);
2330 if (ret <= 0)
2331 {
2332 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2333 return CMD_WARNING;
2334 }
2335
2336 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2337 {
2338 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2339 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2340 continue;
2341
2342 rn = route_node_match (table, (struct prefix *) &p);
2343 if (! rn)
2344 continue;
2345 if (rn->p.prefixlen != p.prefixlen)
2346 {
2347 route_unlock_node (rn);
2348 continue;
2349 }
2350
2351 vty_show_ip_route_detail (vty, rn, 0);
2352
2353 route_unlock_node (rn);
2354 }
2355
2356 return CMD_SUCCESS;
2357}
2358
2359DEFUN (show_ip_route_summary_vrf_all,
2360 show_ip_route_summary_vrf_all_cmd,
2361 "show ip route summary " VRF_ALL_CMD_STR,
2362 SHOW_STR
2363 IP_STR
2364 "IP routing table\n"
2365 "Summary of all routes\n"
2366 VRF_ALL_CMD_HELP_STR)
2367{
2368 struct zebra_vrf *zvrf;
2369 vrf_iter_t iter;
2370
2371 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2372 if ((zvrf = vrf_iter2info (iter)) != NULL)
2373 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2374
2375 return CMD_SUCCESS;
2376}
2377
2378DEFUN (show_ip_route_summary_prefix_vrf_all,
2379 show_ip_route_summary_prefix_vrf_all_cmd,
2380 "show ip route summary prefix " VRF_ALL_CMD_STR,
2381 SHOW_STR
2382 IP_STR
2383 "IP routing table\n"
2384 "Summary of all routes\n"
2385 "Prefix routes\n"
2386 VRF_ALL_CMD_HELP_STR)
2387{
2388 struct zebra_vrf *zvrf;
2389 vrf_iter_t iter;
2390
2391 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2392 if ((zvrf = vrf_iter2info (iter)) != NULL)
2393 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2394
2395 return CMD_SUCCESS;
2396}
2397
paul718e3742002-12-13 20:15:29 +00002398/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002399static int
Everton Marques33d86db2014-07-14 11:19:00 -03002400static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002401{
2402 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05002403 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00002404 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002405 struct zebra_vrf *zvrf;
2406 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002407 int write;
2408
2409 write = 0;
2410
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002411 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2412 {
2413 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2414 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2415 continue;
paul718e3742002-12-13 20:15:29 +00002416
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002417 for (rn = route_top (stable); rn; rn = route_next (rn))
2418 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002419 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002420 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2421 rn->p.prefixlen);
2422
2423 switch (si->type)
2424 {
2425 case STATIC_IPV4_GATEWAY:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002426 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002427 break;
2428 case STATIC_IPV4_IFNAME:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002429 vty_out (vty, " %s", si->ifname);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002430 break;
2431 case STATIC_IPV4_BLACKHOLE:
2432 vty_out (vty, " Null0");
2433 break;
2434 }
2435
2436 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2437 if (si->type != STATIC_IPV4_BLACKHOLE)
2438 {
2439 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2440 vty_out (vty, " %s", "reject");
2441
2442 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2443 vty_out (vty, " %s", "blackhole");
2444 }
2445
2446 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2447 vty_out (vty, " %d", si->distance);
2448
2449 if (si->vrf_id != VRF_DEFAULT)
2450 vty_out (vty, " vrf %u", si->vrf_id);
2451
2452 vty_out (vty, "%s", VTY_NEWLINE);
2453
2454 write = 1;
paul7021c422003-07-15 12:52:22 +00002455 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002456 }
paul718e3742002-12-13 20:15:29 +00002457 return write;
2458}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002459
2460DEFUN (show_ip_protocol,
2461 show_ip_protocol_cmd,
2462 "show ip protocol",
2463 SHOW_STR
2464 IP_STR
2465 "IP protocol filtering status\n")
2466{
2467 int i;
2468
2469 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2470 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2471 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2472 {
2473 if (proto_rm[AFI_IP][i])
2474 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2475 proto_rm[AFI_IP][i],
2476 VTY_NEWLINE);
2477 else
2478 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2479 }
2480 if (proto_rm[AFI_IP][i])
2481 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2482 VTY_NEWLINE);
2483 else
2484 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2485
2486 return CMD_SUCCESS;
2487}
2488
paul718e3742002-12-13 20:15:29 +00002489#ifdef HAVE_IPV6
2490/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002491static int
hasso39db97e2004-10-12 20:50:58 +00002492static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2493 const char *gate_str, const char *ifname,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002494 const char *flag_str, const char *distance_str,
2495 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002496{
2497 int ret;
2498 u_char distance;
2499 struct prefix p;
2500 struct in6_addr *gate = NULL;
2501 struct in6_addr gate_addr;
2502 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002503 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002504 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00002505
2506 ret = str2prefix (dest_str, &p);
2507 if (ret <= 0)
2508 {
2509 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2510 return CMD_WARNING;
2511 }
2512
2513 /* Apply mask for given prefix. */
2514 apply_mask (&p);
2515
hasso81dfcaa2003-05-25 19:21:25 +00002516 /* Route flags */
2517 if (flag_str) {
2518 switch(flag_str[0]) {
2519 case 'r':
2520 case 'R': /* XXX */
2521 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2522 break;
2523 case 'b':
2524 case 'B': /* XXX */
2525 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2526 break;
2527 default:
2528 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002529 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002530 }
2531 }
2532
paul718e3742002-12-13 20:15:29 +00002533 /* Administrative distance. */
2534 if (distance_str)
2535 distance = atoi (distance_str);
2536 else
2537 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2538
2539 /* When gateway is valid IPv6 addrees, then gate is treated as
2540 nexthop address other case gate is treated as interface name. */
2541 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2542
2543 if (ifname)
2544 {
2545 /* When ifname is specified. It must be come with gateway
2546 address. */
2547 if (ret != 1)
2548 {
2549 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2550 return CMD_WARNING;
2551 }
2552 type = STATIC_IPV6_GATEWAY_IFNAME;
2553 gate = &gate_addr;
2554 }
2555 else
2556 {
2557 if (ret == 1)
2558 {
2559 type = STATIC_IPV6_GATEWAY;
2560 gate = &gate_addr;
2561 }
2562 else
2563 {
2564 type = STATIC_IPV6_IFNAME;
2565 ifname = gate_str;
2566 }
2567 }
2568
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002569 /* VRF id */
2570 if (vrf_id_str)
2571 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2572
paul718e3742002-12-13 20:15:29 +00002573 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002574 static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002575 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002576 static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002577
2578 return CMD_SUCCESS;
2579}
2580
2581DEFUN (ipv6_route,
2582 ipv6_route_cmd,
2583 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2584 IP_STR
2585 "Establish static routes\n"
2586 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2587 "IPv6 gateway address\n"
2588 "IPv6 gateway interface name\n")
2589{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002590 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2591 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002592}
2593
2594DEFUN (ipv6_route_flags,
2595 ipv6_route_flags_cmd,
2596 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2597 IP_STR
2598 "Establish static routes\n"
2599 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2600 "IPv6 gateway address\n"
2601 "IPv6 gateway interface name\n"
2602 "Emit an ICMP unreachable when matched\n"
2603 "Silently discard pkts when matched\n")
2604{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002605 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2606 NULL);
paul718e3742002-12-13 20:15:29 +00002607}
2608
2609DEFUN (ipv6_route_ifname,
2610 ipv6_route_ifname_cmd,
2611 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2612 IP_STR
2613 "Establish static routes\n"
2614 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2615 "IPv6 gateway address\n"
2616 "IPv6 gateway interface name\n")
2617{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002618 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2619 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002620}
2621
2622DEFUN (ipv6_route_ifname_flags,
2623 ipv6_route_ifname_flags_cmd,
2624 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2625 IP_STR
2626 "Establish static routes\n"
2627 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2628 "IPv6 gateway address\n"
2629 "IPv6 gateway interface name\n"
2630 "Emit an ICMP unreachable when matched\n"
2631 "Silently discard pkts when matched\n")
2632{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002633 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2634 NULL);
paul718e3742002-12-13 20:15:29 +00002635}
2636
2637DEFUN (ipv6_route_pref,
2638 ipv6_route_pref_cmd,
2639 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2640 IP_STR
2641 "Establish static routes\n"
2642 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2643 "IPv6 gateway address\n"
2644 "IPv6 gateway interface name\n"
2645 "Distance value for this prefix\n")
2646{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002647 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2648 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002649}
2650
2651DEFUN (ipv6_route_flags_pref,
2652 ipv6_route_flags_pref_cmd,
2653 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2654 IP_STR
2655 "Establish static routes\n"
2656 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2657 "IPv6 gateway address\n"
2658 "IPv6 gateway interface name\n"
2659 "Emit an ICMP unreachable when matched\n"
2660 "Silently discard pkts when matched\n"
2661 "Distance value for this prefix\n")
2662{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002663 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2664 NULL);
paul718e3742002-12-13 20:15:29 +00002665}
2666
2667DEFUN (ipv6_route_ifname_pref,
2668 ipv6_route_ifname_pref_cmd,
2669 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2670 IP_STR
2671 "Establish static routes\n"
2672 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2673 "IPv6 gateway address\n"
2674 "IPv6 gateway interface name\n"
2675 "Distance value for this prefix\n")
2676{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002677 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2678 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002679}
2680
2681DEFUN (ipv6_route_ifname_flags_pref,
2682 ipv6_route_ifname_flags_pref_cmd,
2683 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2684 IP_STR
2685 "Establish static routes\n"
2686 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2687 "IPv6 gateway address\n"
2688 "IPv6 gateway interface name\n"
2689 "Emit an ICMP unreachable when matched\n"
2690 "Silently discard pkts when matched\n"
2691 "Distance value for this prefix\n")
2692{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002693 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2694 NULL);
paul718e3742002-12-13 20:15:29 +00002695}
2696
2697DEFUN (no_ipv6_route,
2698 no_ipv6_route_cmd,
2699 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2700 NO_STR
2701 IP_STR
2702 "Establish static routes\n"
2703 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2704 "IPv6 gateway address\n"
2705 "IPv6 gateway interface name\n")
2706{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002707 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2708 NULL);
paul718e3742002-12-13 20:15:29 +00002709}
2710
hasso81dfcaa2003-05-25 19:21:25 +00002711ALIAS (no_ipv6_route,
2712 no_ipv6_route_flags_cmd,
2713 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2714 NO_STR
2715 IP_STR
2716 "Establish static routes\n"
2717 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2718 "IPv6 gateway address\n"
2719 "IPv6 gateway interface name\n"
2720 "Emit an ICMP unreachable when matched\n"
2721 "Silently discard pkts when matched\n")
2722
paul718e3742002-12-13 20:15:29 +00002723DEFUN (no_ipv6_route_ifname,
2724 no_ipv6_route_ifname_cmd,
2725 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2726 NO_STR
2727 IP_STR
2728 "Establish static routes\n"
2729 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2730 "IPv6 gateway address\n"
2731 "IPv6 gateway interface name\n")
2732{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002733 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2734 NULL);
paul718e3742002-12-13 20:15:29 +00002735}
2736
hasso81dfcaa2003-05-25 19:21:25 +00002737ALIAS (no_ipv6_route_ifname,
2738 no_ipv6_route_ifname_flags_cmd,
2739 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2740 NO_STR
2741 IP_STR
2742 "Establish static routes\n"
2743 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2744 "IPv6 gateway address\n"
2745 "IPv6 gateway interface name\n"
2746 "Emit an ICMP unreachable when matched\n"
2747 "Silently discard pkts when matched\n")
2748
paul718e3742002-12-13 20:15:29 +00002749DEFUN (no_ipv6_route_pref,
2750 no_ipv6_route_pref_cmd,
2751 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2752 NO_STR
2753 IP_STR
2754 "Establish static routes\n"
2755 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2756 "IPv6 gateway address\n"
2757 "IPv6 gateway interface name\n"
2758 "Distance value for this prefix\n")
2759{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002760 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
2761 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002762}
2763
2764DEFUN (no_ipv6_route_flags_pref,
2765 no_ipv6_route_flags_pref_cmd,
2766 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2767 NO_STR
2768 IP_STR
2769 "Establish static routes\n"
2770 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2771 "IPv6 gateway address\n"
2772 "IPv6 gateway interface name\n"
2773 "Emit an ICMP unreachable when matched\n"
2774 "Silently discard pkts when matched\n"
2775 "Distance value for this prefix\n")
2776{
2777 /* We do not care about argv[2] */
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002778 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
2779 NULL);
paul718e3742002-12-13 20:15:29 +00002780}
2781
2782DEFUN (no_ipv6_route_ifname_pref,
2783 no_ipv6_route_ifname_pref_cmd,
2784 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2785 NO_STR
2786 IP_STR
2787 "Establish static routes\n"
2788 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2789 "IPv6 gateway address\n"
2790 "IPv6 gateway interface name\n"
2791 "Distance value for this prefix\n")
2792{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002793 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
2794 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002795}
2796
2797DEFUN (no_ipv6_route_ifname_flags_pref,
2798 no_ipv6_route_ifname_flags_pref_cmd,
2799 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2800 NO_STR
2801 IP_STR
2802 "Establish static routes\n"
2803 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2804 "IPv6 gateway address\n"
2805 "IPv6 gateway interface name\n"
2806 "Emit an ICMP unreachable when matched\n"
2807 "Silently discard pkts when matched\n"
2808 "Distance value for this prefix\n")
2809{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002810 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
2811 NULL);
2812}
2813
2814DEFUN (ipv6_route_vrf,
2815 ipv6_route_vrf_cmd,
2816 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2817 IP_STR
2818 "Establish static routes\n"
2819 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2820 "IPv6 gateway address\n"
2821 "IPv6 gateway interface name\n"
2822 VRF_CMD_HELP_STR)
2823{
2824 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2825 argv[2]);
2826}
2827
2828DEFUN (ipv6_route_flags_vrf,
2829 ipv6_route_flags_vrf_cmd,
2830 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2831 IP_STR
2832 "Establish static routes\n"
2833 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2834 "IPv6 gateway address\n"
2835 "IPv6 gateway interface name\n"
2836 "Emit an ICMP unreachable when matched\n"
2837 "Silently discard pkts when matched\n"
2838 VRF_CMD_HELP_STR)
2839{
2840 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2841 argv[3]);
2842}
2843
2844DEFUN (ipv6_route_ifname_vrf,
2845 ipv6_route_ifname_vrf_cmd,
2846 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2847 IP_STR
2848 "Establish static routes\n"
2849 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2850 "IPv6 gateway address\n"
2851 "IPv6 gateway interface name\n"
2852 VRF_CMD_HELP_STR)
2853{
2854 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2855 argv[3]);
2856}
2857
2858DEFUN (ipv6_route_ifname_flags_vrf,
2859 ipv6_route_ifname_flags_vrf_cmd,
2860 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2861 IP_STR
2862 "Establish static routes\n"
2863 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2864 "IPv6 gateway address\n"
2865 "IPv6 gateway interface name\n"
2866 "Emit an ICMP unreachable when matched\n"
2867 "Silently discard pkts when matched\n"
2868 VRF_CMD_HELP_STR)
2869{
2870 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2871 argv[4]);
2872}
2873
2874DEFUN (ipv6_route_pref_vrf,
2875 ipv6_route_pref_vrf_cmd,
2876 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2877 IP_STR
2878 "Establish static routes\n"
2879 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2880 "IPv6 gateway address\n"
2881 "IPv6 gateway interface name\n"
2882 "Distance value for this prefix\n"
2883 VRF_CMD_HELP_STR)
2884{
2885 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2886 argv[3]);
2887}
2888
2889DEFUN (ipv6_route_flags_pref_vrf,
2890 ipv6_route_flags_pref_vrf_cmd,
2891 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2892 IP_STR
2893 "Establish static routes\n"
2894 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2895 "IPv6 gateway address\n"
2896 "IPv6 gateway interface name\n"
2897 "Emit an ICMP unreachable when matched\n"
2898 "Silently discard pkts when matched\n"
2899 "Distance value for this prefix\n"
2900 VRF_CMD_HELP_STR)
2901{
2902 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2903 argv[4]);
2904}
2905
2906DEFUN (ipv6_route_ifname_pref_vrf,
2907 ipv6_route_ifname_pref_vrf_cmd,
2908 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2909 IP_STR
2910 "Establish static routes\n"
2911 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2912 "IPv6 gateway address\n"
2913 "IPv6 gateway interface name\n"
2914 "Distance value for this prefix\n"
2915 VRF_CMD_HELP_STR)
2916{
2917 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2918 argv[4]);
2919}
2920
2921DEFUN (ipv6_route_ifname_flags_pref_vrf,
2922 ipv6_route_ifname_flags_pref_vrf_cmd,
2923 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " 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 "Emit an ICMP unreachable when matched\n"
2930 "Silently discard pkts when matched\n"
2931 "Distance value for this prefix\n"
2932 VRF_CMD_HELP_STR)
2933{
2934 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2935 argv[5]);
2936}
2937
2938DEFUN (no_ipv6_route_vrf,
2939 no_ipv6_route_vrf_cmd,
2940 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2941 NO_STR
2942 IP_STR
2943 "Establish static routes\n"
2944 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2945 "IPv6 gateway address\n"
2946 "IPv6 gateway interface name\n"
2947 VRF_CMD_HELP_STR)
2948{
2949 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2950 (argc > 3) ? argv[3] : argv[2]);
2951}
2952
2953ALIAS (no_ipv6_route_vrf,
2954 no_ipv6_route_flags_vrf_cmd,
2955 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2956 NO_STR
2957 IP_STR
2958 "Establish static routes\n"
2959 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2960 "IPv6 gateway address\n"
2961 "IPv6 gateway interface name\n"
2962 "Emit an ICMP unreachable when matched\n"
2963 "Silently discard pkts when matched\n"
2964 VRF_CMD_HELP_STR)
2965
2966DEFUN (no_ipv6_route_ifname_vrf,
2967 no_ipv6_route_ifname_vrf_cmd,
2968 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2969 NO_STR
2970 IP_STR
2971 "Establish static routes\n"
2972 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2973 "IPv6 gateway address\n"
2974 "IPv6 gateway interface name\n"
2975 VRF_CMD_HELP_STR)
2976{
2977 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2978 (argc > 4) ? argv[4] : argv[3]);
2979}
2980
2981ALIAS (no_ipv6_route_ifname_vrf,
2982 no_ipv6_route_ifname_flags_vrf_cmd,
2983 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2984 NO_STR
2985 IP_STR
2986 "Establish static routes\n"
2987 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2988 "IPv6 gateway address\n"
2989 "IPv6 gateway interface name\n"
2990 "Emit an ICMP unreachable when matched\n"
2991 "Silently discard pkts when matched\n"
2992 VRF_CMD_HELP_STR)
2993
2994DEFUN (no_ipv6_route_pref_vrf,
2995 no_ipv6_route_pref_vrf_cmd,
2996 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2997 NO_STR
2998 IP_STR
2999 "Establish static routes\n"
3000 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3001 "IPv6 gateway address\n"
3002 "IPv6 gateway interface name\n"
3003 "Distance value for this prefix\n"
3004 VRF_CMD_HELP_STR)
3005{
3006 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
3007 argv[3]);
3008}
3009
3010DEFUN (no_ipv6_route_flags_pref_vrf,
3011 no_ipv6_route_flags_pref_vrf_cmd,
3012 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3013 NO_STR
3014 IP_STR
3015 "Establish static routes\n"
3016 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3017 "IPv6 gateway address\n"
3018 "IPv6 gateway interface name\n"
3019 "Emit an ICMP unreachable when matched\n"
3020 "Silently discard pkts when matched\n"
3021 "Distance value for this prefix\n"
3022 VRF_CMD_HELP_STR)
3023{
3024 /* We do not care about argv[2] */
3025 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
3026 argv[4]);
3027}
3028
3029DEFUN (no_ipv6_route_ifname_pref_vrf,
3030 no_ipv6_route_ifname_pref_vrf_cmd,
3031 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3032 NO_STR
3033 IP_STR
3034 "Establish static routes\n"
3035 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3036 "IPv6 gateway address\n"
3037 "IPv6 gateway interface name\n"
3038 "Distance value for this prefix\n"
3039 VRF_CMD_HELP_STR)
3040{
3041 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
3042 argv[4]);
3043}
3044
3045DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3046 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3047 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3048 NO_STR
3049 IP_STR
3050 "Establish static routes\n"
3051 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3052 "IPv6 gateway address\n"
3053 "IPv6 gateway interface name\n"
3054 "Emit an ICMP unreachable when matched\n"
3055 "Silently discard pkts when matched\n"
3056 "Distance value for this prefix\n"
3057 VRF_CMD_HELP_STR)
3058{
3059 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
3060 argv[5]);
paul718e3742002-12-13 20:15:29 +00003061}
3062
paul718e3742002-12-13 20:15:29 +00003063DEFUN (show_ipv6_route,
3064 show_ipv6_route_cmd,
3065 "show ipv6 route",
3066 SHOW_STR
3067 IP_STR
3068 "IPv6 routing table\n")
3069{
3070 struct route_table *table;
3071 struct route_node *rn;
3072 struct rib *rib;
3073 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003074 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003075
Feng Lu4364ee52015-05-22 11:40:03 +02003076 if (argc > 0)
3077 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3078
3079 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003080 if (! table)
3081 return CMD_SUCCESS;
3082
3083 /* Show all IPv6 route. */
3084 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003085 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003086 {
3087 if (first)
3088 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003089 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003090 first = 0;
3091 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003092 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003093 }
3094 return CMD_SUCCESS;
3095}
3096
Feng Lu4364ee52015-05-22 11:40:03 +02003097ALIAS (show_ipv6_route,
3098 show_ipv6_route_vrf_cmd,
3099 "show ipv6 route " VRF_CMD_STR,
3100 SHOW_STR
3101 IP_STR
3102 "IPv6 routing table\n"
3103 VRF_CMD_HELP_STR)
3104
paul718e3742002-12-13 20:15:29 +00003105DEFUN (show_ipv6_route_prefix_longer,
3106 show_ipv6_route_prefix_longer_cmd,
3107 "show ipv6 route X:X::X:X/M longer-prefixes",
3108 SHOW_STR
3109 IP_STR
3110 "IPv6 routing table\n"
3111 "IPv6 prefix\n"
3112 "Show route matching the specified Network/Mask pair only\n")
3113{
3114 struct route_table *table;
3115 struct route_node *rn;
3116 struct rib *rib;
3117 struct prefix p;
3118 int ret;
3119 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003120 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003121
3122 ret = str2prefix (argv[0], &p);
3123 if (! ret)
3124 {
3125 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3126 return CMD_WARNING;
3127 }
3128
Feng Lu4364ee52015-05-22 11:40:03 +02003129 if (argc > 1)
3130 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3131
3132 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3133 if (! table)
3134 return CMD_SUCCESS;
3135
paul718e3742002-12-13 20:15:29 +00003136 /* Show matched type IPv6 routes. */
3137 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003138 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003139 if (prefix_match (&p, &rn->p))
3140 {
3141 if (first)
3142 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003143 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003144 first = 0;
3145 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003146 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003147 }
3148 return CMD_SUCCESS;
3149}
3150
Feng Lu4364ee52015-05-22 11:40:03 +02003151ALIAS (show_ipv6_route_prefix_longer,
3152 show_ipv6_route_prefix_longer_vrf_cmd,
3153 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3154 SHOW_STR
3155 IP_STR
3156 "IPv6 routing table\n"
3157 "IPv6 prefix\n"
3158 "Show route matching the specified Network/Mask pair only\n"
3159 VRF_CMD_HELP_STR)
3160
paul718e3742002-12-13 20:15:29 +00003161DEFUN (show_ipv6_route_protocol,
3162 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003163 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003164 SHOW_STR
3165 IP_STR
3166 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003167 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003168{
3169 int type;
3170 struct route_table *table;
3171 struct route_node *rn;
3172 struct rib *rib;
3173 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003174 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003175
David Lampartere0ca5fd2009-09-16 01:52:42 +02003176 type = proto_redistnum (AFI_IP6, argv[0]);
3177 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003178 {
3179 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3180 return CMD_WARNING;
3181 }
Feng Lu4364ee52015-05-22 11:40:03 +02003182
3183 if (argc > 1)
3184 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3185
3186 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003187 if (! table)
3188 return CMD_SUCCESS;
3189
3190 /* Show matched type IPv6 routes. */
3191 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003192 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003193 if (rib->type == type)
3194 {
3195 if (first)
3196 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003197 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003198 first = 0;
3199 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003200 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003201 }
3202 return CMD_SUCCESS;
3203}
3204
Feng Lu4364ee52015-05-22 11:40:03 +02003205ALIAS (show_ipv6_route_protocol,
3206 show_ipv6_route_protocol_vrf_cmd,
3207 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3208 SHOW_STR
3209 IP_STR
3210 "IP routing table\n"
3211 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3212 VRF_CMD_HELP_STR)
3213
paul718e3742002-12-13 20:15:29 +00003214DEFUN (show_ipv6_route_addr,
3215 show_ipv6_route_addr_cmd,
3216 "show ipv6 route X:X::X:X",
3217 SHOW_STR
3218 IP_STR
3219 "IPv6 routing table\n"
3220 "IPv6 Address\n")
3221{
3222 int ret;
3223 struct prefix_ipv6 p;
3224 struct route_table *table;
3225 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003226 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003227
3228 ret = str2prefix_ipv6 (argv[0], &p);
3229 if (ret <= 0)
3230 {
3231 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3232 return CMD_WARNING;
3233 }
3234
Feng Lu4364ee52015-05-22 11:40:03 +02003235 if (argc > 1)
3236 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3237
3238 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003239 if (! table)
3240 return CMD_SUCCESS;
3241
3242 rn = route_node_match (table, (struct prefix *) &p);
3243 if (! rn)
3244 {
3245 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3246 return CMD_WARNING;
3247 }
3248
Timo Teräs53a5c392015-05-23 11:08:40 +03003249 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003250
3251 route_unlock_node (rn);
3252
3253 return CMD_SUCCESS;
3254}
3255
Feng Lu4364ee52015-05-22 11:40:03 +02003256ALIAS (show_ipv6_route_addr,
3257 show_ipv6_route_addr_vrf_cmd,
3258 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3259 SHOW_STR
3260 IP_STR
3261 "IPv6 routing table\n"
3262 "IPv6 Address\n"
3263 VRF_CMD_HELP_STR)
3264
paul718e3742002-12-13 20:15:29 +00003265DEFUN (show_ipv6_route_prefix,
3266 show_ipv6_route_prefix_cmd,
3267 "show ipv6 route X:X::X:X/M",
3268 SHOW_STR
3269 IP_STR
3270 "IPv6 routing table\n"
3271 "IPv6 prefix\n")
3272{
3273 int ret;
3274 struct prefix_ipv6 p;
3275 struct route_table *table;
3276 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003277 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003278
3279 ret = str2prefix_ipv6 (argv[0], &p);
3280 if (ret <= 0)
3281 {
3282 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3283 return CMD_WARNING;
3284 }
3285
Feng Lu4364ee52015-05-22 11:40:03 +02003286 if (argc > 1)
3287 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3288
3289 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003290 if (! table)
3291 return CMD_SUCCESS;
3292
3293 rn = route_node_match (table, (struct prefix *) &p);
3294 if (! rn || rn->p.prefixlen != p.prefixlen)
3295 {
3296 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003297 if (rn)
3298 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003299 return CMD_WARNING;
3300 }
3301
Timo Teräs53a5c392015-05-23 11:08:40 +03003302 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003303
3304 route_unlock_node (rn);
3305
3306 return CMD_SUCCESS;
3307}
3308
Feng Lu4364ee52015-05-22 11:40:03 +02003309ALIAS (show_ipv6_route_prefix,
3310 show_ipv6_route_prefix_vrf_cmd,
3311 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3312 SHOW_STR
3313 IP_STR
3314 "IPv6 routing table\n"
3315 "IPv6 prefix\n"
3316 VRF_CMD_HELP_STR)
3317
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003318/* Show route summary. */
3319DEFUN (show_ipv6_route_summary,
3320 show_ipv6_route_summary_cmd,
3321 "show ipv6 route summary",
3322 SHOW_STR
3323 IP_STR
3324 "IPv6 routing table\n"
3325 "Summary of all IPv6 routes\n")
3326{
3327 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003328 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003329
Feng Lu4364ee52015-05-22 11:40:03 +02003330 if (argc > 0)
3331 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3332
3333 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003334 if (! table)
3335 return CMD_SUCCESS;
3336
3337 vty_show_ip_route_summary (vty, table);
3338
3339 return CMD_SUCCESS;
3340}
3341
Feng Lu4364ee52015-05-22 11:40:03 +02003342ALIAS (show_ipv6_route_summary,
3343 show_ipv6_route_summary_vrf_cmd,
3344 "show ipv6 route summary " VRF_CMD_STR,
3345 SHOW_STR
3346 IP_STR
3347 "IPv6 routing table\n"
3348 "Summary of all IPv6 routes\n"
3349 VRF_CMD_HELP_STR)
3350
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003351/* Show ipv6 route summary prefix. */
3352DEFUN (show_ipv6_route_summary_prefix,
3353 show_ipv6_route_summary_prefix_cmd,
3354 "show ipv6 route summary prefix",
3355 SHOW_STR
3356 IP_STR
3357 "IPv6 routing table\n"
3358 "Summary of all IPv6 routes\n"
3359 "Prefix routes\n")
3360{
3361 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003362 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003363
Feng Lu4364ee52015-05-22 11:40:03 +02003364 if (argc > 0)
3365 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3366
3367 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003368 if (! table)
3369 return CMD_SUCCESS;
3370
3371 vty_show_ip_route_summary_prefix (vty, table);
3372
3373 return CMD_SUCCESS;
3374}
3375
Feng Lu4364ee52015-05-22 11:40:03 +02003376ALIAS (show_ipv6_route_summary_prefix,
3377 show_ipv6_route_summary_prefix_vrf_cmd,
3378 "show ipv6 route summary prefix " VRF_CMD_STR,
3379 SHOW_STR
3380 IP_STR
3381 "IPv6 routing table\n"
3382 "Summary of all IPv6 routes\n"
3383 "Prefix routes\n"
3384 VRF_CMD_HELP_STR)
3385
G.Balajicddf3912011-11-26 21:59:32 +04003386/*
G.Balajicddf3912011-11-26 21:59:32 +04003387 * Show IPv6 mroute command.Used to dump
3388 * the Multicast routing table.
3389 */
3390
3391DEFUN (show_ipv6_mroute,
3392 show_ipv6_mroute_cmd,
3393 "show ipv6 mroute",
3394 SHOW_STR
3395 IP_STR
3396 "IPv6 Multicast routing table\n")
3397{
3398 struct route_table *table;
3399 struct route_node *rn;
3400 struct rib *rib;
3401 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003402 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003403
Feng Lu4364ee52015-05-22 11:40:03 +02003404 if (argc > 0)
3405 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3406
3407 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003408 if (! table)
3409 return CMD_SUCCESS;
3410
3411 /* Show all IPv6 route. */
3412 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003413 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003414 {
3415 if (first)
3416 {
G.Balajicb32fd62011-11-27 20:09:40 +05303417 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003418 first = 0;
3419 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003420 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003421 }
3422 return CMD_SUCCESS;
3423}
3424
Feng Lu4364ee52015-05-22 11:40:03 +02003425ALIAS (show_ipv6_mroute,
3426 show_ipv6_mroute_vrf_cmd,
3427 "show ipv6 mroute " VRF_CMD_STR,
3428 SHOW_STR
3429 IP_STR
3430 "IPv6 Multicast routing table\n"
3431 VRF_CMD_HELP_STR)
3432
3433DEFUN (show_ipv6_route_vrf_all,
3434 show_ipv6_route_vrf_all_cmd,
3435 "show ipv6 route " VRF_ALL_CMD_STR,
3436 SHOW_STR
3437 IP_STR
3438 "IPv6 routing table\n"
3439 VRF_ALL_CMD_HELP_STR)
3440{
3441 struct route_table *table;
3442 struct route_node *rn;
3443 struct rib *rib;
3444 struct zebra_vrf *zvrf;
3445 vrf_iter_t iter;
3446 int first = 1;
3447
3448 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3449 {
3450 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3451 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3452 continue;
3453
3454 /* Show all IPv6 route. */
3455 for (rn = route_top (table); rn; rn = route_next (rn))
3456 RNODE_FOREACH_RIB (rn, rib)
3457 {
3458 if (first)
3459 {
3460 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3461 first = 0;
3462 }
3463 vty_show_ip_route (vty, rn, rib);
3464 }
3465 }
3466
3467 return CMD_SUCCESS;
3468}
3469
3470DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3471 show_ipv6_route_prefix_longer_vrf_all_cmd,
3472 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3473 SHOW_STR
3474 IP_STR
3475 "IPv6 routing table\n"
3476 "IPv6 prefix\n"
3477 "Show route matching the specified Network/Mask pair only\n"
3478 VRF_ALL_CMD_HELP_STR)
3479{
3480 struct route_table *table;
3481 struct route_node *rn;
3482 struct rib *rib;
3483 struct prefix p;
3484 struct zebra_vrf *zvrf;
3485 vrf_iter_t iter;
3486 int ret;
3487 int first = 1;
3488
3489 ret = str2prefix (argv[0], &p);
3490 if (! ret)
3491 {
3492 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3493 return CMD_WARNING;
3494 }
3495
3496 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3497 {
3498 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3499 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3500 continue;
3501
3502 /* Show matched type IPv6 routes. */
3503 for (rn = route_top (table); rn; rn = route_next (rn))
3504 RNODE_FOREACH_RIB (rn, rib)
3505 if (prefix_match (&p, &rn->p))
3506 {
3507 if (first)
3508 {
3509 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3510 first = 0;
3511 }
3512 vty_show_ip_route (vty, rn, rib);
3513 }
3514 }
3515
3516 return CMD_SUCCESS;
3517}
3518
3519DEFUN (show_ipv6_route_protocol_vrf_all,
3520 show_ipv6_route_protocol_vrf_all_cmd,
3521 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3522 SHOW_STR
3523 IP_STR
3524 "IP routing table\n"
3525 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3526 VRF_ALL_CMD_HELP_STR)
3527{
3528 int type;
3529 struct route_table *table;
3530 struct route_node *rn;
3531 struct rib *rib;
3532 struct zebra_vrf *zvrf;
3533 vrf_iter_t iter;
3534 int first = 1;
3535
3536 type = proto_redistnum (AFI_IP6, argv[0]);
3537 if (type < 0)
3538 {
3539 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3540 return CMD_WARNING;
3541 }
3542
3543 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3544 {
3545 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3546 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3547 continue;
3548
3549 /* Show matched type IPv6 routes. */
3550 for (rn = route_top (table); rn; rn = route_next (rn))
3551 RNODE_FOREACH_RIB (rn, rib)
3552 if (rib->type == type)
3553 {
3554 if (first)
3555 {
3556 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3557 first = 0;
3558 }
3559 vty_show_ip_route (vty, rn, rib);
3560 }
3561 }
3562
3563 return CMD_SUCCESS;
3564}
3565
3566DEFUN (show_ipv6_route_addr_vrf_all,
3567 show_ipv6_route_addr_vrf_all_cmd,
3568 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3569 SHOW_STR
3570 IP_STR
3571 "IPv6 routing table\n"
3572 "IPv6 Address\n"
3573 VRF_ALL_CMD_HELP_STR)
3574{
3575 int ret;
3576 struct prefix_ipv6 p;
3577 struct route_table *table;
3578 struct route_node *rn;
3579 struct zebra_vrf *zvrf;
3580 vrf_iter_t iter;
3581
3582 ret = str2prefix_ipv6 (argv[0], &p);
3583 if (ret <= 0)
3584 {
3585 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3586 return CMD_WARNING;
3587 }
3588
3589 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3590 {
3591 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3592 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3593 continue;
3594
3595 rn = route_node_match (table, (struct prefix *) &p);
3596 if (! rn)
3597 continue;
3598
3599 vty_show_ip_route_detail (vty, rn, 0);
3600
3601 route_unlock_node (rn);
3602 }
3603
3604 return CMD_SUCCESS;
3605}
3606
3607DEFUN (show_ipv6_route_prefix_vrf_all,
3608 show_ipv6_route_prefix_vrf_all_cmd,
3609 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3610 SHOW_STR
3611 IP_STR
3612 "IPv6 routing table\n"
3613 "IPv6 prefix\n"
3614 VRF_ALL_CMD_HELP_STR)
3615{
3616 int ret;
3617 struct prefix_ipv6 p;
3618 struct route_table *table;
3619 struct route_node *rn;
3620 struct zebra_vrf *zvrf;
3621 vrf_iter_t iter;
3622
3623 ret = str2prefix_ipv6 (argv[0], &p);
3624 if (ret <= 0)
3625 {
3626 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3627 return CMD_WARNING;
3628 }
3629
3630 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3631 {
3632 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3633 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3634 continue;
3635
3636 rn = route_node_match (table, (struct prefix *) &p);
3637 if (! rn)
3638 continue;
3639 if (rn->p.prefixlen != p.prefixlen)
3640 {
3641 route_unlock_node (rn);
3642 continue;
3643 }
3644
3645 vty_show_ip_route_detail (vty, rn, 0);
3646
3647 route_unlock_node (rn);
3648 }
3649
3650 return CMD_SUCCESS;
3651}
3652
3653/* Show route summary. */
3654DEFUN (show_ipv6_route_summary_vrf_all,
3655 show_ipv6_route_summary_vrf_all_cmd,
3656 "show ipv6 route summary " VRF_ALL_CMD_STR,
3657 SHOW_STR
3658 IP_STR
3659 "IPv6 routing table\n"
3660 "Summary of all IPv6 routes\n"
3661 VRF_ALL_CMD_HELP_STR)
3662{
3663 struct zebra_vrf *zvrf;
3664 vrf_iter_t iter;
3665
3666 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3667 if ((zvrf = vrf_iter2info (iter)) != NULL)
3668 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3669
3670 return CMD_SUCCESS;
3671}
3672
3673DEFUN (show_ipv6_mroute_vrf_all,
3674 show_ipv6_mroute_vrf_all_cmd,
3675 "show ipv6 mroute " VRF_ALL_CMD_STR,
3676 SHOW_STR
3677 IP_STR
3678 "IPv6 Multicast routing table\n"
3679 VRF_ALL_CMD_HELP_STR)
3680{
3681 struct route_table *table;
3682 struct route_node *rn;
3683 struct rib *rib;
3684 struct zebra_vrf *zvrf;
3685 vrf_iter_t iter;
3686 int first = 1;
3687
3688 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3689 {
3690 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3691 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3692 continue;
3693
3694 /* Show all IPv6 route. */
3695 for (rn = route_top (table); rn; rn = route_next (rn))
3696 RNODE_FOREACH_RIB (rn, rib)
3697 {
3698 if (first)
3699 {
3700 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3701 first = 0;
3702 }
3703 vty_show_ip_route (vty, rn, rib);
3704 }
3705 }
3706 return CMD_SUCCESS;
3707}
3708
3709DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3710 show_ipv6_route_summary_prefix_vrf_all_cmd,
3711 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3712 SHOW_STR
3713 IP_STR
3714 "IPv6 routing table\n"
3715 "Summary of all IPv6 routes\n"
3716 "Prefix routes\n"
3717 VRF_ALL_CMD_HELP_STR)
3718{
3719 struct zebra_vrf *zvrf;
3720 vrf_iter_t iter;
3721
3722 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3723 if ((zvrf = vrf_iter2info (iter)) != NULL)
3724 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3725
3726 return CMD_SUCCESS;
3727}
3728
paul718e3742002-12-13 20:15:29 +00003729/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003730static int
paul718e3742002-12-13 20:15:29 +00003731static_config_ipv6 (struct vty *vty)
3732{
3733 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05003734 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00003735 int write;
3736 char buf[BUFSIZ];
3737 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003738 struct zebra_vrf *zvrf;
3739 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003740
3741 write = 0;
3742
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003743 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3744 {
3745 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3746 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3747 continue;
paul718e3742002-12-13 20:15:29 +00003748
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003749 for (rn = route_top (stable); rn; rn = route_next (rn))
3750 for (si = rn->info; si; si = si->next)
3751 {
3752 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003753
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003754 switch (si->type)
3755 {
3756 case STATIC_IPV6_GATEWAY:
3757 vty_out (vty, " %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003758 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003759 break;
3760 case STATIC_IPV6_IFNAME:
3761 vty_out (vty, " %s", si->ifname);
3762 break;
3763 case STATIC_IPV6_GATEWAY_IFNAME:
3764 vty_out (vty, " %s %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003765 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003766 si->ifname);
3767 break;
3768 }
paul718e3742002-12-13 20:15:29 +00003769
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003770 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3771 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003772
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003773 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3774 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003775
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003776 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3777 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003778
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003779 if (si->vrf_id != VRF_DEFAULT)
3780 vty_out (vty, " vrf %u", si->vrf_id);
3781
3782 vty_out (vty, "%s", VTY_NEWLINE);
3783
3784 write = 1;
3785 }
3786 }
paul718e3742002-12-13 20:15:29 +00003787 return write;
3788}
3789#endif /* HAVE_IPV6 */
3790
3791/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003792static int
paul718e3742002-12-13 20:15:29 +00003793zebra_ip_config (struct vty *vty)
3794{
3795 int write = 0;
3796
Everton Marques33d86db2014-07-14 11:19:00 -03003797 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3798 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003799#ifdef HAVE_IPV6
3800 write += static_config_ipv6 (vty);
3801#endif /* HAVE_IPV6 */
3802
3803 return write;
3804}
3805
David Lamparterbd078122015-01-06 19:53:24 +01003806static int config_write_vty(struct vty *vty)
3807{
Paul Jakma7514fb72007-05-02 16:05:35 +00003808 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003809 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3810
3811 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3812 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3813 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3814 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3815 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3816 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3817 "longer-prefix",
3818 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003819
3820 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3821 {
3822 if (proto_rm[AFI_IP][i])
3823 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3824 proto_rm[AFI_IP][i], VTY_NEWLINE);
3825 }
3826 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3827 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3828 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3829
3830 return 1;
3831}
3832
3833/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003834static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003835
paul718e3742002-12-13 20:15:29 +00003836/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003837static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003838
3839/* Route VTY. */
3840void
paula1ac18c2005-06-28 17:17:12 +00003841zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003842{
3843 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003844 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003845
Everton Marques33d86db2014-07-14 11:19:00 -03003846 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003847 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003848 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003849 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003850 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3851 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3852 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003853 install_element (CONFIG_NODE, &ip_protocol_cmd);
3854 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3855 install_element (VIEW_NODE, &show_ip_protocol_cmd);
3856 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003857 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003858 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003859 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003860 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003861 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003862 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003863 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003864 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003865 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003866 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003867 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003868 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003869 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003870 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003871 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003872 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003873 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003874 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003875 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003876 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003877 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003878 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003879 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003880
3881 install_element (VIEW_NODE, &show_ip_route_cmd);
3882 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3883 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3884 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3885 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3886 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003887 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003888 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003889 install_element (ENABLE_NODE, &show_ip_route_cmd);
3890 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
3891 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
3892 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
3893 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
3894 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00003895 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003896 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003897
Everton Marques33d86db2014-07-14 11:19:00 -03003898 install_element (VIEW_NODE, &show_ip_rpf_cmd);
3899 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003900 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
3901 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003902
Feng Lu4364ee52015-05-22 11:40:03 +02003903 /* Commands for VRF */
3904
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003905 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3906 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3907 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3908 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3909
3910 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3911 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3912 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3913 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3914 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3915 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3916 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3917 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3918 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3919 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
3920 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
3921 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
3922 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
3923 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
3924 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
3925 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
3926 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
3927 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
3928 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
3929 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
3930 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
3931 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
3932 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
3933
Feng Lu4364ee52015-05-22 11:40:03 +02003934 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
3935 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
3936 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
3937 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3938 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
3939 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
3940 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
3941 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3942 install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
3943 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd);
3944 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd);
3945 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3946 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd);
3947 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd);
3948 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd);
3949 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3950
3951 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
3952 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
3953 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
3954 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3955 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
3956 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
3957 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
3958 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3959 install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
3960 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd);
3961 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd);
3962 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3963 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd);
3964 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd);
3965 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd);
3966 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3967
Feng Lu4364ee52015-05-22 11:40:03 +02003968 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
3969 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
3970 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
3971 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3972 install_element (ENABLE_NODE, &show_ip_rpf_vrf_cmd);
3973 install_element (ENABLE_NODE, &show_ip_rpf_vrf_all_cmd);
3974 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_cmd);
3975 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3976
paul718e3742002-12-13 20:15:29 +00003977#ifdef HAVE_IPV6
3978 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003979 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003980 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003981 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003982 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003983 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003984 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003985 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003986 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003987 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003988 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003989 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003990 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003991 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003992 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003993 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003994 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003995 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003996 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003997 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
3998 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
3999 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
4000 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
4001 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
4002 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
4003 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
4004 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
4005 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004006 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004007 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04004008
4009 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
4010 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004011
4012 /* Commands for VRF */
4013
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004014 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4015 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4016 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4017 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4018 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4019 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4020 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4021 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4022 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4023 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4024 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4025 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4026 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4027 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4028 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4029 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4030
Feng Lu4364ee52015-05-22 11:40:03 +02004031 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4032 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4033 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4034 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4035 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4036 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4037 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4038 install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
4039 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd);
4040 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd);
4041 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd);
4042 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4043 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd);
4044 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4045
4046 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4047 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4048 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4049 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4050 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4051 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4052 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4053 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
4054 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4055 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4056 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4057 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4058 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4059 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4060
4061 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
4062 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
4063
4064 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
4065 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004066#endif /* HAVE_IPV6 */
4067}