blob: 3973e4382cc4f64dbd4447edcaf70facb3b331af [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Zebra VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
Paul Jakma7514fb72007-05-02 16:05:35 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
Feng Lu41f44a22015-05-22 11:39:56 +020030#include "vrf.h"
paul718e3742002-12-13 20:15:29 +000031
paula1ac18c2005-06-28 17:17:12 +000032#include "zebra/zserv.h"
33
Feng Lu4364ee52015-05-22 11:40:03 +020034static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
David Lamparter3b02fe82015-01-22 19:12:35 +010035static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
36 int mcast);
Feng Lu4364ee52015-05-22 11:40:03 +020037static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
38 struct rib *rib);
Everton Marques33d86db2014-07-14 11:19:00 -030039
40/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000041static int
Everton Marques33d86db2014-07-14 11:19:00 -030042zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
43 const char *dest_str, const char *mask_str,
44 const char *gate_str, const char *flag_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +020045 const char *distance_str, const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +000046{
47 int ret;
48 u_char distance;
49 struct prefix p;
50 struct in_addr gate;
51 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000052 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000053 u_char flag = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +020054 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +000055
56 ret = str2prefix (dest_str, &p);
57 if (ret <= 0)
58 {
59 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
60 return CMD_WARNING;
61 }
62
63 /* Cisco like mask notation. */
64 if (mask_str)
65 {
66 ret = inet_aton (mask_str, &mask);
67 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000068 {
69 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
70 return CMD_WARNING;
71 }
paul718e3742002-12-13 20:15:29 +000072 p.prefixlen = ip_masklen (mask);
73 }
74
75 /* Apply mask for given prefix. */
76 apply_mask (&p);
77
paul595db7f2003-05-25 21:35:06 +000078 /* Administrative distance. */
79 if (distance_str)
80 distance = atoi (distance_str);
81 else
82 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
83
Feng Lu7aaf4ea2015-05-22 11:40:06 +020084 /* VRF id */
85 if (vrf_id_str)
86 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
87
paul595db7f2003-05-25 21:35:06 +000088 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000089 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000090 {
91 if (flag_str)
92 {
93 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
94 return CMD_WARNING;
95 }
96 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +020097 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +000098 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +020099 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000100 return CMD_SUCCESS;
101 }
102
hasso81dfcaa2003-05-25 19:21:25 +0000103 /* Route flags */
104 if (flag_str) {
105 switch(flag_str[0]) {
106 case 'r':
107 case 'R': /* XXX */
108 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
109 break;
110 case 'b':
111 case 'B': /* XXX */
112 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
113 break;
114 default:
115 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000116 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000117 }
118 }
119
hasso457ef552003-05-28 12:02:15 +0000120 if (gate_str == NULL)
121 {
122 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200123 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000124 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200125 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000126
127 return CMD_SUCCESS;
128 }
129
paul718e3742002-12-13 20:15:29 +0000130 /* When gateway is A.B.C.D format, gate is treated as nexthop
131 address other case gate is treated as interface name. */
132 ret = inet_aton (gate_str, &gate);
133 if (ret)
134 ifname = NULL;
135 else
136 ifname = gate_str;
137
138 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200139 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000140 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200141 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000142
143 return CMD_SUCCESS;
144}
145
Everton Marques33d86db2014-07-14 11:19:00 -0300146static int
147zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
148 const char *mask_str, const char *gate_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200149 const char *flag_str, const char *distance_str,
150 const char *vrf_id_str)
Everton Marques33d86db2014-07-14 11:19:00 -0300151{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200152 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str,
153 gate_str, flag_str, distance_str, vrf_id_str);
Everton Marques33d86db2014-07-14 11:19:00 -0300154}
155
156/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100157DEFUN (ip_mroute_dist,
158 ip_mroute_dist_cmd,
159 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300160 IP_STR
161 "Configure static unicast route into MRIB for multicast RPF lookup\n"
162 "IP destination prefix (e.g. 10.0.0.0/8)\n"
163 "Nexthop address\n"
164 "Nexthop interface name\n"
165 "Distance\n")
166{
David Lamparter863f20c2015-01-27 20:24:15 +0100167 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100168 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200169 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300170}
171
David Lampartera76681b2015-01-22 19:03:53 +0100172ALIAS (ip_mroute_dist,
173 ip_mroute_cmd,
174 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
175 IP_STR
176 "Configure static unicast route into MRIB for multicast RPF lookup\n"
177 "IP destination prefix (e.g. 10.0.0.0/8)\n"
178 "Nexthop address\n"
179 "Nexthop interface name\n")
180
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200181DEFUN (ip_mroute_dist_vrf,
182 ip_mroute_dist_vrf_cmd,
183 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
184 IP_STR
185 "Configure static unicast route into MRIB for multicast RPF lookup\n"
186 "IP destination prefix (e.g. 10.0.0.0/8)\n"
187 "Nexthop address\n"
188 "Nexthop interface name\n"
189 "Distance\n"
190 VRF_CMD_HELP_STR)
191{
192 VTY_WARN_EXPERIMENTAL();
193 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
194 NULL, argc > 3 ? argv[2] : NULL,
195 argc > 3 ? argv[3] : argv[2]);
196}
197
198ALIAS (ip_mroute_dist_vrf,
199 ip_mroute_vrf_cmd,
200 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
201 IP_STR
202 "Configure static unicast route into MRIB for multicast RPF lookup\n"
203 "IP destination prefix (e.g. 10.0.0.0/8)\n"
204 "Nexthop address\n"
205 "Nexthop interface name\n"
206 VRF_CMD_HELP_STR)
207
David Lampartera76681b2015-01-22 19:03:53 +0100208DEFUN (no_ip_mroute_dist,
209 no_ip_mroute_dist_cmd,
210 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300211 IP_STR
212 "Configure static unicast route into MRIB for multicast RPF lookup\n"
213 "IP destination prefix (e.g. 10.0.0.0/8)\n"
214 "Nexthop address\n"
215 "Nexthop interface name\n"
216 "Distance\n")
217{
David Lamparter863f20c2015-01-27 20:24:15 +0100218 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100219 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200220 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300221}
222
David Lampartera76681b2015-01-22 19:03:53 +0100223ALIAS (no_ip_mroute_dist,
224 no_ip_mroute_cmd,
225 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
226 NO_STR
227 IP_STR
228 "Configure static unicast route into MRIB for multicast RPF lookup\n"
229 "IP destination prefix (e.g. 10.0.0.0/8)\n"
230 "Nexthop address\n"
231 "Nexthop interface name\n")
232
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200233DEFUN (no_ip_mroute_dist_vrf,
234 no_ip_mroute_dist_vrf_cmd,
235 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
236 IP_STR
237 "Configure static unicast route into MRIB for multicast RPF lookup\n"
238 "IP destination prefix (e.g. 10.0.0.0/8)\n"
239 "Nexthop address\n"
240 "Nexthop interface name\n"
241 "Distance\n"
242 VRF_CMD_HELP_STR)
243{
244 VTY_WARN_EXPERIMENTAL();
245 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
246 NULL, argc > 3 ? argv[2] : NULL,
247 argc > 3 ? argv[3] : argv[2]);
248}
249
250ALIAS (no_ip_mroute_dist_vrf,
251 no_ip_mroute_vrf_cmd,
252 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
253 NO_STR
254 IP_STR
255 "Configure static unicast route into MRIB for multicast RPF lookup\n"
256 "IP destination prefix (e.g. 10.0.0.0/8)\n"
257 "Nexthop address\n"
258 "Nexthop interface name\n"
259 VRF_CMD_HELP_STR)
260
David Lamparterbd078122015-01-06 19:53:24 +0100261DEFUN (ip_multicast_mode,
262 ip_multicast_mode_cmd,
263 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
264 IP_STR
265 "Multicast options\n"
266 "RPF lookup behavior\n"
267 "Lookup in unicast RIB only\n"
268 "Lookup in multicast RIB only\n"
269 "Try multicast RIB first, fall back to unicast RIB\n"
270 "Lookup both, use entry with lower distance\n"
271 "Lookup both, use entry with longer prefix\n")
272{
David Lamparter863f20c2015-01-27 20:24:15 +0100273 VTY_WARN_EXPERIMENTAL();
274
David Lamparterbd078122015-01-06 19:53:24 +0100275 if (!strncmp (argv[0], "u", 1))
276 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
277 else if (!strncmp (argv[0], "mrib-o", 6))
278 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
279 else if (!strncmp (argv[0], "mrib-t", 6))
280 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
281 else if (!strncmp (argv[0], "low", 3))
282 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
283 else if (!strncmp (argv[0], "lon", 3))
284 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
285 else
286 {
287 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
288 return CMD_WARNING;
289 }
290
291 return CMD_SUCCESS;
292}
293
294DEFUN (no_ip_multicast_mode,
295 no_ip_multicast_mode_cmd,
296 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
297 NO_STR
298 IP_STR
299 "Multicast options\n"
300 "RPF lookup behavior\n"
301 "Lookup in unicast RIB only\n"
302 "Lookup in multicast RIB only\n"
303 "Try multicast RIB first, fall back to unicast RIB\n"
304 "Lookup both, use entry with lower distance\n"
305 "Lookup both, use entry with longer prefix\n")
306{
307 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
308 return CMD_SUCCESS;
309}
310
311ALIAS (no_ip_multicast_mode,
312 no_ip_multicast_mode_noarg_cmd,
313 "no ip multicast rpf-lookup-mode",
314 NO_STR
315 IP_STR
316 "Multicast options\n"
317 "RPF lookup behavior\n")
318
Everton Marques33d86db2014-07-14 11:19:00 -0300319DEFUN (show_ip_rpf,
320 show_ip_rpf_cmd,
321 "show ip rpf",
322 SHOW_STR
323 IP_STR
324 "Display RPF information for multicast source\n")
325{
Feng Lu4364ee52015-05-22 11:40:03 +0200326 vrf_id_t vrf_id = VRF_DEFAULT;
327
328 if (argc > 0)
329 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
330
David Lamparter863f20c2015-01-27 20:24:15 +0100331 VTY_WARN_EXPERIMENTAL();
Feng Lu4364ee52015-05-22 11:40:03 +0200332 return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -0300333}
334
Feng Lu4364ee52015-05-22 11:40:03 +0200335ALIAS (show_ip_rpf,
336 show_ip_rpf_vrf_cmd,
337 "show ip rpf " VRF_CMD_STR,
338 SHOW_STR
339 IP_STR
340 "Display RPF information for multicast source\n"
341 VRF_CMD_HELP_STR)
342
David Lamparter3b02fe82015-01-22 19:12:35 +0100343DEFUN (show_ip_rpf_addr,
344 show_ip_rpf_addr_cmd,
345 "show ip rpf A.B.C.D",
346 SHOW_STR
347 IP_STR
348 "Display RPF information for multicast source\n"
349 "IP multicast source address (e.g. 10.0.0.0)\n")
350{
351 struct in_addr addr;
352 struct route_node *rn;
353 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +0200354 vrf_id_t vrf_id = VRF_DEFAULT;
355 int ret;
356
357 if (argc > 1)
358 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
359
360 VTY_WARN_EXPERIMENTAL();
361
362 ret = inet_aton (argv[0], &addr);
363 if (ret == 0)
364 {
365 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
366 return CMD_WARNING;
367 }
368
369 rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
370
371 if (rib)
372 vty_show_ip_route_detail (vty, rn, 1);
373 else
374 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
375
376 return CMD_SUCCESS;
377}
378
379ALIAS (show_ip_rpf_addr,
380 show_ip_rpf_addr_vrf_cmd,
381 "show ip rpf A.B.C.D " VRF_CMD_STR,
382 SHOW_STR
383 IP_STR
384 "Display RPF information for multicast source\n"
385 "IP multicast source address (e.g. 10.0.0.0)\n"
386 VRF_CMD_HELP_STR)
387
388DEFUN (show_ip_rpf_vrf_all,
389 show_ip_rpf_vrf_all_cmd,
390 "show ip rpf " VRF_ALL_CMD_STR,
391 SHOW_STR
392 IP_STR
393 "Display RPF information for multicast source\n"
394 VRF_ALL_CMD_HELP_STR)
395{
396 struct zebra_vrf *zvrf;
397 struct route_table *table;
398 struct route_node *rn;
399 struct rib *rib;
400 vrf_iter_t iter;
401 int first = 1;
402
403 VTY_WARN_EXPERIMENTAL();
404
405 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
406 {
407 if ((zvrf = vrf_iter2info (iter)) == NULL ||
408 (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
409 continue;
410
411 /* Show all IPv4 routes. */
412 for (rn = route_top (table); rn; rn = route_next (rn))
413 RNODE_FOREACH_RIB (rn, rib)
414 {
415 if (first)
416 {
417 vty_out (vty, SHOW_ROUTE_V4_HEADER);
418 first = 0;
419 }
420 vty_show_ip_route (vty, rn, rib);
421 }
422 }
423
424 return CMD_SUCCESS;
425}
426
427DEFUN (show_ip_rpf_addr_vrf_all,
428 show_ip_rpf_addr_vrf_all_cmd,
429 "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
430 SHOW_STR
431 IP_STR
432 "Display RPF information for multicast source\n"
433 "IP multicast source address (e.g. 10.0.0.0)\n"
434 VRF_ALL_CMD_HELP_STR)
435{
436 struct in_addr addr;
437 struct route_node *rn;
438 vrf_iter_t iter;
David Lamparter3b02fe82015-01-22 19:12:35 +0100439 int ret;
440
David Lamparter863f20c2015-01-27 20:24:15 +0100441 VTY_WARN_EXPERIMENTAL();
442
David Lamparter3b02fe82015-01-22 19:12:35 +0100443 ret = inet_aton (argv[0], &addr);
444 if (ret == 0)
445 {
446 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
Feng Lu4364ee52015-05-22 11:40:03 +0200450 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
451 {
452 if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
453 vty_show_ip_route_detail (vty, rn, 1);
454 }
David Lamparter3b02fe82015-01-22 19:12:35 +0100455
456 return CMD_SUCCESS;
457}
458
paul718e3742002-12-13 20:15:29 +0000459/* Static route configuration. */
460DEFUN (ip_route,
461 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000462 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000463 IP_STR
464 "Establish static routes\n"
465 "IP destination prefix (e.g. 10.0.0.0/8)\n"
466 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000467 "IP gateway interface name\n"
468 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000469{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200470 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
471 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000472}
473
474DEFUN (ip_route_flags,
475 ip_route_flags_cmd,
476 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000477 IP_STR
478 "Establish static routes\n"
479 "IP destination prefix (e.g. 10.0.0.0/8)\n"
480 "IP gateway address\n"
481 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000482 "Emit an ICMP unreachable when matched\n"
483 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000484{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200485 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
486 NULL);
paul718e3742002-12-13 20:15:29 +0000487}
488
hasso457ef552003-05-28 12:02:15 +0000489DEFUN (ip_route_flags2,
490 ip_route_flags2_cmd,
491 "ip route A.B.C.D/M (reject|blackhole)",
492 IP_STR
493 "Establish static routes\n"
494 "IP destination prefix (e.g. 10.0.0.0/8)\n"
495 "Emit an ICMP unreachable when matched\n"
496 "Silently discard pkts when matched\n")
497{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200498 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
499 NULL);
hasso457ef552003-05-28 12:02:15 +0000500}
501
paul718e3742002-12-13 20:15:29 +0000502/* Mask as A.B.C.D format. */
503DEFUN (ip_route_mask,
504 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000505 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000506 IP_STR
507 "Establish static routes\n"
508 "IP destination prefix\n"
509 "IP destination prefix mask\n"
510 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000511 "IP gateway interface name\n"
512 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000513{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200514 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
515 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000516}
517
518DEFUN (ip_route_mask_flags,
519 ip_route_mask_flags_cmd,
520 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000521 IP_STR
522 "Establish static routes\n"
523 "IP destination prefix\n"
524 "IP destination prefix mask\n"
525 "IP gateway address\n"
526 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000527 "Emit an ICMP unreachable when matched\n"
528 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000529{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200530 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
531 NULL);
paul718e3742002-12-13 20:15:29 +0000532}
533
hasso457ef552003-05-28 12:02:15 +0000534DEFUN (ip_route_mask_flags2,
535 ip_route_mask_flags2_cmd,
536 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
537 IP_STR
538 "Establish static routes\n"
539 "IP destination prefix\n"
540 "IP destination prefix mask\n"
541 "Emit an ICMP unreachable when matched\n"
542 "Silently discard pkts when matched\n")
543{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200544 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
545 NULL);
hasso457ef552003-05-28 12:02:15 +0000546}
547
paul718e3742002-12-13 20:15:29 +0000548/* Distance option value. */
549DEFUN (ip_route_distance,
550 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000551 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000552 IP_STR
553 "Establish static routes\n"
554 "IP destination prefix (e.g. 10.0.0.0/8)\n"
555 "IP gateway address\n"
556 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000557 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000558 "Distance value for this route\n")
559{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200560 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
561 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000562}
563
564DEFUN (ip_route_flags_distance,
565 ip_route_flags_distance_cmd,
566 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
567 IP_STR
568 "Establish static routes\n"
569 "IP destination prefix (e.g. 10.0.0.0/8)\n"
570 "IP gateway address\n"
571 "IP gateway interface name\n"
572 "Emit an ICMP unreachable when matched\n"
573 "Silently discard pkts when matched\n"
574 "Distance value for this route\n")
575{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200576 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
577 NULL);
paul718e3742002-12-13 20:15:29 +0000578}
579
hasso457ef552003-05-28 12:02:15 +0000580DEFUN (ip_route_flags_distance2,
581 ip_route_flags_distance2_cmd,
582 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
583 IP_STR
584 "Establish static routes\n"
585 "IP destination prefix (e.g. 10.0.0.0/8)\n"
586 "Emit an ICMP unreachable when matched\n"
587 "Silently discard pkts when matched\n"
588 "Distance value for this route\n")
589{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200590 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
591 NULL);
hasso457ef552003-05-28 12:02:15 +0000592}
593
paul718e3742002-12-13 20:15:29 +0000594DEFUN (ip_route_mask_distance,
595 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000596 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000597 IP_STR
598 "Establish static routes\n"
599 "IP destination prefix\n"
600 "IP destination prefix mask\n"
601 "IP gateway address\n"
602 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000603 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000604 "Distance value for this route\n")
605{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200606 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
607 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000608}
609
610DEFUN (ip_route_mask_flags_distance,
611 ip_route_mask_flags_distance_cmd,
612 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
613 IP_STR
614 "Establish static routes\n"
615 "IP destination prefix\n"
616 "IP destination prefix mask\n"
617 "IP gateway address\n"
618 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000619 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000620 "Silently discard pkts when matched\n"
621 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000622{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200623 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
624 NULL);
paul718e3742002-12-13 20:15:29 +0000625}
626
hasso457ef552003-05-28 12:02:15 +0000627DEFUN (ip_route_mask_flags_distance2,
628 ip_route_mask_flags_distance2_cmd,
629 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
630 IP_STR
631 "Establish static routes\n"
632 "IP destination prefix\n"
633 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000634 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000635 "Silently discard pkts when matched\n"
636 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000637{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200638 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
639 NULL);
hasso457ef552003-05-28 12:02:15 +0000640}
641
paul718e3742002-12-13 20:15:29 +0000642DEFUN (no_ip_route,
643 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000644 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000645 NO_STR
646 IP_STR
647 "Establish static routes\n"
648 "IP destination prefix (e.g. 10.0.0.0/8)\n"
649 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000650 "IP gateway interface name\n"
651 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000652{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200653 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
654 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000655}
656
657ALIAS (no_ip_route,
658 no_ip_route_flags_cmd,
659 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000660 NO_STR
661 IP_STR
662 "Establish static routes\n"
663 "IP destination prefix (e.g. 10.0.0.0/8)\n"
664 "IP gateway address\n"
665 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000666 "Emit an ICMP unreachable when matched\n"
667 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000668
hasso457ef552003-05-28 12:02:15 +0000669DEFUN (no_ip_route_flags2,
670 no_ip_route_flags2_cmd,
671 "no ip route A.B.C.D/M (reject|blackhole)",
672 NO_STR
673 IP_STR
674 "Establish static routes\n"
675 "IP destination prefix (e.g. 10.0.0.0/8)\n"
676 "Emit an ICMP unreachable when matched\n"
677 "Silently discard pkts when matched\n")
678{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200679 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
680 NULL);
hasso457ef552003-05-28 12:02:15 +0000681}
682
paul718e3742002-12-13 20:15:29 +0000683DEFUN (no_ip_route_mask,
684 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000685 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000686 NO_STR
687 IP_STR
688 "Establish static routes\n"
689 "IP destination prefix\n"
690 "IP destination prefix mask\n"
691 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000692 "IP gateway interface name\n"
693 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000694{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200695 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
696 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000697}
698
699ALIAS (no_ip_route_mask,
700 no_ip_route_mask_flags_cmd,
701 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000702 NO_STR
703 IP_STR
704 "Establish static routes\n"
705 "IP destination prefix\n"
706 "IP destination prefix mask\n"
707 "IP gateway address\n"
708 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000709 "Emit an ICMP unreachable when matched\n"
710 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000711
hasso457ef552003-05-28 12:02:15 +0000712DEFUN (no_ip_route_mask_flags2,
713 no_ip_route_mask_flags2_cmd,
714 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
715 NO_STR
716 IP_STR
717 "Establish static routes\n"
718 "IP destination prefix\n"
719 "IP destination prefix mask\n"
720 "Emit an ICMP unreachable when matched\n"
721 "Silently discard pkts when matched\n")
722{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200723 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
724 NULL);
hasso457ef552003-05-28 12:02:15 +0000725}
726
paul718e3742002-12-13 20:15:29 +0000727DEFUN (no_ip_route_distance,
728 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000729 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000730 NO_STR
731 IP_STR
732 "Establish static routes\n"
733 "IP destination prefix (e.g. 10.0.0.0/8)\n"
734 "IP gateway address\n"
735 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000736 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000737 "Distance value for this route\n")
738{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200739 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
740 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000741}
742
743DEFUN (no_ip_route_flags_distance,
744 no_ip_route_flags_distance_cmd,
745 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
746 NO_STR
747 IP_STR
748 "Establish static routes\n"
749 "IP destination prefix (e.g. 10.0.0.0/8)\n"
750 "IP gateway address\n"
751 "IP gateway interface name\n"
752 "Emit an ICMP unreachable when matched\n"
753 "Silently discard pkts when matched\n"
754 "Distance value for this route\n")
755{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200756 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
757 NULL);
paul718e3742002-12-13 20:15:29 +0000758}
759
hasso457ef552003-05-28 12:02:15 +0000760DEFUN (no_ip_route_flags_distance2,
761 no_ip_route_flags_distance2_cmd,
762 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
763 NO_STR
764 IP_STR
765 "Establish static routes\n"
766 "IP destination prefix (e.g. 10.0.0.0/8)\n"
767 "Emit an ICMP unreachable when matched\n"
768 "Silently discard pkts when matched\n"
769 "Distance value for this route\n")
770{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200771 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
772 NULL);
hasso457ef552003-05-28 12:02:15 +0000773}
774
paul718e3742002-12-13 20:15:29 +0000775DEFUN (no_ip_route_mask_distance,
776 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000777 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000778 NO_STR
779 IP_STR
780 "Establish static routes\n"
781 "IP destination prefix\n"
782 "IP destination prefix mask\n"
783 "IP gateway address\n"
784 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000785 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000786 "Distance value for this route\n")
787{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200788 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
789 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000790}
791
792DEFUN (no_ip_route_mask_flags_distance,
793 no_ip_route_mask_flags_distance_cmd,
794 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
795 NO_STR
796 IP_STR
797 "Establish static routes\n"
798 "IP destination prefix\n"
799 "IP destination prefix mask\n"
800 "IP gateway address\n"
801 "IP gateway interface name\n"
802 "Emit an ICMP unreachable when matched\n"
803 "Silently discard pkts when matched\n"
804 "Distance value for this route\n")
805{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200806 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
807 NULL);
paul718e3742002-12-13 20:15:29 +0000808}
809
hasso457ef552003-05-28 12:02:15 +0000810DEFUN (no_ip_route_mask_flags_distance2,
811 no_ip_route_mask_flags_distance2_cmd,
812 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
813 NO_STR
814 IP_STR
815 "Establish static routes\n"
816 "IP destination prefix\n"
817 "IP destination prefix mask\n"
818 "Emit an ICMP unreachable when matched\n"
819 "Silently discard pkts when matched\n"
820 "Distance value for this route\n")
821{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200822 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
823 NULL);
824}
825
826DEFUN (ip_route_vrf,
827 ip_route_vrf_cmd,
828 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
829 IP_STR
830 "Establish static routes\n"
831 "IP destination prefix (e.g. 10.0.0.0/8)\n"
832 "IP gateway address\n"
833 "IP gateway interface name\n"
834 "Null interface\n"
835 VRF_CMD_HELP_STR)
836{
837 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
838 argv[2]);
839}
840
841DEFUN (ip_route_flags_vrf,
842 ip_route_flags_vrf_cmd,
843 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
844 IP_STR
845 "Establish static routes\n"
846 "IP destination prefix (e.g. 10.0.0.0/8)\n"
847 "IP gateway address\n"
848 "IP gateway interface name\n"
849 "Emit an ICMP unreachable when matched\n"
850 "Silently discard pkts when matched\n"
851 VRF_CMD_HELP_STR)
852{
853 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
854 argv[3]);
855}
856
857DEFUN (ip_route_flags2_vrf,
858 ip_route_flags2_vrf_cmd,
859 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
860 IP_STR
861 "Establish static routes\n"
862 "IP destination prefix (e.g. 10.0.0.0/8)\n"
863 "Emit an ICMP unreachable when matched\n"
864 "Silently discard pkts when matched\n"
865 VRF_CMD_HELP_STR)
866{
867 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
868 argv[2]);
869}
870
871/* Mask as A.B.C.D format. */
872DEFUN (ip_route_mask_vrf,
873 ip_route_mask_vrf_cmd,
874 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
875 IP_STR
876 "Establish static routes\n"
877 "IP destination prefix\n"
878 "IP destination prefix mask\n"
879 "IP gateway address\n"
880 "IP gateway interface name\n"
881 "Null interface\n"
882 VRF_CMD_HELP_STR)
883{
884 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
885 argv[3]);
886}
887
888DEFUN (ip_route_mask_flags_vrf,
889 ip_route_mask_flags_vrf_cmd,
890 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
891 IP_STR
892 "Establish static routes\n"
893 "IP destination prefix\n"
894 "IP destination prefix mask\n"
895 "IP gateway address\n"
896 "IP gateway interface name\n"
897 "Emit an ICMP unreachable when matched\n"
898 "Silently discard pkts when matched\n"
899 VRF_CMD_HELP_STR)
900{
901 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
902 argv[4]);
903}
904
905DEFUN (ip_route_mask_flags2_vrf,
906 ip_route_mask_flags2_vrf_cmd,
907 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
908 IP_STR
909 "Establish static routes\n"
910 "IP destination prefix\n"
911 "IP destination prefix mask\n"
912 "Emit an ICMP unreachable when matched\n"
913 "Silently discard pkts when matched\n"
914 VRF_CMD_HELP_STR)
915{
916 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
917 argv[3]);
918}
919
920/* Distance option value. */
921DEFUN (ip_route_distance_vrf,
922 ip_route_distance_vrf_cmd,
923 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
924 IP_STR
925 "Establish static routes\n"
926 "IP destination prefix (e.g. 10.0.0.0/8)\n"
927 "IP gateway address\n"
928 "IP gateway interface name\n"
929 "Null interface\n"
930 "Distance value for this route\n"
931 VRF_CMD_HELP_STR)
932{
933 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
934 argv[3]);
935}
936
937DEFUN (ip_route_flags_distance_vrf,
938 ip_route_flags_distance_vrf_cmd,
939 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
940 IP_STR
941 "Establish static routes\n"
942 "IP destination prefix (e.g. 10.0.0.0/8)\n"
943 "IP gateway address\n"
944 "IP gateway interface name\n"
945 "Emit an ICMP unreachable when matched\n"
946 "Silently discard pkts when matched\n"
947 "Distance value for this route\n"
948 VRF_CMD_HELP_STR)
949{
950 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
951 argv[4]);
952}
953
954DEFUN (ip_route_flags_distance2_vrf,
955 ip_route_flags_distance2_vrf_cmd,
956 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
957 IP_STR
958 "Establish static routes\n"
959 "IP destination prefix (e.g. 10.0.0.0/8)\n"
960 "Emit an ICMP unreachable when matched\n"
961 "Silently discard pkts when matched\n"
962 "Distance value for this route\n"
963 VRF_CMD_HELP_STR)
964{
965 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
966 argv[3]);
967}
968
969DEFUN (ip_route_mask_distance_vrf,
970 ip_route_mask_distance_vrf_cmd,
971 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
972 IP_STR
973 "Establish static routes\n"
974 "IP destination prefix\n"
975 "IP destination prefix mask\n"
976 "IP gateway address\n"
977 "IP gateway interface name\n"
978 "Null interface\n"
979 "Distance value for this route\n"
980 VRF_CMD_HELP_STR)
981{
982 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
983 argv[4]);
984}
985
986DEFUN (ip_route_mask_flags_distance_vrf,
987 ip_route_mask_flags_distance_vrf_cmd,
988 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
989 IP_STR
990 "Establish static routes\n"
991 "IP destination prefix\n"
992 "IP destination prefix mask\n"
993 "IP gateway address\n"
994 "IP gateway interface name\n"
995 "Emit an ICMP unreachable when matched\n"
996 "Silently discard pkts when matched\n"
997 "Distance value for this route\n"
998 VRF_CMD_HELP_STR)
999{
1000 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
1001 argv[5]);
1002}
1003
1004DEFUN (ip_route_mask_flags_distance2_vrf,
1005 ip_route_mask_flags_distance2_vrf_cmd,
1006 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1007 IP_STR
1008 "Establish static routes\n"
1009 "IP destination prefix\n"
1010 "IP destination prefix mask\n"
1011 "Emit an ICMP unreachable when matched\n"
1012 "Silently discard pkts when matched\n"
1013 "Distance value for this route\n"
1014 VRF_CMD_HELP_STR)
1015{
1016 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
1017 argv[4]);
1018}
1019
1020DEFUN (no_ip_route_vrf,
1021 no_ip_route_vrf_cmd,
1022 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1023 NO_STR
1024 IP_STR
1025 "Establish static routes\n"
1026 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1027 "IP gateway address\n"
1028 "IP gateway interface name\n"
1029 "Null interface\n"
1030 VRF_CMD_HELP_STR)
1031{
1032 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
1033 (argc > 3) ? argv[3] : argv[2]);
1034}
1035
1036ALIAS (no_ip_route_vrf,
1037 no_ip_route_flags_vrf_cmd,
1038 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1039 NO_STR
1040 IP_STR
1041 "Establish static routes\n"
1042 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1043 "IP gateway address\n"
1044 "IP gateway interface name\n"
1045 "Emit an ICMP unreachable when matched\n"
1046 "Silently discard pkts when matched\n"
1047 VRF_CMD_HELP_STR)
1048
1049DEFUN (no_ip_route_flags2_vrf,
1050 no_ip_route_flags2_vrf_cmd,
1051 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1052 NO_STR
1053 IP_STR
1054 "Establish static routes\n"
1055 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1056 "Emit an ICMP unreachable when matched\n"
1057 "Silently discard pkts when matched\n"
1058 VRF_CMD_HELP_STR)
1059{
1060 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
1061 argv[2]);
1062}
1063
1064DEFUN (no_ip_route_mask_vrf,
1065 no_ip_route_mask_vrf_cmd,
1066 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1067 NO_STR
1068 IP_STR
1069 "Establish static routes\n"
1070 "IP destination prefix\n"
1071 "IP destination prefix mask\n"
1072 "IP gateway address\n"
1073 "IP gateway interface name\n"
1074 "Null interface\n"
1075 VRF_CMD_HELP_STR)
1076{
1077 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
1078 (argc > 4) ? argv[4] : argv[3]);
1079}
1080
1081ALIAS (no_ip_route_mask_vrf,
1082 no_ip_route_mask_flags_vrf_cmd,
1083 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1084 NO_STR
1085 IP_STR
1086 "Establish static routes\n"
1087 "IP destination prefix\n"
1088 "IP destination prefix mask\n"
1089 "IP gateway address\n"
1090 "IP gateway interface name\n"
1091 "Emit an ICMP unreachable when matched\n"
1092 "Silently discard pkts when matched\n"
1093 VRF_CMD_HELP_STR)
1094
1095DEFUN (no_ip_route_mask_flags2_vrf,
1096 no_ip_route_mask_flags2_vrf_cmd,
1097 "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1098 NO_STR
1099 IP_STR
1100 "Establish static routes\n"
1101 "IP destination prefix\n"
1102 "IP destination prefix mask\n"
1103 "Emit an ICMP unreachable when matched\n"
1104 "Silently discard pkts when matched\n"
1105 VRF_CMD_HELP_STR)
1106{
1107 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
1108 argv[2]);
1109}
1110
1111DEFUN (no_ip_route_distance_vrf,
1112 no_ip_route_distance_vrf_cmd,
1113 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1114 NO_STR
1115 IP_STR
1116 "Establish static routes\n"
1117 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1118 "IP gateway address\n"
1119 "IP gateway interface name\n"
1120 "Null interface\n"
1121 "Distance value for this route\n"
1122 VRF_CMD_HELP_STR)
1123{
1124 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
1125 argv[3]);
1126}
1127
1128DEFUN (no_ip_route_flags_distance_vrf,
1129 no_ip_route_flags_distance_vrf_cmd,
1130 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1131 NO_STR
1132 IP_STR
1133 "Establish static routes\n"
1134 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1135 "IP gateway address\n"
1136 "IP gateway interface name\n"
1137 "Emit an ICMP unreachable when matched\n"
1138 "Silently discard pkts when matched\n"
1139 "Distance value for this route\n"
1140 VRF_CMD_HELP_STR)
1141{
1142 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
1143 argv[4]);
1144}
1145
1146DEFUN (no_ip_route_flags_distance2_vrf,
1147 no_ip_route_flags_distance2_vrf_cmd,
1148 "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1149 NO_STR
1150 IP_STR
1151 "Establish static routes\n"
1152 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1153 "Emit an ICMP unreachable when matched\n"
1154 "Silently discard pkts when matched\n"
1155 "Distance value for this route\n"
1156 VRF_CMD_HELP_STR)
1157{
1158 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
1159 argv[3]);
1160}
1161
1162DEFUN (no_ip_route_mask_distance_vrf,
1163 no_ip_route_mask_distance_vrf_cmd,
1164 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1165 NO_STR
1166 IP_STR
1167 "Establish static routes\n"
1168 "IP destination prefix\n"
1169 "IP destination prefix mask\n"
1170 "IP gateway address\n"
1171 "IP gateway interface name\n"
1172 "Null interface\n"
1173 "Distance value for this route\n"
1174 VRF_CMD_HELP_STR)
1175{
1176 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
1177 argv[4]);
1178}
1179
1180DEFUN (no_ip_route_mask_flags_distance_vrf,
1181 no_ip_route_mask_flags_distance_vrf_cmd,
1182 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1183 NO_STR
1184 IP_STR
1185 "Establish static routes\n"
1186 "IP destination prefix\n"
1187 "IP destination prefix mask\n"
1188 "IP gateway address\n"
1189 "IP gateway interface name\n"
1190 "Emit an ICMP unreachable when matched\n"
1191 "Silently discard pkts when matched\n"
1192 "Distance value for this route\n"
1193 VRF_CMD_HELP_STR)
1194{
1195 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
1196 argv[5]);
1197}
1198
1199DEFUN (no_ip_route_mask_flags_distance2_vrf,
1200 no_ip_route_mask_flags_distance2_vrf_cmd,
1201 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1202 NO_STR
1203 IP_STR
1204 "Establish static routes\n"
1205 "IP destination prefix\n"
1206 "IP destination prefix mask\n"
1207 "Emit an ICMP unreachable when matched\n"
1208 "Silently discard pkts when matched\n"
1209 "Distance value for this route\n"
1210 VRF_CMD_HELP_STR)
1211{
1212 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
1213 argv[4]);
hasso457ef552003-05-28 12:02:15 +00001214}
1215
Paul Jakma7514fb72007-05-02 16:05:35 +00001216char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
1217
1218DEFUN (ip_protocol,
1219 ip_protocol_cmd,
1220 "ip protocol PROTO route-map ROUTE-MAP",
1221 NO_STR
1222 "Apply route map to PROTO\n"
1223 "Protocol name\n"
1224 "Route map name\n")
1225{
1226 int i;
1227
1228 if (strcasecmp(argv[0], "any") == 0)
1229 i = ZEBRA_ROUTE_MAX;
1230 else
1231 i = proto_name2num(argv[0]);
1232 if (i < 0)
1233 {
1234 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1235 VTY_NEWLINE);
1236 return CMD_WARNING;
1237 }
1238 if (proto_rm[AFI_IP][i])
1239 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1240 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
1241 return CMD_SUCCESS;
1242}
1243
1244DEFUN (no_ip_protocol,
1245 no_ip_protocol_cmd,
1246 "no ip protocol PROTO",
1247 NO_STR
1248 "Remove route map from PROTO\n"
1249 "Protocol name\n")
1250{
1251 int i;
1252
1253 if (strcasecmp(argv[0], "any") == 0)
1254 i = ZEBRA_ROUTE_MAX;
1255 else
1256 i = proto_name2num(argv[0]);
1257 if (i < 0)
1258 {
1259 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1260 VTY_NEWLINE);
1261 return CMD_WARNING;
1262 }
1263 if (proto_rm[AFI_IP][i])
1264 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1265 proto_rm[AFI_IP][i] = NULL;
1266 return CMD_SUCCESS;
1267}
1268
paul718e3742002-12-13 20:15:29 +00001269/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +00001270static void
David Lamparter3b02fe82015-01-22 19:12:35 +01001271vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +00001272{
1273 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001274 struct nexthop *nexthop, *tnexthop;
1275 int recursing;
Timo Teräs53a5c392015-05-23 11:08:40 +03001276 char buf[PREFIX_STRLEN];
paul718e3742002-12-13 20:15:29 +00001277
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001278 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001279 {
David Lamparterb7cce952015-03-07 08:40:48 +01001280 const char *mcast_info = "";
David Lamparter3b02fe82015-01-22 19:12:35 +01001281 if (mcast)
1282 {
1283 rib_table_info_t *info = rn->table->info;
1284 mcast_info = (info->safi == SAFI_MULTICAST)
1285 ? " using Multicast RIB"
1286 : " using Unicast RIB";
1287 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001288 vty_out (vty, "Routing entry for %s%s%s",
1289 prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
1290 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001291 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001292 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
Timo Teräsb11f3b52015-11-02 16:50:07 +02001293 if (rib->mtu)
1294 vty_out (vty, ", mtu %u", rib->mtu);
Feng Lu4364ee52015-05-22 11:40:03 +02001295 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001296 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001297 vty_out (vty, ", best");
Timo Teräs325823a2016-01-15 17:36:31 +02001298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE))
1299 vty_out (vty, ", fib-override");
1300 if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
1301 vty_out (vty, ", fib");
paul718e3742002-12-13 20:15:29 +00001302 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001303 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001304 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1305 vty_out (vty, ", blackhole");
1306 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1307 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001308 vty_out (vty, "%s", VTY_NEWLINE);
1309
1310#define ONE_DAY_SECOND 60*60*24
1311#define ONE_WEEK_SECOND 60*60*24*7
1312 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001313 || rib->type == ZEBRA_ROUTE_RIPNG
1314 || rib->type == ZEBRA_ROUTE_OSPF
1315 || rib->type == ZEBRA_ROUTE_OSPF6
1316 || rib->type == ZEBRA_ROUTE_BABEL
1317 || rib->type == ZEBRA_ROUTE_ISIS
1318 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001319 {
1320 time_t uptime;
1321 struct tm *tm;
1322
1323 uptime = time (NULL);
1324 uptime -= rib->uptime;
1325 tm = gmtime (&uptime);
1326
1327 vty_out (vty, " Last update ");
1328
1329 if (uptime < ONE_DAY_SECOND)
1330 vty_out (vty, "%02d:%02d:%02d",
1331 tm->tm_hour, tm->tm_min, tm->tm_sec);
1332 else if (uptime < ONE_WEEK_SECOND)
1333 vty_out (vty, "%dd%02dh%02dm",
1334 tm->tm_yday, tm->tm_hour, tm->tm_min);
1335 else
1336 vty_out (vty, "%02dw%dd%02dh",
1337 tm->tm_yday/7,
1338 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1339 vty_out (vty, " ago%s", VTY_NEWLINE);
1340 }
1341
Christian Frankefa713d92013-07-05 15:35:37 +00001342 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001343 {
Timo Teräs7e73eb72016-04-09 17:22:32 +03001344 vty_out (vty, " %c%c%s",
1345 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? '>' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001346 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1347 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001348
Timo Teräs53a5c392015-05-23 11:08:40 +03001349 switch (nexthop->type)
1350 {
1351 case NEXTHOP_TYPE_IPV4:
1352 case NEXTHOP_TYPE_IPV4_IFINDEX:
1353 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1354 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001355 vty_out (vty, ", via %s",
1356 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001357 break;
1358 case NEXTHOP_TYPE_IPV6:
1359 case NEXTHOP_TYPE_IPV6_IFINDEX:
1360 case NEXTHOP_TYPE_IPV6_IFNAME:
1361 vty_out (vty, " %s",
1362 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1363 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1364 vty_out (vty, ", %s", nexthop->ifname);
1365 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001366 vty_out (vty, ", via %s",
1367 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001368 break;
1369 case NEXTHOP_TYPE_IFINDEX:
1370 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001371 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001372 break;
1373 case NEXTHOP_TYPE_IFNAME:
1374 vty_out (vty, " directly connected, %s", nexthop->ifname);
1375 break;
1376 case NEXTHOP_TYPE_BLACKHOLE:
1377 vty_out (vty, " directly connected, Null0");
1378 break;
1379 default:
1380 break;
1381 }
1382 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1383 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001384
Timo Teräs53a5c392015-05-23 11:08:40 +03001385 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1386 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001387
Timo Teräs53a5c392015-05-23 11:08:40 +03001388 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1389 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001390
Timo Teräs53a5c392015-05-23 11:08:40 +03001391 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001392 {
1393 case NEXTHOP_TYPE_IPV4:
1394 case NEXTHOP_TYPE_IPV4_IFINDEX:
1395 case NEXTHOP_TYPE_IPV4_IFNAME:
1396 if (nexthop->src.ipv4.s_addr)
1397 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001398 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1399 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001400 }
1401 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001402#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001403 case NEXTHOP_TYPE_IPV6:
1404 case NEXTHOP_TYPE_IPV6_IFINDEX:
1405 case NEXTHOP_TYPE_IPV6_IFNAME:
1406 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1407 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001408 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1409 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001410 }
1411 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001412#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001413 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001414 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001415 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001416 vty_out (vty, "%s", VTY_NEWLINE);
1417 }
paul718e3742002-12-13 20:15:29 +00001418 vty_out (vty, "%s", VTY_NEWLINE);
1419 }
1420}
1421
paula1ac18c2005-06-28 17:17:12 +00001422static void
paul718e3742002-12-13 20:15:29 +00001423vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1424{
Christian Frankefa713d92013-07-05 15:35:37 +00001425 struct nexthop *nexthop, *tnexthop;
1426 int recursing;
paul718e3742002-12-13 20:15:29 +00001427 int len = 0;
1428 char buf[BUFSIZ];
1429
1430 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001431 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001432 {
1433 if (nexthop == rib->nexthop)
1434 {
1435 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001436 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001437 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001438 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1439 ? '>' : ' ',
1440 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1441 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001442 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001443
1444 /* Distance and metric display. */
1445 if (rib->type != ZEBRA_ROUTE_CONNECT
1446 && rib->type != ZEBRA_ROUTE_KERNEL)
1447 len += vty_out (vty, " [%d/%d]", rib->distance,
1448 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001449
1450 if (rib->vrf_id != VRF_DEFAULT)
1451 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001452 }
1453 else
1454 vty_out (vty, " %c%*c",
1455 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1456 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001457 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001458
1459 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001460 {
1461 case NEXTHOP_TYPE_IPV4:
1462 case NEXTHOP_TYPE_IPV4_IFINDEX:
1463 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1464 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001465 vty_out (vty, ", %s",
1466 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001467 break;
1468 case NEXTHOP_TYPE_IPV6:
1469 case NEXTHOP_TYPE_IPV6_IFINDEX:
1470 case NEXTHOP_TYPE_IPV6_IFNAME:
1471 vty_out (vty, " via %s",
1472 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1473 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1474 vty_out (vty, ", %s", nexthop->ifname);
1475 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001476 vty_out (vty, ", %s",
1477 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001478 break;
1479 case NEXTHOP_TYPE_IFINDEX:
1480 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001481 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001482 break;
1483 case NEXTHOP_TYPE_IFNAME:
1484 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1485 break;
1486 case NEXTHOP_TYPE_BLACKHOLE:
1487 vty_out (vty, " is directly connected, Null0");
1488 break;
1489 default:
1490 break;
1491 }
paul718e3742002-12-13 20:15:29 +00001492 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001493 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001494
Christian Frankee8d3d292013-07-05 15:35:39 +00001495 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001496 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001497
paul718e3742002-12-13 20:15:29 +00001498 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001499 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001500
Paul Jakma7514fb72007-05-02 16:05:35 +00001501 switch (nexthop->type)
1502 {
1503 case NEXTHOP_TYPE_IPV4:
1504 case NEXTHOP_TYPE_IPV4_IFINDEX:
1505 case NEXTHOP_TYPE_IPV4_IFNAME:
1506 if (nexthop->src.ipv4.s_addr)
1507 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001508 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001509 vty_out (vty, ", src %s", buf);
1510 }
1511 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001512#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001513 case NEXTHOP_TYPE_IPV6:
1514 case NEXTHOP_TYPE_IPV6_IFINDEX:
1515 case NEXTHOP_TYPE_IPV6_IFNAME:
1516 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1517 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001518 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001519 vty_out (vty, ", src %s", buf);
1520 }
1521 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001522#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001523 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001524 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001525 }
paul718e3742002-12-13 20:15:29 +00001526
hasso81dfcaa2003-05-25 19:21:25 +00001527 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1528 vty_out (vty, ", bh");
1529 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1530 vty_out (vty, ", rej");
1531
paul718e3742002-12-13 20:15:29 +00001532 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001533 || rib->type == ZEBRA_ROUTE_RIPNG
1534 || rib->type == ZEBRA_ROUTE_OSPF
1535 || rib->type == ZEBRA_ROUTE_OSPF6
1536 || rib->type == ZEBRA_ROUTE_BABEL
1537 || rib->type == ZEBRA_ROUTE_ISIS
1538 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001539 {
1540 time_t uptime;
1541 struct tm *tm;
1542
1543 uptime = time (NULL);
1544 uptime -= rib->uptime;
1545 tm = gmtime (&uptime);
1546
1547#define ONE_DAY_SECOND 60*60*24
1548#define ONE_WEEK_SECOND 60*60*24*7
1549
1550 if (uptime < ONE_DAY_SECOND)
1551 vty_out (vty, ", %02d:%02d:%02d",
1552 tm->tm_hour, tm->tm_min, tm->tm_sec);
1553 else if (uptime < ONE_WEEK_SECOND)
1554 vty_out (vty, ", %dd%02dh%02dm",
1555 tm->tm_yday, tm->tm_hour, tm->tm_min);
1556 else
1557 vty_out (vty, ", %02dw%dd%02dh",
1558 tm->tm_yday/7,
1559 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1560 }
1561 vty_out (vty, "%s", VTY_NEWLINE);
1562 }
1563}
1564
paul718e3742002-12-13 20:15:29 +00001565DEFUN (show_ip_route,
1566 show_ip_route_cmd,
1567 "show ip route",
1568 SHOW_STR
1569 IP_STR
1570 "IP routing table\n")
1571{
Feng Lu4364ee52015-05-22 11:40:03 +02001572 vrf_id_t vrf_id = VRF_DEFAULT;
1573
1574 if (argc > 0)
1575 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1576
1577 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001578}
1579
Feng Lu4364ee52015-05-22 11:40:03 +02001580static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1581{
paul718e3742002-12-13 20:15:29 +00001582 struct route_table *table;
1583 struct route_node *rn;
1584 struct rib *rib;
1585 int first = 1;
1586
Feng Lu4364ee52015-05-22 11:40:03 +02001587 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001588 if (! table)
1589 return CMD_SUCCESS;
1590
1591 /* Show all IPv4 routes. */
1592 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001593 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001594 {
1595 if (first)
1596 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001597 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001598 first = 0;
1599 }
1600 vty_show_ip_route (vty, rn, rib);
1601 }
1602 return CMD_SUCCESS;
1603}
1604
Feng Lu4364ee52015-05-22 11:40:03 +02001605ALIAS (show_ip_route,
1606 show_ip_route_vrf_cmd,
1607 "show ip route " VRF_CMD_STR,
1608 SHOW_STR
1609 IP_STR
1610 "IP routing table\n"
1611 VRF_CMD_HELP_STR)
1612
paul718e3742002-12-13 20:15:29 +00001613DEFUN (show_ip_route_prefix_longer,
1614 show_ip_route_prefix_longer_cmd,
1615 "show ip route A.B.C.D/M longer-prefixes",
1616 SHOW_STR
1617 IP_STR
1618 "IP routing table\n"
1619 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1620 "Show route matching the specified Network/Mask pair only\n")
1621{
1622 struct route_table *table;
1623 struct route_node *rn;
1624 struct rib *rib;
1625 struct prefix p;
1626 int ret;
1627 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001628 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001629
1630 ret = str2prefix (argv[0], &p);
1631 if (! ret)
1632 {
1633 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1634 return CMD_WARNING;
1635 }
Feng Lu4364ee52015-05-22 11:40:03 +02001636
1637 if (argc > 1)
1638 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1639
1640 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001641 if (! table)
1642 return CMD_SUCCESS;
1643
1644 /* Show matched type IPv4 routes. */
1645 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001646 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001647 if (prefix_match (&p, &rn->p))
1648 {
1649 if (first)
1650 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001651 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001652 first = 0;
1653 }
1654 vty_show_ip_route (vty, rn, rib);
1655 }
1656 return CMD_SUCCESS;
1657}
1658
Feng Lu4364ee52015-05-22 11:40:03 +02001659ALIAS (show_ip_route_prefix_longer,
1660 show_ip_route_prefix_longer_vrf_cmd,
1661 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1662 SHOW_STR
1663 IP_STR
1664 "IP routing table\n"
1665 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1666 "Show route matching the specified Network/Mask pair only\n"
1667 VRF_CMD_HELP_STR)
1668
paul718e3742002-12-13 20:15:29 +00001669DEFUN (show_ip_route_supernets,
1670 show_ip_route_supernets_cmd,
1671 "show ip route supernets-only",
1672 SHOW_STR
1673 IP_STR
1674 "IP routing table\n"
1675 "Show supernet entries only\n")
1676{
1677 struct route_table *table;
1678 struct route_node *rn;
1679 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001680 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001681 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001682 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001683
Feng Lu4364ee52015-05-22 11:40:03 +02001684 if (argc > 0)
1685 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1686
1687 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001688 if (! table)
1689 return CMD_SUCCESS;
1690
1691 /* Show matched type IPv4 routes. */
1692 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001693 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001694 {
1695 addr = ntohl (rn->p.u.prefix4.s_addr);
1696
1697 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1698 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001699 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001700 {
1701 if (first)
1702 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001703 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001704 first = 0;
1705 }
1706 vty_show_ip_route (vty, rn, rib);
1707 }
1708 }
1709 return CMD_SUCCESS;
1710}
1711
Feng Lu4364ee52015-05-22 11:40:03 +02001712ALIAS (show_ip_route_supernets,
1713 show_ip_route_supernets_vrf_cmd,
1714 "show ip route supernets-only " VRF_CMD_STR,
1715 SHOW_STR
1716 IP_STR
1717 "IP routing table\n"
1718 "Show supernet entries only\n"
1719 VRF_CMD_HELP_STR)
1720
paul718e3742002-12-13 20:15:29 +00001721DEFUN (show_ip_route_protocol,
1722 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001723 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001724 SHOW_STR
1725 IP_STR
1726 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001727 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001728{
1729 int type;
1730 struct route_table *table;
1731 struct route_node *rn;
1732 struct rib *rib;
1733 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001734 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001735
David Lampartere0ca5fd2009-09-16 01:52:42 +02001736 type = proto_redistnum (AFI_IP, argv[0]);
1737 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001738 {
1739 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1740 return CMD_WARNING;
1741 }
Feng Lu4364ee52015-05-22 11:40:03 +02001742
1743 if (argc > 1)
1744 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1745
1746 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001747 if (! table)
1748 return CMD_SUCCESS;
1749
1750 /* Show matched type IPv4 routes. */
1751 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001752 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001753 if (rib->type == type)
1754 {
1755 if (first)
1756 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001757 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001758 first = 0;
1759 }
1760 vty_show_ip_route (vty, rn, rib);
1761 }
1762 return CMD_SUCCESS;
1763}
1764
Feng Lu4364ee52015-05-22 11:40:03 +02001765ALIAS (show_ip_route_protocol,
1766 show_ip_route_protocol_vrf_cmd,
1767 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1768 SHOW_STR
1769 IP_STR
1770 "IP routing table\n"
1771 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1772 VRF_CMD_HELP_STR)
1773
paul718e3742002-12-13 20:15:29 +00001774DEFUN (show_ip_route_addr,
1775 show_ip_route_addr_cmd,
1776 "show ip route A.B.C.D",
1777 SHOW_STR
1778 IP_STR
1779 "IP routing table\n"
1780 "Network in the IP routing table to display\n")
1781{
1782 int ret;
1783 struct prefix_ipv4 p;
1784 struct route_table *table;
1785 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001786 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001787
1788 ret = str2prefix_ipv4 (argv[0], &p);
1789 if (ret <= 0)
1790 {
1791 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1792 return CMD_WARNING;
1793 }
1794
Feng Lu4364ee52015-05-22 11:40:03 +02001795 if (argc > 1)
1796 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1797
1798 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001799 if (! table)
1800 return CMD_SUCCESS;
1801
1802 rn = route_node_match (table, (struct prefix *) &p);
1803 if (! rn)
1804 {
1805 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1806 return CMD_WARNING;
1807 }
1808
David Lamparter3b02fe82015-01-22 19:12:35 +01001809 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001810
1811 route_unlock_node (rn);
1812
1813 return CMD_SUCCESS;
1814}
1815
Feng Lu4364ee52015-05-22 11:40:03 +02001816ALIAS (show_ip_route_addr,
1817 show_ip_route_addr_vrf_cmd,
1818 "show ip route A.B.C.D " VRF_CMD_STR,
1819 SHOW_STR
1820 IP_STR
1821 "IP routing table\n"
1822 "Network in the IP routing table to display\n"
1823 VRF_CMD_HELP_STR)
1824
paul718e3742002-12-13 20:15:29 +00001825DEFUN (show_ip_route_prefix,
1826 show_ip_route_prefix_cmd,
1827 "show ip route A.B.C.D/M",
1828 SHOW_STR
1829 IP_STR
1830 "IP routing table\n"
1831 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1832{
1833 int ret;
1834 struct prefix_ipv4 p;
1835 struct route_table *table;
1836 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001837 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001838
1839 ret = str2prefix_ipv4 (argv[0], &p);
1840 if (ret <= 0)
1841 {
1842 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1843 return CMD_WARNING;
1844 }
1845
Feng Lu4364ee52015-05-22 11:40:03 +02001846 if (argc > 1)
1847 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1848
1849 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001850 if (! table)
1851 return CMD_SUCCESS;
1852
1853 rn = route_node_match (table, (struct prefix *) &p);
1854 if (! rn || rn->p.prefixlen != p.prefixlen)
1855 {
1856 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001857 if (rn)
1858 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001859 return CMD_WARNING;
1860 }
1861
David Lamparter3b02fe82015-01-22 19:12:35 +01001862 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001863
1864 route_unlock_node (rn);
1865
1866 return CMD_SUCCESS;
1867}
1868
Feng Lu4364ee52015-05-22 11:40:03 +02001869ALIAS (show_ip_route_prefix,
1870 show_ip_route_prefix_vrf_cmd,
1871 "show ip route A.B.C.D/M " VRF_CMD_STR,
1872 SHOW_STR
1873 IP_STR
1874 "IP routing table\n"
1875 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1876 VRF_CMD_HELP_STR)
1877
paula1ac18c2005-06-28 17:17:12 +00001878static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001879vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001880{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001881 struct route_node *rn;
1882 struct rib *rib;
1883 struct nexthop *nexthop;
1884#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1885#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1886 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1887 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1888 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001889
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001890 memset (&rib_cnt, 0, sizeof(rib_cnt));
1891 memset (&fib_cnt, 0, sizeof(fib_cnt));
1892 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001893 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001894 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1895 {
1896 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1897 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001898 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1899 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001900 {
1901 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1902 fib_cnt[rib->type]++;
1903 }
1904 if (rib->type == ZEBRA_ROUTE_BGP &&
1905 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1906 {
1907 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001908 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1909 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001910 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1911 }
1912 }
paul718e3742002-12-13 20:15:29 +00001913
Feng Lu4364ee52015-05-22 11:40:03 +02001914 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1915 "Route Source", "Routes", "FIB",
1916 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1917 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001918
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001919 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1920 {
1921 if (rib_cnt[i] > 0)
1922 {
1923 if (i == ZEBRA_ROUTE_BGP)
1924 {
1925 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1926 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1927 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1928 VTY_NEWLINE);
1929 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1930 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1931 VTY_NEWLINE);
1932 }
1933 else
1934 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1935 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1936 }
1937 }
paul718e3742002-12-13 20:15:29 +00001938
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001939 vty_out (vty, "------%s", VTY_NEWLINE);
1940 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1941 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001942 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001943}
1944
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001945/*
1946 * Implementation of the ip route summary prefix command.
1947 *
1948 * This command prints the primary prefixes that have been installed by various
1949 * protocols on the box.
1950 *
1951 */
1952static void
1953vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1954{
1955 struct route_node *rn;
1956 struct rib *rib;
1957 struct nexthop *nexthop;
1958#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1959#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1960 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1961 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1962 u_int32_t i;
1963 int cnt;
1964
1965 memset (&rib_cnt, 0, sizeof(rib_cnt));
1966 memset (&fib_cnt, 0, sizeof(fib_cnt));
1967 for (rn = route_top (table); rn; rn = route_next (rn))
1968 RNODE_FOREACH_RIB (rn, rib)
1969 {
1970
1971 /*
1972 * In case of ECMP, count only once.
1973 */
1974 cnt = 0;
1975 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1976 {
1977 cnt++;
1978 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1979 rib_cnt[rib->type]++;
1980 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1981 {
1982 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1983 fib_cnt[rib->type]++;
1984 }
1985 if (rib->type == ZEBRA_ROUTE_BGP &&
1986 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1987 {
1988 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1989 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1990 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1991 }
1992 }
1993 }
1994
Feng Lu4364ee52015-05-22 11:40:03 +02001995 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1996 "Route Source", "Prefix Routes", "FIB",
1997 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1998 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001999
2000 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2001 {
2002 if (rib_cnt[i] > 0)
2003 {
2004 if (i == ZEBRA_ROUTE_BGP)
2005 {
2006 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2007 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2008 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2009 VTY_NEWLINE);
2010 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2011 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2012 VTY_NEWLINE);
2013 }
2014 else
2015 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2016 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2017 }
2018 }
2019
2020 vty_out (vty, "------%s", VTY_NEWLINE);
2021 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2022 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002023 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002024}
2025
paul718e3742002-12-13 20:15:29 +00002026/* Show route summary. */
2027DEFUN (show_ip_route_summary,
2028 show_ip_route_summary_cmd,
2029 "show ip route summary",
2030 SHOW_STR
2031 IP_STR
2032 "IP routing table\n"
2033 "Summary of all routes\n")
2034{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002035 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002036 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002037
Feng Lu4364ee52015-05-22 11:40:03 +02002038 if (argc > 0)
2039 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2040
2041 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002042 if (! table)
2043 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002044
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002045 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002046
2047 return CMD_SUCCESS;
2048}
2049
Feng Lu4364ee52015-05-22 11:40:03 +02002050ALIAS (show_ip_route_summary,
2051 show_ip_route_summary_vrf_cmd,
2052 "show ip route summary " VRF_CMD_STR,
2053 SHOW_STR
2054 IP_STR
2055 "IP routing table\n"
2056 "Summary of all routes\n"
2057 VRF_CMD_HELP_STR)
2058
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002059/* Show route summary prefix. */
2060DEFUN (show_ip_route_summary_prefix,
2061 show_ip_route_summary_prefix_cmd,
2062 "show ip route summary prefix",
2063 SHOW_STR
2064 IP_STR
2065 "IP routing table\n"
2066 "Summary of all routes\n"
2067 "Prefix routes\n")
2068{
2069 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002070 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002071
Feng Lu4364ee52015-05-22 11:40:03 +02002072 if (argc > 0)
2073 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2074
2075 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002076 if (! table)
2077 return CMD_SUCCESS;
2078
2079 vty_show_ip_route_summary_prefix (vty, table);
2080
2081 return CMD_SUCCESS;
2082}
2083
Feng Lu4364ee52015-05-22 11:40:03 +02002084ALIAS (show_ip_route_summary_prefix,
2085 show_ip_route_summary_prefix_vrf_cmd,
2086 "show ip route summary prefix " VRF_CMD_STR,
2087 SHOW_STR
2088 IP_STR
2089 "IP routing table\n"
2090 "Summary of all routes\n"
2091 "Prefix routes\n"
2092 VRF_CMD_HELP_STR)
2093
2094DEFUN (show_ip_route_vrf_all,
2095 show_ip_route_vrf_all_cmd,
2096 "show ip route " VRF_ALL_CMD_STR,
2097 SHOW_STR
2098 IP_STR
2099 "IP routing table\n"
2100 VRF_ALL_CMD_HELP_STR)
2101{
2102 struct route_table *table;
2103 struct route_node *rn;
2104 struct rib *rib;
2105 struct zebra_vrf *zvrf;
2106 vrf_iter_t iter;
2107 int first = 1;
2108
2109 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2110 {
2111 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2112 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2113 continue;
2114
2115 /* Show all IPv4 routes. */
2116 for (rn = route_top (table); rn; rn = route_next (rn))
2117 RNODE_FOREACH_RIB (rn, rib)
2118 {
2119 if (first)
2120 {
2121 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2122 first = 0;
2123 }
2124 vty_show_ip_route (vty, rn, rib);
2125 }
2126 }
2127
2128 return CMD_SUCCESS;
2129}
2130
2131DEFUN (show_ip_route_prefix_longer_vrf_all,
2132 show_ip_route_prefix_longer_vrf_all_cmd,
2133 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2134 SHOW_STR
2135 IP_STR
2136 "IP routing table\n"
2137 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2138 "Show route matching the specified Network/Mask pair only\n"
2139 VRF_ALL_CMD_HELP_STR)
2140{
2141 struct route_table *table;
2142 struct route_node *rn;
2143 struct rib *rib;
2144 struct prefix p;
2145 struct zebra_vrf *zvrf;
2146 vrf_iter_t iter;
2147 int ret;
2148 int first = 1;
2149
2150 ret = str2prefix (argv[0], &p);
2151 if (! ret)
2152 {
2153 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2154 return CMD_WARNING;
2155 }
2156
2157 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2158 {
2159 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2160 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2161 continue;
2162
2163 /* Show matched type IPv4 routes. */
2164 for (rn = route_top (table); rn; rn = route_next (rn))
2165 RNODE_FOREACH_RIB (rn, rib)
2166 if (prefix_match (&p, &rn->p))
2167 {
2168 if (first)
2169 {
2170 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2171 first = 0;
2172 }
2173 vty_show_ip_route (vty, rn, rib);
2174 }
2175 }
2176
2177 return CMD_SUCCESS;
2178}
2179
2180DEFUN (show_ip_route_supernets_vrf_all,
2181 show_ip_route_supernets_vrf_all_cmd,
2182 "show ip route supernets-only " VRF_ALL_CMD_STR,
2183 SHOW_STR
2184 IP_STR
2185 "IP routing table\n"
2186 "Show supernet entries only\n"
2187 VRF_ALL_CMD_HELP_STR)
2188{
2189 struct route_table *table;
2190 struct route_node *rn;
2191 struct rib *rib;
2192 struct zebra_vrf *zvrf;
2193 vrf_iter_t iter;
2194 u_int32_t addr;
2195 int first = 1;
2196
2197 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2198 {
2199 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2200 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2201 continue;
2202
2203 /* Show matched type IPv4 routes. */
2204 for (rn = route_top (table); rn; rn = route_next (rn))
2205 RNODE_FOREACH_RIB (rn, rib)
2206 {
2207 addr = ntohl (rn->p.u.prefix4.s_addr);
2208
2209 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2210 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2211 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2212 {
2213 if (first)
2214 {
2215 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2216 first = 0;
2217 }
2218 vty_show_ip_route (vty, rn, rib);
2219 }
2220 }
2221 }
2222
2223 return CMD_SUCCESS;
2224}
2225
2226DEFUN (show_ip_route_protocol_vrf_all,
2227 show_ip_route_protocol_vrf_all_cmd,
2228 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2229 SHOW_STR
2230 IP_STR
2231 "IP routing table\n"
2232 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2233 VRF_ALL_CMD_HELP_STR)
2234{
2235 int type;
2236 struct route_table *table;
2237 struct route_node *rn;
2238 struct rib *rib;
2239 struct zebra_vrf *zvrf;
2240 vrf_iter_t iter;
2241 int first = 1;
2242
2243 type = proto_redistnum (AFI_IP, argv[0]);
2244 if (type < 0)
2245 {
2246 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2247 return CMD_WARNING;
2248 }
2249
2250 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2251 {
2252 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2253 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2254 continue;
2255
2256 /* Show matched type IPv4 routes. */
2257 for (rn = route_top (table); rn; rn = route_next (rn))
2258 RNODE_FOREACH_RIB (rn, rib)
2259 if (rib->type == type)
2260 {
2261 if (first)
2262 {
2263 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2264 first = 0;
2265 }
2266 vty_show_ip_route (vty, rn, rib);
2267 }
2268 }
2269
2270 return CMD_SUCCESS;
2271}
2272
2273DEFUN (show_ip_route_addr_vrf_all,
2274 show_ip_route_addr_vrf_all_cmd,
2275 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2276 SHOW_STR
2277 IP_STR
2278 "IP routing table\n"
2279 "Network in the IP routing table to display\n"
2280 VRF_ALL_CMD_HELP_STR)
2281{
2282 int ret;
2283 struct prefix_ipv4 p;
2284 struct route_table *table;
2285 struct route_node *rn;
2286 struct zebra_vrf *zvrf;
2287 vrf_iter_t iter;
2288
2289 ret = str2prefix_ipv4 (argv[0], &p);
2290 if (ret <= 0)
2291 {
2292 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2293 return CMD_WARNING;
2294 }
2295
2296 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2297 {
2298 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2299 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2300 continue;
2301
2302 rn = route_node_match (table, (struct prefix *) &p);
2303 if (! rn)
2304 continue;
2305
2306 vty_show_ip_route_detail (vty, rn, 0);
2307
2308 route_unlock_node (rn);
2309 }
2310
2311 return CMD_SUCCESS;
2312}
2313
2314DEFUN (show_ip_route_prefix_vrf_all,
2315 show_ip_route_prefix_vrf_all_cmd,
2316 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2317 SHOW_STR
2318 IP_STR
2319 "IP routing table\n"
2320 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2321 VRF_ALL_CMD_HELP_STR)
2322{
2323 int ret;
2324 struct prefix_ipv4 p;
2325 struct route_table *table;
2326 struct route_node *rn;
2327 struct zebra_vrf *zvrf;
2328 vrf_iter_t iter;
2329
2330 ret = str2prefix_ipv4 (argv[0], &p);
2331 if (ret <= 0)
2332 {
2333 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2334 return CMD_WARNING;
2335 }
2336
2337 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2338 {
2339 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2340 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2341 continue;
2342
2343 rn = route_node_match (table, (struct prefix *) &p);
2344 if (! rn)
2345 continue;
2346 if (rn->p.prefixlen != p.prefixlen)
2347 {
2348 route_unlock_node (rn);
2349 continue;
2350 }
2351
2352 vty_show_ip_route_detail (vty, rn, 0);
2353
2354 route_unlock_node (rn);
2355 }
2356
2357 return CMD_SUCCESS;
2358}
2359
2360DEFUN (show_ip_route_summary_vrf_all,
2361 show_ip_route_summary_vrf_all_cmd,
2362 "show ip route summary " VRF_ALL_CMD_STR,
2363 SHOW_STR
2364 IP_STR
2365 "IP routing table\n"
2366 "Summary of all routes\n"
2367 VRF_ALL_CMD_HELP_STR)
2368{
2369 struct zebra_vrf *zvrf;
2370 vrf_iter_t iter;
2371
2372 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2373 if ((zvrf = vrf_iter2info (iter)) != NULL)
2374 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2375
2376 return CMD_SUCCESS;
2377}
2378
2379DEFUN (show_ip_route_summary_prefix_vrf_all,
2380 show_ip_route_summary_prefix_vrf_all_cmd,
2381 "show ip route summary prefix " VRF_ALL_CMD_STR,
2382 SHOW_STR
2383 IP_STR
2384 "IP routing table\n"
2385 "Summary of all routes\n"
2386 "Prefix routes\n"
2387 VRF_ALL_CMD_HELP_STR)
2388{
2389 struct zebra_vrf *zvrf;
2390 vrf_iter_t iter;
2391
2392 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2393 if ((zvrf = vrf_iter2info (iter)) != NULL)
2394 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2395
2396 return CMD_SUCCESS;
2397}
2398
paul718e3742002-12-13 20:15:29 +00002399/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002400static int
Everton Marques33d86db2014-07-14 11:19:00 -03002401static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002402{
2403 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05002404 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00002405 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002406 struct zebra_vrf *zvrf;
2407 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002408 int write;
2409
2410 write = 0;
2411
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002412 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2413 {
2414 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2415 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2416 continue;
paul718e3742002-12-13 20:15:29 +00002417
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002418 for (rn = route_top (stable); rn; rn = route_next (rn))
2419 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002420 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002421 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2422 rn->p.prefixlen);
2423
2424 switch (si->type)
2425 {
2426 case STATIC_IPV4_GATEWAY:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002427 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002428 break;
2429 case STATIC_IPV4_IFNAME:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002430 vty_out (vty, " %s", si->ifname);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002431 break;
2432 case STATIC_IPV4_BLACKHOLE:
2433 vty_out (vty, " Null0");
2434 break;
2435 }
2436
2437 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2438 if (si->type != STATIC_IPV4_BLACKHOLE)
2439 {
2440 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2441 vty_out (vty, " %s", "reject");
2442
2443 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2444 vty_out (vty, " %s", "blackhole");
2445 }
2446
2447 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2448 vty_out (vty, " %d", si->distance);
2449
2450 if (si->vrf_id != VRF_DEFAULT)
2451 vty_out (vty, " vrf %u", si->vrf_id);
2452
2453 vty_out (vty, "%s", VTY_NEWLINE);
2454
2455 write = 1;
paul7021c422003-07-15 12:52:22 +00002456 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002457 }
paul718e3742002-12-13 20:15:29 +00002458 return write;
2459}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002460
2461DEFUN (show_ip_protocol,
2462 show_ip_protocol_cmd,
2463 "show ip protocol",
2464 SHOW_STR
2465 IP_STR
2466 "IP protocol filtering status\n")
2467{
2468 int i;
2469
2470 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2471 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2472 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2473 {
2474 if (proto_rm[AFI_IP][i])
2475 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2476 proto_rm[AFI_IP][i],
2477 VTY_NEWLINE);
2478 else
2479 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2480 }
2481 if (proto_rm[AFI_IP][i])
2482 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2483 VTY_NEWLINE);
2484 else
2485 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2486
2487 return CMD_SUCCESS;
2488}
2489
paul718e3742002-12-13 20:15:29 +00002490#ifdef HAVE_IPV6
2491/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002492static int
hasso39db97e2004-10-12 20:50:58 +00002493static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2494 const char *gate_str, const char *ifname,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002495 const char *flag_str, const char *distance_str,
2496 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002497{
2498 int ret;
2499 u_char distance;
2500 struct prefix p;
2501 struct in6_addr *gate = NULL;
2502 struct in6_addr gate_addr;
2503 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002504 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002505 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00002506
2507 ret = str2prefix (dest_str, &p);
2508 if (ret <= 0)
2509 {
2510 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2511 return CMD_WARNING;
2512 }
2513
2514 /* Apply mask for given prefix. */
2515 apply_mask (&p);
2516
hasso81dfcaa2003-05-25 19:21:25 +00002517 /* Route flags */
2518 if (flag_str) {
2519 switch(flag_str[0]) {
2520 case 'r':
2521 case 'R': /* XXX */
2522 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2523 break;
2524 case 'b':
2525 case 'B': /* XXX */
2526 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2527 break;
2528 default:
2529 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002530 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002531 }
2532 }
2533
paul718e3742002-12-13 20:15:29 +00002534 /* Administrative distance. */
2535 if (distance_str)
2536 distance = atoi (distance_str);
2537 else
2538 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2539
2540 /* When gateway is valid IPv6 addrees, then gate is treated as
2541 nexthop address other case gate is treated as interface name. */
2542 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2543
2544 if (ifname)
2545 {
2546 /* When ifname is specified. It must be come with gateway
2547 address. */
2548 if (ret != 1)
2549 {
2550 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2551 return CMD_WARNING;
2552 }
2553 type = STATIC_IPV6_GATEWAY_IFNAME;
2554 gate = &gate_addr;
2555 }
2556 else
2557 {
2558 if (ret == 1)
2559 {
2560 type = STATIC_IPV6_GATEWAY;
2561 gate = &gate_addr;
2562 }
2563 else
2564 {
2565 type = STATIC_IPV6_IFNAME;
2566 ifname = gate_str;
2567 }
2568 }
2569
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002570 /* VRF id */
2571 if (vrf_id_str)
2572 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2573
paul718e3742002-12-13 20:15:29 +00002574 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002575 static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002576 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002577 static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002578
2579 return CMD_SUCCESS;
2580}
2581
2582DEFUN (ipv6_route,
2583 ipv6_route_cmd,
2584 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2585 IP_STR
2586 "Establish static routes\n"
2587 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2588 "IPv6 gateway address\n"
2589 "IPv6 gateway interface name\n")
2590{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002591 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2592 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002593}
2594
2595DEFUN (ipv6_route_flags,
2596 ipv6_route_flags_cmd,
2597 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2598 IP_STR
2599 "Establish static routes\n"
2600 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2601 "IPv6 gateway address\n"
2602 "IPv6 gateway interface name\n"
2603 "Emit an ICMP unreachable when matched\n"
2604 "Silently discard pkts when matched\n")
2605{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002606 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2607 NULL);
paul718e3742002-12-13 20:15:29 +00002608}
2609
2610DEFUN (ipv6_route_ifname,
2611 ipv6_route_ifname_cmd,
2612 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2613 IP_STR
2614 "Establish static routes\n"
2615 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2616 "IPv6 gateway address\n"
2617 "IPv6 gateway interface name\n")
2618{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002619 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2620 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002621}
2622
2623DEFUN (ipv6_route_ifname_flags,
2624 ipv6_route_ifname_flags_cmd,
2625 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2626 IP_STR
2627 "Establish static routes\n"
2628 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2629 "IPv6 gateway address\n"
2630 "IPv6 gateway interface name\n"
2631 "Emit an ICMP unreachable when matched\n"
2632 "Silently discard pkts when matched\n")
2633{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002634 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2635 NULL);
paul718e3742002-12-13 20:15:29 +00002636}
2637
2638DEFUN (ipv6_route_pref,
2639 ipv6_route_pref_cmd,
2640 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2641 IP_STR
2642 "Establish static routes\n"
2643 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2644 "IPv6 gateway address\n"
2645 "IPv6 gateway interface name\n"
2646 "Distance value for this prefix\n")
2647{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002648 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2649 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002650}
2651
2652DEFUN (ipv6_route_flags_pref,
2653 ipv6_route_flags_pref_cmd,
2654 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2655 IP_STR
2656 "Establish static routes\n"
2657 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2658 "IPv6 gateway address\n"
2659 "IPv6 gateway interface name\n"
2660 "Emit an ICMP unreachable when matched\n"
2661 "Silently discard pkts when matched\n"
2662 "Distance value for this prefix\n")
2663{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002664 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2665 NULL);
paul718e3742002-12-13 20:15:29 +00002666}
2667
2668DEFUN (ipv6_route_ifname_pref,
2669 ipv6_route_ifname_pref_cmd,
2670 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2671 IP_STR
2672 "Establish static routes\n"
2673 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2674 "IPv6 gateway address\n"
2675 "IPv6 gateway interface name\n"
2676 "Distance value for this prefix\n")
2677{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002678 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2679 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002680}
2681
2682DEFUN (ipv6_route_ifname_flags_pref,
2683 ipv6_route_ifname_flags_pref_cmd,
2684 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2685 IP_STR
2686 "Establish static routes\n"
2687 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2688 "IPv6 gateway address\n"
2689 "IPv6 gateway interface name\n"
2690 "Emit an ICMP unreachable when matched\n"
2691 "Silently discard pkts when matched\n"
2692 "Distance value for this prefix\n")
2693{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002694 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2695 NULL);
paul718e3742002-12-13 20:15:29 +00002696}
2697
2698DEFUN (no_ipv6_route,
2699 no_ipv6_route_cmd,
2700 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2701 NO_STR
2702 IP_STR
2703 "Establish static routes\n"
2704 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2705 "IPv6 gateway address\n"
2706 "IPv6 gateway interface name\n")
2707{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002708 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2709 NULL);
paul718e3742002-12-13 20:15:29 +00002710}
2711
hasso81dfcaa2003-05-25 19:21:25 +00002712ALIAS (no_ipv6_route,
2713 no_ipv6_route_flags_cmd,
2714 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2715 NO_STR
2716 IP_STR
2717 "Establish static routes\n"
2718 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2719 "IPv6 gateway address\n"
2720 "IPv6 gateway interface name\n"
2721 "Emit an ICMP unreachable when matched\n"
2722 "Silently discard pkts when matched\n")
2723
paul718e3742002-12-13 20:15:29 +00002724DEFUN (no_ipv6_route_ifname,
2725 no_ipv6_route_ifname_cmd,
2726 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2727 NO_STR
2728 IP_STR
2729 "Establish static routes\n"
2730 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2731 "IPv6 gateway address\n"
2732 "IPv6 gateway interface name\n")
2733{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002734 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2735 NULL);
paul718e3742002-12-13 20:15:29 +00002736}
2737
hasso81dfcaa2003-05-25 19:21:25 +00002738ALIAS (no_ipv6_route_ifname,
2739 no_ipv6_route_ifname_flags_cmd,
2740 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2741 NO_STR
2742 IP_STR
2743 "Establish static routes\n"
2744 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2745 "IPv6 gateway address\n"
2746 "IPv6 gateway interface name\n"
2747 "Emit an ICMP unreachable when matched\n"
2748 "Silently discard pkts when matched\n")
2749
paul718e3742002-12-13 20:15:29 +00002750DEFUN (no_ipv6_route_pref,
2751 no_ipv6_route_pref_cmd,
2752 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2753 NO_STR
2754 IP_STR
2755 "Establish static routes\n"
2756 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2757 "IPv6 gateway address\n"
2758 "IPv6 gateway interface name\n"
2759 "Distance value for this prefix\n")
2760{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002761 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
2762 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002763}
2764
2765DEFUN (no_ipv6_route_flags_pref,
2766 no_ipv6_route_flags_pref_cmd,
2767 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2768 NO_STR
2769 IP_STR
2770 "Establish static routes\n"
2771 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2772 "IPv6 gateway address\n"
2773 "IPv6 gateway interface name\n"
2774 "Emit an ICMP unreachable when matched\n"
2775 "Silently discard pkts when matched\n"
2776 "Distance value for this prefix\n")
2777{
2778 /* We do not care about argv[2] */
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002779 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
2780 NULL);
paul718e3742002-12-13 20:15:29 +00002781}
2782
2783DEFUN (no_ipv6_route_ifname_pref,
2784 no_ipv6_route_ifname_pref_cmd,
2785 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2786 NO_STR
2787 IP_STR
2788 "Establish static routes\n"
2789 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2790 "IPv6 gateway address\n"
2791 "IPv6 gateway interface name\n"
2792 "Distance value for this prefix\n")
2793{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002794 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
2795 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002796}
2797
2798DEFUN (no_ipv6_route_ifname_flags_pref,
2799 no_ipv6_route_ifname_flags_pref_cmd,
2800 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2801 NO_STR
2802 IP_STR
2803 "Establish static routes\n"
2804 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2805 "IPv6 gateway address\n"
2806 "IPv6 gateway interface name\n"
2807 "Emit an ICMP unreachable when matched\n"
2808 "Silently discard pkts when matched\n"
2809 "Distance value for this prefix\n")
2810{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002811 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
2812 NULL);
2813}
2814
2815DEFUN (ipv6_route_vrf,
2816 ipv6_route_vrf_cmd,
2817 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2818 IP_STR
2819 "Establish static routes\n"
2820 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2821 "IPv6 gateway address\n"
2822 "IPv6 gateway interface name\n"
2823 VRF_CMD_HELP_STR)
2824{
2825 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2826 argv[2]);
2827}
2828
2829DEFUN (ipv6_route_flags_vrf,
2830 ipv6_route_flags_vrf_cmd,
2831 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2832 IP_STR
2833 "Establish static routes\n"
2834 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2835 "IPv6 gateway address\n"
2836 "IPv6 gateway interface name\n"
2837 "Emit an ICMP unreachable when matched\n"
2838 "Silently discard pkts when matched\n"
2839 VRF_CMD_HELP_STR)
2840{
2841 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2842 argv[3]);
2843}
2844
2845DEFUN (ipv6_route_ifname_vrf,
2846 ipv6_route_ifname_vrf_cmd,
2847 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2848 IP_STR
2849 "Establish static routes\n"
2850 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2851 "IPv6 gateway address\n"
2852 "IPv6 gateway interface name\n"
2853 VRF_CMD_HELP_STR)
2854{
2855 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2856 argv[3]);
2857}
2858
2859DEFUN (ipv6_route_ifname_flags_vrf,
2860 ipv6_route_ifname_flags_vrf_cmd,
2861 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2862 IP_STR
2863 "Establish static routes\n"
2864 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2865 "IPv6 gateway address\n"
2866 "IPv6 gateway interface name\n"
2867 "Emit an ICMP unreachable when matched\n"
2868 "Silently discard pkts when matched\n"
2869 VRF_CMD_HELP_STR)
2870{
2871 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2872 argv[4]);
2873}
2874
2875DEFUN (ipv6_route_pref_vrf,
2876 ipv6_route_pref_vrf_cmd,
2877 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2878 IP_STR
2879 "Establish static routes\n"
2880 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2881 "IPv6 gateway address\n"
2882 "IPv6 gateway interface name\n"
2883 "Distance value for this prefix\n"
2884 VRF_CMD_HELP_STR)
2885{
2886 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2887 argv[3]);
2888}
2889
2890DEFUN (ipv6_route_flags_pref_vrf,
2891 ipv6_route_flags_pref_vrf_cmd,
2892 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2893 IP_STR
2894 "Establish static routes\n"
2895 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2896 "IPv6 gateway address\n"
2897 "IPv6 gateway interface name\n"
2898 "Emit an ICMP unreachable when matched\n"
2899 "Silently discard pkts when matched\n"
2900 "Distance value for this prefix\n"
2901 VRF_CMD_HELP_STR)
2902{
2903 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2904 argv[4]);
2905}
2906
2907DEFUN (ipv6_route_ifname_pref_vrf,
2908 ipv6_route_ifname_pref_vrf_cmd,
2909 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2910 IP_STR
2911 "Establish static routes\n"
2912 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2913 "IPv6 gateway address\n"
2914 "IPv6 gateway interface name\n"
2915 "Distance value for this prefix\n"
2916 VRF_CMD_HELP_STR)
2917{
2918 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2919 argv[4]);
2920}
2921
2922DEFUN (ipv6_route_ifname_flags_pref_vrf,
2923 ipv6_route_ifname_flags_pref_vrf_cmd,
2924 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
2925 IP_STR
2926 "Establish static routes\n"
2927 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2928 "IPv6 gateway address\n"
2929 "IPv6 gateway interface name\n"
2930 "Emit an ICMP unreachable when matched\n"
2931 "Silently discard pkts when matched\n"
2932 "Distance value for this prefix\n"
2933 VRF_CMD_HELP_STR)
2934{
2935 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2936 argv[5]);
2937}
2938
2939DEFUN (no_ipv6_route_vrf,
2940 no_ipv6_route_vrf_cmd,
2941 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2942 NO_STR
2943 IP_STR
2944 "Establish static routes\n"
2945 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2946 "IPv6 gateway address\n"
2947 "IPv6 gateway interface name\n"
2948 VRF_CMD_HELP_STR)
2949{
2950 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2951 (argc > 3) ? argv[3] : argv[2]);
2952}
2953
2954ALIAS (no_ipv6_route_vrf,
2955 no_ipv6_route_flags_vrf_cmd,
2956 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2957 NO_STR
2958 IP_STR
2959 "Establish static routes\n"
2960 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2961 "IPv6 gateway address\n"
2962 "IPv6 gateway interface name\n"
2963 "Emit an ICMP unreachable when matched\n"
2964 "Silently discard pkts when matched\n"
2965 VRF_CMD_HELP_STR)
2966
2967DEFUN (no_ipv6_route_ifname_vrf,
2968 no_ipv6_route_ifname_vrf_cmd,
2969 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2970 NO_STR
2971 IP_STR
2972 "Establish static routes\n"
2973 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2974 "IPv6 gateway address\n"
2975 "IPv6 gateway interface name\n"
2976 VRF_CMD_HELP_STR)
2977{
2978 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2979 (argc > 4) ? argv[4] : argv[3]);
2980}
2981
2982ALIAS (no_ipv6_route_ifname_vrf,
2983 no_ipv6_route_ifname_flags_vrf_cmd,
2984 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2985 NO_STR
2986 IP_STR
2987 "Establish static routes\n"
2988 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2989 "IPv6 gateway address\n"
2990 "IPv6 gateway interface name\n"
2991 "Emit an ICMP unreachable when matched\n"
2992 "Silently discard pkts when matched\n"
2993 VRF_CMD_HELP_STR)
2994
2995DEFUN (no_ipv6_route_pref_vrf,
2996 no_ipv6_route_pref_vrf_cmd,
2997 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2998 NO_STR
2999 IP_STR
3000 "Establish static routes\n"
3001 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3002 "IPv6 gateway address\n"
3003 "IPv6 gateway interface name\n"
3004 "Distance value for this prefix\n"
3005 VRF_CMD_HELP_STR)
3006{
3007 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
3008 argv[3]);
3009}
3010
3011DEFUN (no_ipv6_route_flags_pref_vrf,
3012 no_ipv6_route_flags_pref_vrf_cmd,
3013 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3014 NO_STR
3015 IP_STR
3016 "Establish static routes\n"
3017 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3018 "IPv6 gateway address\n"
3019 "IPv6 gateway interface name\n"
3020 "Emit an ICMP unreachable when matched\n"
3021 "Silently discard pkts when matched\n"
3022 "Distance value for this prefix\n"
3023 VRF_CMD_HELP_STR)
3024{
3025 /* We do not care about argv[2] */
3026 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
3027 argv[4]);
3028}
3029
3030DEFUN (no_ipv6_route_ifname_pref_vrf,
3031 no_ipv6_route_ifname_pref_vrf_cmd,
3032 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3033 NO_STR
3034 IP_STR
3035 "Establish static routes\n"
3036 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3037 "IPv6 gateway address\n"
3038 "IPv6 gateway interface name\n"
3039 "Distance value for this prefix\n"
3040 VRF_CMD_HELP_STR)
3041{
3042 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
3043 argv[4]);
3044}
3045
3046DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3047 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3048 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3049 NO_STR
3050 IP_STR
3051 "Establish static routes\n"
3052 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3053 "IPv6 gateway address\n"
3054 "IPv6 gateway interface name\n"
3055 "Emit an ICMP unreachable when matched\n"
3056 "Silently discard pkts when matched\n"
3057 "Distance value for this prefix\n"
3058 VRF_CMD_HELP_STR)
3059{
3060 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
3061 argv[5]);
paul718e3742002-12-13 20:15:29 +00003062}
3063
paul718e3742002-12-13 20:15:29 +00003064DEFUN (show_ipv6_route,
3065 show_ipv6_route_cmd,
3066 "show ipv6 route",
3067 SHOW_STR
3068 IP_STR
3069 "IPv6 routing table\n")
3070{
3071 struct route_table *table;
3072 struct route_node *rn;
3073 struct rib *rib;
3074 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003075 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003076
Feng Lu4364ee52015-05-22 11:40:03 +02003077 if (argc > 0)
3078 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3079
3080 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003081 if (! table)
3082 return CMD_SUCCESS;
3083
3084 /* Show all IPv6 route. */
3085 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003086 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003087 {
3088 if (first)
3089 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003090 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003091 first = 0;
3092 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003093 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003094 }
3095 return CMD_SUCCESS;
3096}
3097
Feng Lu4364ee52015-05-22 11:40:03 +02003098ALIAS (show_ipv6_route,
3099 show_ipv6_route_vrf_cmd,
3100 "show ipv6 route " VRF_CMD_STR,
3101 SHOW_STR
3102 IP_STR
3103 "IPv6 routing table\n"
3104 VRF_CMD_HELP_STR)
3105
paul718e3742002-12-13 20:15:29 +00003106DEFUN (show_ipv6_route_prefix_longer,
3107 show_ipv6_route_prefix_longer_cmd,
3108 "show ipv6 route X:X::X:X/M longer-prefixes",
3109 SHOW_STR
3110 IP_STR
3111 "IPv6 routing table\n"
3112 "IPv6 prefix\n"
3113 "Show route matching the specified Network/Mask pair only\n")
3114{
3115 struct route_table *table;
3116 struct route_node *rn;
3117 struct rib *rib;
3118 struct prefix p;
3119 int ret;
3120 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003121 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003122
3123 ret = str2prefix (argv[0], &p);
3124 if (! ret)
3125 {
3126 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3127 return CMD_WARNING;
3128 }
3129
Feng Lu4364ee52015-05-22 11:40:03 +02003130 if (argc > 1)
3131 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3132
3133 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3134 if (! table)
3135 return CMD_SUCCESS;
3136
paul718e3742002-12-13 20:15:29 +00003137 /* Show matched type IPv6 routes. */
3138 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003139 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003140 if (prefix_match (&p, &rn->p))
3141 {
3142 if (first)
3143 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003144 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003145 first = 0;
3146 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003147 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003148 }
3149 return CMD_SUCCESS;
3150}
3151
Feng Lu4364ee52015-05-22 11:40:03 +02003152ALIAS (show_ipv6_route_prefix_longer,
3153 show_ipv6_route_prefix_longer_vrf_cmd,
3154 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3155 SHOW_STR
3156 IP_STR
3157 "IPv6 routing table\n"
3158 "IPv6 prefix\n"
3159 "Show route matching the specified Network/Mask pair only\n"
3160 VRF_CMD_HELP_STR)
3161
paul718e3742002-12-13 20:15:29 +00003162DEFUN (show_ipv6_route_protocol,
3163 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003164 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003165 SHOW_STR
3166 IP_STR
3167 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003168 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003169{
3170 int type;
3171 struct route_table *table;
3172 struct route_node *rn;
3173 struct rib *rib;
3174 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003175 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003176
David Lampartere0ca5fd2009-09-16 01:52:42 +02003177 type = proto_redistnum (AFI_IP6, argv[0]);
3178 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003179 {
3180 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3181 return CMD_WARNING;
3182 }
Feng Lu4364ee52015-05-22 11:40:03 +02003183
3184 if (argc > 1)
3185 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3186
3187 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003188 if (! table)
3189 return CMD_SUCCESS;
3190
3191 /* Show matched type IPv6 routes. */
3192 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003193 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003194 if (rib->type == type)
3195 {
3196 if (first)
3197 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003198 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003199 first = 0;
3200 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003201 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003202 }
3203 return CMD_SUCCESS;
3204}
3205
Feng Lu4364ee52015-05-22 11:40:03 +02003206ALIAS (show_ipv6_route_protocol,
3207 show_ipv6_route_protocol_vrf_cmd,
3208 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3209 SHOW_STR
3210 IP_STR
3211 "IP routing table\n"
3212 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3213 VRF_CMD_HELP_STR)
3214
paul718e3742002-12-13 20:15:29 +00003215DEFUN (show_ipv6_route_addr,
3216 show_ipv6_route_addr_cmd,
3217 "show ipv6 route X:X::X:X",
3218 SHOW_STR
3219 IP_STR
3220 "IPv6 routing table\n"
3221 "IPv6 Address\n")
3222{
3223 int ret;
3224 struct prefix_ipv6 p;
3225 struct route_table *table;
3226 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003227 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003228
3229 ret = str2prefix_ipv6 (argv[0], &p);
3230 if (ret <= 0)
3231 {
3232 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3233 return CMD_WARNING;
3234 }
3235
Feng Lu4364ee52015-05-22 11:40:03 +02003236 if (argc > 1)
3237 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3238
3239 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003240 if (! table)
3241 return CMD_SUCCESS;
3242
3243 rn = route_node_match (table, (struct prefix *) &p);
3244 if (! rn)
3245 {
3246 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3247 return CMD_WARNING;
3248 }
3249
Timo Teräs53a5c392015-05-23 11:08:40 +03003250 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003251
3252 route_unlock_node (rn);
3253
3254 return CMD_SUCCESS;
3255}
3256
Feng Lu4364ee52015-05-22 11:40:03 +02003257ALIAS (show_ipv6_route_addr,
3258 show_ipv6_route_addr_vrf_cmd,
3259 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3260 SHOW_STR
3261 IP_STR
3262 "IPv6 routing table\n"
3263 "IPv6 Address\n"
3264 VRF_CMD_HELP_STR)
3265
paul718e3742002-12-13 20:15:29 +00003266DEFUN (show_ipv6_route_prefix,
3267 show_ipv6_route_prefix_cmd,
3268 "show ipv6 route X:X::X:X/M",
3269 SHOW_STR
3270 IP_STR
3271 "IPv6 routing table\n"
3272 "IPv6 prefix\n")
3273{
3274 int ret;
3275 struct prefix_ipv6 p;
3276 struct route_table *table;
3277 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003278 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003279
3280 ret = str2prefix_ipv6 (argv[0], &p);
3281 if (ret <= 0)
3282 {
3283 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3284 return CMD_WARNING;
3285 }
3286
Feng Lu4364ee52015-05-22 11:40:03 +02003287 if (argc > 1)
3288 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3289
3290 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003291 if (! table)
3292 return CMD_SUCCESS;
3293
3294 rn = route_node_match (table, (struct prefix *) &p);
3295 if (! rn || rn->p.prefixlen != p.prefixlen)
3296 {
3297 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003298 if (rn)
3299 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003300 return CMD_WARNING;
3301 }
3302
Timo Teräs53a5c392015-05-23 11:08:40 +03003303 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003304
3305 route_unlock_node (rn);
3306
3307 return CMD_SUCCESS;
3308}
3309
Feng Lu4364ee52015-05-22 11:40:03 +02003310ALIAS (show_ipv6_route_prefix,
3311 show_ipv6_route_prefix_vrf_cmd,
3312 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3313 SHOW_STR
3314 IP_STR
3315 "IPv6 routing table\n"
3316 "IPv6 prefix\n"
3317 VRF_CMD_HELP_STR)
3318
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003319/* Show route summary. */
3320DEFUN (show_ipv6_route_summary,
3321 show_ipv6_route_summary_cmd,
3322 "show ipv6 route summary",
3323 SHOW_STR
3324 IP_STR
3325 "IPv6 routing table\n"
3326 "Summary of all IPv6 routes\n")
3327{
3328 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003329 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003330
Feng Lu4364ee52015-05-22 11:40:03 +02003331 if (argc > 0)
3332 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3333
3334 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003335 if (! table)
3336 return CMD_SUCCESS;
3337
3338 vty_show_ip_route_summary (vty, table);
3339
3340 return CMD_SUCCESS;
3341}
3342
Feng Lu4364ee52015-05-22 11:40:03 +02003343ALIAS (show_ipv6_route_summary,
3344 show_ipv6_route_summary_vrf_cmd,
3345 "show ipv6 route summary " VRF_CMD_STR,
3346 SHOW_STR
3347 IP_STR
3348 "IPv6 routing table\n"
3349 "Summary of all IPv6 routes\n"
3350 VRF_CMD_HELP_STR)
3351
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003352/* Show ipv6 route summary prefix. */
3353DEFUN (show_ipv6_route_summary_prefix,
3354 show_ipv6_route_summary_prefix_cmd,
3355 "show ipv6 route summary prefix",
3356 SHOW_STR
3357 IP_STR
3358 "IPv6 routing table\n"
3359 "Summary of all IPv6 routes\n"
3360 "Prefix routes\n")
3361{
3362 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003363 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003364
Feng Lu4364ee52015-05-22 11:40:03 +02003365 if (argc > 0)
3366 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3367
3368 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003369 if (! table)
3370 return CMD_SUCCESS;
3371
3372 vty_show_ip_route_summary_prefix (vty, table);
3373
3374 return CMD_SUCCESS;
3375}
3376
Feng Lu4364ee52015-05-22 11:40:03 +02003377ALIAS (show_ipv6_route_summary_prefix,
3378 show_ipv6_route_summary_prefix_vrf_cmd,
3379 "show ipv6 route summary prefix " VRF_CMD_STR,
3380 SHOW_STR
3381 IP_STR
3382 "IPv6 routing table\n"
3383 "Summary of all IPv6 routes\n"
3384 "Prefix routes\n"
3385 VRF_CMD_HELP_STR)
3386
G.Balajicddf3912011-11-26 21:59:32 +04003387/*
G.Balajicddf3912011-11-26 21:59:32 +04003388 * Show IPv6 mroute command.Used to dump
3389 * the Multicast routing table.
3390 */
3391
3392DEFUN (show_ipv6_mroute,
3393 show_ipv6_mroute_cmd,
3394 "show ipv6 mroute",
3395 SHOW_STR
3396 IP_STR
3397 "IPv6 Multicast routing table\n")
3398{
3399 struct route_table *table;
3400 struct route_node *rn;
3401 struct rib *rib;
3402 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003403 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003404
Feng Lu4364ee52015-05-22 11:40:03 +02003405 if (argc > 0)
3406 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3407
3408 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003409 if (! table)
3410 return CMD_SUCCESS;
3411
3412 /* Show all IPv6 route. */
3413 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003414 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003415 {
3416 if (first)
3417 {
G.Balajicb32fd62011-11-27 20:09:40 +05303418 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003419 first = 0;
3420 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003421 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003422 }
3423 return CMD_SUCCESS;
3424}
3425
Feng Lu4364ee52015-05-22 11:40:03 +02003426ALIAS (show_ipv6_mroute,
3427 show_ipv6_mroute_vrf_cmd,
3428 "show ipv6 mroute " VRF_CMD_STR,
3429 SHOW_STR
3430 IP_STR
3431 "IPv6 Multicast routing table\n"
3432 VRF_CMD_HELP_STR)
3433
3434DEFUN (show_ipv6_route_vrf_all,
3435 show_ipv6_route_vrf_all_cmd,
3436 "show ipv6 route " VRF_ALL_CMD_STR,
3437 SHOW_STR
3438 IP_STR
3439 "IPv6 routing table\n"
3440 VRF_ALL_CMD_HELP_STR)
3441{
3442 struct route_table *table;
3443 struct route_node *rn;
3444 struct rib *rib;
3445 struct zebra_vrf *zvrf;
3446 vrf_iter_t iter;
3447 int first = 1;
3448
3449 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3450 {
3451 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3452 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3453 continue;
3454
3455 /* Show all IPv6 route. */
3456 for (rn = route_top (table); rn; rn = route_next (rn))
3457 RNODE_FOREACH_RIB (rn, rib)
3458 {
3459 if (first)
3460 {
3461 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3462 first = 0;
3463 }
3464 vty_show_ip_route (vty, rn, rib);
3465 }
3466 }
3467
3468 return CMD_SUCCESS;
3469}
3470
3471DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3472 show_ipv6_route_prefix_longer_vrf_all_cmd,
3473 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3474 SHOW_STR
3475 IP_STR
3476 "IPv6 routing table\n"
3477 "IPv6 prefix\n"
3478 "Show route matching the specified Network/Mask pair only\n"
3479 VRF_ALL_CMD_HELP_STR)
3480{
3481 struct route_table *table;
3482 struct route_node *rn;
3483 struct rib *rib;
3484 struct prefix p;
3485 struct zebra_vrf *zvrf;
3486 vrf_iter_t iter;
3487 int ret;
3488 int first = 1;
3489
3490 ret = str2prefix (argv[0], &p);
3491 if (! ret)
3492 {
3493 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3494 return CMD_WARNING;
3495 }
3496
3497 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3498 {
3499 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3500 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3501 continue;
3502
3503 /* Show matched type IPv6 routes. */
3504 for (rn = route_top (table); rn; rn = route_next (rn))
3505 RNODE_FOREACH_RIB (rn, rib)
3506 if (prefix_match (&p, &rn->p))
3507 {
3508 if (first)
3509 {
3510 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3511 first = 0;
3512 }
3513 vty_show_ip_route (vty, rn, rib);
3514 }
3515 }
3516
3517 return CMD_SUCCESS;
3518}
3519
3520DEFUN (show_ipv6_route_protocol_vrf_all,
3521 show_ipv6_route_protocol_vrf_all_cmd,
3522 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3523 SHOW_STR
3524 IP_STR
3525 "IP routing table\n"
3526 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3527 VRF_ALL_CMD_HELP_STR)
3528{
3529 int type;
3530 struct route_table *table;
3531 struct route_node *rn;
3532 struct rib *rib;
3533 struct zebra_vrf *zvrf;
3534 vrf_iter_t iter;
3535 int first = 1;
3536
3537 type = proto_redistnum (AFI_IP6, argv[0]);
3538 if (type < 0)
3539 {
3540 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3541 return CMD_WARNING;
3542 }
3543
3544 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3545 {
3546 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3547 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3548 continue;
3549
3550 /* Show matched type IPv6 routes. */
3551 for (rn = route_top (table); rn; rn = route_next (rn))
3552 RNODE_FOREACH_RIB (rn, rib)
3553 if (rib->type == type)
3554 {
3555 if (first)
3556 {
3557 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3558 first = 0;
3559 }
3560 vty_show_ip_route (vty, rn, rib);
3561 }
3562 }
3563
3564 return CMD_SUCCESS;
3565}
3566
3567DEFUN (show_ipv6_route_addr_vrf_all,
3568 show_ipv6_route_addr_vrf_all_cmd,
3569 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3570 SHOW_STR
3571 IP_STR
3572 "IPv6 routing table\n"
3573 "IPv6 Address\n"
3574 VRF_ALL_CMD_HELP_STR)
3575{
3576 int ret;
3577 struct prefix_ipv6 p;
3578 struct route_table *table;
3579 struct route_node *rn;
3580 struct zebra_vrf *zvrf;
3581 vrf_iter_t iter;
3582
3583 ret = str2prefix_ipv6 (argv[0], &p);
3584 if (ret <= 0)
3585 {
3586 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3587 return CMD_WARNING;
3588 }
3589
3590 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3591 {
3592 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3593 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3594 continue;
3595
3596 rn = route_node_match (table, (struct prefix *) &p);
3597 if (! rn)
3598 continue;
3599
3600 vty_show_ip_route_detail (vty, rn, 0);
3601
3602 route_unlock_node (rn);
3603 }
3604
3605 return CMD_SUCCESS;
3606}
3607
3608DEFUN (show_ipv6_route_prefix_vrf_all,
3609 show_ipv6_route_prefix_vrf_all_cmd,
3610 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3611 SHOW_STR
3612 IP_STR
3613 "IPv6 routing table\n"
3614 "IPv6 prefix\n"
3615 VRF_ALL_CMD_HELP_STR)
3616{
3617 int ret;
3618 struct prefix_ipv6 p;
3619 struct route_table *table;
3620 struct route_node *rn;
3621 struct zebra_vrf *zvrf;
3622 vrf_iter_t iter;
3623
3624 ret = str2prefix_ipv6 (argv[0], &p);
3625 if (ret <= 0)
3626 {
3627 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3628 return CMD_WARNING;
3629 }
3630
3631 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3632 {
3633 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3634 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3635 continue;
3636
3637 rn = route_node_match (table, (struct prefix *) &p);
3638 if (! rn)
3639 continue;
3640 if (rn->p.prefixlen != p.prefixlen)
3641 {
3642 route_unlock_node (rn);
3643 continue;
3644 }
3645
3646 vty_show_ip_route_detail (vty, rn, 0);
3647
3648 route_unlock_node (rn);
3649 }
3650
3651 return CMD_SUCCESS;
3652}
3653
3654/* Show route summary. */
3655DEFUN (show_ipv6_route_summary_vrf_all,
3656 show_ipv6_route_summary_vrf_all_cmd,
3657 "show ipv6 route summary " VRF_ALL_CMD_STR,
3658 SHOW_STR
3659 IP_STR
3660 "IPv6 routing table\n"
3661 "Summary of all IPv6 routes\n"
3662 VRF_ALL_CMD_HELP_STR)
3663{
3664 struct zebra_vrf *zvrf;
3665 vrf_iter_t iter;
3666
3667 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3668 if ((zvrf = vrf_iter2info (iter)) != NULL)
3669 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3670
3671 return CMD_SUCCESS;
3672}
3673
3674DEFUN (show_ipv6_mroute_vrf_all,
3675 show_ipv6_mroute_vrf_all_cmd,
3676 "show ipv6 mroute " VRF_ALL_CMD_STR,
3677 SHOW_STR
3678 IP_STR
3679 "IPv6 Multicast routing table\n"
3680 VRF_ALL_CMD_HELP_STR)
3681{
3682 struct route_table *table;
3683 struct route_node *rn;
3684 struct rib *rib;
3685 struct zebra_vrf *zvrf;
3686 vrf_iter_t iter;
3687 int first = 1;
3688
3689 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3690 {
3691 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3692 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3693 continue;
3694
3695 /* Show all IPv6 route. */
3696 for (rn = route_top (table); rn; rn = route_next (rn))
3697 RNODE_FOREACH_RIB (rn, rib)
3698 {
3699 if (first)
3700 {
3701 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3702 first = 0;
3703 }
3704 vty_show_ip_route (vty, rn, rib);
3705 }
3706 }
3707 return CMD_SUCCESS;
3708}
3709
3710DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3711 show_ipv6_route_summary_prefix_vrf_all_cmd,
3712 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3713 SHOW_STR
3714 IP_STR
3715 "IPv6 routing table\n"
3716 "Summary of all IPv6 routes\n"
3717 "Prefix routes\n"
3718 VRF_ALL_CMD_HELP_STR)
3719{
3720 struct zebra_vrf *zvrf;
3721 vrf_iter_t iter;
3722
3723 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3724 if ((zvrf = vrf_iter2info (iter)) != NULL)
3725 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3726
3727 return CMD_SUCCESS;
3728}
3729
paul718e3742002-12-13 20:15:29 +00003730/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003731static int
paul718e3742002-12-13 20:15:29 +00003732static_config_ipv6 (struct vty *vty)
3733{
3734 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05003735 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00003736 int write;
3737 char buf[BUFSIZ];
3738 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003739 struct zebra_vrf *zvrf;
3740 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003741
3742 write = 0;
3743
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003744 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3745 {
3746 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3747 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3748 continue;
paul718e3742002-12-13 20:15:29 +00003749
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003750 for (rn = route_top (stable); rn; rn = route_next (rn))
3751 for (si = rn->info; si; si = si->next)
3752 {
3753 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003754
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003755 switch (si->type)
3756 {
3757 case STATIC_IPV6_GATEWAY:
3758 vty_out (vty, " %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003759 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003760 break;
3761 case STATIC_IPV6_IFNAME:
3762 vty_out (vty, " %s", si->ifname);
3763 break;
3764 case STATIC_IPV6_GATEWAY_IFNAME:
3765 vty_out (vty, " %s %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003766 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003767 si->ifname);
3768 break;
3769 }
paul718e3742002-12-13 20:15:29 +00003770
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003771 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3772 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003773
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003774 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3775 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003776
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003777 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3778 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003779
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003780 if (si->vrf_id != VRF_DEFAULT)
3781 vty_out (vty, " vrf %u", si->vrf_id);
3782
3783 vty_out (vty, "%s", VTY_NEWLINE);
3784
3785 write = 1;
3786 }
3787 }
paul718e3742002-12-13 20:15:29 +00003788 return write;
3789}
3790#endif /* HAVE_IPV6 */
3791
3792/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003793static int
paul718e3742002-12-13 20:15:29 +00003794zebra_ip_config (struct vty *vty)
3795{
3796 int write = 0;
3797
Everton Marques33d86db2014-07-14 11:19:00 -03003798 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3799 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003800#ifdef HAVE_IPV6
3801 write += static_config_ipv6 (vty);
3802#endif /* HAVE_IPV6 */
3803
3804 return write;
3805}
3806
David Lamparterbd078122015-01-06 19:53:24 +01003807static int config_write_vty(struct vty *vty)
3808{
Paul Jakma7514fb72007-05-02 16:05:35 +00003809 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003810 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3811
3812 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3813 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3814 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3815 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3816 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3817 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3818 "longer-prefix",
3819 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003820
3821 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3822 {
3823 if (proto_rm[AFI_IP][i])
3824 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3825 proto_rm[AFI_IP][i], VTY_NEWLINE);
3826 }
3827 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3828 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3829 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3830
3831 return 1;
3832}
3833
3834/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003835static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003836
paul718e3742002-12-13 20:15:29 +00003837/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003838static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003839
3840/* Route VTY. */
3841void
paula1ac18c2005-06-28 17:17:12 +00003842zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003843{
3844 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003845 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003846
Everton Marques33d86db2014-07-14 11:19:00 -03003847 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003848 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003849 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003850 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003851 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3852 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3853 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003854 install_element (CONFIG_NODE, &ip_protocol_cmd);
3855 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3856 install_element (VIEW_NODE, &show_ip_protocol_cmd);
3857 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003858 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003859 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003860 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003861 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003862 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003863 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003864 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003865 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003866 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003867 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003868 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003869 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003870 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003871 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003872 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003873 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003874 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003875 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003876 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003877 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003878 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003879 install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003880 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003881 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003882
3883 install_element (VIEW_NODE, &show_ip_route_cmd);
3884 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3885 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3886 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3887 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3888 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003889 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003890 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003891 install_element (ENABLE_NODE, &show_ip_route_cmd);
3892 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
3893 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
3894 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
3895 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
3896 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00003897 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003898 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003899
Everton Marques33d86db2014-07-14 11:19:00 -03003900 install_element (VIEW_NODE, &show_ip_rpf_cmd);
3901 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003902 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
3903 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003904
Feng Lu4364ee52015-05-22 11:40:03 +02003905 /* Commands for VRF */
3906
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003907 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3908 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3909 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3910 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3911
3912 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3913 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3914 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3915 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3916 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3917 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3918 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3919 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3920 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3921 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
3922 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
3923 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
3924 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
3925 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
3926 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
3927 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
3928 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
3929 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
3930 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
3931 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
3932 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003933 install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003934 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
3935 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
3936
Feng Lu4364ee52015-05-22 11:40:03 +02003937 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
3938 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
3939 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
3940 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3941 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
3942 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
3943 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
3944 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3945 install_element (ENABLE_NODE, &show_ip_route_vrf_cmd);
3946 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd);
3947 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd);
3948 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3949 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd);
3950 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd);
3951 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd);
3952 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd);
3953
3954 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
3955 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
3956 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
3957 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3958 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
3959 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
3960 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
3961 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3962 install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd);
3963 install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd);
3964 install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd);
3965 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3966 install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd);
3967 install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd);
3968 install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd);
3969 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
3970
Feng Lu4364ee52015-05-22 11:40:03 +02003971 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
3972 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
3973 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
3974 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3975 install_element (ENABLE_NODE, &show_ip_rpf_vrf_cmd);
3976 install_element (ENABLE_NODE, &show_ip_rpf_vrf_all_cmd);
3977 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_cmd);
3978 install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_all_cmd);
3979
paul718e3742002-12-13 20:15:29 +00003980#ifdef HAVE_IPV6
3981 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003982 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003983 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003984 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003985 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003986 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003987 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003988 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003989 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003990 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003991 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003992 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003993 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003994 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003995 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003996 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003997 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003998 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003999 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00004000 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
4001 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
4002 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
4003 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
4004 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
4005 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
4006 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
4007 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
4008 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08004009 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07004010 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04004011
4012 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
4013 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004014
4015 /* Commands for VRF */
4016
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004017 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4018 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4019 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4020 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4021 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4022 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4023 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4024 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4025 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4026 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4027 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4028 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4029 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4030 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4031 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4032 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4033
Feng Lu4364ee52015-05-22 11:40:03 +02004034 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4035 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4036 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4037 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4038 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4039 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4040 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4041 install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd);
4042 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd);
4043 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd);
4044 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd);
4045 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
4046 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd);
4047 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4048
4049 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4050 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4051 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4052 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4053 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4054 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4055 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4056 install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd);
4057 install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4058 install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4059 install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4060 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
4061 install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4062 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4063
4064 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
4065 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd);
4066
4067 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
4068 install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004069#endif /* HAVE_IPV6 */
4070}