blob: e3ef963d499e37686843f19d15623f6396daaddc [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Zebra VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
Paul Jakma7514fb72007-05-02 16:05:35 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
Feng Lu41f44a22015-05-22 11:39:56 +020030#include "vrf.h"
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -050031#include "nexthop.h"
paul718e3742002-12-13 20:15:29 +000032
paula1ac18c2005-06-28 17:17:12 +000033#include "zebra/zserv.h"
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -050034#include "zebra/zebra_rnh.h"
paula1ac18c2005-06-28 17:17:12 +000035
Feng Lu4364ee52015-05-22 11:40:03 +020036static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id);
David Lamparter3b02fe82015-01-22 19:12:35 +010037static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
38 int mcast);
Feng Lu4364ee52015-05-22 11:40:03 +020039static void vty_show_ip_route (struct vty *vty, struct route_node *rn,
40 struct rib *rib);
Everton Marques33d86db2014-07-14 11:19:00 -030041
42/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000043static int
Everton Marques33d86db2014-07-14 11:19:00 -030044zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
45 const char *dest_str, const char *mask_str,
46 const char *gate_str, const char *flag_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +020047 const char *distance_str, const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +000048{
49 int ret;
50 u_char distance;
51 struct prefix p;
52 struct in_addr gate;
53 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000054 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000055 u_char flag = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +020056 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +000057
58 ret = str2prefix (dest_str, &p);
59 if (ret <= 0)
60 {
61 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
62 return CMD_WARNING;
63 }
64
65 /* Cisco like mask notation. */
66 if (mask_str)
67 {
68 ret = inet_aton (mask_str, &mask);
69 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000070 {
71 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
72 return CMD_WARNING;
73 }
paul718e3742002-12-13 20:15:29 +000074 p.prefixlen = ip_masklen (mask);
75 }
76
77 /* Apply mask for given prefix. */
78 apply_mask (&p);
79
paul595db7f2003-05-25 21:35:06 +000080 /* Administrative distance. */
81 if (distance_str)
82 distance = atoi (distance_str);
83 else
84 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
85
Feng Lu7aaf4ea2015-05-22 11:40:06 +020086 /* VRF id */
87 if (vrf_id_str)
88 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
89
paul595db7f2003-05-25 21:35:06 +000090 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000091 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000092 {
93 if (flag_str)
94 {
95 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
96 return CMD_WARNING;
97 }
98 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +020099 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000100 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200101 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
paul595db7f2003-05-25 21:35:06 +0000102 return CMD_SUCCESS;
103 }
104
hasso81dfcaa2003-05-25 19:21:25 +0000105 /* Route flags */
106 if (flag_str) {
107 switch(flag_str[0]) {
108 case 'r':
109 case 'R': /* XXX */
110 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
111 break;
112 case 'b':
113 case 'B': /* XXX */
114 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
115 break;
116 default:
117 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000118 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000119 }
120 }
121
hasso457ef552003-05-28 12:02:15 +0000122 if (gate_str == NULL)
123 {
124 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200125 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000126 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200127 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id);
hasso457ef552003-05-28 12:02:15 +0000128
129 return CMD_SUCCESS;
130 }
131
paul718e3742002-12-13 20:15:29 +0000132 /* When gateway is A.B.C.D format, gate is treated as nexthop
133 address other case gate is treated as interface name. */
134 ret = inet_aton (gate_str, &gate);
135 if (ret)
136 ifname = NULL;
137 else
138 ifname = gate_str;
139
140 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200141 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000142 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200143 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +0000144
145 return CMD_SUCCESS;
146}
147
Everton Marques33d86db2014-07-14 11:19:00 -0300148static int
149zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
150 const char *mask_str, const char *gate_str,
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200151 const char *flag_str, const char *distance_str,
152 const char *vrf_id_str)
Everton Marques33d86db2014-07-14 11:19:00 -0300153{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200154 return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str,
155 gate_str, flag_str, distance_str, vrf_id_str);
Everton Marques33d86db2014-07-14 11:19:00 -0300156}
157
158/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100159DEFUN (ip_mroute_dist,
160 ip_mroute_dist_cmd,
161 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300162 IP_STR
163 "Configure static unicast route into MRIB for multicast RPF lookup\n"
164 "IP destination prefix (e.g. 10.0.0.0/8)\n"
165 "Nexthop address\n"
166 "Nexthop interface name\n"
167 "Distance\n")
168{
David Lamparter863f20c2015-01-27 20:24:15 +0100169 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100170 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200171 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300172}
173
David Lampartera76681b2015-01-22 19:03:53 +0100174ALIAS (ip_mroute_dist,
175 ip_mroute_cmd,
176 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
177 IP_STR
178 "Configure static unicast route into MRIB for multicast RPF lookup\n"
179 "IP destination prefix (e.g. 10.0.0.0/8)\n"
180 "Nexthop address\n"
181 "Nexthop interface name\n")
182
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200183DEFUN (ip_mroute_dist_vrf,
184 ip_mroute_dist_vrf_cmd,
185 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
186 IP_STR
187 "Configure static unicast route into MRIB for multicast RPF lookup\n"
188 "IP destination prefix (e.g. 10.0.0.0/8)\n"
189 "Nexthop address\n"
190 "Nexthop interface name\n"
191 "Distance\n"
192 VRF_CMD_HELP_STR)
193{
194 VTY_WARN_EXPERIMENTAL();
195 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
196 NULL, argc > 3 ? argv[2] : NULL,
197 argc > 3 ? argv[3] : argv[2]);
198}
199
200ALIAS (ip_mroute_dist_vrf,
201 ip_mroute_vrf_cmd,
202 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR,
203 IP_STR
204 "Configure static unicast route into MRIB for multicast RPF lookup\n"
205 "IP destination prefix (e.g. 10.0.0.0/8)\n"
206 "Nexthop address\n"
207 "Nexthop interface name\n"
208 VRF_CMD_HELP_STR)
209
David Lampartera76681b2015-01-22 19:03:53 +0100210DEFUN (no_ip_mroute_dist,
211 no_ip_mroute_dist_cmd,
212 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300213 IP_STR
214 "Configure static unicast route into MRIB for multicast RPF lookup\n"
215 "IP destination prefix (e.g. 10.0.0.0/8)\n"
216 "Nexthop address\n"
217 "Nexthop interface name\n"
218 "Distance\n")
219{
David Lamparter863f20c2015-01-27 20:24:15 +0100220 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100221 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200222 NULL, argc > 2 ? argv[2] : NULL, NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300223}
224
David Lampartera76681b2015-01-22 19:03:53 +0100225ALIAS (no_ip_mroute_dist,
226 no_ip_mroute_cmd,
227 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
228 NO_STR
229 IP_STR
230 "Configure static unicast route into MRIB for multicast RPF lookup\n"
231 "IP destination prefix (e.g. 10.0.0.0/8)\n"
232 "Nexthop address\n"
233 "Nexthop interface name\n")
234
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200235DEFUN (no_ip_mroute_dist_vrf,
236 no_ip_mroute_dist_vrf_cmd,
237 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR,
238 IP_STR
239 "Configure static unicast route into MRIB for multicast RPF lookup\n"
240 "IP destination prefix (e.g. 10.0.0.0/8)\n"
241 "Nexthop address\n"
242 "Nexthop interface name\n"
243 "Distance\n"
244 VRF_CMD_HELP_STR)
245{
246 VTY_WARN_EXPERIMENTAL();
247 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
248 NULL, argc > 3 ? argv[2] : NULL,
249 argc > 3 ? argv[3] : argv[2]);
250}
251
252ALIAS (no_ip_mroute_dist_vrf,
253 no_ip_mroute_vrf_cmd,
254 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR,
255 NO_STR
256 IP_STR
257 "Configure static unicast route into MRIB for multicast RPF lookup\n"
258 "IP destination prefix (e.g. 10.0.0.0/8)\n"
259 "Nexthop address\n"
260 "Nexthop interface name\n"
261 VRF_CMD_HELP_STR)
262
David Lamparterbd078122015-01-06 19:53:24 +0100263DEFUN (ip_multicast_mode,
264 ip_multicast_mode_cmd,
265 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
266 IP_STR
267 "Multicast options\n"
268 "RPF lookup behavior\n"
269 "Lookup in unicast RIB only\n"
270 "Lookup in multicast RIB only\n"
271 "Try multicast RIB first, fall back to unicast RIB\n"
272 "Lookup both, use entry with lower distance\n"
273 "Lookup both, use entry with longer prefix\n")
274{
David Lamparter863f20c2015-01-27 20:24:15 +0100275 VTY_WARN_EXPERIMENTAL();
276
David Lamparterbd078122015-01-06 19:53:24 +0100277 if (!strncmp (argv[0], "u", 1))
278 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
279 else if (!strncmp (argv[0], "mrib-o", 6))
280 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
281 else if (!strncmp (argv[0], "mrib-t", 6))
282 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
283 else if (!strncmp (argv[0], "low", 3))
284 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
285 else if (!strncmp (argv[0], "lon", 3))
286 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
287 else
288 {
289 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
290 return CMD_WARNING;
291 }
292
293 return CMD_SUCCESS;
294}
295
296DEFUN (no_ip_multicast_mode,
297 no_ip_multicast_mode_cmd,
298 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
299 NO_STR
300 IP_STR
301 "Multicast options\n"
302 "RPF lookup behavior\n"
303 "Lookup in unicast RIB only\n"
304 "Lookup in multicast RIB only\n"
305 "Try multicast RIB first, fall back to unicast RIB\n"
306 "Lookup both, use entry with lower distance\n"
307 "Lookup both, use entry with longer prefix\n")
308{
309 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
310 return CMD_SUCCESS;
311}
312
313ALIAS (no_ip_multicast_mode,
314 no_ip_multicast_mode_noarg_cmd,
315 "no ip multicast rpf-lookup-mode",
316 NO_STR
317 IP_STR
318 "Multicast options\n"
319 "RPF lookup behavior\n")
320
Everton Marques33d86db2014-07-14 11:19:00 -0300321DEFUN (show_ip_rpf,
322 show_ip_rpf_cmd,
323 "show ip rpf",
324 SHOW_STR
325 IP_STR
326 "Display RPF information for multicast source\n")
327{
Feng Lu4364ee52015-05-22 11:40:03 +0200328 vrf_id_t vrf_id = VRF_DEFAULT;
329
330 if (argc > 0)
331 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
332
David Lamparter863f20c2015-01-27 20:24:15 +0100333 VTY_WARN_EXPERIMENTAL();
Feng Lu4364ee52015-05-22 11:40:03 +0200334 return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -0300335}
336
Feng Lu4364ee52015-05-22 11:40:03 +0200337ALIAS (show_ip_rpf,
338 show_ip_rpf_vrf_cmd,
339 "show ip rpf " VRF_CMD_STR,
340 SHOW_STR
341 IP_STR
342 "Display RPF information for multicast source\n"
343 VRF_CMD_HELP_STR)
344
David Lamparter3b02fe82015-01-22 19:12:35 +0100345DEFUN (show_ip_rpf_addr,
346 show_ip_rpf_addr_cmd,
347 "show ip rpf A.B.C.D",
348 SHOW_STR
349 IP_STR
350 "Display RPF information for multicast source\n"
351 "IP multicast source address (e.g. 10.0.0.0)\n")
352{
353 struct in_addr addr;
354 struct route_node *rn;
355 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +0200356 vrf_id_t vrf_id = VRF_DEFAULT;
357 int ret;
358
359 if (argc > 1)
360 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
361
362 VTY_WARN_EXPERIMENTAL();
363
364 ret = inet_aton (argv[0], &addr);
365 if (ret == 0)
366 {
367 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
368 return CMD_WARNING;
369 }
370
371 rib = rib_match_ipv4_multicast (addr, &rn, vrf_id);
372
373 if (rib)
374 vty_show_ip_route_detail (vty, rn, 1);
375 else
376 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
377
378 return CMD_SUCCESS;
379}
380
381ALIAS (show_ip_rpf_addr,
382 show_ip_rpf_addr_vrf_cmd,
383 "show ip rpf A.B.C.D " VRF_CMD_STR,
384 SHOW_STR
385 IP_STR
386 "Display RPF information for multicast source\n"
387 "IP multicast source address (e.g. 10.0.0.0)\n"
388 VRF_CMD_HELP_STR)
389
390DEFUN (show_ip_rpf_vrf_all,
391 show_ip_rpf_vrf_all_cmd,
392 "show ip rpf " VRF_ALL_CMD_STR,
393 SHOW_STR
394 IP_STR
395 "Display RPF information for multicast source\n"
396 VRF_ALL_CMD_HELP_STR)
397{
398 struct zebra_vrf *zvrf;
399 struct route_table *table;
400 struct route_node *rn;
401 struct rib *rib;
402 vrf_iter_t iter;
403 int first = 1;
404
405 VTY_WARN_EXPERIMENTAL();
406
407 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
408 {
409 if ((zvrf = vrf_iter2info (iter)) == NULL ||
410 (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL)
411 continue;
412
413 /* Show all IPv4 routes. */
414 for (rn = route_top (table); rn; rn = route_next (rn))
415 RNODE_FOREACH_RIB (rn, rib)
416 {
417 if (first)
418 {
419 vty_out (vty, SHOW_ROUTE_V4_HEADER);
420 first = 0;
421 }
422 vty_show_ip_route (vty, rn, rib);
423 }
424 }
425
426 return CMD_SUCCESS;
427}
428
429DEFUN (show_ip_rpf_addr_vrf_all,
430 show_ip_rpf_addr_vrf_all_cmd,
431 "show ip rpf A.B.C.D " VRF_ALL_CMD_STR,
432 SHOW_STR
433 IP_STR
434 "Display RPF information for multicast source\n"
435 "IP multicast source address (e.g. 10.0.0.0)\n"
436 VRF_ALL_CMD_HELP_STR)
437{
438 struct in_addr addr;
439 struct route_node *rn;
440 vrf_iter_t iter;
David Lamparter3b02fe82015-01-22 19:12:35 +0100441 int ret;
442
David Lamparter863f20c2015-01-27 20:24:15 +0100443 VTY_WARN_EXPERIMENTAL();
444
David Lamparter3b02fe82015-01-22 19:12:35 +0100445 ret = inet_aton (argv[0], &addr);
446 if (ret == 0)
447 {
448 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
449 return CMD_WARNING;
450 }
451
Feng Lu4364ee52015-05-22 11:40:03 +0200452 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
453 {
454 if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter)))
455 vty_show_ip_route_detail (vty, rn, 1);
456 }
David Lamparter3b02fe82015-01-22 19:12:35 +0100457
458 return CMD_SUCCESS;
459}
460
paul718e3742002-12-13 20:15:29 +0000461/* Static route configuration. */
462DEFUN (ip_route,
463 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000464 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000465 IP_STR
466 "Establish static routes\n"
467 "IP destination prefix (e.g. 10.0.0.0/8)\n"
468 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000469 "IP gateway interface name\n"
470 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000471{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200472 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
473 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000474}
475
476DEFUN (ip_route_flags,
477 ip_route_flags_cmd,
478 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000479 IP_STR
480 "Establish static routes\n"
481 "IP destination prefix (e.g. 10.0.0.0/8)\n"
482 "IP gateway address\n"
483 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000484 "Emit an ICMP unreachable when matched\n"
485 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000486{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200487 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
488 NULL);
paul718e3742002-12-13 20:15:29 +0000489}
490
hasso457ef552003-05-28 12:02:15 +0000491DEFUN (ip_route_flags2,
492 ip_route_flags2_cmd,
493 "ip route A.B.C.D/M (reject|blackhole)",
494 IP_STR
495 "Establish static routes\n"
496 "IP destination prefix (e.g. 10.0.0.0/8)\n"
497 "Emit an ICMP unreachable when matched\n"
498 "Silently discard pkts when matched\n")
499{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200500 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
501 NULL);
hasso457ef552003-05-28 12:02:15 +0000502}
503
paul718e3742002-12-13 20:15:29 +0000504/* Mask as A.B.C.D format. */
505DEFUN (ip_route_mask,
506 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000507 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000508 IP_STR
509 "Establish static routes\n"
510 "IP destination prefix\n"
511 "IP destination prefix mask\n"
512 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000513 "IP gateway interface name\n"
514 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000515{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200516 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
517 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000518}
519
520DEFUN (ip_route_mask_flags,
521 ip_route_mask_flags_cmd,
522 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000523 IP_STR
524 "Establish static routes\n"
525 "IP destination prefix\n"
526 "IP destination prefix mask\n"
527 "IP gateway address\n"
528 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000529 "Emit an ICMP unreachable when matched\n"
530 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000531{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200532 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
533 NULL);
paul718e3742002-12-13 20:15:29 +0000534}
535
hasso457ef552003-05-28 12:02:15 +0000536DEFUN (ip_route_mask_flags2,
537 ip_route_mask_flags2_cmd,
538 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
539 IP_STR
540 "Establish static routes\n"
541 "IP destination prefix\n"
542 "IP destination prefix mask\n"
543 "Emit an ICMP unreachable when matched\n"
544 "Silently discard pkts when matched\n")
545{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200546 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
547 NULL);
hasso457ef552003-05-28 12:02:15 +0000548}
549
paul718e3742002-12-13 20:15:29 +0000550/* Distance option value. */
551DEFUN (ip_route_distance,
552 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000553 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000554 IP_STR
555 "Establish static routes\n"
556 "IP destination prefix (e.g. 10.0.0.0/8)\n"
557 "IP gateway address\n"
558 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000559 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000560 "Distance value for this route\n")
561{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200562 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
563 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000564}
565
566DEFUN (ip_route_flags_distance,
567 ip_route_flags_distance_cmd,
568 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
569 IP_STR
570 "Establish static routes\n"
571 "IP destination prefix (e.g. 10.0.0.0/8)\n"
572 "IP gateway address\n"
573 "IP gateway interface name\n"
574 "Emit an ICMP unreachable when matched\n"
575 "Silently discard pkts when matched\n"
576 "Distance value for this route\n")
577{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200578 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
579 NULL);
paul718e3742002-12-13 20:15:29 +0000580}
581
hasso457ef552003-05-28 12:02:15 +0000582DEFUN (ip_route_flags_distance2,
583 ip_route_flags_distance2_cmd,
584 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
585 IP_STR
586 "Establish static routes\n"
587 "IP destination prefix (e.g. 10.0.0.0/8)\n"
588 "Emit an ICMP unreachable when matched\n"
589 "Silently discard pkts when matched\n"
590 "Distance value for this route\n")
591{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200592 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
593 NULL);
hasso457ef552003-05-28 12:02:15 +0000594}
595
paul718e3742002-12-13 20:15:29 +0000596DEFUN (ip_route_mask_distance,
597 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000598 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000599 IP_STR
600 "Establish static routes\n"
601 "IP destination prefix\n"
602 "IP destination prefix mask\n"
603 "IP gateway address\n"
604 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000605 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000606 "Distance value for this route\n")
607{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200608 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
609 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000610}
611
612DEFUN (ip_route_mask_flags_distance,
613 ip_route_mask_flags_distance_cmd,
614 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
615 IP_STR
616 "Establish static routes\n"
617 "IP destination prefix\n"
618 "IP destination prefix mask\n"
619 "IP gateway address\n"
620 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000621 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000622 "Silently discard pkts when matched\n"
623 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000624{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200625 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
626 NULL);
paul718e3742002-12-13 20:15:29 +0000627}
628
hasso457ef552003-05-28 12:02:15 +0000629DEFUN (ip_route_mask_flags_distance2,
630 ip_route_mask_flags_distance2_cmd,
631 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
632 IP_STR
633 "Establish static routes\n"
634 "IP destination prefix\n"
635 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000636 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000637 "Silently discard pkts when matched\n"
638 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000639{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200640 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
641 NULL);
hasso457ef552003-05-28 12:02:15 +0000642}
643
paul718e3742002-12-13 20:15:29 +0000644DEFUN (no_ip_route,
645 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000646 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000647 NO_STR
648 IP_STR
649 "Establish static routes\n"
650 "IP destination prefix (e.g. 10.0.0.0/8)\n"
651 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000652 "IP gateway interface name\n"
653 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000654{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200655 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
656 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000657}
658
659ALIAS (no_ip_route,
660 no_ip_route_flags_cmd,
661 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000662 NO_STR
663 IP_STR
664 "Establish static routes\n"
665 "IP destination prefix (e.g. 10.0.0.0/8)\n"
666 "IP gateway address\n"
667 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000668 "Emit an ICMP unreachable when matched\n"
669 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000670
hasso457ef552003-05-28 12:02:15 +0000671DEFUN (no_ip_route_flags2,
672 no_ip_route_flags2_cmd,
673 "no ip route A.B.C.D/M (reject|blackhole)",
674 NO_STR
675 IP_STR
676 "Establish static routes\n"
677 "IP destination prefix (e.g. 10.0.0.0/8)\n"
678 "Emit an ICMP unreachable when matched\n"
679 "Silently discard pkts when matched\n")
680{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200681 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
682 NULL);
hasso457ef552003-05-28 12:02:15 +0000683}
684
paul718e3742002-12-13 20:15:29 +0000685DEFUN (no_ip_route_mask,
686 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000687 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000688 NO_STR
689 IP_STR
690 "Establish static routes\n"
691 "IP destination prefix\n"
692 "IP destination prefix mask\n"
693 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000694 "IP gateway interface name\n"
695 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000696{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200697 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
698 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000699}
700
701ALIAS (no_ip_route_mask,
702 no_ip_route_mask_flags_cmd,
703 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000704 NO_STR
705 IP_STR
706 "Establish static routes\n"
707 "IP destination prefix\n"
708 "IP destination prefix mask\n"
709 "IP gateway address\n"
710 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000711 "Emit an ICMP unreachable when matched\n"
712 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000713
hasso457ef552003-05-28 12:02:15 +0000714DEFUN (no_ip_route_mask_flags2,
715 no_ip_route_mask_flags2_cmd,
716 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
717 NO_STR
718 IP_STR
719 "Establish static routes\n"
720 "IP destination prefix\n"
721 "IP destination prefix mask\n"
722 "Emit an ICMP unreachable when matched\n"
723 "Silently discard pkts when matched\n")
724{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200725 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
726 NULL);
hasso457ef552003-05-28 12:02:15 +0000727}
728
paul718e3742002-12-13 20:15:29 +0000729DEFUN (no_ip_route_distance,
730 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000731 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000732 NO_STR
733 IP_STR
734 "Establish static routes\n"
735 "IP destination prefix (e.g. 10.0.0.0/8)\n"
736 "IP gateway address\n"
737 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000738 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000739 "Distance value for this route\n")
740{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200741 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
742 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000743}
744
745DEFUN (no_ip_route_flags_distance,
746 no_ip_route_flags_distance_cmd,
747 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
748 NO_STR
749 IP_STR
750 "Establish static routes\n"
751 "IP destination prefix (e.g. 10.0.0.0/8)\n"
752 "IP gateway address\n"
753 "IP gateway interface name\n"
754 "Emit an ICMP unreachable when matched\n"
755 "Silently discard pkts when matched\n"
756 "Distance value for this route\n")
757{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200758 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
759 NULL);
paul718e3742002-12-13 20:15:29 +0000760}
761
hasso457ef552003-05-28 12:02:15 +0000762DEFUN (no_ip_route_flags_distance2,
763 no_ip_route_flags_distance2_cmd,
764 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
765 NO_STR
766 IP_STR
767 "Establish static routes\n"
768 "IP destination prefix (e.g. 10.0.0.0/8)\n"
769 "Emit an ICMP unreachable when matched\n"
770 "Silently discard pkts when matched\n"
771 "Distance value for this route\n")
772{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200773 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
774 NULL);
hasso457ef552003-05-28 12:02:15 +0000775}
776
paul718e3742002-12-13 20:15:29 +0000777DEFUN (no_ip_route_mask_distance,
778 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000779 "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 +0000780 NO_STR
781 IP_STR
782 "Establish static routes\n"
783 "IP destination prefix\n"
784 "IP destination prefix mask\n"
785 "IP gateway address\n"
786 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000787 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000788 "Distance value for this route\n")
789{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200790 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
791 NULL);
hasso81dfcaa2003-05-25 19:21:25 +0000792}
793
794DEFUN (no_ip_route_mask_flags_distance,
795 no_ip_route_mask_flags_distance_cmd,
796 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
797 NO_STR
798 IP_STR
799 "Establish static routes\n"
800 "IP destination prefix\n"
801 "IP destination prefix mask\n"
802 "IP gateway address\n"
803 "IP gateway interface name\n"
804 "Emit an ICMP unreachable when matched\n"
805 "Silently discard pkts when matched\n"
806 "Distance value for this route\n")
807{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200808 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
809 NULL);
paul718e3742002-12-13 20:15:29 +0000810}
811
hasso457ef552003-05-28 12:02:15 +0000812DEFUN (no_ip_route_mask_flags_distance2,
813 no_ip_route_mask_flags_distance2_cmd,
814 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
815 NO_STR
816 IP_STR
817 "Establish static routes\n"
818 "IP destination prefix\n"
819 "IP destination prefix mask\n"
820 "Emit an ICMP unreachable when matched\n"
821 "Silently discard pkts when matched\n"
822 "Distance value for this route\n")
823{
Feng Lu7aaf4ea2015-05-22 11:40:06 +0200824 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
825 NULL);
826}
827
828DEFUN (ip_route_vrf,
829 ip_route_vrf_cmd,
830 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
831 IP_STR
832 "Establish static routes\n"
833 "IP destination prefix (e.g. 10.0.0.0/8)\n"
834 "IP gateway address\n"
835 "IP gateway interface name\n"
836 "Null interface\n"
837 VRF_CMD_HELP_STR)
838{
839 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL,
840 argv[2]);
841}
842
843DEFUN (ip_route_flags_vrf,
844 ip_route_flags_vrf_cmd,
845 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
846 IP_STR
847 "Establish static routes\n"
848 "IP destination prefix (e.g. 10.0.0.0/8)\n"
849 "IP gateway address\n"
850 "IP gateway interface name\n"
851 "Emit an ICMP unreachable when matched\n"
852 "Silently discard pkts when matched\n"
853 VRF_CMD_HELP_STR)
854{
855 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL,
856 argv[3]);
857}
858
859DEFUN (ip_route_flags2_vrf,
860 ip_route_flags2_vrf_cmd,
861 "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
862 IP_STR
863 "Establish static routes\n"
864 "IP destination prefix (e.g. 10.0.0.0/8)\n"
865 "Emit an ICMP unreachable when matched\n"
866 "Silently discard pkts when matched\n"
867 VRF_CMD_HELP_STR)
868{
869 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL,
870 argv[2]);
871}
872
873/* Mask as A.B.C.D format. */
874DEFUN (ip_route_mask_vrf,
875 ip_route_mask_vrf_cmd,
876 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
877 IP_STR
878 "Establish static routes\n"
879 "IP destination prefix\n"
880 "IP destination prefix mask\n"
881 "IP gateway address\n"
882 "IP gateway interface name\n"
883 "Null interface\n"
884 VRF_CMD_HELP_STR)
885{
886 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
887 argv[3]);
888}
889
890DEFUN (ip_route_mask_flags_vrf,
891 ip_route_mask_flags_vrf_cmd,
892 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
893 IP_STR
894 "Establish static routes\n"
895 "IP destination prefix\n"
896 "IP destination prefix mask\n"
897 "IP gateway address\n"
898 "IP gateway interface name\n"
899 "Emit an ICMP unreachable when matched\n"
900 "Silently discard pkts when matched\n"
901 VRF_CMD_HELP_STR)
902{
903 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
904 argv[4]);
905}
906
907DEFUN (ip_route_mask_flags2_vrf,
908 ip_route_mask_flags2_vrf_cmd,
909 "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
910 IP_STR
911 "Establish static routes\n"
912 "IP destination prefix\n"
913 "IP destination prefix mask\n"
914 "Emit an ICMP unreachable when matched\n"
915 "Silently discard pkts when matched\n"
916 VRF_CMD_HELP_STR)
917{
918 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
919 argv[3]);
920}
921
922/* Distance option value. */
923DEFUN (ip_route_distance_vrf,
924 ip_route_distance_vrf_cmd,
925 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
926 IP_STR
927 "Establish static routes\n"
928 "IP destination prefix (e.g. 10.0.0.0/8)\n"
929 "IP gateway address\n"
930 "IP gateway interface name\n"
931 "Null interface\n"
932 "Distance value for this route\n"
933 VRF_CMD_HELP_STR)
934{
935 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2],
936 argv[3]);
937}
938
939DEFUN (ip_route_flags_distance_vrf,
940 ip_route_flags_distance_vrf_cmd,
941 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
942 IP_STR
943 "Establish static routes\n"
944 "IP destination prefix (e.g. 10.0.0.0/8)\n"
945 "IP gateway address\n"
946 "IP gateway interface name\n"
947 "Emit an ICMP unreachable when matched\n"
948 "Silently discard pkts when matched\n"
949 "Distance value for this route\n"
950 VRF_CMD_HELP_STR)
951{
952 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3],
953 argv[4]);
954}
955
956DEFUN (ip_route_flags_distance2_vrf,
957 ip_route_flags_distance2_vrf_cmd,
958 "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
959 IP_STR
960 "Establish static routes\n"
961 "IP destination prefix (e.g. 10.0.0.0/8)\n"
962 "Emit an ICMP unreachable when matched\n"
963 "Silently discard pkts when matched\n"
964 "Distance value for this route\n"
965 VRF_CMD_HELP_STR)
966{
967 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2],
968 argv[3]);
969}
970
971DEFUN (ip_route_mask_distance_vrf,
972 ip_route_mask_distance_vrf_cmd,
973 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
974 IP_STR
975 "Establish static routes\n"
976 "IP destination prefix\n"
977 "IP destination prefix mask\n"
978 "IP gateway address\n"
979 "IP gateway interface name\n"
980 "Null interface\n"
981 "Distance value for this route\n"
982 VRF_CMD_HELP_STR)
983{
984 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
985 argv[4]);
986}
987
988DEFUN (ip_route_mask_flags_distance_vrf,
989 ip_route_mask_flags_distance_vrf_cmd,
990 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
991 IP_STR
992 "Establish static routes\n"
993 "IP destination prefix\n"
994 "IP destination prefix mask\n"
995 "IP gateway address\n"
996 "IP gateway interface name\n"
997 "Emit an ICMP unreachable when matched\n"
998 "Silently discard pkts when matched\n"
999 "Distance value for this route\n"
1000 VRF_CMD_HELP_STR)
1001{
1002 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
1003 argv[5]);
1004}
1005
1006DEFUN (ip_route_mask_flags_distance2_vrf,
1007 ip_route_mask_flags_distance2_vrf_cmd,
1008 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1009 IP_STR
1010 "Establish static routes\n"
1011 "IP destination prefix\n"
1012 "IP destination prefix mask\n"
1013 "Emit an ICMP unreachable when matched\n"
1014 "Silently discard pkts when matched\n"
1015 "Distance value for this route\n"
1016 VRF_CMD_HELP_STR)
1017{
1018 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
1019 argv[4]);
1020}
1021
1022DEFUN (no_ip_route_vrf,
1023 no_ip_route_vrf_cmd,
1024 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1025 NO_STR
1026 IP_STR
1027 "Establish static routes\n"
1028 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1029 "IP gateway address\n"
1030 "IP gateway interface name\n"
1031 "Null interface\n"
1032 VRF_CMD_HELP_STR)
1033{
1034 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL,
1035 (argc > 3) ? argv[3] : argv[2]);
1036}
1037
1038ALIAS (no_ip_route_vrf,
1039 no_ip_route_flags_vrf_cmd,
1040 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1041 NO_STR
1042 IP_STR
1043 "Establish static routes\n"
1044 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1045 "IP gateway address\n"
1046 "IP gateway interface name\n"
1047 "Emit an ICMP unreachable when matched\n"
1048 "Silently discard pkts when matched\n"
1049 VRF_CMD_HELP_STR)
1050
1051DEFUN (no_ip_route_flags2_vrf,
1052 no_ip_route_flags2_vrf_cmd,
1053 "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR,
1054 NO_STR
1055 IP_STR
1056 "Establish static routes\n"
1057 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1058 "Emit an ICMP unreachable when matched\n"
1059 "Silently discard pkts when matched\n"
1060 VRF_CMD_HELP_STR)
1061{
1062 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL,
1063 argv[2]);
1064}
1065
1066DEFUN (no_ip_route_mask_vrf,
1067 no_ip_route_mask_vrf_cmd,
1068 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR,
1069 NO_STR
1070 IP_STR
1071 "Establish static routes\n"
1072 "IP destination prefix\n"
1073 "IP destination prefix mask\n"
1074 "IP gateway address\n"
1075 "IP gateway interface name\n"
1076 "Null interface\n"
1077 VRF_CMD_HELP_STR)
1078{
1079 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
1080 (argc > 4) ? argv[4] : argv[3]);
1081}
1082
1083ALIAS (no_ip_route_mask_vrf,
1084 no_ip_route_mask_flags_vrf_cmd,
1085 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
1086 NO_STR
1087 IP_STR
1088 "Establish static routes\n"
1089 "IP destination prefix\n"
1090 "IP destination prefix mask\n"
1091 "IP gateway address\n"
1092 "IP gateway interface name\n"
1093 "Emit an ICMP unreachable when matched\n"
1094 "Silently discard pkts when matched\n"
1095 VRF_CMD_HELP_STR)
1096
1097DEFUN (no_ip_route_mask_flags2_vrf,
1098 no_ip_route_mask_flags2_vrf_cmd,
1099 "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR,
1100 NO_STR
1101 IP_STR
1102 "Establish static routes\n"
1103 "IP destination prefix\n"
1104 "IP destination prefix mask\n"
1105 "Emit an ICMP unreachable when matched\n"
1106 "Silently discard pkts when matched\n"
1107 VRF_CMD_HELP_STR)
1108{
1109 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
1110 argv[2]);
1111}
1112
1113DEFUN (no_ip_route_distance_vrf,
1114 no_ip_route_distance_vrf_cmd,
1115 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1116 NO_STR
1117 IP_STR
1118 "Establish static routes\n"
1119 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1120 "IP gateway address\n"
1121 "IP gateway interface name\n"
1122 "Null interface\n"
1123 "Distance value for this route\n"
1124 VRF_CMD_HELP_STR)
1125{
1126 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2],
1127 argv[3]);
1128}
1129
1130DEFUN (no_ip_route_flags_distance_vrf,
1131 no_ip_route_flags_distance_vrf_cmd,
1132 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1133 NO_STR
1134 IP_STR
1135 "Establish static routes\n"
1136 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1137 "IP gateway address\n"
1138 "IP gateway interface name\n"
1139 "Emit an ICMP unreachable when matched\n"
1140 "Silently discard pkts when matched\n"
1141 "Distance value for this route\n"
1142 VRF_CMD_HELP_STR)
1143{
1144 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3],
1145 argv[4]);
1146}
1147
1148DEFUN (no_ip_route_flags_distance2_vrf,
1149 no_ip_route_flags_distance2_vrf_cmd,
1150 "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR,
1151 NO_STR
1152 IP_STR
1153 "Establish static routes\n"
1154 "IP destination prefix (e.g. 10.0.0.0/8)\n"
1155 "Emit an ICMP unreachable when matched\n"
1156 "Silently discard pkts when matched\n"
1157 "Distance value for this route\n"
1158 VRF_CMD_HELP_STR)
1159{
1160 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2],
1161 argv[3]);
1162}
1163
1164DEFUN (no_ip_route_mask_distance_vrf,
1165 no_ip_route_mask_distance_vrf_cmd,
1166 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR,
1167 NO_STR
1168 IP_STR
1169 "Establish static routes\n"
1170 "IP destination prefix\n"
1171 "IP destination prefix mask\n"
1172 "IP gateway address\n"
1173 "IP gateway interface name\n"
1174 "Null interface\n"
1175 "Distance value for this route\n"
1176 VRF_CMD_HELP_STR)
1177{
1178 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
1179 argv[4]);
1180}
1181
1182DEFUN (no_ip_route_mask_flags_distance_vrf,
1183 no_ip_route_mask_flags_distance_vrf_cmd,
1184 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
1185 NO_STR
1186 IP_STR
1187 "Establish static routes\n"
1188 "IP destination prefix\n"
1189 "IP destination prefix mask\n"
1190 "IP gateway address\n"
1191 "IP gateway interface name\n"
1192 "Emit an ICMP unreachable when matched\n"
1193 "Silently discard pkts when matched\n"
1194 "Distance value for this route\n"
1195 VRF_CMD_HELP_STR)
1196{
1197 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
1198 argv[5]);
1199}
1200
1201DEFUN (no_ip_route_mask_flags_distance2_vrf,
1202 no_ip_route_mask_flags_distance2_vrf_cmd,
1203 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR,
1204 NO_STR
1205 IP_STR
1206 "Establish static routes\n"
1207 "IP destination prefix\n"
1208 "IP destination prefix mask\n"
1209 "Emit an ICMP unreachable when matched\n"
1210 "Silently discard pkts when matched\n"
1211 "Distance value for this route\n"
1212 VRF_CMD_HELP_STR)
1213{
1214 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
1215 argv[4]);
hasso457ef552003-05-28 12:02:15 +00001216}
1217
Paul Jakma7514fb72007-05-02 16:05:35 +00001218char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
1219
1220DEFUN (ip_protocol,
1221 ip_protocol_cmd,
1222 "ip protocol PROTO route-map ROUTE-MAP",
1223 NO_STR
1224 "Apply route map to PROTO\n"
1225 "Protocol name\n"
1226 "Route map name\n")
1227{
1228 int i;
1229
1230 if (strcasecmp(argv[0], "any") == 0)
1231 i = ZEBRA_ROUTE_MAX;
1232 else
1233 i = proto_name2num(argv[0]);
1234 if (i < 0)
1235 {
1236 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1237 VTY_NEWLINE);
1238 return CMD_WARNING;
1239 }
1240 if (proto_rm[AFI_IP][i])
1241 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1242 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
1243 return CMD_SUCCESS;
1244}
1245
1246DEFUN (no_ip_protocol,
1247 no_ip_protocol_cmd,
1248 "no ip protocol PROTO",
1249 NO_STR
1250 "Remove route map from PROTO\n"
1251 "Protocol name\n")
1252{
1253 int i;
1254
1255 if (strcasecmp(argv[0], "any") == 0)
1256 i = ZEBRA_ROUTE_MAX;
1257 else
1258 i = proto_name2num(argv[0]);
1259 if (i < 0)
1260 {
1261 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
1262 VTY_NEWLINE);
1263 return CMD_WARNING;
1264 }
1265 if (proto_rm[AFI_IP][i])
1266 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
1267 proto_rm[AFI_IP][i] = NULL;
1268 return CMD_SUCCESS;
1269}
1270
paul718e3742002-12-13 20:15:29 +00001271/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +00001272static void
David Lamparter3b02fe82015-01-22 19:12:35 +01001273vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +00001274{
1275 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001276 struct nexthop *nexthop, *tnexthop;
1277 int recursing;
Timo Teräs53a5c392015-05-23 11:08:40 +03001278 char buf[PREFIX_STRLEN];
paul718e3742002-12-13 20:15:29 +00001279
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001280 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001281 {
David Lamparterb7cce952015-03-07 08:40:48 +01001282 const char *mcast_info = "";
David Lamparter3b02fe82015-01-22 19:12:35 +01001283 if (mcast)
1284 {
1285 rib_table_info_t *info = rn->table->info;
1286 mcast_info = (info->safi == SAFI_MULTICAST)
1287 ? " using Multicast RIB"
1288 : " using Unicast RIB";
1289 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001290 vty_out (vty, "Routing entry for %s%s%s",
1291 prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
1292 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001293 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001294 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
Timo Teräsb11f3b52015-11-02 16:50:07 +02001295 if (rib->mtu)
1296 vty_out (vty, ", mtu %u", rib->mtu);
Feng Lu4364ee52015-05-22 11:40:03 +02001297 vty_out (vty, ", vrf %u", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001298 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
Timo Teräs53a5c392015-05-23 11:08:40 +03001299 vty_out (vty, ", best");
Timo Teräs325823a2016-01-15 17:36:31 +02001300 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE))
1301 vty_out (vty, ", fib-override");
1302 if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
1303 vty_out (vty, ", fib");
paul718e3742002-12-13 20:15:29 +00001304 if (rib->refcnt)
Timo Teräs53a5c392015-05-23 11:08:40 +03001305 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001306 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1307 vty_out (vty, ", blackhole");
1308 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1309 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001310 vty_out (vty, "%s", VTY_NEWLINE);
1311
1312#define ONE_DAY_SECOND 60*60*24
1313#define ONE_WEEK_SECOND 60*60*24*7
1314 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001315 || rib->type == ZEBRA_ROUTE_RIPNG
1316 || rib->type == ZEBRA_ROUTE_OSPF
1317 || rib->type == ZEBRA_ROUTE_OSPF6
1318 || rib->type == ZEBRA_ROUTE_BABEL
1319 || rib->type == ZEBRA_ROUTE_ISIS
1320 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001321 {
1322 time_t uptime;
1323 struct tm *tm;
1324
1325 uptime = time (NULL);
1326 uptime -= rib->uptime;
1327 tm = gmtime (&uptime);
1328
1329 vty_out (vty, " Last update ");
1330
1331 if (uptime < ONE_DAY_SECOND)
1332 vty_out (vty, "%02d:%02d:%02d",
1333 tm->tm_hour, tm->tm_min, tm->tm_sec);
1334 else if (uptime < ONE_WEEK_SECOND)
1335 vty_out (vty, "%dd%02dh%02dm",
1336 tm->tm_yday, tm->tm_hour, tm->tm_min);
1337 else
1338 vty_out (vty, "%02dw%dd%02dh",
1339 tm->tm_yday/7,
1340 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1341 vty_out (vty, " ago%s", VTY_NEWLINE);
1342 }
1343
Christian Frankefa713d92013-07-05 15:35:37 +00001344 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
Timo Teräs53a5c392015-05-23 11:08:40 +03001345 {
Timo Teräs7e73eb72016-04-09 17:22:32 +03001346 vty_out (vty, " %c%c%s",
1347 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? '>' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001348 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1349 recursing ? " " : "");
Paul Jakma7514fb72007-05-02 16:05:35 +00001350
Timo Teräs53a5c392015-05-23 11:08:40 +03001351 switch (nexthop->type)
1352 {
1353 case NEXTHOP_TYPE_IPV4:
1354 case NEXTHOP_TYPE_IPV4_IFINDEX:
1355 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
1356 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001357 vty_out (vty, ", via %s",
1358 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001359 break;
1360 case NEXTHOP_TYPE_IPV6:
1361 case NEXTHOP_TYPE_IPV6_IFINDEX:
1362 case NEXTHOP_TYPE_IPV6_IFNAME:
1363 vty_out (vty, " %s",
1364 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf)));
1365 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1366 vty_out (vty, ", %s", nexthop->ifname);
1367 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001368 vty_out (vty, ", via %s",
1369 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001370 break;
1371 case NEXTHOP_TYPE_IFINDEX:
1372 vty_out (vty, " directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001373 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001374 break;
1375 case NEXTHOP_TYPE_IFNAME:
1376 vty_out (vty, " directly connected, %s", nexthop->ifname);
1377 break;
1378 case NEXTHOP_TYPE_BLACKHOLE:
1379 vty_out (vty, " directly connected, Null0");
1380 break;
1381 default:
1382 break;
1383 }
1384 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1385 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001386
Timo Teräs53a5c392015-05-23 11:08:40 +03001387 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1388 vty_out (vty, " onlink");
paul718e3742002-12-13 20:15:29 +00001389
Timo Teräs53a5c392015-05-23 11:08:40 +03001390 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1391 vty_out (vty, " (recursive)");
Christian Frankee8d3d292013-07-05 15:35:39 +00001392
Timo Teräs53a5c392015-05-23 11:08:40 +03001393 switch (nexthop->type)
Paul Jakma7514fb72007-05-02 16:05:35 +00001394 {
1395 case NEXTHOP_TYPE_IPV4:
1396 case NEXTHOP_TYPE_IPV4_IFINDEX:
1397 case NEXTHOP_TYPE_IPV4_IFNAME:
1398 if (nexthop->src.ipv4.s_addr)
1399 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001400 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
1401 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001402 }
1403 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001404#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001405 case NEXTHOP_TYPE_IPV6:
1406 case NEXTHOP_TYPE_IPV6_IFINDEX:
1407 case NEXTHOP_TYPE_IPV6_IFNAME:
1408 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1409 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001410 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
1411 vty_out (vty, ", src %s", buf);
Paul Jakma7514fb72007-05-02 16:05:35 +00001412 }
1413 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001414#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001415 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001416 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001417 }
Timo Teräs53a5c392015-05-23 11:08:40 +03001418 vty_out (vty, "%s", VTY_NEWLINE);
1419 }
paul718e3742002-12-13 20:15:29 +00001420 vty_out (vty, "%s", VTY_NEWLINE);
1421 }
1422}
1423
paula1ac18c2005-06-28 17:17:12 +00001424static void
paul718e3742002-12-13 20:15:29 +00001425vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
1426{
Christian Frankefa713d92013-07-05 15:35:37 +00001427 struct nexthop *nexthop, *tnexthop;
1428 int recursing;
paul718e3742002-12-13 20:15:29 +00001429 int len = 0;
1430 char buf[BUFSIZ];
1431
1432 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001433 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001434 {
1435 if (nexthop == rib->nexthop)
1436 {
1437 /* Prefix information. */
Timo Teräs53a5c392015-05-23 11:08:40 +03001438 len = vty_out (vty, "%c%c%c %s",
ajsf52d13c2005-10-01 17:38:06 +00001439 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001440 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1441 ? '>' : ' ',
1442 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1443 ? '*' : ' ',
Timo Teräs53a5c392015-05-23 11:08:40 +03001444 prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00001445
1446 /* Distance and metric display. */
1447 if (rib->type != ZEBRA_ROUTE_CONNECT
1448 && rib->type != ZEBRA_ROUTE_KERNEL)
1449 len += vty_out (vty, " [%d/%d]", rib->distance,
1450 rib->metric);
Feng Lu4364ee52015-05-22 11:40:03 +02001451
1452 if (rib->vrf_id != VRF_DEFAULT)
1453 len += vty_out (vty, " [vrf %u]", rib->vrf_id);
paul718e3742002-12-13 20:15:29 +00001454 }
1455 else
1456 vty_out (vty, " %c%*c",
1457 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1458 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001459 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001460
1461 switch (nexthop->type)
Timo Teräs53a5c392015-05-23 11:08:40 +03001462 {
1463 case NEXTHOP_TYPE_IPV4:
1464 case NEXTHOP_TYPE_IPV4_IFINDEX:
1465 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
1466 if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001467 vty_out (vty, ", %s",
1468 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001469 break;
1470 case NEXTHOP_TYPE_IPV6:
1471 case NEXTHOP_TYPE_IPV6_IFINDEX:
1472 case NEXTHOP_TYPE_IPV6_IFNAME:
1473 vty_out (vty, " via %s",
1474 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1475 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1476 vty_out (vty, ", %s", nexthop->ifname);
1477 else if (nexthop->ifindex)
Feng Lu0d0686f2015-05-22 11:40:02 +02001478 vty_out (vty, ", %s",
1479 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001480 break;
1481 case NEXTHOP_TYPE_IFINDEX:
1482 vty_out (vty, " is directly connected, %s",
Feng Lu0d0686f2015-05-22 11:40:02 +02001483 ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
Timo Teräs53a5c392015-05-23 11:08:40 +03001484 break;
1485 case NEXTHOP_TYPE_IFNAME:
1486 vty_out (vty, " is directly connected, %s", nexthop->ifname);
1487 break;
1488 case NEXTHOP_TYPE_BLACKHOLE:
1489 vty_out (vty, " is directly connected, Null0");
1490 break;
1491 default:
1492 break;
1493 }
paul718e3742002-12-13 20:15:29 +00001494 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001495 vty_out (vty, " inactive");
paul718e3742002-12-13 20:15:29 +00001496
Christian Frankee8d3d292013-07-05 15:35:39 +00001497 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
Timo Teräs53a5c392015-05-23 11:08:40 +03001498 vty_out (vty, " onlink");
Christian Frankee8d3d292013-07-05 15:35:39 +00001499
paul718e3742002-12-13 20:15:29 +00001500 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Timo Teräs53a5c392015-05-23 11:08:40 +03001501 vty_out (vty, " (recursive)");
Christian Frankefa713d92013-07-05 15:35:37 +00001502
Paul Jakma7514fb72007-05-02 16:05:35 +00001503 switch (nexthop->type)
1504 {
1505 case NEXTHOP_TYPE_IPV4:
1506 case NEXTHOP_TYPE_IPV4_IFINDEX:
1507 case NEXTHOP_TYPE_IPV4_IFNAME:
1508 if (nexthop->src.ipv4.s_addr)
1509 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001510 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001511 vty_out (vty, ", src %s", buf);
1512 }
1513 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001514#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +00001515 case NEXTHOP_TYPE_IPV6:
1516 case NEXTHOP_TYPE_IPV6_IFINDEX:
1517 case NEXTHOP_TYPE_IPV6_IFNAME:
1518 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
1519 {
Timo Teräs53a5c392015-05-23 11:08:40 +03001520 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
Paul Jakma7514fb72007-05-02 16:05:35 +00001521 vty_out (vty, ", src %s", buf);
1522 }
1523 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +00001524#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +00001525 default:
Timo Teräs53a5c392015-05-23 11:08:40 +03001526 break;
Paul Jakma7514fb72007-05-02 16:05:35 +00001527 }
paul718e3742002-12-13 20:15:29 +00001528
hasso81dfcaa2003-05-25 19:21:25 +00001529 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1530 vty_out (vty, ", bh");
1531 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1532 vty_out (vty, ", rej");
1533
paul718e3742002-12-13 20:15:29 +00001534 if (rib->type == ZEBRA_ROUTE_RIP
Timo Teräs53a5c392015-05-23 11:08:40 +03001535 || rib->type == ZEBRA_ROUTE_RIPNG
1536 || rib->type == ZEBRA_ROUTE_OSPF
1537 || rib->type == ZEBRA_ROUTE_OSPF6
1538 || rib->type == ZEBRA_ROUTE_BABEL
1539 || rib->type == ZEBRA_ROUTE_ISIS
1540 || rib->type == ZEBRA_ROUTE_BGP)
paul718e3742002-12-13 20:15:29 +00001541 {
1542 time_t uptime;
1543 struct tm *tm;
1544
1545 uptime = time (NULL);
1546 uptime -= rib->uptime;
1547 tm = gmtime (&uptime);
1548
1549#define ONE_DAY_SECOND 60*60*24
1550#define ONE_WEEK_SECOND 60*60*24*7
1551
1552 if (uptime < ONE_DAY_SECOND)
1553 vty_out (vty, ", %02d:%02d:%02d",
1554 tm->tm_hour, tm->tm_min, tm->tm_sec);
1555 else if (uptime < ONE_WEEK_SECOND)
1556 vty_out (vty, ", %dd%02dh%02dm",
1557 tm->tm_yday, tm->tm_hour, tm->tm_min);
1558 else
1559 vty_out (vty, ", %02dw%dd%02dh",
1560 tm->tm_yday/7,
1561 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1562 }
1563 vty_out (vty, "%s", VTY_NEWLINE);
1564 }
1565}
1566
paul718e3742002-12-13 20:15:29 +00001567DEFUN (show_ip_route,
1568 show_ip_route_cmd,
1569 "show ip route",
1570 SHOW_STR
1571 IP_STR
1572 "IP routing table\n")
1573{
Feng Lu4364ee52015-05-22 11:40:03 +02001574 vrf_id_t vrf_id = VRF_DEFAULT;
1575
1576 if (argc > 0)
1577 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1578
1579 return do_show_ip_route(vty, SAFI_UNICAST, vrf_id);
Everton Marques33d86db2014-07-14 11:19:00 -03001580}
1581
Feng Lu4364ee52015-05-22 11:40:03 +02001582static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id)
1583{
paul718e3742002-12-13 20:15:29 +00001584 struct route_table *table;
1585 struct route_node *rn;
1586 struct rib *rib;
1587 int first = 1;
1588
Feng Lu4364ee52015-05-22 11:40:03 +02001589 table = zebra_vrf_table (AFI_IP, safi, vrf_id);
paul718e3742002-12-13 20:15:29 +00001590 if (! table)
1591 return CMD_SUCCESS;
1592
1593 /* Show all IPv4 routes. */
1594 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001595 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001596 {
1597 if (first)
1598 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001599 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001600 first = 0;
1601 }
1602 vty_show_ip_route (vty, rn, rib);
1603 }
1604 return CMD_SUCCESS;
1605}
1606
Feng Lu4364ee52015-05-22 11:40:03 +02001607ALIAS (show_ip_route,
1608 show_ip_route_vrf_cmd,
1609 "show ip route " VRF_CMD_STR,
1610 SHOW_STR
1611 IP_STR
1612 "IP routing table\n"
1613 VRF_CMD_HELP_STR)
1614
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05001615DEFUN (show_ip_nht,
1616 show_ip_nht_cmd,
1617 "show ip nht",
1618 SHOW_STR
1619 IP_STR
1620 "IP nexthop tracking table\n")
1621{
1622 zebra_print_rnh_table(0, AF_INET, vty);
1623 return CMD_SUCCESS;
1624}
1625
1626DEFUN (show_ipv6_nht,
1627 show_ipv6_nht_cmd,
1628 "show ipv6 nht",
1629 SHOW_STR
1630 IP_STR
1631 "IPv6 nexthop tracking table\n")
1632{
1633 zebra_print_rnh_table(0, AF_INET6, vty);
1634 return CMD_SUCCESS;
1635}
1636
paul718e3742002-12-13 20:15:29 +00001637DEFUN (show_ip_route_prefix_longer,
1638 show_ip_route_prefix_longer_cmd,
1639 "show ip route A.B.C.D/M longer-prefixes",
1640 SHOW_STR
1641 IP_STR
1642 "IP routing table\n"
1643 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1644 "Show route matching the specified Network/Mask pair only\n")
1645{
1646 struct route_table *table;
1647 struct route_node *rn;
1648 struct rib *rib;
1649 struct prefix p;
1650 int ret;
1651 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001652 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001653
1654 ret = str2prefix (argv[0], &p);
1655 if (! ret)
1656 {
1657 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1658 return CMD_WARNING;
1659 }
Feng Lu4364ee52015-05-22 11:40:03 +02001660
1661 if (argc > 1)
1662 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1663
1664 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001665 if (! table)
1666 return CMD_SUCCESS;
1667
1668 /* Show matched type IPv4 routes. */
1669 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001670 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001671 if (prefix_match (&p, &rn->p))
1672 {
1673 if (first)
1674 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001675 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001676 first = 0;
1677 }
1678 vty_show_ip_route (vty, rn, rib);
1679 }
1680 return CMD_SUCCESS;
1681}
1682
Feng Lu4364ee52015-05-22 11:40:03 +02001683ALIAS (show_ip_route_prefix_longer,
1684 show_ip_route_prefix_longer_vrf_cmd,
1685 "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR,
1686 SHOW_STR
1687 IP_STR
1688 "IP routing table\n"
1689 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1690 "Show route matching the specified Network/Mask pair only\n"
1691 VRF_CMD_HELP_STR)
1692
paul718e3742002-12-13 20:15:29 +00001693DEFUN (show_ip_route_supernets,
1694 show_ip_route_supernets_cmd,
1695 "show ip route supernets-only",
1696 SHOW_STR
1697 IP_STR
1698 "IP routing table\n"
1699 "Show supernet entries only\n")
1700{
1701 struct route_table *table;
1702 struct route_node *rn;
1703 struct rib *rib;
Feng Lu4364ee52015-05-22 11:40:03 +02001704 u_int32_t addr;
paul718e3742002-12-13 20:15:29 +00001705 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001706 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001707
Feng Lu4364ee52015-05-22 11:40:03 +02001708 if (argc > 0)
1709 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
1710
1711 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001712 if (! table)
1713 return CMD_SUCCESS;
1714
1715 /* Show matched type IPv4 routes. */
1716 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001717 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001718 {
1719 addr = ntohl (rn->p.u.prefix4.s_addr);
1720
1721 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1722 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
Feng Lu4364ee52015-05-22 11:40:03 +02001723 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
paul718e3742002-12-13 20:15:29 +00001724 {
1725 if (first)
1726 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001727 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001728 first = 0;
1729 }
1730 vty_show_ip_route (vty, rn, rib);
1731 }
1732 }
1733 return CMD_SUCCESS;
1734}
1735
Feng Lu4364ee52015-05-22 11:40:03 +02001736ALIAS (show_ip_route_supernets,
1737 show_ip_route_supernets_vrf_cmd,
1738 "show ip route supernets-only " VRF_CMD_STR,
1739 SHOW_STR
1740 IP_STR
1741 "IP routing table\n"
1742 "Show supernet entries only\n"
1743 VRF_CMD_HELP_STR)
1744
paul718e3742002-12-13 20:15:29 +00001745DEFUN (show_ip_route_protocol,
1746 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001747 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001748 SHOW_STR
1749 IP_STR
1750 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001751 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001752{
1753 int type;
1754 struct route_table *table;
1755 struct route_node *rn;
1756 struct rib *rib;
1757 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02001758 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001759
David Lampartere0ca5fd2009-09-16 01:52:42 +02001760 type = proto_redistnum (AFI_IP, argv[0]);
1761 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001762 {
1763 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1764 return CMD_WARNING;
1765 }
Feng Lu4364ee52015-05-22 11:40:03 +02001766
1767 if (argc > 1)
1768 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1769
1770 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001771 if (! table)
1772 return CMD_SUCCESS;
1773
1774 /* Show matched type IPv4 routes. */
1775 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001776 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001777 if (rib->type == type)
1778 {
1779 if (first)
1780 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001781 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001782 first = 0;
1783 }
1784 vty_show_ip_route (vty, rn, rib);
1785 }
1786 return CMD_SUCCESS;
1787}
1788
Feng Lu4364ee52015-05-22 11:40:03 +02001789ALIAS (show_ip_route_protocol,
1790 show_ip_route_protocol_vrf_cmd,
1791 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR,
1792 SHOW_STR
1793 IP_STR
1794 "IP routing table\n"
1795 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
1796 VRF_CMD_HELP_STR)
1797
paul718e3742002-12-13 20:15:29 +00001798DEFUN (show_ip_route_addr,
1799 show_ip_route_addr_cmd,
1800 "show ip route A.B.C.D",
1801 SHOW_STR
1802 IP_STR
1803 "IP routing table\n"
1804 "Network in the IP routing table to display\n")
1805{
1806 int ret;
1807 struct prefix_ipv4 p;
1808 struct route_table *table;
1809 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001810 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001811
1812 ret = str2prefix_ipv4 (argv[0], &p);
1813 if (ret <= 0)
1814 {
1815 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1816 return CMD_WARNING;
1817 }
1818
Feng Lu4364ee52015-05-22 11:40:03 +02001819 if (argc > 1)
1820 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1821
1822 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001823 if (! table)
1824 return CMD_SUCCESS;
1825
1826 rn = route_node_match (table, (struct prefix *) &p);
1827 if (! rn)
1828 {
1829 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1830 return CMD_WARNING;
1831 }
1832
David Lamparter3b02fe82015-01-22 19:12:35 +01001833 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001834
1835 route_unlock_node (rn);
1836
1837 return CMD_SUCCESS;
1838}
1839
Feng Lu4364ee52015-05-22 11:40:03 +02001840ALIAS (show_ip_route_addr,
1841 show_ip_route_addr_vrf_cmd,
1842 "show ip route A.B.C.D " VRF_CMD_STR,
1843 SHOW_STR
1844 IP_STR
1845 "IP routing table\n"
1846 "Network in the IP routing table to display\n"
1847 VRF_CMD_HELP_STR)
1848
paul718e3742002-12-13 20:15:29 +00001849DEFUN (show_ip_route_prefix,
1850 show_ip_route_prefix_cmd,
1851 "show ip route A.B.C.D/M",
1852 SHOW_STR
1853 IP_STR
1854 "IP routing table\n"
1855 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1856{
1857 int ret;
1858 struct prefix_ipv4 p;
1859 struct route_table *table;
1860 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02001861 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00001862
1863 ret = str2prefix_ipv4 (argv[0], &p);
1864 if (ret <= 0)
1865 {
1866 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1867 return CMD_WARNING;
1868 }
1869
Feng Lu4364ee52015-05-22 11:40:03 +02001870 if (argc > 1)
1871 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
1872
1873 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00001874 if (! table)
1875 return CMD_SUCCESS;
1876
1877 rn = route_node_match (table, (struct prefix *) &p);
1878 if (! rn || rn->p.prefixlen != p.prefixlen)
1879 {
1880 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001881 if (rn)
1882 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001883 return CMD_WARNING;
1884 }
1885
David Lamparter3b02fe82015-01-22 19:12:35 +01001886 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001887
1888 route_unlock_node (rn);
1889
1890 return CMD_SUCCESS;
1891}
1892
Feng Lu4364ee52015-05-22 11:40:03 +02001893ALIAS (show_ip_route_prefix,
1894 show_ip_route_prefix_vrf_cmd,
1895 "show ip route A.B.C.D/M " VRF_CMD_STR,
1896 SHOW_STR
1897 IP_STR
1898 "IP routing table\n"
1899 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1900 VRF_CMD_HELP_STR)
1901
paula1ac18c2005-06-28 17:17:12 +00001902static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001903vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001904{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001905 struct route_node *rn;
1906 struct rib *rib;
1907 struct nexthop *nexthop;
1908#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1909#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1910 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1911 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1912 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001913
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001914 memset (&rib_cnt, 0, sizeof(rib_cnt));
1915 memset (&fib_cnt, 0, sizeof(fib_cnt));
1916 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001917 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001918 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1919 {
1920 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1921 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001922 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1923 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001924 {
1925 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1926 fib_cnt[rib->type]++;
1927 }
1928 if (rib->type == ZEBRA_ROUTE_BGP &&
1929 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1930 {
1931 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001932 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1933 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001934 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1935 }
1936 }
paul718e3742002-12-13 20:15:29 +00001937
Feng Lu4364ee52015-05-22 11:40:03 +02001938 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
1939 "Route Source", "Routes", "FIB",
1940 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
1941 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001942
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001943 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1944 {
1945 if (rib_cnt[i] > 0)
1946 {
1947 if (i == ZEBRA_ROUTE_BGP)
1948 {
1949 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1950 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1951 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1952 VTY_NEWLINE);
1953 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1954 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1955 VTY_NEWLINE);
1956 }
1957 else
1958 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1959 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1960 }
1961 }
paul718e3742002-12-13 20:15:29 +00001962
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001963 vty_out (vty, "------%s", VTY_NEWLINE);
1964 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1965 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02001966 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001967}
1968
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001969/*
1970 * Implementation of the ip route summary prefix command.
1971 *
1972 * This command prints the primary prefixes that have been installed by various
1973 * protocols on the box.
1974 *
1975 */
1976static void
1977vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1978{
1979 struct route_node *rn;
1980 struct rib *rib;
1981 struct nexthop *nexthop;
1982#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1983#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1984 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1985 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1986 u_int32_t i;
1987 int cnt;
1988
1989 memset (&rib_cnt, 0, sizeof(rib_cnt));
1990 memset (&fib_cnt, 0, sizeof(fib_cnt));
1991 for (rn = route_top (table); rn; rn = route_next (rn))
1992 RNODE_FOREACH_RIB (rn, rib)
1993 {
1994
1995 /*
1996 * In case of ECMP, count only once.
1997 */
1998 cnt = 0;
1999 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
2000 {
2001 cnt++;
2002 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
2003 rib_cnt[rib->type]++;
2004 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2005 {
2006 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
2007 fib_cnt[rib->type]++;
2008 }
2009 if (rib->type == ZEBRA_ROUTE_BGP &&
2010 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
2011 {
2012 rib_cnt[ZEBRA_ROUTE_IBGP]++;
2013 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
2014 fib_cnt[ZEBRA_ROUTE_IBGP]++;
2015 }
2016 }
2017 }
2018
Feng Lu4364ee52015-05-22 11:40:03 +02002019 vty_out (vty, "%-20s %-20s %s (vrf %u)%s",
2020 "Route Source", "Prefix Routes", "FIB",
2021 ((rib_table_info_t *)table->info)->zvrf->vrf_id,
2022 VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002023
2024 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2025 {
2026 if (rib_cnt[i] > 0)
2027 {
2028 if (i == ZEBRA_ROUTE_BGP)
2029 {
2030 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
2031 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
2032 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
2033 VTY_NEWLINE);
2034 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
2035 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
2036 VTY_NEWLINE);
2037 }
2038 else
2039 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
2040 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
2041 }
2042 }
2043
2044 vty_out (vty, "------%s", VTY_NEWLINE);
2045 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
2046 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
Feng Lu4364ee52015-05-22 11:40:03 +02002047 vty_out (vty, "%s", VTY_NEWLINE);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002048}
2049
paul718e3742002-12-13 20:15:29 +00002050/* Show route summary. */
2051DEFUN (show_ip_route_summary,
2052 show_ip_route_summary_cmd,
2053 "show ip route summary",
2054 SHOW_STR
2055 IP_STR
2056 "IP routing table\n"
2057 "Summary of all routes\n")
2058{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002059 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002060 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002061
Feng Lu4364ee52015-05-22 11:40:03 +02002062 if (argc > 0)
2063 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2064
2065 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002066 if (! table)
2067 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00002068
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002069 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00002070
2071 return CMD_SUCCESS;
2072}
2073
Feng Lu4364ee52015-05-22 11:40:03 +02002074ALIAS (show_ip_route_summary,
2075 show_ip_route_summary_vrf_cmd,
2076 "show ip route summary " VRF_CMD_STR,
2077 SHOW_STR
2078 IP_STR
2079 "IP routing table\n"
2080 "Summary of all routes\n"
2081 VRF_CMD_HELP_STR)
2082
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002083/* Show route summary prefix. */
2084DEFUN (show_ip_route_summary_prefix,
2085 show_ip_route_summary_prefix_cmd,
2086 "show ip route summary prefix",
2087 SHOW_STR
2088 IP_STR
2089 "IP routing table\n"
2090 "Summary of all routes\n"
2091 "Prefix routes\n")
2092{
2093 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02002094 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002095
Feng Lu4364ee52015-05-22 11:40:03 +02002096 if (argc > 0)
2097 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
2098
2099 table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002100 if (! table)
2101 return CMD_SUCCESS;
2102
2103 vty_show_ip_route_summary_prefix (vty, table);
2104
2105 return CMD_SUCCESS;
2106}
2107
Feng Lu4364ee52015-05-22 11:40:03 +02002108ALIAS (show_ip_route_summary_prefix,
2109 show_ip_route_summary_prefix_vrf_cmd,
2110 "show ip route summary prefix " VRF_CMD_STR,
2111 SHOW_STR
2112 IP_STR
2113 "IP routing table\n"
2114 "Summary of all routes\n"
2115 "Prefix routes\n"
2116 VRF_CMD_HELP_STR)
2117
2118DEFUN (show_ip_route_vrf_all,
2119 show_ip_route_vrf_all_cmd,
2120 "show ip route " VRF_ALL_CMD_STR,
2121 SHOW_STR
2122 IP_STR
2123 "IP routing table\n"
2124 VRF_ALL_CMD_HELP_STR)
2125{
2126 struct route_table *table;
2127 struct route_node *rn;
2128 struct rib *rib;
2129 struct zebra_vrf *zvrf;
2130 vrf_iter_t iter;
2131 int first = 1;
2132
2133 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2134 {
2135 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2136 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2137 continue;
2138
2139 /* Show all IPv4 routes. */
2140 for (rn = route_top (table); rn; rn = route_next (rn))
2141 RNODE_FOREACH_RIB (rn, rib)
2142 {
2143 if (first)
2144 {
2145 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2146 first = 0;
2147 }
2148 vty_show_ip_route (vty, rn, rib);
2149 }
2150 }
2151
2152 return CMD_SUCCESS;
2153}
2154
2155DEFUN (show_ip_route_prefix_longer_vrf_all,
2156 show_ip_route_prefix_longer_vrf_all_cmd,
2157 "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR,
2158 SHOW_STR
2159 IP_STR
2160 "IP routing table\n"
2161 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2162 "Show route matching the specified Network/Mask pair only\n"
2163 VRF_ALL_CMD_HELP_STR)
2164{
2165 struct route_table *table;
2166 struct route_node *rn;
2167 struct rib *rib;
2168 struct prefix p;
2169 struct zebra_vrf *zvrf;
2170 vrf_iter_t iter;
2171 int ret;
2172 int first = 1;
2173
2174 ret = str2prefix (argv[0], &p);
2175 if (! ret)
2176 {
2177 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2178 return CMD_WARNING;
2179 }
2180
2181 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2182 {
2183 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2184 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2185 continue;
2186
2187 /* Show matched type IPv4 routes. */
2188 for (rn = route_top (table); rn; rn = route_next (rn))
2189 RNODE_FOREACH_RIB (rn, rib)
2190 if (prefix_match (&p, &rn->p))
2191 {
2192 if (first)
2193 {
2194 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2195 first = 0;
2196 }
2197 vty_show_ip_route (vty, rn, rib);
2198 }
2199 }
2200
2201 return CMD_SUCCESS;
2202}
2203
2204DEFUN (show_ip_route_supernets_vrf_all,
2205 show_ip_route_supernets_vrf_all_cmd,
2206 "show ip route supernets-only " VRF_ALL_CMD_STR,
2207 SHOW_STR
2208 IP_STR
2209 "IP routing table\n"
2210 "Show supernet entries only\n"
2211 VRF_ALL_CMD_HELP_STR)
2212{
2213 struct route_table *table;
2214 struct route_node *rn;
2215 struct rib *rib;
2216 struct zebra_vrf *zvrf;
2217 vrf_iter_t iter;
2218 u_int32_t addr;
2219 int first = 1;
2220
2221 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2222 {
2223 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2224 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2225 continue;
2226
2227 /* Show matched type IPv4 routes. */
2228 for (rn = route_top (table); rn; rn = route_next (rn))
2229 RNODE_FOREACH_RIB (rn, rib)
2230 {
2231 addr = ntohl (rn->p.u.prefix4.s_addr);
2232
2233 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
2234 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
2235 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
2236 {
2237 if (first)
2238 {
2239 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2240 first = 0;
2241 }
2242 vty_show_ip_route (vty, rn, rib);
2243 }
2244 }
2245 }
2246
2247 return CMD_SUCCESS;
2248}
2249
2250DEFUN (show_ip_route_protocol_vrf_all,
2251 show_ip_route_protocol_vrf_all_cmd,
2252 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
2253 SHOW_STR
2254 IP_STR
2255 "IP routing table\n"
2256 QUAGGA_IP_REDIST_HELP_STR_ZEBRA
2257 VRF_ALL_CMD_HELP_STR)
2258{
2259 int type;
2260 struct route_table *table;
2261 struct route_node *rn;
2262 struct rib *rib;
2263 struct zebra_vrf *zvrf;
2264 vrf_iter_t iter;
2265 int first = 1;
2266
2267 type = proto_redistnum (AFI_IP, argv[0]);
2268 if (type < 0)
2269 {
2270 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2271 return CMD_WARNING;
2272 }
2273
2274 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2275 {
2276 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2277 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2278 continue;
2279
2280 /* Show matched type IPv4 routes. */
2281 for (rn = route_top (table); rn; rn = route_next (rn))
2282 RNODE_FOREACH_RIB (rn, rib)
2283 if (rib->type == type)
2284 {
2285 if (first)
2286 {
2287 vty_out (vty, SHOW_ROUTE_V4_HEADER);
2288 first = 0;
2289 }
2290 vty_show_ip_route (vty, rn, rib);
2291 }
2292 }
2293
2294 return CMD_SUCCESS;
2295}
2296
2297DEFUN (show_ip_route_addr_vrf_all,
2298 show_ip_route_addr_vrf_all_cmd,
2299 "show ip route A.B.C.D " VRF_ALL_CMD_STR,
2300 SHOW_STR
2301 IP_STR
2302 "IP routing table\n"
2303 "Network in the IP routing table to display\n"
2304 VRF_ALL_CMD_HELP_STR)
2305{
2306 int ret;
2307 struct prefix_ipv4 p;
2308 struct route_table *table;
2309 struct route_node *rn;
2310 struct zebra_vrf *zvrf;
2311 vrf_iter_t iter;
2312
2313 ret = str2prefix_ipv4 (argv[0], &p);
2314 if (ret <= 0)
2315 {
2316 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2317 return CMD_WARNING;
2318 }
2319
2320 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2321 {
2322 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2323 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2324 continue;
2325
2326 rn = route_node_match (table, (struct prefix *) &p);
2327 if (! rn)
2328 continue;
2329
2330 vty_show_ip_route_detail (vty, rn, 0);
2331
2332 route_unlock_node (rn);
2333 }
2334
2335 return CMD_SUCCESS;
2336}
2337
2338DEFUN (show_ip_route_prefix_vrf_all,
2339 show_ip_route_prefix_vrf_all_cmd,
2340 "show ip route A.B.C.D/M " VRF_ALL_CMD_STR,
2341 SHOW_STR
2342 IP_STR
2343 "IP routing table\n"
2344 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2345 VRF_ALL_CMD_HELP_STR)
2346{
2347 int ret;
2348 struct prefix_ipv4 p;
2349 struct route_table *table;
2350 struct route_node *rn;
2351 struct zebra_vrf *zvrf;
2352 vrf_iter_t iter;
2353
2354 ret = str2prefix_ipv4 (argv[0], &p);
2355 if (ret <= 0)
2356 {
2357 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
2358 return CMD_WARNING;
2359 }
2360
2361 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2362 {
2363 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2364 (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
2365 continue;
2366
2367 rn = route_node_match (table, (struct prefix *) &p);
2368 if (! rn)
2369 continue;
2370 if (rn->p.prefixlen != p.prefixlen)
2371 {
2372 route_unlock_node (rn);
2373 continue;
2374 }
2375
2376 vty_show_ip_route_detail (vty, rn, 0);
2377
2378 route_unlock_node (rn);
2379 }
2380
2381 return CMD_SUCCESS;
2382}
2383
2384DEFUN (show_ip_route_summary_vrf_all,
2385 show_ip_route_summary_vrf_all_cmd,
2386 "show ip route summary " VRF_ALL_CMD_STR,
2387 SHOW_STR
2388 IP_STR
2389 "IP routing table\n"
2390 "Summary of all routes\n"
2391 VRF_ALL_CMD_HELP_STR)
2392{
2393 struct zebra_vrf *zvrf;
2394 vrf_iter_t iter;
2395
2396 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2397 if ((zvrf = vrf_iter2info (iter)) != NULL)
2398 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2399
2400 return CMD_SUCCESS;
2401}
2402
2403DEFUN (show_ip_route_summary_prefix_vrf_all,
2404 show_ip_route_summary_prefix_vrf_all_cmd,
2405 "show ip route summary prefix " VRF_ALL_CMD_STR,
2406 SHOW_STR
2407 IP_STR
2408 "IP routing table\n"
2409 "Summary of all routes\n"
2410 "Prefix routes\n"
2411 VRF_ALL_CMD_HELP_STR)
2412{
2413 struct zebra_vrf *zvrf;
2414 vrf_iter_t iter;
2415
2416 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2417 if ((zvrf = vrf_iter2info (iter)) != NULL)
2418 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
2419
2420 return CMD_SUCCESS;
2421}
2422
paul718e3742002-12-13 20:15:29 +00002423/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002424static int
Everton Marques33d86db2014-07-14 11:19:00 -03002425static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00002426{
2427 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05002428 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00002429 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002430 struct zebra_vrf *zvrf;
2431 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00002432 int write;
2433
2434 write = 0;
2435
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002436 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
2437 {
2438 if ((zvrf = vrf_iter2info (iter)) == NULL ||
2439 (stable = zvrf->stable[AFI_IP][safi]) == NULL)
2440 continue;
paul718e3742002-12-13 20:15:29 +00002441
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002442 for (rn = route_top (stable); rn; rn = route_next (rn))
2443 for (si = rn->info; si; si = si->next)
paul7021c422003-07-15 12:52:22 +00002444 {
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002445 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
2446 rn->p.prefixlen);
2447
2448 switch (si->type)
2449 {
2450 case STATIC_IPV4_GATEWAY:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002451 vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002452 break;
2453 case STATIC_IPV4_IFNAME:
Donald Sharpd4c27d62015-11-04 13:26:35 -05002454 vty_out (vty, " %s", si->ifname);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002455 break;
2456 case STATIC_IPV4_BLACKHOLE:
2457 vty_out (vty, " Null0");
2458 break;
2459 }
2460
2461 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
2462 if (si->type != STATIC_IPV4_BLACKHOLE)
2463 {
2464 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2465 vty_out (vty, " %s", "reject");
2466
2467 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2468 vty_out (vty, " %s", "blackhole");
2469 }
2470
2471 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2472 vty_out (vty, " %d", si->distance);
2473
2474 if (si->vrf_id != VRF_DEFAULT)
2475 vty_out (vty, " vrf %u", si->vrf_id);
2476
2477 vty_out (vty, "%s", VTY_NEWLINE);
2478
2479 write = 1;
paul7021c422003-07-15 12:52:22 +00002480 }
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002481 }
paul718e3742002-12-13 20:15:29 +00002482 return write;
2483}
Andrew J. Schorr09303312007-05-30 20:10:34 +00002484
2485DEFUN (show_ip_protocol,
2486 show_ip_protocol_cmd,
2487 "show ip protocol",
2488 SHOW_STR
2489 IP_STR
2490 "IP protocol filtering status\n")
2491{
2492 int i;
2493
2494 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
2495 vty_out(vty, "------------------------%s", VTY_NEWLINE);
2496 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2497 {
2498 if (proto_rm[AFI_IP][i])
2499 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
2500 proto_rm[AFI_IP][i],
2501 VTY_NEWLINE);
2502 else
2503 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
2504 }
2505 if (proto_rm[AFI_IP][i])
2506 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
2507 VTY_NEWLINE);
2508 else
2509 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
2510
2511 return CMD_SUCCESS;
2512}
2513
paul718e3742002-12-13 20:15:29 +00002514#ifdef HAVE_IPV6
2515/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00002516static int
hasso39db97e2004-10-12 20:50:58 +00002517static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
2518 const char *gate_str, const char *ifname,
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002519 const char *flag_str, const char *distance_str,
2520 const char *vrf_id_str)
paul718e3742002-12-13 20:15:29 +00002521{
2522 int ret;
2523 u_char distance;
2524 struct prefix p;
2525 struct in6_addr *gate = NULL;
2526 struct in6_addr gate_addr;
2527 u_char type = 0;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002528 vrf_id_t vrf_id = VRF_DEFAULT;
hasso81dfcaa2003-05-25 19:21:25 +00002529 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00002530
2531 ret = str2prefix (dest_str, &p);
2532 if (ret <= 0)
2533 {
2534 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2535 return CMD_WARNING;
2536 }
2537
2538 /* Apply mask for given prefix. */
2539 apply_mask (&p);
2540
hasso81dfcaa2003-05-25 19:21:25 +00002541 /* Route flags */
2542 if (flag_str) {
2543 switch(flag_str[0]) {
2544 case 'r':
2545 case 'R': /* XXX */
2546 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
2547 break;
2548 case 'b':
2549 case 'B': /* XXX */
2550 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
2551 break;
2552 default:
2553 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00002554 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00002555 }
2556 }
2557
paul718e3742002-12-13 20:15:29 +00002558 /* Administrative distance. */
2559 if (distance_str)
2560 distance = atoi (distance_str);
2561 else
2562 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
2563
2564 /* When gateway is valid IPv6 addrees, then gate is treated as
2565 nexthop address other case gate is treated as interface name. */
2566 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
2567
2568 if (ifname)
2569 {
2570 /* When ifname is specified. It must be come with gateway
2571 address. */
2572 if (ret != 1)
2573 {
2574 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
2575 return CMD_WARNING;
2576 }
2577 type = STATIC_IPV6_GATEWAY_IFNAME;
2578 gate = &gate_addr;
2579 }
2580 else
2581 {
2582 if (ret == 1)
2583 {
2584 type = STATIC_IPV6_GATEWAY;
2585 gate = &gate_addr;
2586 }
2587 else
2588 {
2589 type = STATIC_IPV6_IFNAME;
2590 ifname = gate_str;
2591 }
2592 }
2593
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002594 /* VRF id */
2595 if (vrf_id_str)
2596 VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str);
2597
paul718e3742002-12-13 20:15:29 +00002598 if (add_cmd)
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002599 static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002600 else
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002601 static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id);
paul718e3742002-12-13 20:15:29 +00002602
2603 return CMD_SUCCESS;
2604}
2605
2606DEFUN (ipv6_route,
2607 ipv6_route_cmd,
2608 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2609 IP_STR
2610 "Establish static routes\n"
2611 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2612 "IPv6 gateway address\n"
2613 "IPv6 gateway interface name\n")
2614{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002615 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2616 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002617}
2618
2619DEFUN (ipv6_route_flags,
2620 ipv6_route_flags_cmd,
2621 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2622 IP_STR
2623 "Establish static routes\n"
2624 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2625 "IPv6 gateway address\n"
2626 "IPv6 gateway interface name\n"
2627 "Emit an ICMP unreachable when matched\n"
2628 "Silently discard pkts when matched\n")
2629{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002630 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2631 NULL);
paul718e3742002-12-13 20:15:29 +00002632}
2633
2634DEFUN (ipv6_route_ifname,
2635 ipv6_route_ifname_cmd,
2636 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2637 IP_STR
2638 "Establish static routes\n"
2639 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2640 "IPv6 gateway address\n"
2641 "IPv6 gateway interface name\n")
2642{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002643 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2644 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002645}
2646
2647DEFUN (ipv6_route_ifname_flags,
2648 ipv6_route_ifname_flags_cmd,
2649 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2650 IP_STR
2651 "Establish static routes\n"
2652 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2653 "IPv6 gateway address\n"
2654 "IPv6 gateway interface name\n"
2655 "Emit an ICMP unreachable when matched\n"
2656 "Silently discard pkts when matched\n")
2657{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002658 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2659 NULL);
paul718e3742002-12-13 20:15:29 +00002660}
2661
2662DEFUN (ipv6_route_pref,
2663 ipv6_route_pref_cmd,
2664 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2665 IP_STR
2666 "Establish static routes\n"
2667 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2668 "IPv6 gateway address\n"
2669 "IPv6 gateway interface name\n"
2670 "Distance value for this prefix\n")
2671{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002672 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2673 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002674}
2675
2676DEFUN (ipv6_route_flags_pref,
2677 ipv6_route_flags_pref_cmd,
2678 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2679 IP_STR
2680 "Establish static routes\n"
2681 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2682 "IPv6 gateway address\n"
2683 "IPv6 gateway interface name\n"
2684 "Emit an ICMP unreachable when matched\n"
2685 "Silently discard pkts when matched\n"
2686 "Distance value for this prefix\n")
2687{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002688 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2689 NULL);
paul718e3742002-12-13 20:15:29 +00002690}
2691
2692DEFUN (ipv6_route_ifname_pref,
2693 ipv6_route_ifname_pref_cmd,
2694 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2695 IP_STR
2696 "Establish static routes\n"
2697 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2698 "IPv6 gateway address\n"
2699 "IPv6 gateway interface name\n"
2700 "Distance value for this prefix\n")
2701{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002702 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2703 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002704}
2705
2706DEFUN (ipv6_route_ifname_flags_pref,
2707 ipv6_route_ifname_flags_pref_cmd,
2708 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2709 IP_STR
2710 "Establish static routes\n"
2711 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2712 "IPv6 gateway address\n"
2713 "IPv6 gateway interface name\n"
2714 "Emit an ICMP unreachable when matched\n"
2715 "Silently discard pkts when matched\n"
2716 "Distance value for this prefix\n")
2717{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002718 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2719 NULL);
paul718e3742002-12-13 20:15:29 +00002720}
2721
2722DEFUN (no_ipv6_route,
2723 no_ipv6_route_cmd,
2724 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
2725 NO_STR
2726 IP_STR
2727 "Establish static routes\n"
2728 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2729 "IPv6 gateway address\n"
2730 "IPv6 gateway interface name\n")
2731{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002732 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2733 NULL);
paul718e3742002-12-13 20:15:29 +00002734}
2735
hasso81dfcaa2003-05-25 19:21:25 +00002736ALIAS (no_ipv6_route,
2737 no_ipv6_route_flags_cmd,
2738 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
2739 NO_STR
2740 IP_STR
2741 "Establish static routes\n"
2742 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2743 "IPv6 gateway address\n"
2744 "IPv6 gateway interface name\n"
2745 "Emit an ICMP unreachable when matched\n"
2746 "Silently discard pkts when matched\n")
2747
paul718e3742002-12-13 20:15:29 +00002748DEFUN (no_ipv6_route_ifname,
2749 no_ipv6_route_ifname_cmd,
2750 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
2751 NO_STR
2752 IP_STR
2753 "Establish static routes\n"
2754 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2755 "IPv6 gateway address\n"
2756 "IPv6 gateway interface name\n")
2757{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002758 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
2759 NULL);
paul718e3742002-12-13 20:15:29 +00002760}
2761
hasso81dfcaa2003-05-25 19:21:25 +00002762ALIAS (no_ipv6_route_ifname,
2763 no_ipv6_route_ifname_flags_cmd,
2764 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
2765 NO_STR
2766 IP_STR
2767 "Establish static routes\n"
2768 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2769 "IPv6 gateway address\n"
2770 "IPv6 gateway interface name\n"
2771 "Emit an ICMP unreachable when matched\n"
2772 "Silently discard pkts when matched\n")
2773
paul718e3742002-12-13 20:15:29 +00002774DEFUN (no_ipv6_route_pref,
2775 no_ipv6_route_pref_cmd,
2776 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
2777 NO_STR
2778 IP_STR
2779 "Establish static routes\n"
2780 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2781 "IPv6 gateway address\n"
2782 "IPv6 gateway interface name\n"
2783 "Distance value for this prefix\n")
2784{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002785 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
2786 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002787}
2788
2789DEFUN (no_ipv6_route_flags_pref,
2790 no_ipv6_route_flags_pref_cmd,
2791 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
2792 NO_STR
2793 IP_STR
2794 "Establish static routes\n"
2795 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2796 "IPv6 gateway address\n"
2797 "IPv6 gateway interface name\n"
2798 "Emit an ICMP unreachable when matched\n"
2799 "Silently discard pkts when matched\n"
2800 "Distance value for this prefix\n")
2801{
2802 /* We do not care about argv[2] */
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002803 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
2804 NULL);
paul718e3742002-12-13 20:15:29 +00002805}
2806
2807DEFUN (no_ipv6_route_ifname_pref,
2808 no_ipv6_route_ifname_pref_cmd,
2809 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
2810 NO_STR
2811 IP_STR
2812 "Establish static routes\n"
2813 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2814 "IPv6 gateway address\n"
2815 "IPv6 gateway interface name\n"
2816 "Distance value for this prefix\n")
2817{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002818 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
2819 NULL);
hasso81dfcaa2003-05-25 19:21:25 +00002820}
2821
2822DEFUN (no_ipv6_route_ifname_flags_pref,
2823 no_ipv6_route_ifname_flags_pref_cmd,
2824 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
2825 NO_STR
2826 IP_STR
2827 "Establish static routes\n"
2828 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2829 "IPv6 gateway address\n"
2830 "IPv6 gateway interface name\n"
2831 "Emit an ICMP unreachable when matched\n"
2832 "Silently discard pkts when matched\n"
2833 "Distance value for this prefix\n")
2834{
Feng Lu7aaf4ea2015-05-22 11:40:06 +02002835 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
2836 NULL);
2837}
2838
2839DEFUN (ipv6_route_vrf,
2840 ipv6_route_vrf_cmd,
2841 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2842 IP_STR
2843 "Establish static routes\n"
2844 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2845 "IPv6 gateway address\n"
2846 "IPv6 gateway interface name\n"
2847 VRF_CMD_HELP_STR)
2848{
2849 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL,
2850 argv[2]);
2851}
2852
2853DEFUN (ipv6_route_flags_vrf,
2854 ipv6_route_flags_vrf_cmd,
2855 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2856 IP_STR
2857 "Establish static routes\n"
2858 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2859 "IPv6 gateway address\n"
2860 "IPv6 gateway interface name\n"
2861 "Emit an ICMP unreachable when matched\n"
2862 "Silently discard pkts when matched\n"
2863 VRF_CMD_HELP_STR)
2864{
2865 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL,
2866 argv[3]);
2867}
2868
2869DEFUN (ipv6_route_ifname_vrf,
2870 ipv6_route_ifname_vrf_cmd,
2871 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2872 IP_STR
2873 "Establish static routes\n"
2874 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2875 "IPv6 gateway address\n"
2876 "IPv6 gateway interface name\n"
2877 VRF_CMD_HELP_STR)
2878{
2879 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL,
2880 argv[3]);
2881}
2882
2883DEFUN (ipv6_route_ifname_flags_vrf,
2884 ipv6_route_ifname_flags_vrf_cmd,
2885 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
2886 IP_STR
2887 "Establish static routes\n"
2888 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2889 "IPv6 gateway address\n"
2890 "IPv6 gateway interface name\n"
2891 "Emit an ICMP unreachable when matched\n"
2892 "Silently discard pkts when matched\n"
2893 VRF_CMD_HELP_STR)
2894{
2895 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL,
2896 argv[4]);
2897}
2898
2899DEFUN (ipv6_route_pref_vrf,
2900 ipv6_route_pref_vrf_cmd,
2901 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
2902 IP_STR
2903 "Establish static routes\n"
2904 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2905 "IPv6 gateway address\n"
2906 "IPv6 gateway interface name\n"
2907 "Distance value for this prefix\n"
2908 VRF_CMD_HELP_STR)
2909{
2910 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2],
2911 argv[3]);
2912}
2913
2914DEFUN (ipv6_route_flags_pref_vrf,
2915 ipv6_route_flags_pref_vrf_cmd,
2916 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
2917 IP_STR
2918 "Establish static routes\n"
2919 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2920 "IPv6 gateway address\n"
2921 "IPv6 gateway interface name\n"
2922 "Emit an ICMP unreachable when matched\n"
2923 "Silently discard pkts when matched\n"
2924 "Distance value for this prefix\n"
2925 VRF_CMD_HELP_STR)
2926{
2927 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3],
2928 argv[4]);
2929}
2930
2931DEFUN (ipv6_route_ifname_pref_vrf,
2932 ipv6_route_ifname_pref_vrf_cmd,
2933 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
2934 IP_STR
2935 "Establish static routes\n"
2936 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2937 "IPv6 gateway address\n"
2938 "IPv6 gateway interface name\n"
2939 "Distance value for this prefix\n"
2940 VRF_CMD_HELP_STR)
2941{
2942 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3],
2943 argv[4]);
2944}
2945
2946DEFUN (ipv6_route_ifname_flags_pref_vrf,
2947 ipv6_route_ifname_flags_pref_vrf_cmd,
2948 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
2949 IP_STR
2950 "Establish static routes\n"
2951 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2952 "IPv6 gateway address\n"
2953 "IPv6 gateway interface name\n"
2954 "Emit an ICMP unreachable when matched\n"
2955 "Silently discard pkts when matched\n"
2956 "Distance value for this prefix\n"
2957 VRF_CMD_HELP_STR)
2958{
2959 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4],
2960 argv[5]);
2961}
2962
2963DEFUN (no_ipv6_route_vrf,
2964 no_ipv6_route_vrf_cmd,
2965 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR,
2966 NO_STR
2967 IP_STR
2968 "Establish static routes\n"
2969 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2970 "IPv6 gateway address\n"
2971 "IPv6 gateway interface name\n"
2972 VRF_CMD_HELP_STR)
2973{
2974 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL,
2975 (argc > 3) ? argv[3] : argv[2]);
2976}
2977
2978ALIAS (no_ipv6_route_vrf,
2979 no_ipv6_route_flags_vrf_cmd,
2980 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR,
2981 NO_STR
2982 IP_STR
2983 "Establish static routes\n"
2984 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2985 "IPv6 gateway address\n"
2986 "IPv6 gateway interface name\n"
2987 "Emit an ICMP unreachable when matched\n"
2988 "Silently discard pkts when matched\n"
2989 VRF_CMD_HELP_STR)
2990
2991DEFUN (no_ipv6_route_ifname_vrf,
2992 no_ipv6_route_ifname_vrf_cmd,
2993 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR,
2994 NO_STR
2995 IP_STR
2996 "Establish static routes\n"
2997 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
2998 "IPv6 gateway address\n"
2999 "IPv6 gateway interface name\n"
3000 VRF_CMD_HELP_STR)
3001{
3002 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL,
3003 (argc > 4) ? argv[4] : argv[3]);
3004}
3005
3006ALIAS (no_ipv6_route_ifname_vrf,
3007 no_ipv6_route_ifname_flags_vrf_cmd,
3008 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR,
3009 NO_STR
3010 IP_STR
3011 "Establish static routes\n"
3012 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3013 "IPv6 gateway address\n"
3014 "IPv6 gateway interface name\n"
3015 "Emit an ICMP unreachable when matched\n"
3016 "Silently discard pkts when matched\n"
3017 VRF_CMD_HELP_STR)
3018
3019DEFUN (no_ipv6_route_pref_vrf,
3020 no_ipv6_route_pref_vrf_cmd,
3021 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR,
3022 NO_STR
3023 IP_STR
3024 "Establish static routes\n"
3025 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3026 "IPv6 gateway address\n"
3027 "IPv6 gateway interface name\n"
3028 "Distance value for this prefix\n"
3029 VRF_CMD_HELP_STR)
3030{
3031 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2],
3032 argv[3]);
3033}
3034
3035DEFUN (no_ipv6_route_flags_pref_vrf,
3036 no_ipv6_route_flags_pref_vrf_cmd,
3037 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR,
3038 NO_STR
3039 IP_STR
3040 "Establish static routes\n"
3041 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3042 "IPv6 gateway address\n"
3043 "IPv6 gateway interface name\n"
3044 "Emit an ICMP unreachable when matched\n"
3045 "Silently discard pkts when matched\n"
3046 "Distance value for this prefix\n"
3047 VRF_CMD_HELP_STR)
3048{
3049 /* We do not care about argv[2] */
3050 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3],
3051 argv[4]);
3052}
3053
3054DEFUN (no_ipv6_route_ifname_pref_vrf,
3055 no_ipv6_route_ifname_pref_vrf_cmd,
3056 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR,
3057 NO_STR
3058 IP_STR
3059 "Establish static routes\n"
3060 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3061 "IPv6 gateway address\n"
3062 "IPv6 gateway interface name\n"
3063 "Distance value for this prefix\n"
3064 VRF_CMD_HELP_STR)
3065{
3066 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3],
3067 argv[4]);
3068}
3069
3070DEFUN (no_ipv6_route_ifname_flags_pref_vrf,
3071 no_ipv6_route_ifname_flags_pref_vrf_cmd,
3072 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR,
3073 NO_STR
3074 IP_STR
3075 "Establish static routes\n"
3076 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
3077 "IPv6 gateway address\n"
3078 "IPv6 gateway interface name\n"
3079 "Emit an ICMP unreachable when matched\n"
3080 "Silently discard pkts when matched\n"
3081 "Distance value for this prefix\n"
3082 VRF_CMD_HELP_STR)
3083{
3084 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4],
3085 argv[5]);
paul718e3742002-12-13 20:15:29 +00003086}
3087
paul718e3742002-12-13 20:15:29 +00003088DEFUN (show_ipv6_route,
3089 show_ipv6_route_cmd,
3090 "show ipv6 route",
3091 SHOW_STR
3092 IP_STR
3093 "IPv6 routing table\n")
3094{
3095 struct route_table *table;
3096 struct route_node *rn;
3097 struct rib *rib;
3098 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003099 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003100
Feng Lu4364ee52015-05-22 11:40:03 +02003101 if (argc > 0)
3102 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3103
3104 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003105 if (! table)
3106 return CMD_SUCCESS;
3107
3108 /* Show all IPv6 route. */
3109 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003110 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003111 {
3112 if (first)
3113 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003114 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003115 first = 0;
3116 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003117 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003118 }
3119 return CMD_SUCCESS;
3120}
3121
Feng Lu4364ee52015-05-22 11:40:03 +02003122ALIAS (show_ipv6_route,
3123 show_ipv6_route_vrf_cmd,
3124 "show ipv6 route " VRF_CMD_STR,
3125 SHOW_STR
3126 IP_STR
3127 "IPv6 routing table\n"
3128 VRF_CMD_HELP_STR)
3129
paul718e3742002-12-13 20:15:29 +00003130DEFUN (show_ipv6_route_prefix_longer,
3131 show_ipv6_route_prefix_longer_cmd,
3132 "show ipv6 route X:X::X:X/M longer-prefixes",
3133 SHOW_STR
3134 IP_STR
3135 "IPv6 routing table\n"
3136 "IPv6 prefix\n"
3137 "Show route matching the specified Network/Mask pair only\n")
3138{
3139 struct route_table *table;
3140 struct route_node *rn;
3141 struct rib *rib;
3142 struct prefix p;
3143 int ret;
3144 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003145 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003146
3147 ret = str2prefix (argv[0], &p);
3148 if (! ret)
3149 {
3150 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3151 return CMD_WARNING;
3152 }
3153
Feng Lu4364ee52015-05-22 11:40:03 +02003154 if (argc > 1)
3155 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3156
3157 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
3158 if (! table)
3159 return CMD_SUCCESS;
3160
paul718e3742002-12-13 20:15:29 +00003161 /* Show matched type IPv6 routes. */
3162 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003163 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003164 if (prefix_match (&p, &rn->p))
3165 {
3166 if (first)
3167 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003168 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003169 first = 0;
3170 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003171 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003172 }
3173 return CMD_SUCCESS;
3174}
3175
Feng Lu4364ee52015-05-22 11:40:03 +02003176ALIAS (show_ipv6_route_prefix_longer,
3177 show_ipv6_route_prefix_longer_vrf_cmd,
3178 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR,
3179 SHOW_STR
3180 IP_STR
3181 "IPv6 routing table\n"
3182 "IPv6 prefix\n"
3183 "Show route matching the specified Network/Mask pair only\n"
3184 VRF_CMD_HELP_STR)
3185
paul718e3742002-12-13 20:15:29 +00003186DEFUN (show_ipv6_route_protocol,
3187 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02003188 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00003189 SHOW_STR
3190 IP_STR
3191 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02003192 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00003193{
3194 int type;
3195 struct route_table *table;
3196 struct route_node *rn;
3197 struct rib *rib;
3198 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003199 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003200
David Lampartere0ca5fd2009-09-16 01:52:42 +02003201 type = proto_redistnum (AFI_IP6, argv[0]);
3202 if (type < 0)
paul718e3742002-12-13 20:15:29 +00003203 {
3204 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3205 return CMD_WARNING;
3206 }
Feng Lu4364ee52015-05-22 11:40:03 +02003207
3208 if (argc > 1)
3209 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3210
3211 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003212 if (! table)
3213 return CMD_SUCCESS;
3214
3215 /* Show matched type IPv6 routes. */
3216 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003217 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00003218 if (rib->type == type)
3219 {
3220 if (first)
3221 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02003222 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00003223 first = 0;
3224 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003225 vty_show_ip_route (vty, rn, rib);
paul718e3742002-12-13 20:15:29 +00003226 }
3227 return CMD_SUCCESS;
3228}
3229
Feng Lu4364ee52015-05-22 11:40:03 +02003230ALIAS (show_ipv6_route_protocol,
3231 show_ipv6_route_protocol_vrf_cmd,
3232 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR,
3233 SHOW_STR
3234 IP_STR
3235 "IP routing table\n"
3236 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3237 VRF_CMD_HELP_STR)
3238
paul718e3742002-12-13 20:15:29 +00003239DEFUN (show_ipv6_route_addr,
3240 show_ipv6_route_addr_cmd,
3241 "show ipv6 route X:X::X:X",
3242 SHOW_STR
3243 IP_STR
3244 "IPv6 routing table\n"
3245 "IPv6 Address\n")
3246{
3247 int ret;
3248 struct prefix_ipv6 p;
3249 struct route_table *table;
3250 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003251 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003252
3253 ret = str2prefix_ipv6 (argv[0], &p);
3254 if (ret <= 0)
3255 {
3256 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3257 return CMD_WARNING;
3258 }
3259
Feng Lu4364ee52015-05-22 11:40:03 +02003260 if (argc > 1)
3261 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3262
3263 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003264 if (! table)
3265 return CMD_SUCCESS;
3266
3267 rn = route_node_match (table, (struct prefix *) &p);
3268 if (! rn)
3269 {
3270 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
3271 return CMD_WARNING;
3272 }
3273
Timo Teräs53a5c392015-05-23 11:08:40 +03003274 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003275
3276 route_unlock_node (rn);
3277
3278 return CMD_SUCCESS;
3279}
3280
Feng Lu4364ee52015-05-22 11:40:03 +02003281ALIAS (show_ipv6_route_addr,
3282 show_ipv6_route_addr_vrf_cmd,
3283 "show ipv6 route X:X::X:X " VRF_CMD_STR,
3284 SHOW_STR
3285 IP_STR
3286 "IPv6 routing table\n"
3287 "IPv6 Address\n"
3288 VRF_CMD_HELP_STR)
3289
paul718e3742002-12-13 20:15:29 +00003290DEFUN (show_ipv6_route_prefix,
3291 show_ipv6_route_prefix_cmd,
3292 "show ipv6 route X:X::X:X/M",
3293 SHOW_STR
3294 IP_STR
3295 "IPv6 routing table\n"
3296 "IPv6 prefix\n")
3297{
3298 int ret;
3299 struct prefix_ipv6 p;
3300 struct route_table *table;
3301 struct route_node *rn;
Feng Lu4364ee52015-05-22 11:40:03 +02003302 vrf_id_t vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +00003303
3304 ret = str2prefix_ipv6 (argv[0], &p);
3305 if (ret <= 0)
3306 {
3307 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3308 return CMD_WARNING;
3309 }
3310
Feng Lu4364ee52015-05-22 11:40:03 +02003311 if (argc > 1)
3312 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]);
3313
3314 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
paul718e3742002-12-13 20:15:29 +00003315 if (! table)
3316 return CMD_SUCCESS;
3317
3318 rn = route_node_match (table, (struct prefix *) &p);
3319 if (! rn || rn->p.prefixlen != p.prefixlen)
3320 {
3321 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00003322 if (rn)
3323 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00003324 return CMD_WARNING;
3325 }
3326
Timo Teräs53a5c392015-05-23 11:08:40 +03003327 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00003328
3329 route_unlock_node (rn);
3330
3331 return CMD_SUCCESS;
3332}
3333
Feng Lu4364ee52015-05-22 11:40:03 +02003334ALIAS (show_ipv6_route_prefix,
3335 show_ipv6_route_prefix_vrf_cmd,
3336 "show ipv6 route X:X::X:X/M " VRF_CMD_STR,
3337 SHOW_STR
3338 IP_STR
3339 "IPv6 routing table\n"
3340 "IPv6 prefix\n"
3341 VRF_CMD_HELP_STR)
3342
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003343/* Show route summary. */
3344DEFUN (show_ipv6_route_summary,
3345 show_ipv6_route_summary_cmd,
3346 "show ipv6 route summary",
3347 SHOW_STR
3348 IP_STR
3349 "IPv6 routing table\n"
3350 "Summary of all IPv6 routes\n")
3351{
3352 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003353 vrf_id_t vrf_id = VRF_DEFAULT;
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003354
Feng Lu4364ee52015-05-22 11:40:03 +02003355 if (argc > 0)
3356 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3357
3358 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003359 if (! table)
3360 return CMD_SUCCESS;
3361
3362 vty_show_ip_route_summary (vty, table);
3363
3364 return CMD_SUCCESS;
3365}
3366
Feng Lu4364ee52015-05-22 11:40:03 +02003367ALIAS (show_ipv6_route_summary,
3368 show_ipv6_route_summary_vrf_cmd,
3369 "show ipv6 route summary " VRF_CMD_STR,
3370 SHOW_STR
3371 IP_STR
3372 "IPv6 routing table\n"
3373 "Summary of all IPv6 routes\n"
3374 VRF_CMD_HELP_STR)
3375
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003376/* Show ipv6 route summary prefix. */
3377DEFUN (show_ipv6_route_summary_prefix,
3378 show_ipv6_route_summary_prefix_cmd,
3379 "show ipv6 route summary prefix",
3380 SHOW_STR
3381 IP_STR
3382 "IPv6 routing table\n"
3383 "Summary of all IPv6 routes\n"
3384 "Prefix routes\n")
3385{
3386 struct route_table *table;
Feng Lu4364ee52015-05-22 11:40:03 +02003387 vrf_id_t vrf_id = VRF_DEFAULT;
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003388
Feng Lu4364ee52015-05-22 11:40:03 +02003389 if (argc > 0)
3390 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3391
3392 table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003393 if (! table)
3394 return CMD_SUCCESS;
3395
3396 vty_show_ip_route_summary_prefix (vty, table);
3397
3398 return CMD_SUCCESS;
3399}
3400
Feng Lu4364ee52015-05-22 11:40:03 +02003401ALIAS (show_ipv6_route_summary_prefix,
3402 show_ipv6_route_summary_prefix_vrf_cmd,
3403 "show ipv6 route summary prefix " VRF_CMD_STR,
3404 SHOW_STR
3405 IP_STR
3406 "IPv6 routing table\n"
3407 "Summary of all IPv6 routes\n"
3408 "Prefix routes\n"
3409 VRF_CMD_HELP_STR)
3410
G.Balajicddf3912011-11-26 21:59:32 +04003411/*
G.Balajicddf3912011-11-26 21:59:32 +04003412 * Show IPv6 mroute command.Used to dump
3413 * the Multicast routing table.
3414 */
3415
3416DEFUN (show_ipv6_mroute,
3417 show_ipv6_mroute_cmd,
3418 "show ipv6 mroute",
3419 SHOW_STR
3420 IP_STR
3421 "IPv6 Multicast routing table\n")
3422{
3423 struct route_table *table;
3424 struct route_node *rn;
3425 struct rib *rib;
3426 int first = 1;
Feng Lu4364ee52015-05-22 11:40:03 +02003427 vrf_id_t vrf_id = VRF_DEFAULT;
G.Balajicddf3912011-11-26 21:59:32 +04003428
Feng Lu4364ee52015-05-22 11:40:03 +02003429 if (argc > 0)
3430 VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]);
3431
3432 table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id);
G.Balajicddf3912011-11-26 21:59:32 +04003433 if (! table)
3434 return CMD_SUCCESS;
3435
3436 /* Show all IPv6 route. */
3437 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00003438 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04003439 {
3440 if (first)
3441 {
G.Balajicb32fd62011-11-27 20:09:40 +05303442 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04003443 first = 0;
3444 }
Timo Teräs53a5c392015-05-23 11:08:40 +03003445 vty_show_ip_route (vty, rn, rib);
G.Balajicddf3912011-11-26 21:59:32 +04003446 }
3447 return CMD_SUCCESS;
3448}
3449
Feng Lu4364ee52015-05-22 11:40:03 +02003450ALIAS (show_ipv6_mroute,
3451 show_ipv6_mroute_vrf_cmd,
3452 "show ipv6 mroute " VRF_CMD_STR,
3453 SHOW_STR
3454 IP_STR
3455 "IPv6 Multicast routing table\n"
3456 VRF_CMD_HELP_STR)
3457
3458DEFUN (show_ipv6_route_vrf_all,
3459 show_ipv6_route_vrf_all_cmd,
3460 "show ipv6 route " VRF_ALL_CMD_STR,
3461 SHOW_STR
3462 IP_STR
3463 "IPv6 routing table\n"
3464 VRF_ALL_CMD_HELP_STR)
3465{
3466 struct route_table *table;
3467 struct route_node *rn;
3468 struct rib *rib;
3469 struct zebra_vrf *zvrf;
3470 vrf_iter_t iter;
3471 int first = 1;
3472
3473 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3474 {
3475 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3476 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3477 continue;
3478
3479 /* Show all IPv6 route. */
3480 for (rn = route_top (table); rn; rn = route_next (rn))
3481 RNODE_FOREACH_RIB (rn, rib)
3482 {
3483 if (first)
3484 {
3485 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3486 first = 0;
3487 }
3488 vty_show_ip_route (vty, rn, rib);
3489 }
3490 }
3491
3492 return CMD_SUCCESS;
3493}
3494
3495DEFUN (show_ipv6_route_prefix_longer_vrf_all,
3496 show_ipv6_route_prefix_longer_vrf_all_cmd,
3497 "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR,
3498 SHOW_STR
3499 IP_STR
3500 "IPv6 routing table\n"
3501 "IPv6 prefix\n"
3502 "Show route matching the specified Network/Mask pair only\n"
3503 VRF_ALL_CMD_HELP_STR)
3504{
3505 struct route_table *table;
3506 struct route_node *rn;
3507 struct rib *rib;
3508 struct prefix p;
3509 struct zebra_vrf *zvrf;
3510 vrf_iter_t iter;
3511 int ret;
3512 int first = 1;
3513
3514 ret = str2prefix (argv[0], &p);
3515 if (! ret)
3516 {
3517 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
3518 return CMD_WARNING;
3519 }
3520
3521 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3522 {
3523 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3524 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3525 continue;
3526
3527 /* Show matched type IPv6 routes. */
3528 for (rn = route_top (table); rn; rn = route_next (rn))
3529 RNODE_FOREACH_RIB (rn, rib)
3530 if (prefix_match (&p, &rn->p))
3531 {
3532 if (first)
3533 {
3534 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3535 first = 0;
3536 }
3537 vty_show_ip_route (vty, rn, rib);
3538 }
3539 }
3540
3541 return CMD_SUCCESS;
3542}
3543
3544DEFUN (show_ipv6_route_protocol_vrf_all,
3545 show_ipv6_route_protocol_vrf_all_cmd,
3546 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR,
3547 SHOW_STR
3548 IP_STR
3549 "IP routing table\n"
3550 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA
3551 VRF_ALL_CMD_HELP_STR)
3552{
3553 int type;
3554 struct route_table *table;
3555 struct route_node *rn;
3556 struct rib *rib;
3557 struct zebra_vrf *zvrf;
3558 vrf_iter_t iter;
3559 int first = 1;
3560
3561 type = proto_redistnum (AFI_IP6, argv[0]);
3562 if (type < 0)
3563 {
3564 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
3565 return CMD_WARNING;
3566 }
3567
3568 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3569 {
3570 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3571 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3572 continue;
3573
3574 /* Show matched type IPv6 routes. */
3575 for (rn = route_top (table); rn; rn = route_next (rn))
3576 RNODE_FOREACH_RIB (rn, rib)
3577 if (rib->type == type)
3578 {
3579 if (first)
3580 {
3581 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3582 first = 0;
3583 }
3584 vty_show_ip_route (vty, rn, rib);
3585 }
3586 }
3587
3588 return CMD_SUCCESS;
3589}
3590
3591DEFUN (show_ipv6_route_addr_vrf_all,
3592 show_ipv6_route_addr_vrf_all_cmd,
3593 "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR,
3594 SHOW_STR
3595 IP_STR
3596 "IPv6 routing table\n"
3597 "IPv6 Address\n"
3598 VRF_ALL_CMD_HELP_STR)
3599{
3600 int ret;
3601 struct prefix_ipv6 p;
3602 struct route_table *table;
3603 struct route_node *rn;
3604 struct zebra_vrf *zvrf;
3605 vrf_iter_t iter;
3606
3607 ret = str2prefix_ipv6 (argv[0], &p);
3608 if (ret <= 0)
3609 {
3610 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
3611 return CMD_WARNING;
3612 }
3613
3614 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3615 {
3616 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3617 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3618 continue;
3619
3620 rn = route_node_match (table, (struct prefix *) &p);
3621 if (! rn)
3622 continue;
3623
3624 vty_show_ip_route_detail (vty, rn, 0);
3625
3626 route_unlock_node (rn);
3627 }
3628
3629 return CMD_SUCCESS;
3630}
3631
3632DEFUN (show_ipv6_route_prefix_vrf_all,
3633 show_ipv6_route_prefix_vrf_all_cmd,
3634 "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR,
3635 SHOW_STR
3636 IP_STR
3637 "IPv6 routing table\n"
3638 "IPv6 prefix\n"
3639 VRF_ALL_CMD_HELP_STR)
3640{
3641 int ret;
3642 struct prefix_ipv6 p;
3643 struct route_table *table;
3644 struct route_node *rn;
3645 struct zebra_vrf *zvrf;
3646 vrf_iter_t iter;
3647
3648 ret = str2prefix_ipv6 (argv[0], &p);
3649 if (ret <= 0)
3650 {
3651 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
3652 return CMD_WARNING;
3653 }
3654
3655 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3656 {
3657 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3658 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3659 continue;
3660
3661 rn = route_node_match (table, (struct prefix *) &p);
3662 if (! rn)
3663 continue;
3664 if (rn->p.prefixlen != p.prefixlen)
3665 {
3666 route_unlock_node (rn);
3667 continue;
3668 }
3669
3670 vty_show_ip_route_detail (vty, rn, 0);
3671
3672 route_unlock_node (rn);
3673 }
3674
3675 return CMD_SUCCESS;
3676}
3677
3678/* Show route summary. */
3679DEFUN (show_ipv6_route_summary_vrf_all,
3680 show_ipv6_route_summary_vrf_all_cmd,
3681 "show ipv6 route summary " VRF_ALL_CMD_STR,
3682 SHOW_STR
3683 IP_STR
3684 "IPv6 routing table\n"
3685 "Summary of all IPv6 routes\n"
3686 VRF_ALL_CMD_HELP_STR)
3687{
3688 struct zebra_vrf *zvrf;
3689 vrf_iter_t iter;
3690
3691 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3692 if ((zvrf = vrf_iter2info (iter)) != NULL)
3693 vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3694
3695 return CMD_SUCCESS;
3696}
3697
3698DEFUN (show_ipv6_mroute_vrf_all,
3699 show_ipv6_mroute_vrf_all_cmd,
3700 "show ipv6 mroute " VRF_ALL_CMD_STR,
3701 SHOW_STR
3702 IP_STR
3703 "IPv6 Multicast routing table\n"
3704 VRF_ALL_CMD_HELP_STR)
3705{
3706 struct route_table *table;
3707 struct route_node *rn;
3708 struct rib *rib;
3709 struct zebra_vrf *zvrf;
3710 vrf_iter_t iter;
3711 int first = 1;
3712
3713 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3714 {
3715 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3716 (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
3717 continue;
3718
3719 /* Show all IPv6 route. */
3720 for (rn = route_top (table); rn; rn = route_next (rn))
3721 RNODE_FOREACH_RIB (rn, rib)
3722 {
3723 if (first)
3724 {
3725 vty_out (vty, SHOW_ROUTE_V6_HEADER);
3726 first = 0;
3727 }
3728 vty_show_ip_route (vty, rn, rib);
3729 }
3730 }
3731 return CMD_SUCCESS;
3732}
3733
3734DEFUN (show_ipv6_route_summary_prefix_vrf_all,
3735 show_ipv6_route_summary_prefix_vrf_all_cmd,
3736 "show ipv6 route summary prefix " VRF_ALL_CMD_STR,
3737 SHOW_STR
3738 IP_STR
3739 "IPv6 routing table\n"
3740 "Summary of all IPv6 routes\n"
3741 "Prefix routes\n"
3742 VRF_ALL_CMD_HELP_STR)
3743{
3744 struct zebra_vrf *zvrf;
3745 vrf_iter_t iter;
3746
3747 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3748 if ((zvrf = vrf_iter2info (iter)) != NULL)
3749 vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
3750
3751 return CMD_SUCCESS;
3752}
3753
paul718e3742002-12-13 20:15:29 +00003754/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00003755static int
paul718e3742002-12-13 20:15:29 +00003756static_config_ipv6 (struct vty *vty)
3757{
3758 struct route_node *rn;
Donald Sharpd4c27d62015-11-04 13:26:35 -05003759 struct static_route *si;
paul718e3742002-12-13 20:15:29 +00003760 int write;
3761 char buf[BUFSIZ];
3762 struct route_table *stable;
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003763 struct zebra_vrf *zvrf;
3764 vrf_iter_t iter;
paul718e3742002-12-13 20:15:29 +00003765
3766 write = 0;
3767
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003768 for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
3769 {
3770 if ((zvrf = vrf_iter2info (iter)) == NULL ||
3771 (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL)
3772 continue;
paul718e3742002-12-13 20:15:29 +00003773
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003774 for (rn = route_top (stable); rn; rn = route_next (rn))
3775 for (si = rn->info; si; si = si->next)
3776 {
3777 vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf));
paul718e3742002-12-13 20:15:29 +00003778
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003779 switch (si->type)
3780 {
3781 case STATIC_IPV6_GATEWAY:
3782 vty_out (vty, " %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003783 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003784 break;
3785 case STATIC_IPV6_IFNAME:
3786 vty_out (vty, " %s", si->ifname);
3787 break;
3788 case STATIC_IPV6_GATEWAY_IFNAME:
3789 vty_out (vty, " %s %s",
Donald Sharpd4c27d62015-11-04 13:26:35 -05003790 inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003791 si->ifname);
3792 break;
3793 }
paul718e3742002-12-13 20:15:29 +00003794
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003795 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
3796 vty_out (vty, " %s", "reject");
hasso81dfcaa2003-05-25 19:21:25 +00003797
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003798 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
3799 vty_out (vty, " %s", "blackhole");
hasso81dfcaa2003-05-25 19:21:25 +00003800
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003801 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
3802 vty_out (vty, " %d", si->distance);
paul718e3742002-12-13 20:15:29 +00003803
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003804 if (si->vrf_id != VRF_DEFAULT)
3805 vty_out (vty, " vrf %u", si->vrf_id);
3806
3807 vty_out (vty, "%s", VTY_NEWLINE);
3808
3809 write = 1;
3810 }
3811 }
paul718e3742002-12-13 20:15:29 +00003812 return write;
3813}
3814#endif /* HAVE_IPV6 */
3815
3816/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00003817static int
paul718e3742002-12-13 20:15:29 +00003818zebra_ip_config (struct vty *vty)
3819{
3820 int write = 0;
3821
Everton Marques33d86db2014-07-14 11:19:00 -03003822 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
3823 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00003824#ifdef HAVE_IPV6
3825 write += static_config_ipv6 (vty);
3826#endif /* HAVE_IPV6 */
3827
3828 return write;
3829}
3830
David Lamparterbd078122015-01-06 19:53:24 +01003831static int config_write_vty(struct vty *vty)
3832{
Paul Jakma7514fb72007-05-02 16:05:35 +00003833 int i;
David Lamparterbd078122015-01-06 19:53:24 +01003834 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
3835
3836 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
3837 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
3838 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
3839 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
3840 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
3841 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
3842 "longer-prefix",
3843 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00003844
3845 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
3846 {
3847 if (proto_rm[AFI_IP][i])
3848 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
3849 proto_rm[AFI_IP][i], VTY_NEWLINE);
3850 }
3851 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
3852 vty_out (vty, "ip protocol %s route-map %s%s", "any",
3853 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
3854
3855 return 1;
3856}
3857
3858/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003859static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00003860
paul718e3742002-12-13 20:15:29 +00003861/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08003862static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00003863
3864/* Route VTY. */
3865void
paula1ac18c2005-06-28 17:17:12 +00003866zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00003867{
3868 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01003869 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00003870
Everton Marques33d86db2014-07-14 11:19:00 -03003871 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003872 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03003873 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01003874 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01003875 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
3876 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
3877 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00003878 install_element (CONFIG_NODE, &ip_protocol_cmd);
3879 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
3880 install_element (VIEW_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00003881 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003882 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003883 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003884 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003885 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003886 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003887 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003888 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003889 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003890 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003891 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00003892 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00003893 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003894 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003895 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003896 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003897 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003898 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003899 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003900 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003901 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003902 install_element (CONFIG_NODE, &no_ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003903 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00003904 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00003905
3906 install_element (VIEW_NODE, &show_ip_route_cmd);
Pradosh Mohapatra60cc9592015-11-09 20:21:41 -05003907 install_element (VIEW_NODE, &show_ip_nht_cmd);
3908 install_element (VIEW_NODE, &show_ipv6_nht_cmd);
paul718e3742002-12-13 20:15:29 +00003909 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
3910 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
3911 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
3912 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
3913 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003914 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003915 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003916
Everton Marques33d86db2014-07-14 11:19:00 -03003917 install_element (VIEW_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01003918 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003919
Feng Lu4364ee52015-05-22 11:40:03 +02003920 /* Commands for VRF */
3921
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003922 install_element (CONFIG_NODE, &ip_mroute_vrf_cmd);
3923 install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd);
3924 install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd);
3925 install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd);
3926
3927 install_element (CONFIG_NODE, &ip_route_vrf_cmd);
3928 install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd);
3929 install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd);
3930 install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd);
3931 install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd);
3932 install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd);
3933 install_element (CONFIG_NODE, &no_ip_route_vrf_cmd);
3934 install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd);
3935 install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd);
3936 install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd);
3937 install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd);
3938 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd);
3939 install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd);
3940 install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd);
3941 install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd);
3942 install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd);
3943 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd);
3944 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd);
3945 install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd);
3946 install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd);
3947 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd);
Igor Ryzhov5f678882016-04-22 17:38:24 +03003948 install_element (CONFIG_NODE, &no_ip_route_mask_distance_vrf_cmd);
Feng Lu7aaf4ea2015-05-22 11:40:06 +02003949 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd);
3950 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd);
3951
Feng Lu4364ee52015-05-22 11:40:03 +02003952 install_element (VIEW_NODE, &show_ip_route_vrf_cmd);
3953 install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd);
3954 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd);
3955 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd);
3956 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd);
3957 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd);
3958 install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd);
3959 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003960
3961 install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd);
3962 install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd);
3963 install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd);
3964 install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd);
3965 install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd);
3966 install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd);
3967 install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd);
3968 install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003969
Feng Lu4364ee52015-05-22 11:40:03 +02003970 install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd);
3971 install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd);
3972 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd);
3973 install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02003974
paul718e3742002-12-13 20:15:29 +00003975 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003976 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003977 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003978 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003979 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003980 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003981 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003982 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00003983 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003984 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003985 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003986 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003987 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003988 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003989 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00003990 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00003991 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08003992 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07003993 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00003994 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
3995 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
3996 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
3997 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04003998
3999 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004000
4001 /* Commands for VRF */
4002
Feng Lu7aaf4ea2015-05-22 11:40:06 +02004003 install_element (CONFIG_NODE, &ipv6_route_vrf_cmd);
4004 install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd);
4005 install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd);
4006 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd);
4007 install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd);
4008 install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd);
4009 install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd);
4010 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd);
4011 install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd);
4012 install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd);
4013 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd);
4014 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd);
4015 install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd);
4016 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd);
4017 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd);
4018 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd);
4019
Feng Lu4364ee52015-05-22 11:40:03 +02004020 install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd);
4021 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd);
4022 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd);
4023 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd);
4024 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd);
4025 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd);
4026 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004027
4028 install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd);
4029 install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd);
4030 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd);
4031 install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd);
4032 install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd);
4033 install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd);
4034 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004035
4036 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
Feng Lu4364ee52015-05-22 11:40:03 +02004037
4038 install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
paul718e3742002-12-13 20:15:29 +00004039}