blob: 6ad286ff01dc042b26d1de9d8b3bbdaff5c60baf [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Zebra VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
Paul Jakma7514fb72007-05-02 16:05:35 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
Feng Lu41f44a22015-05-22 11:39:56 +020030#include "vrf.h"
paul718e3742002-12-13 20:15:29 +000031
paula1ac18c2005-06-28 17:17:12 +000032#include "zebra/zserv.h"
33
Feng Lu4364ee52015-05-22 11:40:03 +020034static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
David Lamparter3b02fe82015-01-22 19:12:35 +010035static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
36 int mcast);
Feng Lu4364ee52015-05-22 11:40:03 +020037static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
38 struct rib *rib);
Everton Marques33d86db2014-07-14 11:19:00 -030039
40/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000041static int
Everton Marques33d86db2014-07-14 11:19:00 -030042zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
43 const char *dest_str, const char *mask_str,
44 const char *gate_str, const char *flag_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +020045 const char *distance_str, const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +000046{
47 int ret;
48 u_char distance;
49 struct prefix p;
50 struct in_addr gate;
51 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000052 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000053 u_char flag = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +020054 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +000055
56 ret = str2prefix (dest_str, &p);
57 if (ret <= 0)
58 {
59 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
60 return CMD_WARNING;
61 }
62
63 /* Cisco like mask notation. */
64 if (mask_str)
65 {
66 ret = inet_aton (mask_str, &mask);
67 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000068 {
69 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
70 return CMD_WARNING;
71 }
paul718e3742002-12-13 20:15:29 +000072 p.prefixlen = ip_masklen (mask);
73 }
74
75 /* Apply mask for given prefix. */
76 apply_mask (&p);
77
paul595db7f2003-05-25 21:35:06 +000078 /* Administrative distance. */
79 if (distance_str)
80 distance = atoi (distance_str);
81 else
82 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
83
Feng Lu7aaf4ea2015-05-22 11:40:06 +020084 /* VRF id */
85 if (vrf_id_str)
86 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
87
paul595db7f2003-05-25 21:35:06 +000088 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000089 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000090 {
91 if (flag_str)
92 {
93 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
94 return CMD_WARNING;
95 }
96 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +020097 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +000098 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +020099 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000100 return CMD_SUCCESS;
101 }
102
hasso81dfcaa2003-05-25 19:21:25 +0000103 /* Route flags */
104 if (flag_str) {
105 switch(flag_str[0]) {
106 case 'r':
107 case 'R': /* XXX */
108 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
109 break;
110 case 'b':
111 case 'B': /* XXX */
112 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
113 break;
114 default:
115 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000116 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000117 }
118 }
119
hasso457ef552003-05-28 12:02:15 +0000120 if (gate_str == NULL)
121 {
122 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200123 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000124 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200125 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000126
127 return CMD_SUCCESS;
128 }
129
paul718e3742002-12-13 20:15:29 +0000130 /* When gateway is A.B.C.D format, gate is treated as nexthop
131 address other case gate is treated as interface name. */
132 ret = inet_aton (gate_str, &gate);
133 if (ret)
134 ifname = NULL;
135 else
136 ifname = gate_str;
137
138 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200139 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000140 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200141 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000142
143 return CMD_SUCCESS;
144}
145
Everton Marques33d86db2014-07-14 11:19:00 -0300146static int
147zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
148 const char *mask_str, const char *gate_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200149 const char *flag_str, const char *distance_str,
150 const char *vrf_id_str)
Everton Marques33d86db2014-07-14 11:19:00 -0300151{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200152 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str,
153 gate_str, flag_str, distance_str, vrf_id_str);
Everton Marques33d86db2014-07-14 11:19:00 -0300154}
155
156/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100157DEFUN (ip_mroute_dist,
158 ip_mroute_dist_cmd,
159 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300160 IP_STR
161 "Configure static unicast route into MRIB for multicast RPF lookup\n"
162 "IP destination prefix (e.g. 10.0.0.0/8)\n"
163 "Nexthop address\n"
164 "Nexthop interface name\n"
165 "Distance\n")
166{
David Lamparter863f20c2015-01-27 20:24:15 +0100167 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100168 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200169 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300170}
171
David Lampartera76681b2015-01-22 19:03:53 +0100172ALIAS (ip_mroute_dist,
173 ip_mroute_cmd,
174 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
175 IP_STR
176 "Configure static unicast route into MRIB for multicast RPF lookup\n"
177 "IP destination prefix (e.g. 10.0.0.0/8)\n"
178 "Nexthop address\n"
179 "Nexthop interface name\n")
180
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200181DEFUN (ip_mroute_dist_vrf,
182 ip_mroute_dist_vrf_cmd,
183 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
184 IP_STR
185 "Configure static unicast route into MRIB for multicast RPF lookup\n"
186 "IP destination prefix (e.g. 10.0.0.0/8)\n"
187 "Nexthop address\n"
188 "Nexthop interface name\n"
189 "Distance\n"
190 VRF_CMD_HELP_STR)
191{
192 VTY_WARN_EXPERIMENTAL();
193 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
194 NULL, argc > 3 ? argv[2] : NULL,
195 argc > 3 ? argv[3] : argv[2]);
196}
197
198ALIAS (ip_mroute_dist_vrf,
199 ip_mroute_vrf_cmd,
200 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
201 IP_STR
202 "Configure static unicast route into MRIB for multicast RPF lookup\n"
203 "IP destination prefix (e.g. 10.0.0.0/8)\n"
204 "Nexthop address\n"
205 "Nexthop interface name\n"
206 VRF_CMD_HELP_STR)
207
David Lampartera76681b2015-01-22 19:03:53 +0100208DEFUN (no_ip_mroute_dist,
209 no_ip_mroute_dist_cmd,
210 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300211 IP_STR
212 "Configure static unicast route into MRIB for multicast RPF lookup\n"
213 "IP destination prefix (e.g. 10.0.0.0/8)\n"
214 "Nexthop address\n"
215 "Nexthop interface name\n"
216 "Distance\n")
217{
David Lamparter863f20c2015-01-27 20:24:15 +0100218 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100219 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200220 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300221}
222
David Lampartera76681b2015-01-22 19:03:53 +0100223ALIAS (no_ip_mroute_dist,
224 no_ip_mroute_cmd,
225 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
226 NO_STR
227 IP_STR
228 "Configure static unicast route into MRIB for multicast RPF lookup\n"
229 "IP destination prefix (e.g. 10.0.0.0/8)\n"
230 "Nexthop address\n"
231 "Nexthop interface name\n")
232
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200233DEFUN (no_ip_mroute_dist_vrf,
234 no_ip_mroute_dist_vrf_cmd,
235 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
236 IP_STR
237 "Configure static unicast route into MRIB for multicast RPF lookup\n"
238 "IP destination prefix (e.g. 10.0.0.0/8)\n"
239 "Nexthop address\n"
240 "Nexthop interface name\n"
241 "Distance\n"
242 VRF_CMD_HELP_STR)
243{
244 VTY_WARN_EXPERIMENTAL();
245 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
246 NULL, argc > 3 ? argv[2] : NULL,
247 argc > 3 ? argv[3] : argv[2]);
248}
249
250ALIAS (no_ip_mroute_dist_vrf,
251 no_ip_mroute_vrf_cmd,
252 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
253 NO_STR
254 IP_STR
255 "Configure static unicast route into MRIB for multicast RPF lookup\n"
256 "IP destination prefix (e.g. 10.0.0.0/8)\n"
257 "Nexthop address\n"
258 "Nexthop interface name\n"
259 VRF_CMD_HELP_STR)
260
David Lamparterbd078122015-01-06 19:53:24 +0100261DEFUN (ip_multicast_mode,
262 ip_multicast_mode_cmd,
263 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
264 IP_STR
265 "Multicast options\n"
266 "RPF lookup behavior\n"
267 "Lookup in unicast RIB only\n"
268 "Lookup in multicast RIB only\n"
269 "Try multicast RIB first, fall back to unicast RIB\n"
270 "Lookup both, use entry with lower distance\n"
271 "Lookup both, use entry with longer prefix\n")
272{
David Lamparter863f20c2015-01-27 20:24:15 +0100273 VTY_WARN_EXPERIMENTAL();
274
David Lamparterbd078122015-01-06 19:53:24 +0100275 if (!strncmp (argv[0], "u", 1))
276 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
277 else if (!strncmp (argv[0], "mrib-o", 6))
278 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
279 else if (!strncmp (argv[0], "mrib-t", 6))
280 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
281 else if (!strncmp (argv[0], "low", 3))
282 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
283 else if (!strncmp (argv[0], "lon", 3))
284 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
285 else
286 {
287 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
288 return CMD_WARNING;
289 }
290
291 return CMD_SUCCESS;
292}
293
294DEFUN (no_ip_multicast_mode,
295 no_ip_multicast_mode_cmd,
296 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
297 NO_STR
298 IP_STR
299 "Multicast options\n"
300 "RPF lookup behavior\n"
301 "Lookup in unicast RIB only\n"
302 "Lookup in multicast RIB only\n"
303 "Try multicast RIB first, fall back to unicast RIB\n"
304 "Lookup both, use entry with lower distance\n"
305 "Lookup both, use entry with longer prefix\n")
306{
307 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
308 return CMD_SUCCESS;
309}
310
311ALIAS (no_ip_multicast_mode,
312 no_ip_multicast_mode_noarg_cmd,
313 "no ip multicast rpf-lookup-mode",
314 NO_STR
315 IP_STR
316 "Multicast options\n"
317 "RPF lookup behavior\n")
318
Everton Marques33d86db2014-07-14 11:19:00 -0300319DEFUN (show_ip_rpf,
320 show_ip_rpf_cmd,
321 "show ip rpf",
322 SHOW_STR
323 IP_STR
324 "Display RPF information for multicast source\n")
325{
Feng Lu4364ee52015-05-22 11:40:03 +0200326 vrf_id_t vrf_id = VRF_DEFAULT;
327
328 if (argc > 0)
329 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
330
David Lamparter863f20c2015-01-27 20:24:15 +0100331 VTY_WARN_EXPERIMENTAL();
Feng Lu4364ee52015-05-22 11:40:03 +0200332 return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -0300333}
334
Feng Lu4364ee52015-05-22 11:40:03 +0200335ALIAS (show_ip_rpf,
336 show_ip_rpf_vrf_cmd,
337 "show ip rpf " VRF_CMD_STR,
338 SHOW_STR
339 IP_STR
340 "Display RPF information for multicast source\n"
341 VRF_CMD_HELP_STR)
342
David Lamparter3b02fe82015-01-22 19:12:35 +0100343DEFUN (show_ip_rpf_addr,
344 show_ip_rpf_addr_cmd,
345 "show ip rpf A.B.C.D",
346 SHOW_STR
347 IP_STR
348 "Display RPF information for multicast source\n"
349 "IP multicast source address (e.g. 10.0.0.0)\n")
350{
351 struct in_addr addr;
352 struct route_node *rn;
353 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +0200354 vrf_id_t vrf_id = VRF_DEFAULT;
355 int ret;
356
357 if (argc > 1)
358 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
359
360 VTY_WARN_EXPERIMENTAL();
361
362 ret = inet_aton (argv[0], &addr);
363 if (ret == 0)
364 {
365 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
366 return CMD_WARNING;
367 }
368
369 rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
370
371 if (rib)
372 vty_show_ip_route_detail (vty, rn, 1);
373 else
374 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
375
376 return CMD_SUCCESS;
377}
378
379ALIAS (show_ip_rpf_addr,
380 show_ip_rpf_addr_vrf_cmd,
381 "show ip rpf A.B.C.D " VRF_CMD_STR,
382 SHOW_STR
383 IP_STR
384 "Display RPF information for multicast source\n"
385 "IP multicast source address (e.g. 10.0.0.0)\n"
386 VRF_CMD_HELP_STR)
387
388DEFUN (show_ip_rpf_vrf_all,
389 show_ip_rpf_vrf_all_cmd,
390 "show ip rpf " VRF_ALL_CMD_STR,
391 SHOW_STR
392 IP_STR
393 "Display RPF information for multicast source\n"
394 VRF_ALL_CMD_HELP_STR)
395{
396 struct zebra_vrf *zvrf;
397 struct route_table *table;
398 struct route_node *rn;
399 struct rib *rib;
400 vrf_iter_t iter;
401 int first = 1;
402
403 VTY_WARN_EXPERIMENTAL();
404
405 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
406 {
407 if ((zvrf = vrf_iter2info (iter)) == NULL ||
408 (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
409 continue;
410
411 /* Show all IPv4 routes. */
412 for (rn = route_top (table); rn; rn = route_next (rn))
413 RNODE_FOREACH_RIB (rn, rib)
414 {
415 if (first)
416 {
417 vty_out (vty, SHOW_ROUTE_V4_HEADER);
418 first = 0;
419 }
420 vty_show_ip_route (vty, rn, rib);
421 }
422 }
423
424 return CMD_SUCCESS;
425}
426
427DEFUN (show_ip_rpf_addr_vrf_all,
428 show_ip_rpf_addr_vrf_all_cmd,
429 "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
430 SHOW_STR
431 IP_STR
432 "Display RPF information for multicast source\n"
433 "IP multicast source address (e.g. 10.0.0.0)\n"
434 VRF_ALL_CMD_HELP_STR)
435{
436 struct in_addr addr;
437 struct route_node *rn;
438 vrf_iter_t iter;
David Lamparter3b02fe82015-01-22 19:12:35 +0100439 int ret;
440
David Lamparter863f20c2015-01-27 20:24:15 +0100441 VTY_WARN_EXPERIMENTAL();
442
David Lamparter3b02fe82015-01-22 19:12:35 +0100443 ret = inet_aton (argv[0], &addr);
444 if (ret == 0)
445 {
446 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
Feng Lu4364ee52015-05-22 11:40:03 +0200450 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
451 {
452 if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
453 vty_show_ip_route_detail (vty, rn, 1);
454 }
David Lamparter3b02fe82015-01-22 19:12:35 +0100455
456 return CMD_SUCCESS;
457}
458
paul718e3742002-12-13 20:15:29 +0000459/* Static route configuration. */
460DEFUN (ip_route,
461 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000462 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000463 IP_STR
464 "Establish static routes\n"
465 "IP destination prefix (e.g. 10.0.0.0/8)\n"
466 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000467 "IP gateway interface name\n"
468 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000469{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200470 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
471 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000472}
473
474DEFUN (ip_route_flags,
475 ip_route_flags_cmd,
476 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000477 IP_STR
478 "Establish static routes\n"
479 "IP destination prefix (e.g. 10.0.0.0/8)\n"
480 "IP gateway address\n"
481 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000482 "Emit an ICMP unreachable when matched\n"
483 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000484{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200485 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
486 NULL);
paul718e3742002-12-13 20:15:29 +0000487}
488
hasso457ef552003-05-28 12:02:15 +0000489DEFUN (ip_route_flags2,
490 ip_route_flags2_cmd,
491 "ip route A.B.C.D/M (reject|blackhole)",
492 IP_STR
493 "Establish static routes\n"
494 "IP destination prefix (e.g. 10.0.0.0/8)\n"
495 "Emit an ICMP unreachable when matched\n"
496 "Silently discard pkts when matched\n")
497{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200498 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
499 NULL);
hasso457ef552003-05-28 12:02:15 +0000500}
501
paul718e3742002-12-13 20:15:29 +0000502/* Mask as A.B.C.D format. */
503DEFUN (ip_route_mask,
504 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000505 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000506 IP_STR
507 "Establish static routes\n"
508 "IP destination prefix\n"
509 "IP destination prefix mask\n"
510 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000511 "IP gateway interface name\n"
512 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000513{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200514 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
515 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000516}
517
518DEFUN (ip_route_mask_flags,
519 ip_route_mask_flags_cmd,
520 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000521 IP_STR
522 "Establish static routes\n"
523 "IP destination prefix\n"
524 "IP destination prefix mask\n"
525 "IP gateway address\n"
526 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000527 "Emit an ICMP unreachable when matched\n"
528 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000529{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200530 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
531 NULL);
paul718e3742002-12-13 20:15:29 +0000532}
533
hasso457ef552003-05-28 12:02:15 +0000534DEFUN (ip_route_mask_flags2,
535 ip_route_mask_flags2_cmd,
536 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
537 IP_STR
538 "Establish static routes\n"
539 "IP destination prefix\n"
540 "IP destination prefix mask\n"
541 "Emit an ICMP unreachable when matched\n"
542 "Silently discard pkts when matched\n")
543{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200544 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
545 NULL);
hasso457ef552003-05-28 12:02:15 +0000546}
547
paul718e3742002-12-13 20:15:29 +0000548/* Distance option value. */
549DEFUN (ip_route_distance,
550 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000551 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000552 IP_STR
553 "Establish static routes\n"
554 "IP destination prefix (e.g. 10.0.0.0/8)\n"
555 "IP gateway address\n"
556 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000557 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000558 "Distance value for this route\n")
559{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200560 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
561 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000562}
563
564DEFUN (ip_route_flags_distance,
565 ip_route_flags_distance_cmd,
566 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
567 IP_STR
568 "Establish static routes\n"
569 "IP destination prefix (e.g. 10.0.0.0/8)\n"
570 "IP gateway address\n"
571 "IP gateway interface name\n"
572 "Emit an ICMP unreachable when matched\n"
573 "Silently discard pkts when matched\n"
574 "Distance value for this route\n")
575{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200576 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
577 NULL);
paul718e3742002-12-13 20:15:29 +0000578}
579
hasso457ef552003-05-28 12:02:15 +0000580DEFUN (ip_route_flags_distance2,
581 ip_route_flags_distance2_cmd,
582 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
583 IP_STR
584 "Establish static routes\n"
585 "IP destination prefix (e.g. 10.0.0.0/8)\n"
586 "Emit an ICMP unreachable when matched\n"
587 "Silently discard pkts when matched\n"
588 "Distance value for this route\n")
589{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200590 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
591 NULL);
hasso457ef552003-05-28 12:02:15 +0000592}
593
paul718e3742002-12-13 20:15:29 +0000594DEFUN (ip_route_mask_distance,
595 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000596 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000597 IP_STR
598 "Establish static routes\n"
599 "IP destination prefix\n"
600 "IP destination prefix mask\n"
601 "IP gateway address\n"
602 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000603 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000604 "Distance value for this route\n")
605{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200606 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
607 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000608}
609
610DEFUN (ip_route_mask_flags_distance,
611 ip_route_mask_flags_distance_cmd,
612 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
613 IP_STR
614 "Establish static routes\n"
615 "IP destination prefix\n"
616 "IP destination prefix mask\n"
617 "IP gateway address\n"
618 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000619 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000620 "Silently discard pkts when matched\n"
621 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000622{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200623 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
624 NULL);
paul718e3742002-12-13 20:15:29 +0000625}
626
hasso457ef552003-05-28 12:02:15 +0000627DEFUN (ip_route_mask_flags_distance2,
628 ip_route_mask_flags_distance2_cmd,
629 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
630 IP_STR
631 "Establish static routes\n"
632 "IP destination prefix\n"
633 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000634 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000635 "Silently discard pkts when matched\n"
636 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000637{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200638 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
639 NULL);
hasso457ef552003-05-28 12:02:15 +0000640}
641
paul718e3742002-12-13 20:15:29 +0000642DEFUN (no_ip_route,
643 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000644 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000645 NO_STR
646 IP_STR
647 "Establish static routes\n"
648 "IP destination prefix (e.g. 10.0.0.0/8)\n"
649 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000650 "IP gateway interface name\n"
651 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000652{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200653 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
654 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000655}
656
657ALIAS (no_ip_route,
658 no_ip_route_flags_cmd,
659 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000660 NO_STR
661 IP_STR
662 "Establish static routes\n"
663 "IP destination prefix (e.g. 10.0.0.0/8)\n"
664 "IP gateway address\n"
665 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000666 "Emit an ICMP unreachable when matched\n"
667 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000668
hasso457ef552003-05-28 12:02:15 +0000669DEFUN (no_ip_route_flags2,
670 no_ip_route_flags2_cmd,
671 "no ip route A.B.C.D/M (reject|blackhole)",
672 NO_STR
673 IP_STR
674 "Establish static routes\n"
675 "IP destination prefix (e.g. 10.0.0.0/8)\n"
676 "Emit an ICMP unreachable when matched\n"
677 "Silently discard pkts when matched\n")
678{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200679 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
680 NULL);
hasso457ef552003-05-28 12:02:15 +0000681}
682
paul718e3742002-12-13 20:15:29 +0000683DEFUN (no_ip_route_mask,
684 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000685 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000686 NO_STR
687 IP_STR
688 "Establish static routes\n"
689 "IP destination prefix\n"
690 "IP destination prefix mask\n"
691 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000692 "IP gateway interface name\n"
693 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000694{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200695 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
696 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000697}
698
699ALIAS (no_ip_route_mask,
700 no_ip_route_mask_flags_cmd,
701 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000702 NO_STR
703 IP_STR
704 "Establish static routes\n"
705 "IP destination prefix\n"
706 "IP destination prefix mask\n"
707 "IP gateway address\n"
708 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000709 "Emit an ICMP unreachable when matched\n"
710 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000711
hasso457ef552003-05-28 12:02:15 +0000712DEFUN (no_ip_route_mask_flags2,
713 no_ip_route_mask_flags2_cmd,
714 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
715 NO_STR
716 IP_STR
717 "Establish static routes\n"
718 "IP destination prefix\n"
719 "IP destination prefix mask\n"
720 "Emit an ICMP unreachable when matched\n"
721 "Silently discard pkts when matched\n")
722{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200723 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
724 NULL);
hasso457ef552003-05-28 12:02:15 +0000725}
726
paul718e3742002-12-13 20:15:29 +0000727DEFUN (no_ip_route_distance,
728 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000729 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000730 NO_STR
731 IP_STR
732 "Establish static routes\n"
733 "IP destination prefix (e.g. 10.0.0.0/8)\n"
734 "IP gateway address\n"
735 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000736 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000737 "Distance value for this route\n")
738{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200739 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
740 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000741}
742
743DEFUN (no_ip_route_flags_distance,
744 no_ip_route_flags_distance_cmd,
745 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
746 NO_STR
747 IP_STR
748 "Establish static routes\n"
749 "IP destination prefix (e.g. 10.0.0.0/8)\n"
750 "IP gateway address\n"
751 "IP gateway interface name\n"
752 "Emit an ICMP unreachable when matched\n"
753 "Silently discard pkts when matched\n"
754 "Distance value for this route\n")
755{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200756 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
757 NULL);
paul718e3742002-12-13 20:15:29 +0000758}
759
hasso457ef552003-05-28 12:02:15 +0000760DEFUN (no_ip_route_flags_distance2,
761 no_ip_route_flags_distance2_cmd,
762 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
763 NO_STR
764 IP_STR
765 "Establish static routes\n"
766 "IP destination prefix (e.g. 10.0.0.0/8)\n"
767 "Emit an ICMP unreachable when matched\n"
768 "Silently discard pkts when matched\n"
769 "Distance value for this route\n")
770{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200771 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
772 NULL);
hasso457ef552003-05-28 12:02:15 +0000773}
774
paul718e3742002-12-13 20:15:29 +0000775DEFUN (no_ip_route_mask_distance,
776 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000777 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000778 NO_STR
779 IP_STR
780 "Establish static routes\n"
781 "IP destination prefix\n"
782 "IP destination prefix mask\n"
783 "IP gateway address\n"
784 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000785 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000786 "Distance value for this route\n")
787{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200788 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
789 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000790}
791
792DEFUN (no_ip_route_mask_flags_distance,
793 no_ip_route_mask_flags_distance_cmd,
794 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
795 NO_STR
796 IP_STR
797 "Establish static routes\n"
798 "IP destination prefix\n"
799 "IP destination prefix mask\n"
800 "IP gateway address\n"
801 "IP gateway interface name\n"
802 "Emit an ICMP unreachable when matched\n"
803 "Silently discard pkts when matched\n"
804 "Distance value for this route\n")
805{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200806 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
807 NULL);
paul718e3742002-12-13 20:15:29 +0000808}
809
hasso457ef552003-05-28 12:02:15 +0000810DEFUN (no_ip_route_mask_flags_distance2,
811 no_ip_route_mask_flags_distance2_cmd,
812 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
813 NO_STR
814 IP_STR
815 "Establish static routes\n"
816 "IP destination prefix\n"
817 "IP destination prefix mask\n"
818 "Emit an ICMP unreachable when matched\n"
819 "Silently discard pkts when matched\n"
820 "Distance value for this route\n")
821{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200822 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
823 NULL);
824}
825
826DEFUN (ip_route_vrf,
827 ip_route_vrf_cmd,
828 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
829 IP_STR
830 "Establish static routes\n"
831 "IP destination prefix (e.g. 10.0.0.0/8)\n"
832 "IP gateway address\n"
833 "IP gateway interface name\n"
834 "Null interface\n"
835 VRF_CMD_HELP_STR)
836{
837 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
838 argv[2]);
839}
840
841DEFUN (ip_route_flags_vrf,
842 ip_route_flags_vrf_cmd,
843 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
844 IP_STR
845 "Establish static routes\n"
846 "IP destination prefix (e.g. 10.0.0.0/8)\n"
847 "IP gateway address\n"
848 "IP gateway interface name\n"
849 "Emit an ICMP unreachable when matched\n"
850 "Silently discard pkts when matched\n"
851 VRF_CMD_HELP_STR)
852{
853 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
854 argv[3]);
855}
856
857DEFUN (ip_route_flags2_vrf,
858 ip_route_flags2_vrf_cmd,
859 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
860 IP_STR
861 "Establish static routes\n"
862 "IP destination prefix (e.g. 10.0.0.0/8)\n"
863 "Emit an ICMP unreachable when matched\n"
864 "Silently discard pkts when matched\n"
865 VRF_CMD_HELP_STR)
866{
867 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
868 argv[2]);
869}
870
871/* Mask as A.B.C.D format. */
872DEFUN (ip_route_mask_vrf,
873 ip_route_mask_vrf_cmd,
874 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
875 IP_STR
876 "Establish static routes\n"
877 "IP destination prefix\n"
878 "IP destination prefix mask\n"
879 "IP gateway address\n"
880 "IP gateway interface name\n"
881 "Null interface\n"
882 VRF_CMD_HELP_STR)
883{
884 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
885 argv[3]);
886}
887
888DEFUN (ip_route_mask_flags_vrf,
889 ip_route_mask_flags_vrf_cmd,
890 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
891 IP_STR
892 "Establish static routes\n"
893 "IP destination prefix\n"
894 "IP destination prefix mask\n"
895 "IP gateway address\n"
896 "IP gateway interface name\n"
897 "Emit an ICMP unreachable when matched\n"
898 "Silently discard pkts when matched\n"
899 VRF_CMD_HELP_STR)
900{
901 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
902 argv[4]);
903}
904
905DEFUN (ip_route_mask_flags2_vrf,
906 ip_route_mask_flags2_vrf_cmd,
907 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
908 IP_STR
909 "Establish static routes\n"
910 "IP destination prefix\n"
911 "IP destination prefix mask\n"
912 "Emit an ICMP unreachable when matched\n"
913 "Silently discard pkts when matched\n"
914 VRF_CMD_HELP_STR)
915{
916 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
917 argv[3]);
918}
919
920/* Distance option value. */
921DEFUN (ip_route_distance_vrf,
922 ip_route_distance_vrf_cmd,
923 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
924 IP_STR
925 "Establish static routes\n"
926 "IP destination prefix (e.g. 10.0.0.0/8)\n"
927 "IP gateway address\n"
928 "IP gateway interface name\n"
929 "Null interface\n"
930 "Distance value for this route\n"
931 VRF_CMD_HELP_STR)
932{
933 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
934 argv[3]);
935}
936
937DEFUN (ip_route_flags_distance_vrf,
938 ip_route_flags_distance_vrf_cmd,
939 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
940 IP_STR
941 "Establish static routes\n"
942 "IP destination prefix (e.g. 10.0.0.0/8)\n"
943 "IP gateway address\n"
944 "IP gateway interface name\n"
945 "Emit an ICMP unreachable when matched\n"
946 "Silently discard pkts when matched\n"
947 "Distance value for this route\n"
948 VRF_CMD_HELP_STR)
949{
950 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
951 argv[4]);
952}
953
954DEFUN (ip_route_flags_distance2_vrf,
955 ip_route_flags_distance2_vrf_cmd,
956 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
957 IP_STR
958 "Establish static routes\n"
959 "IP destination prefix (e.g. 10.0.0.0/8)\n"
960 "Emit an ICMP unreachable when matched\n"
961 "Silently discard pkts when matched\n"
962 "Distance value for this route\n"
963 VRF_CMD_HELP_STR)
964{
965 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
966 argv[3]);
967}
968
969DEFUN (ip_route_mask_distance_vrf,
970 ip_route_mask_distance_vrf_cmd,
971 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
972 IP_STR
973 "Establish static routes\n"
974 "IP destination prefix\n"
975 "IP destination prefix mask\n"
976 "IP gateway address\n"
977 "IP gateway interface name\n"
978 "Null interface\n"
979 "Distance value for this route\n"
980 VRF_CMD_HELP_STR)
981{
982 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
983 argv[4]);
984}
985
986DEFUN (ip_route_mask_flags_distance_vrf,
987 ip_route_mask_flags_distance_vrf_cmd,
988 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
989 IP_STR
990 "Establish static routes\n"
991 "IP destination prefix\n"
992 "IP destination prefix mask\n"
993 "IP gateway address\n"
994 "IP gateway interface name\n"
995 "Emit an ICMP unreachable when matched\n"
996 "Silently discard pkts when matched\n"
997 "Distance value for this route\n"
998 VRF_CMD_HELP_STR)
999{
1000 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
1001 argv[5]);
1002}
1003
1004DEFUN (ip_route_mask_flags_distance2_vrf,
1005 ip_route_mask_flags_distance2_vrf_cmd,
1006 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1007 IP_STR
1008 "Establish static routes\n"
1009 "IP destination prefix\n"
1010 "IP destination prefix mask\n"
1011 "Emit an ICMP unreachable when matched\n"
1012 "Silently discard pkts when matched\n"
1013 "Distance value for this route\n"
1014 VRF_CMD_HELP_STR)
1015{
1016 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
1017 argv[4]);
1018}
1019
1020DEFUN (no_ip_route_vrf,
1021 no_ip_route_vrf_cmd,
1022 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1023 NO_STR
1024 IP_STR
1025 "Establish static routes\n"
1026 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1027 "IP gateway address\n"
1028 "IP gateway interface name\n"
1029 "Null interface\n"
1030 VRF_CMD_HELP_STR)
1031{
1032 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
1033 (argc > 3) ? argv[3] : argv[2]);
1034}
1035
1036ALIAS (no_ip_route_vrf,
1037 no_ip_route_flags_vrf_cmd,
1038 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1039 NO_STR
1040 IP_STR
1041 "Establish static routes\n"
1042 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1043 "IP gateway address\n"
1044 "IP gateway interface name\n"
1045 "Emit an ICMP unreachable when matched\n"
1046 "Silently discard pkts when matched\n"
1047 VRF_CMD_HELP_STR)
1048
1049DEFUN (no_ip_route_flags2_vrf,
1050 no_ip_route_flags2_vrf_cmd,
1051 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1052 NO_STR
1053 IP_STR
1054 "Establish static routes\n"
1055 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1056 "Emit an ICMP unreachable when matched\n"
1057 "Silently discard pkts when matched\n"
1058 VRF_CMD_HELP_STR)
1059{
1060 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
1061 argv[2]);
1062}
1063
1064DEFUN (no_ip_route_mask_vrf,
1065 no_ip_route_mask_vrf_cmd,
1066 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1067 NO_STR
1068 IP_STR
1069 "Establish static routes\n"
1070 "IP destination prefix\n"
1071 "IP destination prefix mask\n"
1072 "IP gateway address\n"
1073 "IP gateway interface name\n"
1074 "Null interface\n"
1075 VRF_CMD_HELP_STR)
1076{
1077 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
1078 (argc > 4) ? argv[4] : argv[3]);
1079}
1080
1081ALIAS (no_ip_route_mask_vrf,
1082 no_ip_route_mask_flags_vrf_cmd,
1083 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1084 NO_STR
1085 IP_STR
1086 "Establish static routes\n"
1087 "IP destination prefix\n"
1088 "IP destination prefix mask\n"
1089 "IP gateway address\n"
1090 "IP gateway interface name\n"
1091 "Emit an ICMP unreachable when matched\n"
1092 "Silently discard pkts when matched\n"
1093 VRF_CMD_HELP_STR)
1094
1095DEFUN (no_ip_route_mask_flags2_vrf,
1096 no_ip_route_mask_flags2_vrf_cmd,
1097 "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1098 NO_STR
1099 IP_STR
1100 "Establish static routes\n"
1101 "IP destination prefix\n"
1102 "IP destination prefix mask\n"
1103 "Emit an ICMP unreachable when matched\n"
1104 "Silently discard pkts when matched\n"
1105 VRF_CMD_HELP_STR)
1106{
1107 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
1108 argv[2]);
1109}
1110
1111DEFUN (no_ip_route_distance_vrf,
1112 no_ip_route_distance_vrf_cmd,
1113 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1114 NO_STR
1115 IP_STR
1116 "Establish static routes\n"
1117 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1118 "IP gateway address\n"
1119 "IP gateway interface name\n"
1120 "Null interface\n"
1121 "Distance value for this route\n"
1122 VRF_CMD_HELP_STR)
1123{
1124 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
1125 argv[3]);
1126}
1127
1128DEFUN (no_ip_route_flags_distance_vrf,
1129 no_ip_route_flags_distance_vrf_cmd,
1130 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1131 NO_STR
1132 IP_STR
1133 "Establish static routes\n"
1134 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1135 "IP gateway address\n"
1136 "IP gateway interface name\n"
1137 "Emit an ICMP unreachable when matched\n"
1138 "Silently discard pkts when matched\n"
1139 "Distance value for this route\n"
1140 VRF_CMD_HELP_STR)
1141{
1142 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
1143 argv[4]);
1144}
1145
1146DEFUN (no_ip_route_flags_distance2_vrf,
1147 no_ip_route_flags_distance2_vrf_cmd,
1148 "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1149 NO_STR
1150 IP_STR
1151 "Establish static routes\n"
1152 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1153 "Emit an ICMP unreachable when matched\n"
1154 "Silently discard pkts when matched\n"
1155 "Distance value for this route\n"
1156 VRF_CMD_HELP_STR)
1157{
1158 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
1159 argv[3]);
1160}
1161
1162DEFUN (no_ip_route_mask_distance_vrf,
1163 no_ip_route_mask_distance_vrf_cmd,
1164 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1165 NO_STR
1166 IP_STR
1167 "Establish static routes\n"
1168 "IP destination prefix\n"
1169 "IP destination prefix mask\n"
1170 "IP gateway address\n"
1171 "IP gateway interface name\n"
1172 "Null interface\n"
1173 "Distance value for this route\n"
1174 VRF_CMD_HELP_STR)
1175{
1176 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
1177 argv[4]);
1178}
1179
1180DEFUN (no_ip_route_mask_flags_distance_vrf,
1181 no_ip_route_mask_flags_distance_vrf_cmd,
1182 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1183 NO_STR
1184 IP_STR
1185 "Establish static routes\n"
1186 "IP destination prefix\n"
1187 "IP destination prefix mask\n"
1188 "IP gateway address\n"
1189 "IP gateway interface name\n"
1190 "Emit an ICMP unreachable when matched\n"
1191 "Silently discard pkts when matched\n"
1192 "Distance value for this route\n"
1193 VRF_CMD_HELP_STR)
1194{
1195 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
1196 argv[5]);
1197}
1198
1199DEFUN (no_ip_route_mask_flags_distance2_vrf,
1200 no_ip_route_mask_flags_distance2_vrf_cmd,
1201 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1202 NO_STR
1203 IP_STR
1204 "Establish static routes\n"
1205 "IP destination prefix\n"
1206 "IP destination prefix mask\n"
1207 "Emit an ICMP unreachable when matched\n"
1208 "Silently discard pkts when matched\n"
1209 "Distance value for this route\n"
1210 VRF_CMD_HELP_STR)
1211{
1212 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
1213 argv[4]);
hasso457ef552003-05-28 12:02:15 +00001214}
1215
Paul Jakma7514fb72007-05-02 16:05:35 +00001216char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
1217
1218DEFUN (ip_protocol,
1219 ip_protocol_cmd,
1220 "ip protocol PROTO route-map ROUTE-MAP",
1221 NO_STR
1222 "Apply route map to PROTO\n"
1223 "Protocol name\n"
1224 "Route map name\n")
1225{
1226 int i;
1227
1228 if (strcasecmp(argv[0], "any") == 0)
1229 i = ZEBRA_ROUTE_MAX;
1230 else
1231 i = proto_name2num(argv[0]);
1232 if (i < 0)
1233 {
1234 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1235 VTY_NEWLINE);
1236 return CMD_WARNING;
1237 }
1238 if (proto_rm[AFI_IP][i])
1239 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1240 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
1241 return CMD_SUCCESS;
1242}
1243
1244DEFUN (no_ip_protocol,
1245 no_ip_protocol_cmd,
1246 "no ip protocol PROTO",
1247 NO_STR
1248 "Remove route map from PROTO\n"
1249 "Protocol name\n")
1250{
1251 int i;
1252
1253 if (strcasecmp(argv[0], "any") == 0)
1254 i = ZEBRA_ROUTE_MAX;
1255 else
1256 i = proto_name2num(argv[0]);
1257 if (i < 0)
1258 {
1259 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1260 VTY_NEWLINE);
1261 return CMD_WARNING;
1262 }
1263 if (proto_rm[AFI_IP][i])
1264 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1265 proto_rm[AFI_IP][i] = NULL;
1266 return CMD_SUCCESS;
1267}
1268
paul718e3742002-12-13 20:15:29 +00001269/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +00001270static void
David Lamparter3b02fe82015-01-22 19:12:35 +01001271vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +00001272{
1273 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001274 struct nexthop *nexthop, *tnexthop;
1275 int recursing;
Timo Teräs53a5c392015-05-23 11:08:40 +03001276 char buf[PREFIX_STRLEN];
paul718e3742002-12-13 20:15:29 +00001277
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001278 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001279 {
David Lamparterb7cce952015-03-07 08:40:48 +01001280 const char *mcast_info = "";
David Lamparter3b02fe82015-01-22 19:12:35 +01001281 if (mcast)
1282 {
1283 rib_table_info_t *info = rn->table->info;
1284 mcast_info = (info->safi == SAFI_MULTICAST)
1285 ? " using Multicast RIB"
1286 : " using Unicast RIB";
1287 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001288 vty_out (vty, "Routing entry for %s%s%s",
1289 prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
1290 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001291 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001292 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001293 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001294 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001295 vty_out (vty, ", best");
paul718e3742002-12-13 20:15:29 +00001296 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001297 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1299 vty_out (vty, ", blackhole");
1300 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1301 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001302 vty_out (vty, "%s", VTY_NEWLINE);
1303
1304#define ONE_DAY_SECOND 60*60*24
1305#define ONE_WEEK_SECOND 60*60*24*7
1306 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001307 || rib->type == ZEBRA_ROUTE_RIPNG
1308 || rib->type == ZEBRA_ROUTE_OSPF
1309 || rib->type == ZEBRA_ROUTE_OSPF6
1310 || rib->type == ZEBRA_ROUTE_BABEL
1311 || rib->type == ZEBRA_ROUTE_ISIS
1312 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001313 {
1314 time_t uptime;
1315 struct tm *tm;
1316
1317 uptime = time (NULL);
1318 uptime -= rib->uptime;
1319 tm = gmtime (&uptime);
1320
1321 vty_out (vty, " Last update ");
1322
1323 if (uptime < ONE_DAY_SECOND)
1324 vty_out (vty, "%02d:%02d:%02d",
1325 tm->tm_hour, tm->tm_min, tm->tm_sec);
1326 else if (uptime < ONE_WEEK_SECOND)
1327 vty_out (vty, "%dd%02dh%02dm",
1328 tm->tm_yday, tm->tm_hour, tm->tm_min);
1329 else
1330 vty_out (vty, "%02dw%dd%02dh",
1331 tm->tm_yday/7,
1332 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1333 vty_out (vty, " ago%s", VTY_NEWLINE);
1334 }
1335
Christian Frankefa713d92013-07-05 15:35:37 +00001336 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001337 {
1338 vty_out (vty, " %c%s",
1339 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1340 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001341
Timo Teräs53a5c392015-05-23 11:08:40 +03001342 switch (nexthop->type)
1343 {
1344 case NEXTHOP_TYPE_IPV4:
1345 case NEXTHOP_TYPE_IPV4_IFINDEX:
1346 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1347 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001348 vty_out (vty, ", via %s",
1349 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001350 break;
1351 case NEXTHOP_TYPE_IPV6:
1352 case NEXTHOP_TYPE_IPV6_IFINDEX:
1353 case NEXTHOP_TYPE_IPV6_IFNAME:
1354 vty_out (vty, " %s",
1355 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1356 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1357 vty_out (vty, ", %s", nexthop->ifname);
1358 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001359 vty_out (vty, ", via %s",
1360 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001361 break;
1362 case NEXTHOP_TYPE_IFINDEX:
1363 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001364 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001365 break;
1366 case NEXTHOP_TYPE_IFNAME:
1367 vty_out (vty, " directly connected, %s", nexthop->ifname);
1368 break;
1369 case NEXTHOP_TYPE_BLACKHOLE:
1370 vty_out (vty, " directly connected, Null0");
1371 break;
1372 default:
1373 break;
1374 }
1375 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1376 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001377
Timo Teräs53a5c392015-05-23 11:08:40 +03001378 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1379 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001380
Timo Teräs53a5c392015-05-23 11:08:40 +03001381 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1382 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001383
Timo Teräs53a5c392015-05-23 11:08:40 +03001384 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001385 {
1386 case NEXTHOP_TYPE_IPV4:
1387 case NEXTHOP_TYPE_IPV4_IFINDEX:
1388 case NEXTHOP_TYPE_IPV4_IFNAME:
1389 if (nexthop->src.ipv4.s_addr)
1390 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001391 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1392 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001393 }
1394 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001395#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001396 case NEXTHOP_TYPE_IPV6:
1397 case NEXTHOP_TYPE_IPV6_IFINDEX:
1398 case NEXTHOP_TYPE_IPV6_IFNAME:
1399 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1400 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001401 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1402 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001403 }
1404 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001405#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001406 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001407 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001408 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001409 vty_out (vty, "%s", VTY_NEWLINE);
1410 }
paul718e3742002-12-13 20:15:29 +00001411 vty_out (vty, "%s", VTY_NEWLINE);
1412 }
1413}
1414
paula1ac18c2005-06-28 17:17:12 +00001415static void
paul718e3742002-12-13 20:15:29 +00001416vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1417{
Christian Frankefa713d92013-07-05 15:35:37 +00001418 struct nexthop *nexthop, *tnexthop;
1419 int recursing;
paul718e3742002-12-13 20:15:29 +00001420 int len = 0;
1421 char buf[BUFSIZ];
1422
1423 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001424 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001425 {
1426 if (nexthop == rib->nexthop)
1427 {
1428 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001429 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001430 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001431 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1432 ? '>' : ' ',
1433 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1434 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001435 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001436
1437 /* Distance and metric display. */
1438 if (rib->type != ZEBRA_ROUTE_CONNECT
1439 && rib->type != ZEBRA_ROUTE_KERNEL)
1440 len += vty_out (vty, " [%d/%d]", rib->distance,
1441 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001442
1443 if (rib->vrf_id != VRF_DEFAULT)
1444 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001445 }
1446 else
1447 vty_out (vty, " %c%*c",
1448 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1449 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001450 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001451
1452 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001453 {
1454 case NEXTHOP_TYPE_IPV4:
1455 case NEXTHOP_TYPE_IPV4_IFINDEX:
1456 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1457 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001458 vty_out (vty, ", %s",
1459 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001460 break;
1461 case NEXTHOP_TYPE_IPV6:
1462 case NEXTHOP_TYPE_IPV6_IFINDEX:
1463 case NEXTHOP_TYPE_IPV6_IFNAME:
1464 vty_out (vty, " via %s",
1465 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1466 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1467 vty_out (vty, ", %s", nexthop->ifname);
1468 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001469 vty_out (vty, ", %s",
1470 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001471 break;
1472 case NEXTHOP_TYPE_IFINDEX:
1473 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001474 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001475 break;
1476 case NEXTHOP_TYPE_IFNAME:
1477 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1478 break;
1479 case NEXTHOP_TYPE_BLACKHOLE:
1480 vty_out (vty, " is directly connected, Null0");
1481 break;
1482 default:
1483 break;
1484 }
paul718e3742002-12-13 20:15:29 +00001485 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001486 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001487
Christian Frankee8d3d292013-07-05 15:35:39 +00001488 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001489 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001490
paul718e3742002-12-13 20:15:29 +00001491 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001492 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001493
Paul Jakma7514fb72007-05-02 16:05:35 +00001494 switch (nexthop->type)
1495 {
1496 case NEXTHOP_TYPE_IPV4:
1497 case NEXTHOP_TYPE_IPV4_IFINDEX:
1498 case NEXTHOP_TYPE_IPV4_IFNAME:
1499 if (nexthop->src.ipv4.s_addr)
1500 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001501 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001502 vty_out (vty, ", src %s", buf);
1503 }
1504 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001505#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001506 case NEXTHOP_TYPE_IPV6:
1507 case NEXTHOP_TYPE_IPV6_IFINDEX:
1508 case NEXTHOP_TYPE_IPV6_IFNAME:
1509 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1510 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001511 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001512 vty_out (vty, ", src %s", buf);
1513 }
1514 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001515#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001516 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001517 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001518 }
paul718e3742002-12-13 20:15:29 +00001519
hasso81dfcaa2003-05-25 19:21:25 +00001520 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1521 vty_out (vty, ", bh");
1522 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1523 vty_out (vty, ", rej");
1524
paul718e3742002-12-13 20:15:29 +00001525 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001526 || rib->type == ZEBRA_ROUTE_RIPNG
1527 || rib->type == ZEBRA_ROUTE_OSPF
1528 || rib->type == ZEBRA_ROUTE_OSPF6
1529 || rib->type == ZEBRA_ROUTE_BABEL
1530 || rib->type == ZEBRA_ROUTE_ISIS
1531 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001532 {
1533 time_t uptime;
1534 struct tm *tm;
1535
1536 uptime = time (NULL);
1537 uptime -= rib->uptime;
1538 tm = gmtime (&uptime);
1539
1540#define ONE_DAY_SECOND 60*60*24
1541#define ONE_WEEK_SECOND 60*60*24*7
1542
1543 if (uptime < ONE_DAY_SECOND)
1544 vty_out (vty, ", %02d:%02d:%02d",
1545 tm->tm_hour, tm->tm_min, tm->tm_sec);
1546 else if (uptime < ONE_WEEK_SECOND)
1547 vty_out (vty, ", %dd%02dh%02dm",
1548 tm->tm_yday, tm->tm_hour, tm->tm_min);
1549 else
1550 vty_out (vty, ", %02dw%dd%02dh",
1551 tm->tm_yday/7,
1552 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1553 }
1554 vty_out (vty, "%s", VTY_NEWLINE);
1555 }
1556}
1557
paul718e3742002-12-13 20:15:29 +00001558DEFUN (show_ip_route,
1559 show_ip_route_cmd,
1560 "show ip route",
1561 SHOW_STR
1562 IP_STR
1563 "IP routing table\n")
1564{
Feng Lu4364ee52015-05-22 11:40:03 +02001565 vrf_id_t vrf_id = VRF_DEFAULT;
1566
1567 if (argc > 0)
1568 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1569
1570 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001571}
1572
Feng Lu4364ee52015-05-22 11:40:03 +02001573static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1574{
paul718e3742002-12-13 20:15:29 +00001575 struct route_table *table;
1576 struct route_node *rn;
1577 struct rib *rib;
1578 int first = 1;
1579
Feng Lu4364ee52015-05-22 11:40:03 +02001580 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001581 if (! table)
1582 return CMD_SUCCESS;
1583
1584 /* Show all IPv4 routes. */
1585 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001586 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001587 {
1588 if (first)
1589 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001590 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001591 first = 0;
1592 }
1593 vty_show_ip_route (vty, rn, rib);
1594 }
1595 return CMD_SUCCESS;
1596}
1597
Feng Lu4364ee52015-05-22 11:40:03 +02001598ALIAS (show_ip_route,
1599 show_ip_route_vrf_cmd,
1600 "show ip route " VRF_CMD_STR,
1601 SHOW_STR
1602 IP_STR
1603 "IP routing table\n"
1604 VRF_CMD_HELP_STR)
1605
paul718e3742002-12-13 20:15:29 +00001606DEFUN (show_ip_route_prefix_longer,
1607 show_ip_route_prefix_longer_cmd,
1608 "show ip route A.B.C.D/M longer-prefixes",
1609 SHOW_STR
1610 IP_STR
1611 "IP routing table\n"
1612 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1613 "Show route matching the specified Network/Mask pair only\n")
1614{
1615 struct route_table *table;
1616 struct route_node *rn;
1617 struct rib *rib;
1618 struct prefix p;
1619 int ret;
1620 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001621 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001622
1623 ret = str2prefix (argv[0], &p);
1624 if (! ret)
1625 {
1626 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1627 return CMD_WARNING;
1628 }
Feng Lu4364ee52015-05-22 11:40:03 +02001629
1630 if (argc > 1)
1631 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1632
1633 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001634 if (! table)
1635 return CMD_SUCCESS;
1636
1637 /* Show matched type IPv4 routes. */
1638 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001639 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001640 if (prefix_match (&p, &rn->p))
1641 {
1642 if (first)
1643 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001644 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001645 first = 0;
1646 }
1647 vty_show_ip_route (vty, rn, rib);
1648 }
1649 return CMD_SUCCESS;
1650}
1651
Feng Lu4364ee52015-05-22 11:40:03 +02001652ALIAS (show_ip_route_prefix_longer,
1653 show_ip_route_prefix_longer_vrf_cmd,
1654 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1655 SHOW_STR
1656 IP_STR
1657 "IP routing table\n"
1658 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1659 "Show route matching the specified Network/Mask pair only\n"
1660 VRF_CMD_HELP_STR)
1661
paul718e3742002-12-13 20:15:29 +00001662DEFUN (show_ip_route_supernets,
1663 show_ip_route_supernets_cmd,
1664 "show ip route supernets-only",
1665 SHOW_STR
1666 IP_STR
1667 "IP routing table\n"
1668 "Show supernet entries only\n")
1669{
1670 struct route_table *table;
1671 struct route_node *rn;
1672 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001673 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001674 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001675 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001676
Feng Lu4364ee52015-05-22 11:40:03 +02001677 if (argc > 0)
1678 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1679
1680 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001681 if (! table)
1682 return CMD_SUCCESS;
1683
1684 /* Show matched type IPv4 routes. */
1685 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001686 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001687 {
1688 addr = ntohl (rn->p.u.prefix4.s_addr);
1689
1690 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1691 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001692 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001693 {
1694 if (first)
1695 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001696 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001697 first = 0;
1698 }
1699 vty_show_ip_route (vty, rn, rib);
1700 }
1701 }
1702 return CMD_SUCCESS;
1703}
1704
Feng Lu4364ee52015-05-22 11:40:03 +02001705ALIAS (show_ip_route_supernets,
1706 show_ip_route_supernets_vrf_cmd,
1707 "show ip route supernets-only " VRF_CMD_STR,
1708 SHOW_STR
1709 IP_STR
1710 "IP routing table\n"
1711 "Show supernet entries only\n"
1712 VRF_CMD_HELP_STR)
1713
paul718e3742002-12-13 20:15:29 +00001714DEFUN (show_ip_route_protocol,
1715 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001716 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001717 SHOW_STR
1718 IP_STR
1719 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001720 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001721{
1722 int type;
1723 struct route_table *table;
1724 struct route_node *rn;
1725 struct rib *rib;
1726 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001727 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001728
David Lampartere0ca5fd2009-09-16 01:52:42 +02001729 type = proto_redistnum (AFI_IP, argv[0]);
1730 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001731 {
1732 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1733 return CMD_WARNING;
1734 }
Feng Lu4364ee52015-05-22 11:40:03 +02001735
1736 if (argc > 1)
1737 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1738
1739 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001740 if (! table)
1741 return CMD_SUCCESS;
1742
1743 /* Show matched type IPv4 routes. */
1744 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001745 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001746 if (rib->type == type)
1747 {
1748 if (first)
1749 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001750 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001751 first = 0;
1752 }
1753 vty_show_ip_route (vty, rn, rib);
1754 }
1755 return CMD_SUCCESS;
1756}
1757
Feng Lu4364ee52015-05-22 11:40:03 +02001758ALIAS (show_ip_route_protocol,
1759 show_ip_route_protocol_vrf_cmd,
1760 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1761 SHOW_STR
1762 IP_STR
1763 "IP routing table\n"
1764 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1765 VRF_CMD_HELP_STR)
1766
paul718e3742002-12-13 20:15:29 +00001767DEFUN (show_ip_route_addr,
1768 show_ip_route_addr_cmd,
1769 "show ip route A.B.C.D",
1770 SHOW_STR
1771 IP_STR
1772 "IP routing table\n"
1773 "Network in the IP routing table to display\n")
1774{
1775 int ret;
1776 struct prefix_ipv4 p;
1777 struct route_table *table;
1778 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001779 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001780
1781 ret = str2prefix_ipv4 (argv[0], &p);
1782 if (ret <= 0)
1783 {
1784 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1785 return CMD_WARNING;
1786 }
1787
Feng Lu4364ee52015-05-22 11:40:03 +02001788 if (argc > 1)
1789 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1790
1791 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001792 if (! table)
1793 return CMD_SUCCESS;
1794
1795 rn = route_node_match (table, (struct prefix *) &p);
1796 if (! rn)
1797 {
1798 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1799 return CMD_WARNING;
1800 }
1801
David Lamparter3b02fe82015-01-22 19:12:35 +01001802 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001803
1804 route_unlock_node (rn);
1805
1806 return CMD_SUCCESS;
1807}
1808
Feng Lu4364ee52015-05-22 11:40:03 +02001809ALIAS (show_ip_route_addr,
1810 show_ip_route_addr_vrf_cmd,
1811 "show ip route A.B.C.D " VRF_CMD_STR,
1812 SHOW_STR
1813 IP_STR
1814 "IP routing table\n"
1815 "Network in the IP routing table to display\n"
1816 VRF_CMD_HELP_STR)
1817
paul718e3742002-12-13 20:15:29 +00001818DEFUN (show_ip_route_prefix,
1819 show_ip_route_prefix_cmd,
1820 "show ip route A.B.C.D/M",
1821 SHOW_STR
1822 IP_STR
1823 "IP routing table\n"
1824 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1825{
1826 int ret;
1827 struct prefix_ipv4 p;
1828 struct route_table *table;
1829 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001830 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001831
1832 ret = str2prefix_ipv4 (argv[0], &p);
1833 if (ret <= 0)
1834 {
1835 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1836 return CMD_WARNING;
1837 }
1838
Feng Lu4364ee52015-05-22 11:40:03 +02001839 if (argc > 1)
1840 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1841
1842 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001843 if (! table)
1844 return CMD_SUCCESS;
1845
1846 rn = route_node_match (table, (struct prefix *) &p);
1847 if (! rn || rn->p.prefixlen != p.prefixlen)
1848 {
1849 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001850 if (rn)
1851 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001852 return CMD_WARNING;
1853 }
1854
David Lamparter3b02fe82015-01-22 19:12:35 +01001855 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001856
1857 route_unlock_node (rn);
1858
1859 return CMD_SUCCESS;
1860}
1861
Feng Lu4364ee52015-05-22 11:40:03 +02001862ALIAS (show_ip_route_prefix,
1863 show_ip_route_prefix_vrf_cmd,
1864 "show ip route A.B.C.D/M " VRF_CMD_STR,
1865 SHOW_STR
1866 IP_STR
1867 "IP routing table\n"
1868 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1869 VRF_CMD_HELP_STR)
1870
paula1ac18c2005-06-28 17:17:12 +00001871static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001872vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001873{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001874 struct route_node *rn;
1875 struct rib *rib;
1876 struct nexthop *nexthop;
1877#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1878#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1879 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1880 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1881 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001882
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001883 memset (&rib_cnt, 0, sizeof(rib_cnt));
1884 memset (&fib_cnt, 0, sizeof(fib_cnt));
1885 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001886 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001887 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1888 {
1889 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1890 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001891 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1892 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001893 {
1894 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1895 fib_cnt[rib->type]++;
1896 }
1897 if (rib->type == ZEBRA_ROUTE_BGP &&
1898 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1899 {
1900 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001901 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1902 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001903 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1904 }
1905 }
paul718e3742002-12-13 20:15:29 +00001906
Feng Lu4364ee52015-05-22 11:40:03 +02001907 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1908 "Route Source", "Routes", "FIB",
1909 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1910 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001911
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001912 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1913 {
1914 if (rib_cnt[i] > 0)
1915 {
1916 if (i == ZEBRA_ROUTE_BGP)
1917 {
1918 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1919 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1920 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1921 VTY_NEWLINE);
1922 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1923 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1924 VTY_NEWLINE);
1925 }
1926 else
1927 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1928 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1929 }
1930 }
paul718e3742002-12-13 20:15:29 +00001931
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001932 vty_out (vty, "------%s", VTY_NEWLINE);
1933 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1934 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001935 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001936}
1937
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001938/*
1939 * Implementation of the ip route summary prefix command.
1940 *
1941 * This command prints the primary prefixes that have been installed by various
1942 * protocols on the box.
1943 *
1944 */
1945static void
1946vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1947{
1948 struct route_node *rn;
1949 struct rib *rib;
1950 struct nexthop *nexthop;
1951#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1952#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1953 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1954 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1955 u_int32_t i;
1956 int cnt;
1957
1958 memset (&rib_cnt, 0, sizeof(rib_cnt));
1959 memset (&fib_cnt, 0, sizeof(fib_cnt));
1960 for (rn = route_top (table); rn; rn = route_next (rn))
1961 RNODE_FOREACH_RIB (rn, rib)
1962 {
1963
1964 /*
1965 * In case of ECMP, count only once.
1966 */
1967 cnt = 0;
1968 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1969 {
1970 cnt++;
1971 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1972 rib_cnt[rib->type]++;
1973 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1974 {
1975 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1976 fib_cnt[rib->type]++;
1977 }
1978 if (rib->type == ZEBRA_ROUTE_BGP &&
1979 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1980 {
1981 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1982 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1983 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1984 }
1985 }
1986 }
1987
Feng Lu4364ee52015-05-22 11:40:03 +02001988 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1989 "Route Source", "Prefix Routes", "FIB",
1990 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1991 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001992
1993 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1994 {
1995 if (rib_cnt[i] > 0)
1996 {
1997 if (i == ZEBRA_ROUTE_BGP)
1998 {
1999 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2000 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2001 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2002 VTY_NEWLINE);
2003 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2004 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2005 VTY_NEWLINE);
2006 }
2007 else
2008 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2009 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2010 }
2011 }
2012
2013 vty_out (vty, "------%s", VTY_NEWLINE);
2014 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2015 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002016 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002017}
2018
paul718e3742002-12-13 20:15:29 +00002019/* Show route summary. */
2020DEFUN (show_ip_route_summary,
2021 show_ip_route_summary_cmd,
2022 "show ip route summary",
2023 SHOW_STR
2024 IP_STR
2025 "IP routing table\n"
2026 "Summary of all routes\n")
2027{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002028 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002029 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002030
Feng Lu4364ee52015-05-22 11:40:03 +02002031 if (argc > 0)
2032 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2033
2034 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002035 if (! table)
2036 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002037
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002038 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002039
2040 return CMD_SUCCESS;
2041}
2042
Feng Lu4364ee52015-05-22 11:40:03 +02002043ALIAS (show_ip_route_summary,
2044 show_ip_route_summary_vrf_cmd,
2045 "show ip route summary " VRF_CMD_STR,
2046 SHOW_STR
2047 IP_STR
2048 "IP routing table\n"
2049 "Summary of all routes\n"
2050 VRF_CMD_HELP_STR)
2051
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002052/* Show route summary prefix. */
2053DEFUN (show_ip_route_summary_prefix,
2054 show_ip_route_summary_prefix_cmd,
2055 "show ip route summary prefix",
2056 SHOW_STR
2057 IP_STR
2058 "IP routing table\n"
2059 "Summary of all routes\n"
2060 "Prefix routes\n")
2061{
2062 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002063 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002064
Feng Lu4364ee52015-05-22 11:40:03 +02002065 if (argc > 0)
2066 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2067
2068 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002069 if (! table)
2070 return CMD_SUCCESS;
2071
2072 vty_show_ip_route_summary_prefix (vty, table);
2073
2074 return CMD_SUCCESS;
2075}
2076
Feng Lu4364ee52015-05-22 11:40:03 +02002077ALIAS (show_ip_route_summary_prefix,
2078 show_ip_route_summary_prefix_vrf_cmd,
2079 "show ip route summary prefix " VRF_CMD_STR,
2080 SHOW_STR
2081 IP_STR
2082 "IP routing table\n"
2083 "Summary of all routes\n"
2084 "Prefix routes\n"
2085 VRF_CMD_HELP_STR)
2086
2087DEFUN (show_ip_route_vrf_all,
2088 show_ip_route_vrf_all_cmd,
2089 "show ip route " VRF_ALL_CMD_STR,
2090 SHOW_STR
2091 IP_STR
2092 "IP routing table\n"
2093 VRF_ALL_CMD_HELP_STR)
2094{
2095 struct route_table *table;
2096 struct route_node *rn;
2097 struct rib *rib;
2098 struct zebra_vrf *zvrf;
2099 vrf_iter_t iter;
2100 int first = 1;
2101
2102 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2103 {
2104 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2105 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2106 continue;
2107
2108 /* Show all IPv4 routes. */
2109 for (rn = route_top (table); rn; rn = route_next (rn))
2110 RNODE_FOREACH_RIB (rn, rib)
2111 {
2112 if (first)
2113 {
2114 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2115 first = 0;
2116 }
2117 vty_show_ip_route (vty, rn, rib);
2118 }
2119 }
2120
2121 return CMD_SUCCESS;
2122}
2123
2124DEFUN (show_ip_route_prefix_longer_vrf_all,
2125 show_ip_route_prefix_longer_vrf_all_cmd,
2126 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2127 SHOW_STR
2128 IP_STR
2129 "IP routing table\n"
2130 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2131 "Show route matching the specified Network/Mask pair only\n"
2132 VRF_ALL_CMD_HELP_STR)
2133{
2134 struct route_table *table;
2135 struct route_node *rn;
2136 struct rib *rib;
2137 struct prefix p;
2138 struct zebra_vrf *zvrf;
2139 vrf_iter_t iter;
2140 int ret;
2141 int first = 1;
2142
2143 ret = str2prefix (argv[0], &p);
2144 if (! ret)
2145 {
2146 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2147 return CMD_WARNING;
2148 }
2149
2150 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2151 {
2152 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2153 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2154 continue;
2155
2156 /* Show matched type IPv4 routes. */
2157 for (rn = route_top (table); rn; rn = route_next (rn))
2158 RNODE_FOREACH_RIB (rn, rib)
2159 if (prefix_match (&p, &rn->p))
2160 {
2161 if (first)
2162 {
2163 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2164 first = 0;
2165 }
2166 vty_show_ip_route (vty, rn, rib);
2167 }
2168 }
2169
2170 return CMD_SUCCESS;
2171}
2172
2173DEFUN (show_ip_route_supernets_vrf_all,
2174 show_ip_route_supernets_vrf_all_cmd,
2175 "show ip route supernets-only " VRF_ALL_CMD_STR,
2176 SHOW_STR
2177 IP_STR
2178 "IP routing table\n"
2179 "Show supernet entries only\n"
2180 VRF_ALL_CMD_HELP_STR)
2181{
2182 struct route_table *table;
2183 struct route_node *rn;
2184 struct rib *rib;
2185 struct zebra_vrf *zvrf;
2186 vrf_iter_t iter;
2187 u_int32_t addr;
2188 int first = 1;
2189
2190 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2191 {
2192 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2193 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2194 continue;
2195
2196 /* Show matched type IPv4 routes. */
2197 for (rn = route_top (table); rn; rn = route_next (rn))
2198 RNODE_FOREACH_RIB (rn, rib)
2199 {
2200 addr = ntohl (rn->p.u.prefix4.s_addr);
2201
2202 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2203 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2204 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2205 {
2206 if (first)
2207 {
2208 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2209 first = 0;
2210 }
2211 vty_show_ip_route (vty, rn, rib);
2212 }
2213 }
2214 }
2215
2216 return CMD_SUCCESS;
2217}
2218
2219DEFUN (show_ip_route_protocol_vrf_all,
2220 show_ip_route_protocol_vrf_all_cmd,
2221 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2222 SHOW_STR
2223 IP_STR
2224 "IP routing table\n"
2225 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2226 VRF_ALL_CMD_HELP_STR)
2227{
2228 int type;
2229 struct route_table *table;
2230 struct route_node *rn;
2231 struct rib *rib;
2232 struct zebra_vrf *zvrf;
2233 vrf_iter_t iter;
2234 int first = 1;
2235
2236 type = proto_redistnum (AFI_IP, argv[0]);
2237 if (type < 0)
2238 {
2239 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2240 return CMD_WARNING;
2241 }
2242
2243 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2244 {
2245 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2246 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2247 continue;
2248
2249 /* Show matched type IPv4 routes. */
2250 for (rn = route_top (table); rn; rn = route_next (rn))
2251 RNODE_FOREACH_RIB (rn, rib)
2252 if (rib->type == type)
2253 {
2254 if (first)
2255 {
2256 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2257 first = 0;
2258 }
2259 vty_show_ip_route (vty, rn, rib);
2260 }
2261 }
2262
2263 return CMD_SUCCESS;
2264}
2265
2266DEFUN (show_ip_route_addr_vrf_all,
2267 show_ip_route_addr_vrf_all_cmd,
2268 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2269 SHOW_STR
2270 IP_STR
2271 "IP routing table\n"
2272 "Network in the IP routing table to display\n"
2273 VRF_ALL_CMD_HELP_STR)
2274{
2275 int ret;
2276 struct prefix_ipv4 p;
2277 struct route_table *table;
2278 struct route_node *rn;
2279 struct zebra_vrf *zvrf;
2280 vrf_iter_t iter;
2281
2282 ret = str2prefix_ipv4 (argv[0], &p);
2283 if (ret <= 0)
2284 {
2285 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2286 return CMD_WARNING;
2287 }
2288
2289 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2290 {
2291 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2292 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2293 continue;
2294
2295 rn = route_node_match (table, (struct prefix *) &p);
2296 if (! rn)
2297 continue;
2298
2299 vty_show_ip_route_detail (vty, rn, 0);
2300
2301 route_unlock_node (rn);
2302 }
2303
2304 return CMD_SUCCESS;
2305}
2306
2307DEFUN (show_ip_route_prefix_vrf_all,
2308 show_ip_route_prefix_vrf_all_cmd,
2309 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2310 SHOW_STR
2311 IP_STR
2312 "IP routing table\n"
2313 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2314 VRF_ALL_CMD_HELP_STR)
2315{
2316 int ret;
2317 struct prefix_ipv4 p;
2318 struct route_table *table;
2319 struct route_node *rn;
2320 struct zebra_vrf *zvrf;
2321 vrf_iter_t iter;
2322
2323 ret = str2prefix_ipv4 (argv[0], &p);
2324 if (ret <= 0)
2325 {
2326 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2327 return CMD_WARNING;
2328 }
2329
2330 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2331 {
2332 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2333 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2334 continue;
2335
2336 rn = route_node_match (table, (struct prefix *) &p);
2337 if (! rn)
2338 continue;
2339 if (rn->p.prefixlen != p.prefixlen)
2340 {
2341 route_unlock_node (rn);
2342 continue;
2343 }
2344
2345 vty_show_ip_route_detail (vty, rn, 0);
2346
2347 route_unlock_node (rn);
2348 }
2349
2350 return CMD_SUCCESS;
2351}
2352
2353DEFUN (show_ip_route_summary_vrf_all,
2354 show_ip_route_summary_vrf_all_cmd,
2355 "show ip route summary " VRF_ALL_CMD_STR,
2356 SHOW_STR
2357 IP_STR
2358 "IP routing table\n"
2359 "Summary of all routes\n"
2360 VRF_ALL_CMD_HELP_STR)
2361{
2362 struct zebra_vrf *zvrf;
2363 vrf_iter_t iter;
2364
2365 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2366 if ((zvrf = vrf_iter2info (iter)) != NULL)
2367 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2368
2369 return CMD_SUCCESS;
2370}
2371
2372DEFUN (show_ip_route_summary_prefix_vrf_all,
2373 show_ip_route_summary_prefix_vrf_all_cmd,
2374 "show ip route summary prefix " VRF_ALL_CMD_STR,
2375 SHOW_STR
2376 IP_STR
2377 "IP routing table\n"
2378 "Summary of all routes\n"
2379 "Prefix routes\n"
2380 VRF_ALL_CMD_HELP_STR)
2381{
2382 struct zebra_vrf *zvrf;
2383 vrf_iter_t iter;
2384
2385 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2386 if ((zvrf = vrf_iter2info (iter)) != NULL)
2387 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2388
2389 return CMD_SUCCESS;
2390}
2391
paul718e3742002-12-13 20:15:29 +00002392/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002393static int
Everton Marques33d86db2014-07-14 11:19:00 -03002394static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002395{
2396 struct route_node *rn;
2397 struct static_ipv4 *si;
2398 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002399 struct zebra_vrf *zvrf;
2400 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002401 int write;
2402
2403 write = 0;
2404
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002405 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2406 {
2407 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2408 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2409 continue;
paul718e3742002-12-13 20:15:29 +00002410
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002411 for (rn = route_top (stable); rn; rn = route_next (rn))
2412 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002413 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002414 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2415 rn->p.prefixlen);
2416
2417 switch (si->type)
2418 {
2419 case STATIC_IPV4_GATEWAY:
2420 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
2421 break;
2422 case STATIC_IPV4_IFNAME:
2423 vty_out (vty, " %s", si->gate.ifname);
2424 break;
2425 case STATIC_IPV4_BLACKHOLE:
2426 vty_out (vty, " Null0");
2427 break;
2428 }
2429
2430 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2431 if (si->type != STATIC_IPV4_BLACKHOLE)
2432 {
2433 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2434 vty_out (vty, " %s", "reject");
2435
2436 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2437 vty_out (vty, " %s", "blackhole");
2438 }
2439
2440 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2441 vty_out (vty, " %d", si->distance);
2442
2443 if (si->vrf_id != VRF_DEFAULT)
2444 vty_out (vty, " vrf %u", si->vrf_id);
2445
2446 vty_out (vty, "%s", VTY_NEWLINE);
2447
2448 write = 1;
paul7021c422003-07-15 12:52:22 +00002449 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002450 }
paul718e3742002-12-13 20:15:29 +00002451 return write;
2452}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002453
2454DEFUN (show_ip_protocol,
2455 show_ip_protocol_cmd,
2456 "show ip protocol",
2457 SHOW_STR
2458 IP_STR
2459 "IP protocol filtering status\n")
2460{
2461 int i;
2462
2463 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2464 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2465 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2466 {
2467 if (proto_rm[AFI_IP][i])
2468 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2469 proto_rm[AFI_IP][i],
2470 VTY_NEWLINE);
2471 else
2472 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2473 }
2474 if (proto_rm[AFI_IP][i])
2475 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2476 VTY_NEWLINE);
2477 else
2478 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2479
2480 return CMD_SUCCESS;
2481}
2482
paul718e3742002-12-13 20:15:29 +00002483#ifdef HAVE_IPV6
2484/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002485static int
hasso39db97e2004-10-12 20:50:58 +00002486static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2487 const char *gate_str, const char *ifname,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002488 const char *flag_str, const char *distance_str,
2489 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002490{
2491 int ret;
2492 u_char distance;
2493 struct prefix p;
2494 struct in6_addr *gate = NULL;
2495 struct in6_addr gate_addr;
2496 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002497 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002498 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00002499
2500 ret = str2prefix (dest_str, &p);
2501 if (ret <= 0)
2502 {
2503 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2504 return CMD_WARNING;
2505 }
2506
2507 /* Apply mask for given prefix. */
2508 apply_mask (&p);
2509
hasso81dfcaa2003-05-25 19:21:25 +00002510 /* Route flags */
2511 if (flag_str) {
2512 switch(flag_str[0]) {
2513 case 'r':
2514 case 'R': /* XXX */
2515 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2516 break;
2517 case 'b':
2518 case 'B': /* XXX */
2519 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2520 break;
2521 default:
2522 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002523 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002524 }
2525 }
2526
paul718e3742002-12-13 20:15:29 +00002527 /* Administrative distance. */
2528 if (distance_str)
2529 distance = atoi (distance_str);
2530 else
2531 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2532
2533 /* When gateway is valid IPv6 addrees, then gate is treated as
2534 nexthop address other case gate is treated as interface name. */
2535 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2536
2537 if (ifname)
2538 {
2539 /* When ifname is specified. It must be come with gateway
2540 address. */
2541 if (ret != 1)
2542 {
2543 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2544 return CMD_WARNING;
2545 }
2546 type = STATIC_IPV6_GATEWAY_IFNAME;
2547 gate = &gate_addr;
2548 }
2549 else
2550 {
2551 if (ret == 1)
2552 {
2553 type = STATIC_IPV6_GATEWAY;
2554 gate = &gate_addr;
2555 }
2556 else
2557 {
2558 type = STATIC_IPV6_IFNAME;
2559 ifname = gate_str;
2560 }
2561 }
2562
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002563 /* VRF id */
2564 if (vrf_id_str)
2565 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2566
paul718e3742002-12-13 20:15:29 +00002567 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002568 static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002569 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002570 static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002571
2572 return CMD_SUCCESS;
2573}
2574
2575DEFUN (ipv6_route,
2576 ipv6_route_cmd,
2577 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2578 IP_STR
2579 "Establish static routes\n"
2580 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2581 "IPv6 gateway address\n"
2582 "IPv6 gateway interface name\n")
2583{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002584 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2585 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002586}
2587
2588DEFUN (ipv6_route_flags,
2589 ipv6_route_flags_cmd,
2590 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2591 IP_STR
2592 "Establish static routes\n"
2593 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2594 "IPv6 gateway address\n"
2595 "IPv6 gateway interface name\n"
2596 "Emit an ICMP unreachable when matched\n"
2597 "Silently discard pkts when matched\n")
2598{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002599 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2600 NULL);
paul718e3742002-12-13 20:15:29 +00002601}
2602
2603DEFUN (ipv6_route_ifname,
2604 ipv6_route_ifname_cmd,
2605 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2606 IP_STR
2607 "Establish static routes\n"
2608 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2609 "IPv6 gateway address\n"
2610 "IPv6 gateway interface name\n")
2611{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002612 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2613 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002614}
2615
2616DEFUN (ipv6_route_ifname_flags,
2617 ipv6_route_ifname_flags_cmd,
2618 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2619 IP_STR
2620 "Establish static routes\n"
2621 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2622 "IPv6 gateway address\n"
2623 "IPv6 gateway interface name\n"
2624 "Emit an ICMP unreachable when matched\n"
2625 "Silently discard pkts when matched\n")
2626{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002627 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2628 NULL);
paul718e3742002-12-13 20:15:29 +00002629}
2630
2631DEFUN (ipv6_route_pref,
2632 ipv6_route_pref_cmd,
2633 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2634 IP_STR
2635 "Establish static routes\n"
2636 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2637 "IPv6 gateway address\n"
2638 "IPv6 gateway interface name\n"
2639 "Distance value for this prefix\n")
2640{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002641 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2642 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002643}
2644
2645DEFUN (ipv6_route_flags_pref,
2646 ipv6_route_flags_pref_cmd,
2647 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2648 IP_STR
2649 "Establish static routes\n"
2650 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2651 "IPv6 gateway address\n"
2652 "IPv6 gateway interface name\n"
2653 "Emit an ICMP unreachable when matched\n"
2654 "Silently discard pkts when matched\n"
2655 "Distance value for this prefix\n")
2656{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002657 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2658 NULL);
paul718e3742002-12-13 20:15:29 +00002659}
2660
2661DEFUN (ipv6_route_ifname_pref,
2662 ipv6_route_ifname_pref_cmd,
2663 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2664 IP_STR
2665 "Establish static routes\n"
2666 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2667 "IPv6 gateway address\n"
2668 "IPv6 gateway interface name\n"
2669 "Distance value for this prefix\n")
2670{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002671 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2672 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002673}
2674
2675DEFUN (ipv6_route_ifname_flags_pref,
2676 ipv6_route_ifname_flags_pref_cmd,
2677 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2678 IP_STR
2679 "Establish static routes\n"
2680 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2681 "IPv6 gateway address\n"
2682 "IPv6 gateway interface name\n"
2683 "Emit an ICMP unreachable when matched\n"
2684 "Silently discard pkts when matched\n"
2685 "Distance value for this prefix\n")
2686{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002687 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2688 NULL);
paul718e3742002-12-13 20:15:29 +00002689}
2690
2691DEFUN (no_ipv6_route,
2692 no_ipv6_route_cmd,
2693 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2694 NO_STR
2695 IP_STR
2696 "Establish static routes\n"
2697 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2698 "IPv6 gateway address\n"
2699 "IPv6 gateway interface name\n")
2700{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002701 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2702 NULL);
paul718e3742002-12-13 20:15:29 +00002703}
2704
hasso81dfcaa2003-05-25 19:21:25 +00002705ALIAS (no_ipv6_route,
2706 no_ipv6_route_flags_cmd,
2707 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2708 NO_STR
2709 IP_STR
2710 "Establish static routes\n"
2711 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2712 "IPv6 gateway address\n"
2713 "IPv6 gateway interface name\n"
2714 "Emit an ICMP unreachable when matched\n"
2715 "Silently discard pkts when matched\n")
2716
paul718e3742002-12-13 20:15:29 +00002717DEFUN (no_ipv6_route_ifname,
2718 no_ipv6_route_ifname_cmd,
2719 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2720 NO_STR
2721 IP_STR
2722 "Establish static routes\n"
2723 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2724 "IPv6 gateway address\n"
2725 "IPv6 gateway interface name\n")
2726{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002727 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2728 NULL);
paul718e3742002-12-13 20:15:29 +00002729}
2730
hasso81dfcaa2003-05-25 19:21:25 +00002731ALIAS (no_ipv6_route_ifname,
2732 no_ipv6_route_ifname_flags_cmd,
2733 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2734 NO_STR
2735 IP_STR
2736 "Establish static routes\n"
2737 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2738 "IPv6 gateway address\n"
2739 "IPv6 gateway interface name\n"
2740 "Emit an ICMP unreachable when matched\n"
2741 "Silently discard pkts when matched\n")
2742
paul718e3742002-12-13 20:15:29 +00002743DEFUN (no_ipv6_route_pref,
2744 no_ipv6_route_pref_cmd,
2745 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2746 NO_STR
2747 IP_STR
2748 "Establish static routes\n"
2749 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2750 "IPv6 gateway address\n"
2751 "IPv6 gateway interface name\n"
2752 "Distance value for this prefix\n")
2753{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002754 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
2755 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002756}
2757
2758DEFUN (no_ipv6_route_flags_pref,
2759 no_ipv6_route_flags_pref_cmd,
2760 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2761 NO_STR
2762 IP_STR
2763 "Establish static routes\n"
2764 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2765 "IPv6 gateway address\n"
2766 "IPv6 gateway interface name\n"
2767 "Emit an ICMP unreachable when matched\n"
2768 "Silently discard pkts when matched\n"
2769 "Distance value for this prefix\n")
2770{
2771 /* We do not care about argv[2] */
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002772 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
2773 NULL);
paul718e3742002-12-13 20:15:29 +00002774}
2775
2776DEFUN (no_ipv6_route_ifname_pref,
2777 no_ipv6_route_ifname_pref_cmd,
2778 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2779 NO_STR
2780 IP_STR
2781 "Establish static routes\n"
2782 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2783 "IPv6 gateway address\n"
2784 "IPv6 gateway interface name\n"
2785 "Distance value for this prefix\n")
2786{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002787 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
2788 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002789}
2790
2791DEFUN (no_ipv6_route_ifname_flags_pref,
2792 no_ipv6_route_ifname_flags_pref_cmd,
2793 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2794 NO_STR
2795 IP_STR
2796 "Establish static routes\n"
2797 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2798 "IPv6 gateway address\n"
2799 "IPv6 gateway interface name\n"
2800 "Emit an ICMP unreachable when matched\n"
2801 "Silently discard pkts when matched\n"
2802 "Distance value for this prefix\n")
2803{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002804 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
2805 NULL);
2806}
2807
2808DEFUN (ipv6_route_vrf,
2809 ipv6_route_vrf_cmd,
2810 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2811 IP_STR
2812 "Establish static routes\n"
2813 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2814 "IPv6 gateway address\n"
2815 "IPv6 gateway interface name\n"
2816 VRF_CMD_HELP_STR)
2817{
2818 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2819 argv[2]);
2820}
2821
2822DEFUN (ipv6_route_flags_vrf,
2823 ipv6_route_flags_vrf_cmd,
2824 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2825 IP_STR
2826 "Establish static routes\n"
2827 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2828 "IPv6 gateway address\n"
2829 "IPv6 gateway interface name\n"
2830 "Emit an ICMP unreachable when matched\n"
2831 "Silently discard pkts when matched\n"
2832 VRF_CMD_HELP_STR)
2833{
2834 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2835 argv[3]);
2836}
2837
2838DEFUN (ipv6_route_ifname_vrf,
2839 ipv6_route_ifname_vrf_cmd,
2840 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2841 IP_STR
2842 "Establish static routes\n"
2843 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2844 "IPv6 gateway address\n"
2845 "IPv6 gateway interface name\n"
2846 VRF_CMD_HELP_STR)
2847{
2848 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2849 argv[3]);
2850}
2851
2852DEFUN (ipv6_route_ifname_flags_vrf,
2853 ipv6_route_ifname_flags_vrf_cmd,
2854 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2855 IP_STR
2856 "Establish static routes\n"
2857 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2858 "IPv6 gateway address\n"
2859 "IPv6 gateway interface name\n"
2860 "Emit an ICMP unreachable when matched\n"
2861 "Silently discard pkts when matched\n"
2862 VRF_CMD_HELP_STR)
2863{
2864 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2865 argv[4]);
2866}
2867
2868DEFUN (ipv6_route_pref_vrf,
2869 ipv6_route_pref_vrf_cmd,
2870 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2871 IP_STR
2872 "Establish static routes\n"
2873 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2874 "IPv6 gateway address\n"
2875 "IPv6 gateway interface name\n"
2876 "Distance value for this prefix\n"
2877 VRF_CMD_HELP_STR)
2878{
2879 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2880 argv[3]);
2881}
2882
2883DEFUN (ipv6_route_flags_pref_vrf,
2884 ipv6_route_flags_pref_vrf_cmd,
2885 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2886 IP_STR
2887 "Establish static routes\n"
2888 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2889 "IPv6 gateway address\n"
2890 "IPv6 gateway interface name\n"
2891 "Emit an ICMP unreachable when matched\n"
2892 "Silently discard pkts when matched\n"
2893 "Distance value for this prefix\n"
2894 VRF_CMD_HELP_STR)
2895{
2896 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2897 argv[4]);
2898}
2899
2900DEFUN (ipv6_route_ifname_pref_vrf,
2901 ipv6_route_ifname_pref_vrf_cmd,
2902 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2903 IP_STR
2904 "Establish static routes\n"
2905 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2906 "IPv6 gateway address\n"
2907 "IPv6 gateway interface name\n"
2908 "Distance value for this prefix\n"
2909 VRF_CMD_HELP_STR)
2910{
2911 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2912 argv[4]);
2913}
2914
2915DEFUN (ipv6_route_ifname_flags_pref_vrf,
2916 ipv6_route_ifname_flags_pref_vrf_cmd,
2917 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
2918 IP_STR
2919 "Establish static routes\n"
2920 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2921 "IPv6 gateway address\n"
2922 "IPv6 gateway interface name\n"
2923 "Emit an ICMP unreachable when matched\n"
2924 "Silently discard pkts when matched\n"
2925 "Distance value for this prefix\n"
2926 VRF_CMD_HELP_STR)
2927{
2928 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2929 argv[5]);
2930}
2931
2932DEFUN (no_ipv6_route_vrf,
2933 no_ipv6_route_vrf_cmd,
2934 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2935 NO_STR
2936 IP_STR
2937 "Establish static routes\n"
2938 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2939 "IPv6 gateway address\n"
2940 "IPv6 gateway interface name\n"
2941 VRF_CMD_HELP_STR)
2942{
2943 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2944 (argc > 3) ? argv[3] : argv[2]);
2945}
2946
2947ALIAS (no_ipv6_route_vrf,
2948 no_ipv6_route_flags_vrf_cmd,
2949 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2950 NO_STR
2951 IP_STR
2952 "Establish static routes\n"
2953 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2954 "IPv6 gateway address\n"
2955 "IPv6 gateway interface name\n"
2956 "Emit an ICMP unreachable when matched\n"
2957 "Silently discard pkts when matched\n"
2958 VRF_CMD_HELP_STR)
2959
2960DEFUN (no_ipv6_route_ifname_vrf,
2961 no_ipv6_route_ifname_vrf_cmd,
2962 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2963 NO_STR
2964 IP_STR
2965 "Establish static routes\n"
2966 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2967 "IPv6 gateway address\n"
2968 "IPv6 gateway interface name\n"
2969 VRF_CMD_HELP_STR)
2970{
2971 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2972 (argc > 4) ? argv[4] : argv[3]);
2973}
2974
2975ALIAS (no_ipv6_route_ifname_vrf,
2976 no_ipv6_route_ifname_flags_vrf_cmd,
2977 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2978 NO_STR
2979 IP_STR
2980 "Establish static routes\n"
2981 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2982 "IPv6 gateway address\n"
2983 "IPv6 gateway interface name\n"
2984 "Emit an ICMP unreachable when matched\n"
2985 "Silently discard pkts when matched\n"
2986 VRF_CMD_HELP_STR)
2987
2988DEFUN (no_ipv6_route_pref_vrf,
2989 no_ipv6_route_pref_vrf_cmd,
2990 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2991 NO_STR
2992 IP_STR
2993 "Establish static routes\n"
2994 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2995 "IPv6 gateway address\n"
2996 "IPv6 gateway interface name\n"
2997 "Distance value for this prefix\n"
2998 VRF_CMD_HELP_STR)
2999{
3000 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
3001 argv[3]);
3002}
3003
3004DEFUN (no_ipv6_route_flags_pref_vrf,
3005 no_ipv6_route_flags_pref_vrf_cmd,
3006 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3007 NO_STR
3008 IP_STR
3009 "Establish static routes\n"
3010 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3011 "IPv6 gateway address\n"
3012 "IPv6 gateway interface name\n"
3013 "Emit an ICMP unreachable when matched\n"
3014 "Silently discard pkts when matched\n"
3015 "Distance value for this prefix\n"
3016 VRF_CMD_HELP_STR)
3017{
3018 /* We do not care about argv[2] */
3019 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
3020 argv[4]);
3021}
3022
3023DEFUN (no_ipv6_route_ifname_pref_vrf,
3024 no_ipv6_route_ifname_pref_vrf_cmd,
3025 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3026 NO_STR
3027 IP_STR
3028 "Establish static routes\n"
3029 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3030 "IPv6 gateway address\n"
3031 "IPv6 gateway interface name\n"
3032 "Distance value for this prefix\n"
3033 VRF_CMD_HELP_STR)
3034{
3035 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
3036 argv[4]);
3037}
3038
3039DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3040 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3041 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3042 NO_STR
3043 IP_STR
3044 "Establish static routes\n"
3045 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3046 "IPv6 gateway address\n"
3047 "IPv6 gateway interface name\n"
3048 "Emit an ICMP unreachable when matched\n"
3049 "Silently discard pkts when matched\n"
3050 "Distance value for this prefix\n"
3051 VRF_CMD_HELP_STR)
3052{
3053 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
3054 argv[5]);
paul718e3742002-12-13 20:15:29 +00003055}
3056
paul718e3742002-12-13 20:15:29 +00003057DEFUN (show_ipv6_route,
3058 show_ipv6_route_cmd,
3059 "show ipv6 route",
3060 SHOW_STR
3061 IP_STR
3062 "IPv6 routing table\n")
3063{
3064 struct route_table *table;
3065 struct route_node *rn;
3066 struct rib *rib;
3067 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003068 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003069
Feng Lu4364ee52015-05-22 11:40:03 +02003070 if (argc > 0)
3071 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3072
3073 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003074 if (! table)
3075 return CMD_SUCCESS;
3076
3077 /* Show all IPv6 route. */
3078 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003079 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003080 {
3081 if (first)
3082 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003083 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003084 first = 0;
3085 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003086 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003087 }
3088 return CMD_SUCCESS;
3089}
3090
Feng Lu4364ee52015-05-22 11:40:03 +02003091ALIAS (show_ipv6_route,
3092 show_ipv6_route_vrf_cmd,
3093 "show ipv6 route " VRF_CMD_STR,
3094 SHOW_STR
3095 IP_STR
3096 "IPv6 routing table\n"
3097 VRF_CMD_HELP_STR)
3098
paul718e3742002-12-13 20:15:29 +00003099DEFUN (show_ipv6_route_prefix_longer,
3100 show_ipv6_route_prefix_longer_cmd,
3101 "show ipv6 route X:X::X:X/M longer-prefixes",
3102 SHOW_STR
3103 IP_STR
3104 "IPv6 routing table\n"
3105 "IPv6 prefix\n"
3106 "Show route matching the specified Network/Mask pair only\n")
3107{
3108 struct route_table *table;
3109 struct route_node *rn;
3110 struct rib *rib;
3111 struct prefix p;
3112 int ret;
3113 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003114 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003115
3116 ret = str2prefix (argv[0], &p);
3117 if (! ret)
3118 {
3119 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3120 return CMD_WARNING;
3121 }
3122
Feng Lu4364ee52015-05-22 11:40:03 +02003123 if (argc > 1)
3124 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3125
3126 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3127 if (! table)
3128 return CMD_SUCCESS;
3129
paul718e3742002-12-13 20:15:29 +00003130 /* Show matched type IPv6 routes. */
3131 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003132 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003133 if (prefix_match (&p, &rn->p))
3134 {
3135 if (first)
3136 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003137 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003138 first = 0;
3139 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003140 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003141 }
3142 return CMD_SUCCESS;
3143}
3144
Feng Lu4364ee52015-05-22 11:40:03 +02003145ALIAS (show_ipv6_route_prefix_longer,
3146 show_ipv6_route_prefix_longer_vrf_cmd,
3147 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3148 SHOW_STR
3149 IP_STR
3150 "IPv6 routing table\n"
3151 "IPv6 prefix\n"
3152 "Show route matching the specified Network/Mask pair only\n"
3153 VRF_CMD_HELP_STR)
3154
paul718e3742002-12-13 20:15:29 +00003155DEFUN (show_ipv6_route_protocol,
3156 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003157 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003158 SHOW_STR
3159 IP_STR
3160 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003161 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003162{
3163 int type;
3164 struct route_table *table;
3165 struct route_node *rn;
3166 struct rib *rib;
3167 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003168 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003169
David Lampartere0ca5fd2009-09-16 01:52:42 +02003170 type = proto_redistnum (AFI_IP6, argv[0]);
3171 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003172 {
3173 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3174 return CMD_WARNING;
3175 }
Feng Lu4364ee52015-05-22 11:40:03 +02003176
3177 if (argc > 1)
3178 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3179
3180 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003181 if (! table)
3182 return CMD_SUCCESS;
3183
3184 /* Show matched type IPv6 routes. */
3185 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003186 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003187 if (rib->type == type)
3188 {
3189 if (first)
3190 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003191 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003192 first = 0;
3193 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003194 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003195 }
3196 return CMD_SUCCESS;
3197}
3198
Feng Lu4364ee52015-05-22 11:40:03 +02003199ALIAS (show_ipv6_route_protocol,
3200 show_ipv6_route_protocol_vrf_cmd,
3201 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3202 SHOW_STR
3203 IP_STR
3204 "IP routing table\n"
3205 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3206 VRF_CMD_HELP_STR)
3207
paul718e3742002-12-13 20:15:29 +00003208DEFUN (show_ipv6_route_addr,
3209 show_ipv6_route_addr_cmd,
3210 "show ipv6 route X:X::X:X",
3211 SHOW_STR
3212 IP_STR
3213 "IPv6 routing table\n"
3214 "IPv6 Address\n")
3215{
3216 int ret;
3217 struct prefix_ipv6 p;
3218 struct route_table *table;
3219 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003220 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003221
3222 ret = str2prefix_ipv6 (argv[0], &p);
3223 if (ret <= 0)
3224 {
3225 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3226 return CMD_WARNING;
3227 }
3228
Feng Lu4364ee52015-05-22 11:40:03 +02003229 if (argc > 1)
3230 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3231
3232 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003233 if (! table)
3234 return CMD_SUCCESS;
3235
3236 rn = route_node_match (table, (struct prefix *) &p);
3237 if (! rn)
3238 {
3239 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3240 return CMD_WARNING;
3241 }
3242
Timo Teräs53a5c392015-05-23 11:08:40 +03003243 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003244
3245 route_unlock_node (rn);
3246
3247 return CMD_SUCCESS;
3248}
3249
Feng Lu4364ee52015-05-22 11:40:03 +02003250ALIAS (show_ipv6_route_addr,
3251 show_ipv6_route_addr_vrf_cmd,
3252 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3253 SHOW_STR
3254 IP_STR
3255 "IPv6 routing table\n"
3256 "IPv6 Address\n"
3257 VRF_CMD_HELP_STR)
3258
paul718e3742002-12-13 20:15:29 +00003259DEFUN (show_ipv6_route_prefix,
3260 show_ipv6_route_prefix_cmd,
3261 "show ipv6 route X:X::X:X/M",
3262 SHOW_STR
3263 IP_STR
3264 "IPv6 routing table\n"
3265 "IPv6 prefix\n")
3266{
3267 int ret;
3268 struct prefix_ipv6 p;
3269 struct route_table *table;
3270 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003271 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003272
3273 ret = str2prefix_ipv6 (argv[0], &p);
3274 if (ret <= 0)
3275 {
3276 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3277 return CMD_WARNING;
3278 }
3279
Feng Lu4364ee52015-05-22 11:40:03 +02003280 if (argc > 1)
3281 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3282
3283 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003284 if (! table)
3285 return CMD_SUCCESS;
3286
3287 rn = route_node_match (table, (struct prefix *) &p);
3288 if (! rn || rn->p.prefixlen != p.prefixlen)
3289 {
3290 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003291 if (rn)
3292 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003293 return CMD_WARNING;
3294 }
3295
Timo Teräs53a5c392015-05-23 11:08:40 +03003296 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003297
3298 route_unlock_node (rn);
3299
3300 return CMD_SUCCESS;
3301}
3302
Feng Lu4364ee52015-05-22 11:40:03 +02003303ALIAS (show_ipv6_route_prefix,
3304 show_ipv6_route_prefix_vrf_cmd,
3305 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3306 SHOW_STR
3307 IP_STR
3308 "IPv6 routing table\n"
3309 "IPv6 prefix\n"
3310 VRF_CMD_HELP_STR)
3311
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003312/* Show route summary. */
3313DEFUN (show_ipv6_route_summary,
3314 show_ipv6_route_summary_cmd,
3315 "show ipv6 route summary",
3316 SHOW_STR
3317 IP_STR
3318 "IPv6 routing table\n"
3319 "Summary of all IPv6 routes\n")
3320{
3321 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003322 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003323
Feng Lu4364ee52015-05-22 11:40:03 +02003324 if (argc > 0)
3325 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3326
3327 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003328 if (! table)
3329 return CMD_SUCCESS;
3330
3331 vty_show_ip_route_summary (vty, table);
3332
3333 return CMD_SUCCESS;
3334}
3335
Feng Lu4364ee52015-05-22 11:40:03 +02003336ALIAS (show_ipv6_route_summary,
3337 show_ipv6_route_summary_vrf_cmd,
3338 "show ipv6 route summary " VRF_CMD_STR,
3339 SHOW_STR
3340 IP_STR
3341 "IPv6 routing table\n"
3342 "Summary of all IPv6 routes\n"
3343 VRF_CMD_HELP_STR)
3344
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003345/* Show ipv6 route summary prefix. */
3346DEFUN (show_ipv6_route_summary_prefix,
3347 show_ipv6_route_summary_prefix_cmd,
3348 "show ipv6 route summary prefix",
3349 SHOW_STR
3350 IP_STR
3351 "IPv6 routing table\n"
3352 "Summary of all IPv6 routes\n"
3353 "Prefix routes\n")
3354{
3355 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003356 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003357
Feng Lu4364ee52015-05-22 11:40:03 +02003358 if (argc > 0)
3359 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3360
3361 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003362 if (! table)
3363 return CMD_SUCCESS;
3364
3365 vty_show_ip_route_summary_prefix (vty, table);
3366
3367 return CMD_SUCCESS;
3368}
3369
Feng Lu4364ee52015-05-22 11:40:03 +02003370ALIAS (show_ipv6_route_summary_prefix,
3371 show_ipv6_route_summary_prefix_vrf_cmd,
3372 "show ipv6 route summary prefix " VRF_CMD_STR,
3373 SHOW_STR
3374 IP_STR
3375 "IPv6 routing table\n"
3376 "Summary of all IPv6 routes\n"
3377 "Prefix routes\n"
3378 VRF_CMD_HELP_STR)
3379
G.Balajicddf3912011-11-26 21:59:32 +04003380/*
G.Balajicddf3912011-11-26 21:59:32 +04003381 * Show IPv6 mroute command.Used to dump
3382 * the Multicast routing table.
3383 */
3384
3385DEFUN (show_ipv6_mroute,
3386 show_ipv6_mroute_cmd,
3387 "show ipv6 mroute",
3388 SHOW_STR
3389 IP_STR
3390 "IPv6 Multicast routing table\n")
3391{
3392 struct route_table *table;
3393 struct route_node *rn;
3394 struct rib *rib;
3395 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003396 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003397
Feng Lu4364ee52015-05-22 11:40:03 +02003398 if (argc > 0)
3399 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3400
3401 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003402 if (! table)
3403 return CMD_SUCCESS;
3404
3405 /* Show all IPv6 route. */
3406 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003407 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003408 {
3409 if (first)
3410 {
G.Balajicb32fd62011-11-27 20:09:40 +05303411 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003412 first = 0;
3413 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003414 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003415 }
3416 return CMD_SUCCESS;
3417}
3418
Feng Lu4364ee52015-05-22 11:40:03 +02003419ALIAS (show_ipv6_mroute,
3420 show_ipv6_mroute_vrf_cmd,
3421 "show ipv6 mroute " VRF_CMD_STR,
3422 SHOW_STR
3423 IP_STR
3424 "IPv6 Multicast routing table\n"
3425 VRF_CMD_HELP_STR)
3426
3427DEFUN (show_ipv6_route_vrf_all,
3428 show_ipv6_route_vrf_all_cmd,
3429 "show ipv6 route " VRF_ALL_CMD_STR,
3430 SHOW_STR
3431 IP_STR
3432 "IPv6 routing table\n"
3433 VRF_ALL_CMD_HELP_STR)
3434{
3435 struct route_table *table;
3436 struct route_node *rn;
3437 struct rib *rib;
3438 struct zebra_vrf *zvrf;
3439 vrf_iter_t iter;
3440 int first = 1;
3441
3442 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3443 {
3444 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3445 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3446 continue;
3447
3448 /* Show all IPv6 route. */
3449 for (rn = route_top (table); rn; rn = route_next (rn))
3450 RNODE_FOREACH_RIB (rn, rib)
3451 {
3452 if (first)
3453 {
3454 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3455 first = 0;
3456 }
3457 vty_show_ip_route (vty, rn, rib);
3458 }
3459 }
3460
3461 return CMD_SUCCESS;
3462}
3463
3464DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3465 show_ipv6_route_prefix_longer_vrf_all_cmd,
3466 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3467 SHOW_STR
3468 IP_STR
3469 "IPv6 routing table\n"
3470 "IPv6 prefix\n"
3471 "Show route matching the specified Network/Mask pair only\n"
3472 VRF_ALL_CMD_HELP_STR)
3473{
3474 struct route_table *table;
3475 struct route_node *rn;
3476 struct rib *rib;
3477 struct prefix p;
3478 struct zebra_vrf *zvrf;
3479 vrf_iter_t iter;
3480 int ret;
3481 int first = 1;
3482
3483 ret = str2prefix (argv[0], &p);
3484 if (! ret)
3485 {
3486 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3487 return CMD_WARNING;
3488 }
3489
3490 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3491 {
3492 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3493 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3494 continue;
3495
3496 /* Show matched type IPv6 routes. */
3497 for (rn = route_top (table); rn; rn = route_next (rn))
3498 RNODE_FOREACH_RIB (rn, rib)
3499 if (prefix_match (&p, &rn->p))
3500 {
3501 if (first)
3502 {
3503 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3504 first = 0;
3505 }
3506 vty_show_ip_route (vty, rn, rib);
3507 }
3508 }
3509
3510 return CMD_SUCCESS;
3511}
3512
3513DEFUN (show_ipv6_route_protocol_vrf_all,
3514 show_ipv6_route_protocol_vrf_all_cmd,
3515 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3516 SHOW_STR
3517 IP_STR
3518 "IP routing table\n"
3519 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3520 VRF_ALL_CMD_HELP_STR)
3521{
3522 int type;
3523 struct route_table *table;
3524 struct route_node *rn;
3525 struct rib *rib;
3526 struct zebra_vrf *zvrf;
3527 vrf_iter_t iter;
3528 int first = 1;
3529
3530 type = proto_redistnum (AFI_IP6, argv[0]);
3531 if (type < 0)
3532 {
3533 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3534 return CMD_WARNING;
3535 }
3536
3537 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3538 {
3539 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3540 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3541 continue;
3542
3543 /* Show matched type IPv6 routes. */
3544 for (rn = route_top (table); rn; rn = route_next (rn))
3545 RNODE_FOREACH_RIB (rn, rib)
3546 if (rib->type == type)
3547 {
3548 if (first)
3549 {
3550 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3551 first = 0;
3552 }
3553 vty_show_ip_route (vty, rn, rib);
3554 }
3555 }
3556
3557 return CMD_SUCCESS;
3558}
3559
3560DEFUN (show_ipv6_route_addr_vrf_all,
3561 show_ipv6_route_addr_vrf_all_cmd,
3562 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3563 SHOW_STR
3564 IP_STR
3565 "IPv6 routing table\n"
3566 "IPv6 Address\n"
3567 VRF_ALL_CMD_HELP_STR)
3568{
3569 int ret;
3570 struct prefix_ipv6 p;
3571 struct route_table *table;
3572 struct route_node *rn;
3573 struct zebra_vrf *zvrf;
3574 vrf_iter_t iter;
3575
3576 ret = str2prefix_ipv6 (argv[0], &p);
3577 if (ret <= 0)
3578 {
3579 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3580 return CMD_WARNING;
3581 }
3582
3583 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3584 {
3585 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3586 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3587 continue;
3588
3589 rn = route_node_match (table, (struct prefix *) &p);
3590 if (! rn)
3591 continue;
3592
3593 vty_show_ip_route_detail (vty, rn, 0);
3594
3595 route_unlock_node (rn);
3596 }
3597
3598 return CMD_SUCCESS;
3599}
3600
3601DEFUN (show_ipv6_route_prefix_vrf_all,
3602 show_ipv6_route_prefix_vrf_all_cmd,
3603 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3604 SHOW_STR
3605 IP_STR
3606 "IPv6 routing table\n"
3607 "IPv6 prefix\n"
3608 VRF_ALL_CMD_HELP_STR)
3609{
3610 int ret;
3611 struct prefix_ipv6 p;
3612 struct route_table *table;
3613 struct route_node *rn;
3614 struct zebra_vrf *zvrf;
3615 vrf_iter_t iter;
3616
3617 ret = str2prefix_ipv6 (argv[0], &p);
3618 if (ret <= 0)
3619 {
3620 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3621 return CMD_WARNING;
3622 }
3623
3624 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3625 {
3626 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3627 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3628 continue;
3629
3630 rn = route_node_match (table, (struct prefix *) &p);
3631 if (! rn)
3632 continue;
3633 if (rn->p.prefixlen != p.prefixlen)
3634 {
3635 route_unlock_node (rn);
3636 continue;
3637 }
3638
3639 vty_show_ip_route_detail (vty, rn, 0);
3640
3641 route_unlock_node (rn);
3642 }
3643
3644 return CMD_SUCCESS;
3645}
3646
3647/* Show route summary. */
3648DEFUN (show_ipv6_route_summary_vrf_all,
3649 show_ipv6_route_summary_vrf_all_cmd,
3650 "show ipv6 route summary " VRF_ALL_CMD_STR,
3651 SHOW_STR
3652 IP_STR
3653 "IPv6 routing table\n"
3654 "Summary of all IPv6 routes\n"
3655 VRF_ALL_CMD_HELP_STR)
3656{
3657 struct zebra_vrf *zvrf;
3658 vrf_iter_t iter;
3659
3660 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3661 if ((zvrf = vrf_iter2info (iter)) != NULL)
3662 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3663
3664 return CMD_SUCCESS;
3665}
3666
3667DEFUN (show_ipv6_mroute_vrf_all,
3668 show_ipv6_mroute_vrf_all_cmd,
3669 "show ipv6 mroute " VRF_ALL_CMD_STR,
3670 SHOW_STR
3671 IP_STR
3672 "IPv6 Multicast routing table\n"
3673 VRF_ALL_CMD_HELP_STR)
3674{
3675 struct route_table *table;
3676 struct route_node *rn;
3677 struct rib *rib;
3678 struct zebra_vrf *zvrf;
3679 vrf_iter_t iter;
3680 int first = 1;
3681
3682 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3683 {
3684 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3685 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3686 continue;
3687
3688 /* Show all IPv6 route. */
3689 for (rn = route_top (table); rn; rn = route_next (rn))
3690 RNODE_FOREACH_RIB (rn, rib)
3691 {
3692 if (first)
3693 {
3694 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3695 first = 0;
3696 }
3697 vty_show_ip_route (vty, rn, rib);
3698 }
3699 }
3700 return CMD_SUCCESS;
3701}
3702
3703DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3704 show_ipv6_route_summary_prefix_vrf_all_cmd,
3705 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3706 SHOW_STR
3707 IP_STR
3708 "IPv6 routing table\n"
3709 "Summary of all IPv6 routes\n"
3710 "Prefix routes\n"
3711 VRF_ALL_CMD_HELP_STR)
3712{
3713 struct zebra_vrf *zvrf;
3714 vrf_iter_t iter;
3715
3716 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3717 if ((zvrf = vrf_iter2info (iter)) != NULL)
3718 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3719
3720 return CMD_SUCCESS;
3721}
3722
paul718e3742002-12-13 20:15:29 +00003723/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003724static int
paul718e3742002-12-13 20:15:29 +00003725static_config_ipv6 (struct vty *vty)
3726{
3727 struct route_node *rn;
3728 struct static_ipv6 *si;
3729 int write;
3730 char buf[BUFSIZ];
3731 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003732 struct zebra_vrf *zvrf;
3733 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003734
3735 write = 0;
3736
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003737 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3738 {
3739 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3740 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3741 continue;
paul718e3742002-12-13 20:15:29 +00003742
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003743 for (rn = route_top (stable); rn; rn = route_next (rn))
3744 for (si = rn->info; si; si = si->next)
3745 {
3746 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003747
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003748 switch (si->type)
3749 {
3750 case STATIC_IPV6_GATEWAY:
3751 vty_out (vty, " %s",
3752 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
3753 break;
3754 case STATIC_IPV6_IFNAME:
3755 vty_out (vty, " %s", si->ifname);
3756 break;
3757 case STATIC_IPV6_GATEWAY_IFNAME:
3758 vty_out (vty, " %s %s",
3759 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ),
3760 si->ifname);
3761 break;
3762 }
paul718e3742002-12-13 20:15:29 +00003763
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003764 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3765 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003766
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003767 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3768 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003769
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003770 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3771 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003772
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003773 if (si->vrf_id != VRF_DEFAULT)
3774 vty_out (vty, " vrf %u", si->vrf_id);
3775
3776 vty_out (vty, "%s", VTY_NEWLINE);
3777
3778 write = 1;
3779 }
3780 }
paul718e3742002-12-13 20:15:29 +00003781 return write;
3782}
3783#endif /* HAVE_IPV6 */
3784
3785/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003786static int
paul718e3742002-12-13 20:15:29 +00003787zebra_ip_config (struct vty *vty)
3788{
3789 int write = 0;
3790
Everton Marques33d86db2014-07-14 11:19:00 -03003791 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3792 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003793#ifdef HAVE_IPV6
3794 write += static_config_ipv6 (vty);
3795#endif /* HAVE_IPV6 */
3796
3797 return write;
3798}
3799
David Lamparterbd078122015-01-06 19:53:24 +01003800static int config_write_vty(struct vty *vty)
3801{
Paul Jakma7514fb72007-05-02 16:05:35 +00003802 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003803 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3804
3805 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3806 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3807 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3808 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3809 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3810 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3811 "longer-prefix",
3812 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003813
3814 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3815 {
3816 if (proto_rm[AFI_IP][i])
3817 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3818 proto_rm[AFI_IP][i], VTY_NEWLINE);
3819 }
3820 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3821 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3822 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3823
3824 return 1;
3825}
3826
3827/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003828static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003829
paul718e3742002-12-13 20:15:29 +00003830/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003831static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003832
3833/* Route VTY. */
3834void
paula1ac18c2005-06-28 17:17:12 +00003835zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003836{
3837 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003838 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003839
Everton Marques33d86db2014-07-14 11:19:00 -03003840 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003841 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003842 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003843 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003844 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3845 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3846 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003847 install_element (CONFIG_NODE, &ip_protocol_cmd);
3848 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3849 install_element (VIEW_NODE, &show_ip_protocol_cmd);
3850 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003851 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003852 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003853 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003854 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003855 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003856 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003857 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003858 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003859 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003860 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003861 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003862 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003863 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003864 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003865 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003866 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003867 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003868 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003869 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003870 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003871 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003872 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003873 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003874
3875 install_element (VIEW_NODE, &show_ip_route_cmd);
3876 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3877 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3878 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3879 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3880 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003881 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003882 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003883 install_element (ENABLE_NODE, &show_ip_route_cmd);
3884 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
3885 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
3886 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
3887 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
3888 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00003889 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003890 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003891
Everton Marques33d86db2014-07-14 11:19:00 -03003892 install_element (VIEW_NODE, &show_ip_rpf_cmd);
3893 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003894 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
3895 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003896
Feng Lu4364ee52015-05-22 11:40:03 +02003897 /* Commands for VRF */
3898
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003899 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3900 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3901 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3902 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3903
3904 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3905 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3906 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3907 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3908 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3909 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3910 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3911 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3912 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3913 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
3914 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
3915 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
3916 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
3917 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
3918 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
3919 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
3920 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
3921 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
3922 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
3923 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
3924 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
3925 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
3926 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
3927
Feng Lu4364ee52015-05-22 11:40:03 +02003928 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
3929 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
3930 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
3931 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3932 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
3933 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
3934 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
3935 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3936 install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
3937 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd);
3938 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd);
3939 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3940 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd);
3941 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd);
3942 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd);
3943 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3944
3945 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
3946 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
3947 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
3948 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3949 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
3950 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
3951 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
3952 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3953 install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
3954 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd);
3955 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd);
3956 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3957 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd);
3958 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd);
3959 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd);
3960 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3961
Feng Lu4364ee52015-05-22 11:40:03 +02003962 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
3963 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
3964 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
3965 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3966 install_element (ENABLE_NODE, &show_ip_rpf_vrf_cmd);
3967 install_element (ENABLE_NODE, &show_ip_rpf_vrf_all_cmd);
3968 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_cmd);
3969 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3970
paul718e3742002-12-13 20:15:29 +00003971#ifdef HAVE_IPV6
3972 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003973 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003974 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003975 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003976 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003977 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003978 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003979 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003980 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003981 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003982 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003983 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003984 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003985 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003986 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003987 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003988 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003989 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003990 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003991 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
3992 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
3993 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
3994 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
3995 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
3996 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
3997 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
3998 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
3999 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004000 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004001 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04004002
4003 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
4004 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004005
4006 /* Commands for VRF */
4007
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004008 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4009 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4010 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4011 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4012 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4013 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4014 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4015 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4016 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4017 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4018 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4019 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4020 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4021 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4022 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4023 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4024
Feng Lu4364ee52015-05-22 11:40:03 +02004025 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4026 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4027 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4028 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4029 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4030 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4031 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4032 install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
4033 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd);
4034 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd);
4035 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd);
4036 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4037 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd);
4038 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4039
4040 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4041 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4042 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4043 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4044 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4045 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4046 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4047 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
4048 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4049 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4050 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4051 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4052 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4053 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4054
4055 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
4056 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
4057
4058 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
4059 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004060#endif /* HAVE_IPV6 */
4061}