paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* 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 Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 24 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "if.h" |
| 26 | #include "prefix.h" |
| 27 | #include "command.h" |
| 28 | #include "table.h" |
| 29 | #include "rib.h" |
Feng Lu | 41f44a2 | 2015-05-22 11:39:56 +0200 | [diff] [blame] | 30 | #include "vrf.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 32 | #include "zebra/zserv.h" |
| 33 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 34 | static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id); |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 35 | static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, |
| 36 | int mcast); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 37 | static void vty_show_ip_route (struct vty *vty, struct route_node *rn, |
| 38 | struct rib *rib); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 39 | |
| 40 | /* General function for static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 41 | static int |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 42 | zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, |
| 43 | const char *dest_str, const char *mask_str, |
| 44 | const char *gate_str, const char *flag_str, |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 45 | const char *distance_str, const char *vrf_id_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 46 | { |
| 47 | int ret; |
| 48 | u_char distance; |
| 49 | struct prefix p; |
| 50 | struct in_addr gate; |
| 51 | struct in_addr mask; |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 52 | const char *ifname; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 53 | u_char flag = 0; |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 54 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | |
| 56 | ret = str2prefix (dest_str, &p); |
| 57 | if (ret <= 0) |
| 58 | { |
| 59 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 60 | return CMD_WARNING; |
| 61 | } |
| 62 | |
| 63 | /* Cisco like mask notation. */ |
| 64 | if (mask_str) |
| 65 | { |
| 66 | ret = inet_aton (mask_str, &mask); |
| 67 | if (ret == 0) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 68 | { |
| 69 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 70 | return CMD_WARNING; |
| 71 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | p.prefixlen = ip_masklen (mask); |
| 73 | } |
| 74 | |
| 75 | /* Apply mask for given prefix. */ |
| 76 | apply_mask (&p); |
| 77 | |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 78 | /* Administrative distance. */ |
| 79 | if (distance_str) |
| 80 | distance = atoi (distance_str); |
| 81 | else |
| 82 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 83 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 84 | /* VRF id */ |
| 85 | if (vrf_id_str) |
| 86 | VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str); |
| 87 | |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 88 | /* Null0 static route. */ |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 89 | if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0)) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 90 | { |
| 91 | if (flag_str) |
| 92 | { |
| 93 | vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE); |
| 94 | return CMD_WARNING; |
| 95 | } |
| 96 | if (add_cmd) |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 97 | static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 98 | else |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 99 | static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 100 | return CMD_SUCCESS; |
| 101 | } |
| 102 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 103 | /* Route flags */ |
| 104 | if (flag_str) { |
| 105 | switch(flag_str[0]) { |
| 106 | case 'r': |
| 107 | case 'R': /* XXX */ |
| 108 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 109 | break; |
| 110 | case 'b': |
| 111 | case 'B': /* XXX */ |
| 112 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 113 | break; |
| 114 | default: |
| 115 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 116 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 120 | if (gate_str == NULL) |
| 121 | { |
| 122 | if (add_cmd) |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 123 | static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 124 | else |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 125 | static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 126 | |
| 127 | return CMD_SUCCESS; |
| 128 | } |
| 129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 130 | /* When gateway is A.B.C.D format, gate is treated as nexthop |
| 131 | address other case gate is treated as interface name. */ |
| 132 | ret = inet_aton (gate_str, &gate); |
| 133 | if (ret) |
| 134 | ifname = NULL; |
| 135 | else |
| 136 | ifname = gate_str; |
| 137 | |
| 138 | if (add_cmd) |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 139 | static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | else |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 141 | static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 142 | |
| 143 | return CMD_SUCCESS; |
| 144 | } |
| 145 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 146 | static int |
| 147 | zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str, |
| 148 | const char *mask_str, const char *gate_str, |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 149 | const char *flag_str, const char *distance_str, |
| 150 | const char *vrf_id_str) |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 151 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 152 | return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, |
| 153 | gate_str, flag_str, distance_str, vrf_id_str); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /* Static unicast routes for multicast RPF lookup. */ |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 157 | DEFUN (ip_mroute_dist, |
| 158 | ip_mroute_dist_cmd, |
| 159 | "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 160 | IP_STR |
| 161 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 162 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 163 | "Nexthop address\n" |
| 164 | "Nexthop interface name\n" |
| 165 | "Distance\n") |
| 166 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 167 | VTY_WARN_EXPERIMENTAL(); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 168 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 169 | NULL, argc > 2 ? argv[2] : NULL, NULL); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 170 | } |
| 171 | |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 172 | ALIAS (ip_mroute_dist, |
| 173 | ip_mroute_cmd, |
| 174 | "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 175 | IP_STR |
| 176 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 177 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 178 | "Nexthop address\n" |
| 179 | "Nexthop interface name\n") |
| 180 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 181 | DEFUN (ip_mroute_dist_vrf, |
| 182 | ip_mroute_dist_vrf_cmd, |
| 183 | "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR, |
| 184 | IP_STR |
| 185 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 186 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 187 | "Nexthop address\n" |
| 188 | "Nexthop interface name\n" |
| 189 | "Distance\n" |
| 190 | VRF_CMD_HELP_STR) |
| 191 | { |
| 192 | VTY_WARN_EXPERIMENTAL(); |
| 193 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], |
| 194 | NULL, argc > 3 ? argv[2] : NULL, |
| 195 | argc > 3 ? argv[3] : argv[2]); |
| 196 | } |
| 197 | |
| 198 | ALIAS (ip_mroute_dist_vrf, |
| 199 | ip_mroute_vrf_cmd, |
| 200 | "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) "VRF_CMD_STR, |
| 201 | IP_STR |
| 202 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 203 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 204 | "Nexthop address\n" |
| 205 | "Nexthop interface name\n" |
| 206 | VRF_CMD_HELP_STR) |
| 207 | |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 208 | DEFUN (no_ip_mroute_dist, |
| 209 | no_ip_mroute_dist_cmd, |
| 210 | "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 211 | IP_STR |
| 212 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 213 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 214 | "Nexthop address\n" |
| 215 | "Nexthop interface name\n" |
| 216 | "Distance\n") |
| 217 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 218 | VTY_WARN_EXPERIMENTAL(); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 219 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 220 | NULL, argc > 2 ? argv[2] : NULL, NULL); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 221 | } |
| 222 | |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 223 | ALIAS (no_ip_mroute_dist, |
| 224 | no_ip_mroute_cmd, |
| 225 | "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 226 | NO_STR |
| 227 | IP_STR |
| 228 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 229 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 230 | "Nexthop address\n" |
| 231 | "Nexthop interface name\n") |
| 232 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 233 | DEFUN (no_ip_mroute_dist_vrf, |
| 234 | no_ip_mroute_dist_vrf_cmd, |
| 235 | "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> " VRF_CMD_STR, |
| 236 | IP_STR |
| 237 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 238 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 239 | "Nexthop address\n" |
| 240 | "Nexthop interface name\n" |
| 241 | "Distance\n" |
| 242 | VRF_CMD_HELP_STR) |
| 243 | { |
| 244 | VTY_WARN_EXPERIMENTAL(); |
| 245 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], |
| 246 | NULL, argc > 3 ? argv[2] : NULL, |
| 247 | argc > 3 ? argv[3] : argv[2]); |
| 248 | } |
| 249 | |
| 250 | ALIAS (no_ip_mroute_dist_vrf, |
| 251 | no_ip_mroute_vrf_cmd, |
| 252 | "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) " VRF_CMD_STR, |
| 253 | NO_STR |
| 254 | IP_STR |
| 255 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 256 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 257 | "Nexthop address\n" |
| 258 | "Nexthop interface name\n" |
| 259 | VRF_CMD_HELP_STR) |
| 260 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 261 | DEFUN (ip_multicast_mode, |
| 262 | ip_multicast_mode_cmd, |
| 263 | "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", |
| 264 | IP_STR |
| 265 | "Multicast options\n" |
| 266 | "RPF lookup behavior\n" |
| 267 | "Lookup in unicast RIB only\n" |
| 268 | "Lookup in multicast RIB only\n" |
| 269 | "Try multicast RIB first, fall back to unicast RIB\n" |
| 270 | "Lookup both, use entry with lower distance\n" |
| 271 | "Lookup both, use entry with longer prefix\n") |
| 272 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 273 | VTY_WARN_EXPERIMENTAL(); |
| 274 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 275 | if (!strncmp (argv[0], "u", 1)) |
| 276 | multicast_mode_ipv4_set (MCAST_URIB_ONLY); |
| 277 | else if (!strncmp (argv[0], "mrib-o", 6)) |
| 278 | multicast_mode_ipv4_set (MCAST_MRIB_ONLY); |
| 279 | else if (!strncmp (argv[0], "mrib-t", 6)) |
| 280 | multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST); |
| 281 | else if (!strncmp (argv[0], "low", 3)) |
| 282 | multicast_mode_ipv4_set (MCAST_MIX_DISTANCE); |
| 283 | else if (!strncmp (argv[0], "lon", 3)) |
| 284 | multicast_mode_ipv4_set (MCAST_MIX_PFXLEN); |
| 285 | else |
| 286 | { |
| 287 | vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE); |
| 288 | return CMD_WARNING; |
| 289 | } |
| 290 | |
| 291 | return CMD_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | DEFUN (no_ip_multicast_mode, |
| 295 | no_ip_multicast_mode_cmd, |
| 296 | "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", |
| 297 | NO_STR |
| 298 | IP_STR |
| 299 | "Multicast options\n" |
| 300 | "RPF lookup behavior\n" |
| 301 | "Lookup in unicast RIB only\n" |
| 302 | "Lookup in multicast RIB only\n" |
| 303 | "Try multicast RIB first, fall back to unicast RIB\n" |
| 304 | "Lookup both, use entry with lower distance\n" |
| 305 | "Lookup both, use entry with longer prefix\n") |
| 306 | { |
| 307 | multicast_mode_ipv4_set (MCAST_NO_CONFIG); |
| 308 | return CMD_SUCCESS; |
| 309 | } |
| 310 | |
| 311 | ALIAS (no_ip_multicast_mode, |
| 312 | no_ip_multicast_mode_noarg_cmd, |
| 313 | "no ip multicast rpf-lookup-mode", |
| 314 | NO_STR |
| 315 | IP_STR |
| 316 | "Multicast options\n" |
| 317 | "RPF lookup behavior\n") |
| 318 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 319 | DEFUN (show_ip_rpf, |
| 320 | show_ip_rpf_cmd, |
| 321 | "show ip rpf", |
| 322 | SHOW_STR |
| 323 | IP_STR |
| 324 | "Display RPF information for multicast source\n") |
| 325 | { |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 326 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 327 | |
| 328 | if (argc > 0) |
| 329 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 330 | |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 331 | VTY_WARN_EXPERIMENTAL(); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 332 | return do_show_ip_route(vty, SAFI_MULTICAST, vrf_id); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 333 | } |
| 334 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 335 | ALIAS (show_ip_rpf, |
| 336 | show_ip_rpf_vrf_cmd, |
| 337 | "show ip rpf " VRF_CMD_STR, |
| 338 | SHOW_STR |
| 339 | IP_STR |
| 340 | "Display RPF information for multicast source\n" |
| 341 | VRF_CMD_HELP_STR) |
| 342 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 343 | DEFUN (show_ip_rpf_addr, |
| 344 | show_ip_rpf_addr_cmd, |
| 345 | "show ip rpf A.B.C.D", |
| 346 | SHOW_STR |
| 347 | IP_STR |
| 348 | "Display RPF information for multicast source\n" |
| 349 | "IP multicast source address (e.g. 10.0.0.0)\n") |
| 350 | { |
| 351 | struct in_addr addr; |
| 352 | struct route_node *rn; |
| 353 | struct rib *rib; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 354 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 355 | int ret; |
| 356 | |
| 357 | if (argc > 1) |
| 358 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 359 | |
| 360 | VTY_WARN_EXPERIMENTAL(); |
| 361 | |
| 362 | ret = inet_aton (argv[0], &addr); |
| 363 | if (ret == 0) |
| 364 | { |
| 365 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 366 | return CMD_WARNING; |
| 367 | } |
| 368 | |
| 369 | rib = rib_match_ipv4_multicast (addr, &rn, vrf_id); |
| 370 | |
| 371 | if (rib) |
| 372 | vty_show_ip_route_detail (vty, rn, 1); |
| 373 | else |
| 374 | vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE); |
| 375 | |
| 376 | return CMD_SUCCESS; |
| 377 | } |
| 378 | |
| 379 | ALIAS (show_ip_rpf_addr, |
| 380 | show_ip_rpf_addr_vrf_cmd, |
| 381 | "show ip rpf A.B.C.D " VRF_CMD_STR, |
| 382 | SHOW_STR |
| 383 | IP_STR |
| 384 | "Display RPF information for multicast source\n" |
| 385 | "IP multicast source address (e.g. 10.0.0.0)\n" |
| 386 | VRF_CMD_HELP_STR) |
| 387 | |
| 388 | DEFUN (show_ip_rpf_vrf_all, |
| 389 | show_ip_rpf_vrf_all_cmd, |
| 390 | "show ip rpf " VRF_ALL_CMD_STR, |
| 391 | SHOW_STR |
| 392 | IP_STR |
| 393 | "Display RPF information for multicast source\n" |
| 394 | VRF_ALL_CMD_HELP_STR) |
| 395 | { |
| 396 | struct zebra_vrf *zvrf; |
| 397 | struct route_table *table; |
| 398 | struct route_node *rn; |
| 399 | struct rib *rib; |
| 400 | vrf_iter_t iter; |
| 401 | int first = 1; |
| 402 | |
| 403 | VTY_WARN_EXPERIMENTAL(); |
| 404 | |
| 405 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 406 | { |
| 407 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 408 | (table = zvrf->table[AFI_IP][SAFI_MULTICAST]) == NULL) |
| 409 | continue; |
| 410 | |
| 411 | /* Show all IPv4 routes. */ |
| 412 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 413 | RNODE_FOREACH_RIB (rn, rib) |
| 414 | { |
| 415 | if (first) |
| 416 | { |
| 417 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 418 | first = 0; |
| 419 | } |
| 420 | vty_show_ip_route (vty, rn, rib); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | return CMD_SUCCESS; |
| 425 | } |
| 426 | |
| 427 | DEFUN (show_ip_rpf_addr_vrf_all, |
| 428 | show_ip_rpf_addr_vrf_all_cmd, |
| 429 | "show ip rpf A.B.C.D " VRF_ALL_CMD_STR, |
| 430 | SHOW_STR |
| 431 | IP_STR |
| 432 | "Display RPF information for multicast source\n" |
| 433 | "IP multicast source address (e.g. 10.0.0.0)\n" |
| 434 | VRF_ALL_CMD_HELP_STR) |
| 435 | { |
| 436 | struct in_addr addr; |
| 437 | struct route_node *rn; |
| 438 | vrf_iter_t iter; |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 439 | int ret; |
| 440 | |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 441 | VTY_WARN_EXPERIMENTAL(); |
| 442 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 443 | ret = inet_aton (argv[0], &addr); |
| 444 | if (ret == 0) |
| 445 | { |
| 446 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 447 | return CMD_WARNING; |
| 448 | } |
| 449 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 450 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 451 | { |
| 452 | if (rib_match_ipv4_multicast (addr, &rn, vrf_iter2id (iter))) |
| 453 | vty_show_ip_route_detail (vty, rn, 1); |
| 454 | } |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 455 | |
| 456 | return CMD_SUCCESS; |
| 457 | } |
| 458 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 459 | /* Static route configuration. */ |
| 460 | DEFUN (ip_route, |
| 461 | ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 462 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 463 | IP_STR |
| 464 | "Establish static routes\n" |
| 465 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 466 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 467 | "IP gateway interface name\n" |
| 468 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 469 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 470 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, |
| 471 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | DEFUN (ip_route_flags, |
| 475 | ip_route_flags_cmd, |
| 476 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 477 | IP_STR |
| 478 | "Establish static routes\n" |
| 479 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 480 | "IP gateway address\n" |
| 481 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 482 | "Emit an ICMP unreachable when matched\n" |
| 483 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 484 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 485 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL, |
| 486 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 487 | } |
| 488 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 489 | DEFUN (ip_route_flags2, |
| 490 | ip_route_flags2_cmd, |
| 491 | "ip route A.B.C.D/M (reject|blackhole)", |
| 492 | IP_STR |
| 493 | "Establish static routes\n" |
| 494 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 495 | "Emit an ICMP unreachable when matched\n" |
| 496 | "Silently discard pkts when matched\n") |
| 497 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 498 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL, |
| 499 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 500 | } |
| 501 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 502 | /* Mask as A.B.C.D format. */ |
| 503 | DEFUN (ip_route_mask, |
| 504 | ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 505 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 506 | IP_STR |
| 507 | "Establish static routes\n" |
| 508 | "IP destination prefix\n" |
| 509 | "IP destination prefix mask\n" |
| 510 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 511 | "IP gateway interface name\n" |
| 512 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 513 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 514 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, |
| 515 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | DEFUN (ip_route_mask_flags, |
| 519 | ip_route_mask_flags_cmd, |
| 520 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 521 | IP_STR |
| 522 | "Establish static routes\n" |
| 523 | "IP destination prefix\n" |
| 524 | "IP destination prefix mask\n" |
| 525 | "IP gateway address\n" |
| 526 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 527 | "Emit an ICMP unreachable when matched\n" |
| 528 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 530 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, |
| 531 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | } |
| 533 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 534 | DEFUN (ip_route_mask_flags2, |
| 535 | ip_route_mask_flags2_cmd, |
| 536 | "ip route A.B.C.D A.B.C.D (reject|blackhole)", |
| 537 | IP_STR |
| 538 | "Establish static routes\n" |
| 539 | "IP destination prefix\n" |
| 540 | "IP destination prefix mask\n" |
| 541 | "Emit an ICMP unreachable when matched\n" |
| 542 | "Silently discard pkts when matched\n") |
| 543 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 544 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, |
| 545 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 546 | } |
| 547 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 548 | /* Distance option value. */ |
| 549 | DEFUN (ip_route_distance, |
| 550 | ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 551 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 552 | IP_STR |
| 553 | "Establish static routes\n" |
| 554 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 555 | "IP gateway address\n" |
| 556 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 557 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 558 | "Distance value for this route\n") |
| 559 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 560 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], |
| 561 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | DEFUN (ip_route_flags_distance, |
| 565 | ip_route_flags_distance_cmd, |
| 566 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 567 | IP_STR |
| 568 | "Establish static routes\n" |
| 569 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 570 | "IP gateway address\n" |
| 571 | "IP gateway interface name\n" |
| 572 | "Emit an ICMP unreachable when matched\n" |
| 573 | "Silently discard pkts when matched\n" |
| 574 | "Distance value for this route\n") |
| 575 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 576 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3], |
| 577 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 578 | } |
| 579 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 580 | DEFUN (ip_route_flags_distance2, |
| 581 | ip_route_flags_distance2_cmd, |
| 582 | "ip route A.B.C.D/M (reject|blackhole) <1-255>", |
| 583 | IP_STR |
| 584 | "Establish static routes\n" |
| 585 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 586 | "Emit an ICMP unreachable when matched\n" |
| 587 | "Silently discard pkts when matched\n" |
| 588 | "Distance value for this route\n") |
| 589 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 590 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2], |
| 591 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 592 | } |
| 593 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | DEFUN (ip_route_mask_distance, |
| 595 | ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 596 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 597 | IP_STR |
| 598 | "Establish static routes\n" |
| 599 | "IP destination prefix\n" |
| 600 | "IP destination prefix mask\n" |
| 601 | "IP gateway address\n" |
| 602 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 603 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | "Distance value for this route\n") |
| 605 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 606 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], |
| 607 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | DEFUN (ip_route_mask_flags_distance, |
| 611 | ip_route_mask_flags_distance_cmd, |
| 612 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 613 | IP_STR |
| 614 | "Establish static routes\n" |
| 615 | "IP destination prefix\n" |
| 616 | "IP destination prefix mask\n" |
| 617 | "IP gateway address\n" |
| 618 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 619 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 620 | "Silently discard pkts when matched\n" |
| 621 | "Distance value for this route\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 622 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 623 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 624 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | } |
| 626 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 627 | DEFUN (ip_route_mask_flags_distance2, |
| 628 | ip_route_mask_flags_distance2_cmd, |
| 629 | "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", |
| 630 | IP_STR |
| 631 | "Establish static routes\n" |
| 632 | "IP destination prefix\n" |
| 633 | "IP destination prefix mask\n" |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 634 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 635 | "Silently discard pkts when matched\n" |
| 636 | "Distance value for this route\n") |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 637 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 638 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], |
| 639 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 640 | } |
| 641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | DEFUN (no_ip_route, |
| 643 | no_ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 644 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 645 | NO_STR |
| 646 | IP_STR |
| 647 | "Establish static routes\n" |
| 648 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 649 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 650 | "IP gateway interface name\n" |
| 651 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 652 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 653 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL, |
| 654 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | ALIAS (no_ip_route, |
| 658 | no_ip_route_flags_cmd, |
| 659 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 660 | NO_STR |
| 661 | IP_STR |
| 662 | "Establish static routes\n" |
| 663 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 664 | "IP gateway address\n" |
| 665 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 666 | "Emit an ICMP unreachable when matched\n" |
| 667 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 668 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 669 | DEFUN (no_ip_route_flags2, |
| 670 | no_ip_route_flags2_cmd, |
| 671 | "no ip route A.B.C.D/M (reject|blackhole)", |
| 672 | NO_STR |
| 673 | IP_STR |
| 674 | "Establish static routes\n" |
| 675 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 676 | "Emit an ICMP unreachable when matched\n" |
| 677 | "Silently discard pkts when matched\n") |
| 678 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 679 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL, |
| 680 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 681 | } |
| 682 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 683 | DEFUN (no_ip_route_mask, |
| 684 | no_ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 685 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 686 | NO_STR |
| 687 | IP_STR |
| 688 | "Establish static routes\n" |
| 689 | "IP destination prefix\n" |
| 690 | "IP destination prefix mask\n" |
| 691 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 692 | "IP gateway interface name\n" |
| 693 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 694 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 695 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, |
| 696 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | ALIAS (no_ip_route_mask, |
| 700 | no_ip_route_mask_flags_cmd, |
| 701 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 702 | NO_STR |
| 703 | IP_STR |
| 704 | "Establish static routes\n" |
| 705 | "IP destination prefix\n" |
| 706 | "IP destination prefix mask\n" |
| 707 | "IP gateway address\n" |
| 708 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 709 | "Emit an ICMP unreachable when matched\n" |
| 710 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 711 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 712 | DEFUN (no_ip_route_mask_flags2, |
| 713 | no_ip_route_mask_flags2_cmd, |
| 714 | "no ip route A.B.C.D A.B.C.D (reject|blackhole)", |
| 715 | NO_STR |
| 716 | IP_STR |
| 717 | "Establish static routes\n" |
| 718 | "IP destination prefix\n" |
| 719 | "IP destination prefix mask\n" |
| 720 | "Emit an ICMP unreachable when matched\n" |
| 721 | "Silently discard pkts when matched\n") |
| 722 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 723 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL, |
| 724 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 725 | } |
| 726 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | DEFUN (no_ip_route_distance, |
| 728 | no_ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 729 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 730 | NO_STR |
| 731 | IP_STR |
| 732 | "Establish static routes\n" |
| 733 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 734 | "IP gateway address\n" |
| 735 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 736 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 737 | "Distance value for this route\n") |
| 738 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 739 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2], |
| 740 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | DEFUN (no_ip_route_flags_distance, |
| 744 | no_ip_route_flags_distance_cmd, |
| 745 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 746 | NO_STR |
| 747 | IP_STR |
| 748 | "Establish static routes\n" |
| 749 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 750 | "IP gateway address\n" |
| 751 | "IP gateway interface name\n" |
| 752 | "Emit an ICMP unreachable when matched\n" |
| 753 | "Silently discard pkts when matched\n" |
| 754 | "Distance value for this route\n") |
| 755 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 756 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3], |
| 757 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 758 | } |
| 759 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 760 | DEFUN (no_ip_route_flags_distance2, |
| 761 | no_ip_route_flags_distance2_cmd, |
| 762 | "no ip route A.B.C.D/M (reject|blackhole) <1-255>", |
| 763 | NO_STR |
| 764 | IP_STR |
| 765 | "Establish static routes\n" |
| 766 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 767 | "Emit an ICMP unreachable when matched\n" |
| 768 | "Silently discard pkts when matched\n" |
| 769 | "Distance value for this route\n") |
| 770 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 771 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2], |
| 772 | NULL); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 773 | } |
| 774 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | DEFUN (no_ip_route_mask_distance, |
| 776 | no_ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 777 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 778 | NO_STR |
| 779 | IP_STR |
| 780 | "Establish static routes\n" |
| 781 | "IP destination prefix\n" |
| 782 | "IP destination prefix mask\n" |
| 783 | "IP gateway address\n" |
| 784 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 785 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 786 | "Distance value for this route\n") |
| 787 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 788 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], |
| 789 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | DEFUN (no_ip_route_mask_flags_distance, |
| 793 | no_ip_route_mask_flags_distance_cmd, |
| 794 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 795 | NO_STR |
| 796 | IP_STR |
| 797 | "Establish static routes\n" |
| 798 | "IP destination prefix\n" |
| 799 | "IP destination prefix mask\n" |
| 800 | "IP gateway address\n" |
| 801 | "IP gateway interface name\n" |
| 802 | "Emit an ICMP unreachable when matched\n" |
| 803 | "Silently discard pkts when matched\n" |
| 804 | "Distance value for this route\n") |
| 805 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 806 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 807 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 808 | } |
| 809 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 810 | DEFUN (no_ip_route_mask_flags_distance2, |
| 811 | no_ip_route_mask_flags_distance2_cmd, |
| 812 | "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", |
| 813 | NO_STR |
| 814 | IP_STR |
| 815 | "Establish static routes\n" |
| 816 | "IP destination prefix\n" |
| 817 | "IP destination prefix mask\n" |
| 818 | "Emit an ICMP unreachable when matched\n" |
| 819 | "Silently discard pkts when matched\n" |
| 820 | "Distance value for this route\n") |
| 821 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 822 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], |
| 823 | NULL); |
| 824 | } |
| 825 | |
| 826 | DEFUN (ip_route_vrf, |
| 827 | ip_route_vrf_cmd, |
| 828 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, |
| 829 | IP_STR |
| 830 | "Establish static routes\n" |
| 831 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 832 | "IP gateway address\n" |
| 833 | "IP gateway interface name\n" |
| 834 | "Null interface\n" |
| 835 | VRF_CMD_HELP_STR) |
| 836 | { |
| 837 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, |
| 838 | argv[2]); |
| 839 | } |
| 840 | |
| 841 | DEFUN (ip_route_flags_vrf, |
| 842 | ip_route_flags_vrf_cmd, |
| 843 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 844 | IP_STR |
| 845 | "Establish static routes\n" |
| 846 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 847 | "IP gateway address\n" |
| 848 | "IP gateway interface name\n" |
| 849 | "Emit an ICMP unreachable when matched\n" |
| 850 | "Silently discard pkts when matched\n" |
| 851 | VRF_CMD_HELP_STR) |
| 852 | { |
| 853 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL, |
| 854 | argv[3]); |
| 855 | } |
| 856 | |
| 857 | DEFUN (ip_route_flags2_vrf, |
| 858 | ip_route_flags2_vrf_cmd, |
| 859 | "ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR, |
| 860 | IP_STR |
| 861 | "Establish static routes\n" |
| 862 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 863 | "Emit an ICMP unreachable when matched\n" |
| 864 | "Silently discard pkts when matched\n" |
| 865 | VRF_CMD_HELP_STR) |
| 866 | { |
| 867 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL, |
| 868 | argv[2]); |
| 869 | } |
| 870 | |
| 871 | /* Mask as A.B.C.D format. */ |
| 872 | DEFUN (ip_route_mask_vrf, |
| 873 | ip_route_mask_vrf_cmd, |
| 874 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, |
| 875 | IP_STR |
| 876 | "Establish static routes\n" |
| 877 | "IP destination prefix\n" |
| 878 | "IP destination prefix mask\n" |
| 879 | "IP gateway address\n" |
| 880 | "IP gateway interface name\n" |
| 881 | "Null interface\n" |
| 882 | VRF_CMD_HELP_STR) |
| 883 | { |
| 884 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, |
| 885 | argv[3]); |
| 886 | } |
| 887 | |
| 888 | DEFUN (ip_route_mask_flags_vrf, |
| 889 | ip_route_mask_flags_vrf_cmd, |
| 890 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 891 | IP_STR |
| 892 | "Establish static routes\n" |
| 893 | "IP destination prefix\n" |
| 894 | "IP destination prefix mask\n" |
| 895 | "IP gateway address\n" |
| 896 | "IP gateway interface name\n" |
| 897 | "Emit an ICMP unreachable when matched\n" |
| 898 | "Silently discard pkts when matched\n" |
| 899 | VRF_CMD_HELP_STR) |
| 900 | { |
| 901 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, |
| 902 | argv[4]); |
| 903 | } |
| 904 | |
| 905 | DEFUN (ip_route_mask_flags2_vrf, |
| 906 | ip_route_mask_flags2_vrf_cmd, |
| 907 | "ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR, |
| 908 | IP_STR |
| 909 | "Establish static routes\n" |
| 910 | "IP destination prefix\n" |
| 911 | "IP destination prefix mask\n" |
| 912 | "Emit an ICMP unreachable when matched\n" |
| 913 | "Silently discard pkts when matched\n" |
| 914 | VRF_CMD_HELP_STR) |
| 915 | { |
| 916 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, |
| 917 | argv[3]); |
| 918 | } |
| 919 | |
| 920 | /* Distance option value. */ |
| 921 | DEFUN (ip_route_distance_vrf, |
| 922 | ip_route_distance_vrf_cmd, |
| 923 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, |
| 924 | IP_STR |
| 925 | "Establish static routes\n" |
| 926 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 927 | "IP gateway address\n" |
| 928 | "IP gateway interface name\n" |
| 929 | "Null interface\n" |
| 930 | "Distance value for this route\n" |
| 931 | VRF_CMD_HELP_STR) |
| 932 | { |
| 933 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], |
| 934 | argv[3]); |
| 935 | } |
| 936 | |
| 937 | DEFUN (ip_route_flags_distance_vrf, |
| 938 | ip_route_flags_distance_vrf_cmd, |
| 939 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 940 | IP_STR |
| 941 | "Establish static routes\n" |
| 942 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 943 | "IP gateway address\n" |
| 944 | "IP gateway interface name\n" |
| 945 | "Emit an ICMP unreachable when matched\n" |
| 946 | "Silently discard pkts when matched\n" |
| 947 | "Distance value for this route\n" |
| 948 | VRF_CMD_HELP_STR) |
| 949 | { |
| 950 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3], |
| 951 | argv[4]); |
| 952 | } |
| 953 | |
| 954 | DEFUN (ip_route_flags_distance2_vrf, |
| 955 | ip_route_flags_distance2_vrf_cmd, |
| 956 | "ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 957 | IP_STR |
| 958 | "Establish static routes\n" |
| 959 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 960 | "Emit an ICMP unreachable when matched\n" |
| 961 | "Silently discard pkts when matched\n" |
| 962 | "Distance value for this route\n" |
| 963 | VRF_CMD_HELP_STR) |
| 964 | { |
| 965 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2], |
| 966 | argv[3]); |
| 967 | } |
| 968 | |
| 969 | DEFUN (ip_route_mask_distance_vrf, |
| 970 | ip_route_mask_distance_vrf_cmd, |
| 971 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, |
| 972 | IP_STR |
| 973 | "Establish static routes\n" |
| 974 | "IP destination prefix\n" |
| 975 | "IP destination prefix mask\n" |
| 976 | "IP gateway address\n" |
| 977 | "IP gateway interface name\n" |
| 978 | "Null interface\n" |
| 979 | "Distance value for this route\n" |
| 980 | VRF_CMD_HELP_STR) |
| 981 | { |
| 982 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], |
| 983 | argv[4]); |
| 984 | } |
| 985 | |
| 986 | DEFUN (ip_route_mask_flags_distance_vrf, |
| 987 | ip_route_mask_flags_distance_vrf_cmd, |
| 988 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 989 | IP_STR |
| 990 | "Establish static routes\n" |
| 991 | "IP destination prefix\n" |
| 992 | "IP destination prefix mask\n" |
| 993 | "IP gateway address\n" |
| 994 | "IP gateway interface name\n" |
| 995 | "Emit an ICMP unreachable when matched\n" |
| 996 | "Silently discard pkts when matched\n" |
| 997 | "Distance value for this route\n" |
| 998 | VRF_CMD_HELP_STR) |
| 999 | { |
| 1000 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 1001 | argv[5]); |
| 1002 | } |
| 1003 | |
| 1004 | DEFUN (ip_route_mask_flags_distance2_vrf, |
| 1005 | ip_route_mask_flags_distance2_vrf_cmd, |
| 1006 | "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 1007 | IP_STR |
| 1008 | "Establish static routes\n" |
| 1009 | "IP destination prefix\n" |
| 1010 | "IP destination prefix mask\n" |
| 1011 | "Emit an ICMP unreachable when matched\n" |
| 1012 | "Silently discard pkts when matched\n" |
| 1013 | "Distance value for this route\n" |
| 1014 | VRF_CMD_HELP_STR) |
| 1015 | { |
| 1016 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], |
| 1017 | argv[4]); |
| 1018 | } |
| 1019 | |
| 1020 | DEFUN (no_ip_route_vrf, |
| 1021 | no_ip_route_vrf_cmd, |
| 1022 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, |
| 1023 | NO_STR |
| 1024 | IP_STR |
| 1025 | "Establish static routes\n" |
| 1026 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1027 | "IP gateway address\n" |
| 1028 | "IP gateway interface name\n" |
| 1029 | "Null interface\n" |
| 1030 | VRF_CMD_HELP_STR) |
| 1031 | { |
| 1032 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL, |
| 1033 | (argc > 3) ? argv[3] : argv[2]); |
| 1034 | } |
| 1035 | |
| 1036 | ALIAS (no_ip_route_vrf, |
| 1037 | no_ip_route_flags_vrf_cmd, |
| 1038 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 1039 | NO_STR |
| 1040 | IP_STR |
| 1041 | "Establish static routes\n" |
| 1042 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1043 | "IP gateway address\n" |
| 1044 | "IP gateway interface name\n" |
| 1045 | "Emit an ICMP unreachable when matched\n" |
| 1046 | "Silently discard pkts when matched\n" |
| 1047 | VRF_CMD_HELP_STR) |
| 1048 | |
| 1049 | DEFUN (no_ip_route_flags2_vrf, |
| 1050 | no_ip_route_flags2_vrf_cmd, |
| 1051 | "no ip route A.B.C.D/M (reject|blackhole) " VRF_CMD_STR, |
| 1052 | NO_STR |
| 1053 | IP_STR |
| 1054 | "Establish static routes\n" |
| 1055 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1056 | "Emit an ICMP unreachable when matched\n" |
| 1057 | "Silently discard pkts when matched\n" |
| 1058 | VRF_CMD_HELP_STR) |
| 1059 | { |
| 1060 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL, |
| 1061 | argv[2]); |
| 1062 | } |
| 1063 | |
| 1064 | DEFUN (no_ip_route_mask_vrf, |
| 1065 | no_ip_route_mask_vrf_cmd, |
| 1066 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) " VRF_CMD_STR, |
| 1067 | NO_STR |
| 1068 | IP_STR |
| 1069 | "Establish static routes\n" |
| 1070 | "IP destination prefix\n" |
| 1071 | "IP destination prefix mask\n" |
| 1072 | "IP gateway address\n" |
| 1073 | "IP gateway interface name\n" |
| 1074 | "Null interface\n" |
| 1075 | VRF_CMD_HELP_STR) |
| 1076 | { |
| 1077 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, |
| 1078 | (argc > 4) ? argv[4] : argv[3]); |
| 1079 | } |
| 1080 | |
| 1081 | ALIAS (no_ip_route_mask_vrf, |
| 1082 | no_ip_route_mask_flags_vrf_cmd, |
| 1083 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 1084 | NO_STR |
| 1085 | IP_STR |
| 1086 | "Establish static routes\n" |
| 1087 | "IP destination prefix\n" |
| 1088 | "IP destination prefix mask\n" |
| 1089 | "IP gateway address\n" |
| 1090 | "IP gateway interface name\n" |
| 1091 | "Emit an ICMP unreachable when matched\n" |
| 1092 | "Silently discard pkts when matched\n" |
| 1093 | VRF_CMD_HELP_STR) |
| 1094 | |
| 1095 | DEFUN (no_ip_route_mask_flags2_vrf, |
| 1096 | no_ip_route_mask_flags2_vrf_cmd, |
| 1097 | "no ip route A.B.C.D A.B.C.D (reject|blackhole) " VRF_CMD_STR, |
| 1098 | NO_STR |
| 1099 | IP_STR |
| 1100 | "Establish static routes\n" |
| 1101 | "IP destination prefix\n" |
| 1102 | "IP destination prefix mask\n" |
| 1103 | "Emit an ICMP unreachable when matched\n" |
| 1104 | "Silently discard pkts when matched\n" |
| 1105 | VRF_CMD_HELP_STR) |
| 1106 | { |
| 1107 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL, |
| 1108 | argv[2]); |
| 1109 | } |
| 1110 | |
| 1111 | DEFUN (no_ip_route_distance_vrf, |
| 1112 | no_ip_route_distance_vrf_cmd, |
| 1113 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, |
| 1114 | NO_STR |
| 1115 | IP_STR |
| 1116 | "Establish static routes\n" |
| 1117 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1118 | "IP gateway address\n" |
| 1119 | "IP gateway interface name\n" |
| 1120 | "Null interface\n" |
| 1121 | "Distance value for this route\n" |
| 1122 | VRF_CMD_HELP_STR) |
| 1123 | { |
| 1124 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2], |
| 1125 | argv[3]); |
| 1126 | } |
| 1127 | |
| 1128 | DEFUN (no_ip_route_flags_distance_vrf, |
| 1129 | no_ip_route_flags_distance_vrf_cmd, |
| 1130 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 1131 | NO_STR |
| 1132 | IP_STR |
| 1133 | "Establish static routes\n" |
| 1134 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1135 | "IP gateway address\n" |
| 1136 | "IP gateway interface name\n" |
| 1137 | "Emit an ICMP unreachable when matched\n" |
| 1138 | "Silently discard pkts when matched\n" |
| 1139 | "Distance value for this route\n" |
| 1140 | VRF_CMD_HELP_STR) |
| 1141 | { |
| 1142 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3], |
| 1143 | argv[4]); |
| 1144 | } |
| 1145 | |
| 1146 | DEFUN (no_ip_route_flags_distance2_vrf, |
| 1147 | no_ip_route_flags_distance2_vrf_cmd, |
| 1148 | "no ip route A.B.C.D/M (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 1149 | NO_STR |
| 1150 | IP_STR |
| 1151 | "Establish static routes\n" |
| 1152 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 1153 | "Emit an ICMP unreachable when matched\n" |
| 1154 | "Silently discard pkts when matched\n" |
| 1155 | "Distance value for this route\n" |
| 1156 | VRF_CMD_HELP_STR) |
| 1157 | { |
| 1158 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2], |
| 1159 | argv[3]); |
| 1160 | } |
| 1161 | |
| 1162 | DEFUN (no_ip_route_mask_distance_vrf, |
| 1163 | no_ip_route_mask_distance_vrf_cmd, |
| 1164 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> " VRF_CMD_STR, |
| 1165 | NO_STR |
| 1166 | IP_STR |
| 1167 | "Establish static routes\n" |
| 1168 | "IP destination prefix\n" |
| 1169 | "IP destination prefix mask\n" |
| 1170 | "IP gateway address\n" |
| 1171 | "IP gateway interface name\n" |
| 1172 | "Null interface\n" |
| 1173 | "Distance value for this route\n" |
| 1174 | VRF_CMD_HELP_STR) |
| 1175 | { |
| 1176 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], |
| 1177 | argv[4]); |
| 1178 | } |
| 1179 | |
| 1180 | DEFUN (no_ip_route_mask_flags_distance_vrf, |
| 1181 | no_ip_route_mask_flags_distance_vrf_cmd, |
| 1182 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 1183 | NO_STR |
| 1184 | IP_STR |
| 1185 | "Establish static routes\n" |
| 1186 | "IP destination prefix\n" |
| 1187 | "IP destination prefix mask\n" |
| 1188 | "IP gateway address\n" |
| 1189 | "IP gateway interface name\n" |
| 1190 | "Emit an ICMP unreachable when matched\n" |
| 1191 | "Silently discard pkts when matched\n" |
| 1192 | "Distance value for this route\n" |
| 1193 | VRF_CMD_HELP_STR) |
| 1194 | { |
| 1195 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 1196 | argv[5]); |
| 1197 | } |
| 1198 | |
| 1199 | DEFUN (no_ip_route_mask_flags_distance2_vrf, |
| 1200 | no_ip_route_mask_flags_distance2_vrf_cmd, |
| 1201 | "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 1202 | NO_STR |
| 1203 | IP_STR |
| 1204 | "Establish static routes\n" |
| 1205 | "IP destination prefix\n" |
| 1206 | "IP destination prefix mask\n" |
| 1207 | "Emit an ICMP unreachable when matched\n" |
| 1208 | "Silently discard pkts when matched\n" |
| 1209 | "Distance value for this route\n" |
| 1210 | VRF_CMD_HELP_STR) |
| 1211 | { |
| 1212 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], |
| 1213 | argv[4]); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1216 | char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */ |
| 1217 | |
| 1218 | DEFUN (ip_protocol, |
| 1219 | ip_protocol_cmd, |
| 1220 | "ip protocol PROTO route-map ROUTE-MAP", |
| 1221 | NO_STR |
| 1222 | "Apply route map to PROTO\n" |
| 1223 | "Protocol name\n" |
| 1224 | "Route map name\n") |
| 1225 | { |
| 1226 | int i; |
| 1227 | |
| 1228 | if (strcasecmp(argv[0], "any") == 0) |
| 1229 | i = ZEBRA_ROUTE_MAX; |
| 1230 | else |
| 1231 | i = proto_name2num(argv[0]); |
| 1232 | if (i < 0) |
| 1233 | { |
| 1234 | vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", |
| 1235 | VTY_NEWLINE); |
| 1236 | return CMD_WARNING; |
| 1237 | } |
| 1238 | if (proto_rm[AFI_IP][i]) |
| 1239 | XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); |
| 1240 | proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); |
| 1241 | return CMD_SUCCESS; |
| 1242 | } |
| 1243 | |
| 1244 | DEFUN (no_ip_protocol, |
| 1245 | no_ip_protocol_cmd, |
| 1246 | "no ip protocol PROTO", |
| 1247 | NO_STR |
| 1248 | "Remove route map from PROTO\n" |
| 1249 | "Protocol name\n") |
| 1250 | { |
| 1251 | int i; |
| 1252 | |
| 1253 | if (strcasecmp(argv[0], "any") == 0) |
| 1254 | i = ZEBRA_ROUTE_MAX; |
| 1255 | else |
| 1256 | i = proto_name2num(argv[0]); |
| 1257 | if (i < 0) |
| 1258 | { |
| 1259 | vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", |
| 1260 | VTY_NEWLINE); |
| 1261 | return CMD_WARNING; |
| 1262 | } |
| 1263 | if (proto_rm[AFI_IP][i]) |
| 1264 | XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); |
| 1265 | proto_rm[AFI_IP][i] = NULL; |
| 1266 | return CMD_SUCCESS; |
| 1267 | } |
| 1268 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1269 | /* New RIB. Detailed information for IPv4 route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1270 | static void |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1271 | vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1272 | { |
| 1273 | struct rib *rib; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1274 | struct nexthop *nexthop, *tnexthop; |
| 1275 | int recursing; |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1276 | char buf[PREFIX_STRLEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1277 | |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1278 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1279 | { |
David Lamparter | b7cce95 | 2015-03-07 08:40:48 +0100 | [diff] [blame] | 1280 | const char *mcast_info = ""; |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1281 | if (mcast) |
| 1282 | { |
| 1283 | rib_table_info_t *info = rn->table->info; |
| 1284 | mcast_info = (info->safi == SAFI_MULTICAST) |
| 1285 | ? " using Multicast RIB" |
| 1286 | : " using Unicast RIB"; |
| 1287 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1288 | vty_out (vty, "Routing entry for %s%s%s", |
| 1289 | prefix2str (&rn->p, buf, sizeof(buf)), mcast_info, |
| 1290 | VTY_NEWLINE); |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 1291 | vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type)); |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 1292 | vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1293 | vty_out (vty, ", vrf %u", rib->vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1294 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1295 | vty_out (vty, ", best"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1296 | if (rib->refcnt) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1297 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1298 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1299 | vty_out (vty, ", blackhole"); |
| 1300 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1301 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1302 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1303 | |
| 1304 | #define ONE_DAY_SECOND 60*60*24 |
| 1305 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1306 | if (rib->type == ZEBRA_ROUTE_RIP |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1307 | || rib->type == ZEBRA_ROUTE_RIPNG |
| 1308 | || rib->type == ZEBRA_ROUTE_OSPF |
| 1309 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 1310 | || rib->type == ZEBRA_ROUTE_BABEL |
| 1311 | || rib->type == ZEBRA_ROUTE_ISIS |
| 1312 | || rib->type == ZEBRA_ROUTE_BGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | { |
| 1314 | time_t uptime; |
| 1315 | struct tm *tm; |
| 1316 | |
| 1317 | uptime = time (NULL); |
| 1318 | uptime -= rib->uptime; |
| 1319 | tm = gmtime (&uptime); |
| 1320 | |
| 1321 | vty_out (vty, " Last update "); |
| 1322 | |
| 1323 | if (uptime < ONE_DAY_SECOND) |
| 1324 | vty_out (vty, "%02d:%02d:%02d", |
| 1325 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1326 | else if (uptime < ONE_WEEK_SECOND) |
| 1327 | vty_out (vty, "%dd%02dh%02dm", |
| 1328 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1329 | else |
| 1330 | vty_out (vty, "%02dw%dd%02dh", |
| 1331 | tm->tm_yday/7, |
| 1332 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1333 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 1334 | } |
| 1335 | |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1336 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1337 | { |
| 1338 | vty_out (vty, " %c%s", |
| 1339 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', |
| 1340 | recursing ? " " : ""); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1341 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1342 | switch (nexthop->type) |
| 1343 | { |
| 1344 | case NEXTHOP_TYPE_IPV4: |
| 1345 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 1346 | vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4)); |
| 1347 | if (nexthop->ifindex) |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1348 | vty_out (vty, ", via %s", |
| 1349 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1350 | break; |
| 1351 | case NEXTHOP_TYPE_IPV6: |
| 1352 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1353 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1354 | vty_out (vty, " %s", |
| 1355 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf))); |
| 1356 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1357 | vty_out (vty, ", %s", nexthop->ifname); |
| 1358 | else if (nexthop->ifindex) |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1359 | vty_out (vty, ", via %s", |
| 1360 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1361 | break; |
| 1362 | case NEXTHOP_TYPE_IFINDEX: |
| 1363 | vty_out (vty, " directly connected, %s", |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1364 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1365 | break; |
| 1366 | case NEXTHOP_TYPE_IFNAME: |
| 1367 | vty_out (vty, " directly connected, %s", nexthop->ifname); |
| 1368 | break; |
| 1369 | case NEXTHOP_TYPE_BLACKHOLE: |
| 1370 | vty_out (vty, " directly connected, Null0"); |
| 1371 | break; |
| 1372 | default: |
| 1373 | break; |
| 1374 | } |
| 1375 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 1376 | vty_out (vty, " inactive"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1378 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
| 1379 | vty_out (vty, " onlink"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1380 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1381 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 1382 | vty_out (vty, " (recursive)"); |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 1383 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1384 | switch (nexthop->type) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1385 | { |
| 1386 | case NEXTHOP_TYPE_IPV4: |
| 1387 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 1388 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 1389 | if (nexthop->src.ipv4.s_addr) |
| 1390 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1391 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf)) |
| 1392 | vty_out (vty, ", src %s", buf); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1393 | } |
| 1394 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1395 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1396 | case NEXTHOP_TYPE_IPV6: |
| 1397 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1398 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1399 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 1400 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1401 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf)) |
| 1402 | vty_out (vty, ", src %s", buf); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1403 | } |
| 1404 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1405 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1406 | default: |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1407 | break; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1408 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1409 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1410 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1411 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1412 | } |
| 1413 | } |
| 1414 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1415 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib) |
| 1417 | { |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1418 | struct nexthop *nexthop, *tnexthop; |
| 1419 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1420 | int len = 0; |
| 1421 | char buf[BUFSIZ]; |
| 1422 | |
| 1423 | /* Nexthop information. */ |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1424 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1425 | { |
| 1426 | if (nexthop == rib->nexthop) |
| 1427 | { |
| 1428 | /* Prefix information. */ |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1429 | len = vty_out (vty, "%c%c%c %s", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 1430 | zebra_route_char (rib->type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1431 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 1432 | ? '>' : ' ', |
| 1433 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1434 | ? '*' : ' ', |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1435 | prefix2str (&rn->p, buf, sizeof buf)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1436 | |
| 1437 | /* Distance and metric display. */ |
| 1438 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 1439 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 1440 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 1441 | rib->metric); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1442 | |
| 1443 | if (rib->vrf_id != VRF_DEFAULT) |
| 1444 | len += vty_out (vty, " [vrf %u]", rib->vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1445 | } |
| 1446 | else |
| 1447 | vty_out (vty, " %c%*c", |
| 1448 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1449 | ? '*' : ' ', |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1450 | len - 3 + (2 * recursing), ' '); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1451 | |
| 1452 | switch (nexthop->type) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1453 | { |
| 1454 | case NEXTHOP_TYPE_IPV4: |
| 1455 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 1456 | vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4)); |
| 1457 | if (nexthop->ifindex) |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1458 | vty_out (vty, ", %s", |
| 1459 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1460 | break; |
| 1461 | case NEXTHOP_TYPE_IPV6: |
| 1462 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1463 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1464 | vty_out (vty, " via %s", |
| 1465 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 1466 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1467 | vty_out (vty, ", %s", nexthop->ifname); |
| 1468 | else if (nexthop->ifindex) |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1469 | vty_out (vty, ", %s", |
| 1470 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1471 | break; |
| 1472 | case NEXTHOP_TYPE_IFINDEX: |
| 1473 | vty_out (vty, " is directly connected, %s", |
Feng Lu | 0d0686f | 2015-05-22 11:40:02 +0200 | [diff] [blame] | 1474 | ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id)); |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1475 | break; |
| 1476 | case NEXTHOP_TYPE_IFNAME: |
| 1477 | vty_out (vty, " is directly connected, %s", nexthop->ifname); |
| 1478 | break; |
| 1479 | case NEXTHOP_TYPE_BLACKHOLE: |
| 1480 | vty_out (vty, " is directly connected, Null0"); |
| 1481 | break; |
| 1482 | default: |
| 1483 | break; |
| 1484 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1485 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1486 | vty_out (vty, " inactive"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1487 | |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 1488 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1489 | vty_out (vty, " onlink"); |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 1490 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1491 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1492 | vty_out (vty, " (recursive)"); |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1493 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1494 | switch (nexthop->type) |
| 1495 | { |
| 1496 | case NEXTHOP_TYPE_IPV4: |
| 1497 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 1498 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 1499 | if (nexthop->src.ipv4.s_addr) |
| 1500 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1501 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf)) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1502 | vty_out (vty, ", src %s", buf); |
| 1503 | } |
| 1504 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1505 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1506 | case NEXTHOP_TYPE_IPV6: |
| 1507 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1508 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1509 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 1510 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1511 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf)) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1512 | vty_out (vty, ", src %s", buf); |
| 1513 | } |
| 1514 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1515 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1516 | default: |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1517 | break; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 1518 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1519 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1520 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1521 | vty_out (vty, ", bh"); |
| 1522 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1523 | vty_out (vty, ", rej"); |
| 1524 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1525 | if (rib->type == ZEBRA_ROUTE_RIP |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1526 | || rib->type == ZEBRA_ROUTE_RIPNG |
| 1527 | || rib->type == ZEBRA_ROUTE_OSPF |
| 1528 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 1529 | || rib->type == ZEBRA_ROUTE_BABEL |
| 1530 | || rib->type == ZEBRA_ROUTE_ISIS |
| 1531 | || rib->type == ZEBRA_ROUTE_BGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1532 | { |
| 1533 | time_t uptime; |
| 1534 | struct tm *tm; |
| 1535 | |
| 1536 | uptime = time (NULL); |
| 1537 | uptime -= rib->uptime; |
| 1538 | tm = gmtime (&uptime); |
| 1539 | |
| 1540 | #define ONE_DAY_SECOND 60*60*24 |
| 1541 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1542 | |
| 1543 | if (uptime < ONE_DAY_SECOND) |
| 1544 | vty_out (vty, ", %02d:%02d:%02d", |
| 1545 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1546 | else if (uptime < ONE_WEEK_SECOND) |
| 1547 | vty_out (vty, ", %dd%02dh%02dm", |
| 1548 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1549 | else |
| 1550 | vty_out (vty, ", %02dw%dd%02dh", |
| 1551 | tm->tm_yday/7, |
| 1552 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1553 | } |
| 1554 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1555 | } |
| 1556 | } |
| 1557 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1558 | DEFUN (show_ip_route, |
| 1559 | show_ip_route_cmd, |
| 1560 | "show ip route", |
| 1561 | SHOW_STR |
| 1562 | IP_STR |
| 1563 | "IP routing table\n") |
| 1564 | { |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1565 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 1566 | |
| 1567 | if (argc > 0) |
| 1568 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 1569 | |
| 1570 | return do_show_ip_route(vty, SAFI_UNICAST, vrf_id); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 1571 | } |
| 1572 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1573 | static int do_show_ip_route(struct vty *vty, safi_t safi, vrf_id_t vrf_id) |
| 1574 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1575 | struct route_table *table; |
| 1576 | struct route_node *rn; |
| 1577 | struct rib *rib; |
| 1578 | int first = 1; |
| 1579 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1580 | table = zebra_vrf_table (AFI_IP, safi, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1581 | if (! table) |
| 1582 | return CMD_SUCCESS; |
| 1583 | |
| 1584 | /* Show all IPv4 routes. */ |
| 1585 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1586 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1587 | { |
| 1588 | if (first) |
| 1589 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1590 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1591 | first = 0; |
| 1592 | } |
| 1593 | vty_show_ip_route (vty, rn, rib); |
| 1594 | } |
| 1595 | return CMD_SUCCESS; |
| 1596 | } |
| 1597 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1598 | ALIAS (show_ip_route, |
| 1599 | show_ip_route_vrf_cmd, |
| 1600 | "show ip route " VRF_CMD_STR, |
| 1601 | SHOW_STR |
| 1602 | IP_STR |
| 1603 | "IP routing table\n" |
| 1604 | VRF_CMD_HELP_STR) |
| 1605 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1606 | DEFUN (show_ip_route_prefix_longer, |
| 1607 | show_ip_route_prefix_longer_cmd, |
| 1608 | "show ip route A.B.C.D/M longer-prefixes", |
| 1609 | SHOW_STR |
| 1610 | IP_STR |
| 1611 | "IP routing table\n" |
| 1612 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1613 | "Show route matching the specified Network/Mask pair only\n") |
| 1614 | { |
| 1615 | struct route_table *table; |
| 1616 | struct route_node *rn; |
| 1617 | struct rib *rib; |
| 1618 | struct prefix p; |
| 1619 | int ret; |
| 1620 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1621 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | |
| 1623 | ret = str2prefix (argv[0], &p); |
| 1624 | if (! ret) |
| 1625 | { |
| 1626 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 1627 | return CMD_WARNING; |
| 1628 | } |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1629 | |
| 1630 | if (argc > 1) |
| 1631 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 1632 | |
| 1633 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | if (! table) |
| 1635 | return CMD_SUCCESS; |
| 1636 | |
| 1637 | /* Show matched type IPv4 routes. */ |
| 1638 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1639 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1640 | if (prefix_match (&p, &rn->p)) |
| 1641 | { |
| 1642 | if (first) |
| 1643 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1644 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1645 | first = 0; |
| 1646 | } |
| 1647 | vty_show_ip_route (vty, rn, rib); |
| 1648 | } |
| 1649 | return CMD_SUCCESS; |
| 1650 | } |
| 1651 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1652 | ALIAS (show_ip_route_prefix_longer, |
| 1653 | show_ip_route_prefix_longer_vrf_cmd, |
| 1654 | "show ip route A.B.C.D/M longer-prefixes " VRF_CMD_STR, |
| 1655 | SHOW_STR |
| 1656 | IP_STR |
| 1657 | "IP routing table\n" |
| 1658 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1659 | "Show route matching the specified Network/Mask pair only\n" |
| 1660 | VRF_CMD_HELP_STR) |
| 1661 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1662 | DEFUN (show_ip_route_supernets, |
| 1663 | show_ip_route_supernets_cmd, |
| 1664 | "show ip route supernets-only", |
| 1665 | SHOW_STR |
| 1666 | IP_STR |
| 1667 | "IP routing table\n" |
| 1668 | "Show supernet entries only\n") |
| 1669 | { |
| 1670 | struct route_table *table; |
| 1671 | struct route_node *rn; |
| 1672 | struct rib *rib; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1673 | u_int32_t addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1674 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1675 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1676 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1677 | if (argc > 0) |
| 1678 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 1679 | |
| 1680 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1681 | if (! table) |
| 1682 | return CMD_SUCCESS; |
| 1683 | |
| 1684 | /* Show matched type IPv4 routes. */ |
| 1685 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1686 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | { |
| 1688 | addr = ntohl (rn->p.u.prefix4.s_addr); |
| 1689 | |
| 1690 | if ((IN_CLASSC (addr) && rn->p.prefixlen < 24) |
| 1691 | || (IN_CLASSB (addr) && rn->p.prefixlen < 16) |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1692 | || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1693 | { |
| 1694 | if (first) |
| 1695 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1696 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1697 | first = 0; |
| 1698 | } |
| 1699 | vty_show_ip_route (vty, rn, rib); |
| 1700 | } |
| 1701 | } |
| 1702 | return CMD_SUCCESS; |
| 1703 | } |
| 1704 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1705 | ALIAS (show_ip_route_supernets, |
| 1706 | show_ip_route_supernets_vrf_cmd, |
| 1707 | "show ip route supernets-only " VRF_CMD_STR, |
| 1708 | SHOW_STR |
| 1709 | IP_STR |
| 1710 | "IP routing table\n" |
| 1711 | "Show supernet entries only\n" |
| 1712 | VRF_CMD_HELP_STR) |
| 1713 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1714 | DEFUN (show_ip_route_protocol, |
| 1715 | show_ip_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1716 | "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1717 | SHOW_STR |
| 1718 | IP_STR |
| 1719 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1720 | QUAGGA_IP_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | { |
| 1722 | int type; |
| 1723 | struct route_table *table; |
| 1724 | struct route_node *rn; |
| 1725 | struct rib *rib; |
| 1726 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1727 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1728 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1729 | type = proto_redistnum (AFI_IP, argv[0]); |
| 1730 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1731 | { |
| 1732 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 1733 | return CMD_WARNING; |
| 1734 | } |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1735 | |
| 1736 | if (argc > 1) |
| 1737 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 1738 | |
| 1739 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1740 | if (! table) |
| 1741 | return CMD_SUCCESS; |
| 1742 | |
| 1743 | /* Show matched type IPv4 routes. */ |
| 1744 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1745 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1746 | if (rib->type == type) |
| 1747 | { |
| 1748 | if (first) |
| 1749 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1750 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1751 | first = 0; |
| 1752 | } |
| 1753 | vty_show_ip_route (vty, rn, rib); |
| 1754 | } |
| 1755 | return CMD_SUCCESS; |
| 1756 | } |
| 1757 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1758 | ALIAS (show_ip_route_protocol, |
| 1759 | show_ip_route_protocol_vrf_cmd, |
| 1760 | "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_CMD_STR, |
| 1761 | SHOW_STR |
| 1762 | IP_STR |
| 1763 | "IP routing table\n" |
| 1764 | QUAGGA_IP_REDIST_HELP_STR_ZEBRA |
| 1765 | VRF_CMD_HELP_STR) |
| 1766 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1767 | DEFUN (show_ip_route_addr, |
| 1768 | show_ip_route_addr_cmd, |
| 1769 | "show ip route A.B.C.D", |
| 1770 | SHOW_STR |
| 1771 | IP_STR |
| 1772 | "IP routing table\n" |
| 1773 | "Network in the IP routing table to display\n") |
| 1774 | { |
| 1775 | int ret; |
| 1776 | struct prefix_ipv4 p; |
| 1777 | struct route_table *table; |
| 1778 | struct route_node *rn; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1779 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1780 | |
| 1781 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1782 | if (ret <= 0) |
| 1783 | { |
| 1784 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 1785 | return CMD_WARNING; |
| 1786 | } |
| 1787 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1788 | if (argc > 1) |
| 1789 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 1790 | |
| 1791 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | if (! table) |
| 1793 | return CMD_SUCCESS; |
| 1794 | |
| 1795 | rn = route_node_match (table, (struct prefix *) &p); |
| 1796 | if (! rn) |
| 1797 | { |
| 1798 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1799 | return CMD_WARNING; |
| 1800 | } |
| 1801 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1802 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1803 | |
| 1804 | route_unlock_node (rn); |
| 1805 | |
| 1806 | return CMD_SUCCESS; |
| 1807 | } |
| 1808 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1809 | ALIAS (show_ip_route_addr, |
| 1810 | show_ip_route_addr_vrf_cmd, |
| 1811 | "show ip route A.B.C.D " VRF_CMD_STR, |
| 1812 | SHOW_STR |
| 1813 | IP_STR |
| 1814 | "IP routing table\n" |
| 1815 | "Network in the IP routing table to display\n" |
| 1816 | VRF_CMD_HELP_STR) |
| 1817 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | DEFUN (show_ip_route_prefix, |
| 1819 | show_ip_route_prefix_cmd, |
| 1820 | "show ip route A.B.C.D/M", |
| 1821 | SHOW_STR |
| 1822 | IP_STR |
| 1823 | "IP routing table\n" |
| 1824 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 1825 | { |
| 1826 | int ret; |
| 1827 | struct prefix_ipv4 p; |
| 1828 | struct route_table *table; |
| 1829 | struct route_node *rn; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1830 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1831 | |
| 1832 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1833 | if (ret <= 0) |
| 1834 | { |
| 1835 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 1836 | return CMD_WARNING; |
| 1837 | } |
| 1838 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1839 | if (argc > 1) |
| 1840 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 1841 | |
| 1842 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | if (! table) |
| 1844 | return CMD_SUCCESS; |
| 1845 | |
| 1846 | rn = route_node_match (table, (struct prefix *) &p); |
| 1847 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 1848 | { |
| 1849 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 1850 | if (rn) |
| 1851 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | return CMD_WARNING; |
| 1853 | } |
| 1854 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1855 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1856 | |
| 1857 | route_unlock_node (rn); |
| 1858 | |
| 1859 | return CMD_SUCCESS; |
| 1860 | } |
| 1861 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1862 | ALIAS (show_ip_route_prefix, |
| 1863 | show_ip_route_prefix_vrf_cmd, |
| 1864 | "show ip route A.B.C.D/M " VRF_CMD_STR, |
| 1865 | SHOW_STR |
| 1866 | IP_STR |
| 1867 | "IP routing table\n" |
| 1868 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1869 | VRF_CMD_HELP_STR) |
| 1870 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1871 | static void |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1872 | vty_show_ip_route_summary (struct vty *vty, struct route_table *table) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1874 | struct route_node *rn; |
| 1875 | struct rib *rib; |
| 1876 | struct nexthop *nexthop; |
| 1877 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1878 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1879 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1880 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1881 | u_int32_t i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1883 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1884 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1885 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1886 | RNODE_FOREACH_RIB (rn, rib) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1887 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 1888 | { |
| 1889 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1890 | rib_cnt[rib->type]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1891 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1892 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1893 | { |
| 1894 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1895 | fib_cnt[rib->type]++; |
| 1896 | } |
| 1897 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1898 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1899 | { |
| 1900 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1901 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1902 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1903 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1904 | } |
| 1905 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1906 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1907 | vty_out (vty, "%-20s %-20s %s (vrf %u)%s", |
| 1908 | "Route Source", "Routes", "FIB", |
| 1909 | ((rib_table_info_t *)table->info)->zvrf->vrf_id, |
| 1910 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1911 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1912 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1913 | { |
| 1914 | if (rib_cnt[i] > 0) |
| 1915 | { |
| 1916 | if (i == ZEBRA_ROUTE_BGP) |
| 1917 | { |
| 1918 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 1919 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 1920 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1921 | VTY_NEWLINE); |
| 1922 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 1923 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1924 | VTY_NEWLINE); |
| 1925 | } |
| 1926 | else |
| 1927 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 1928 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 1929 | } |
| 1930 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1931 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1932 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 1933 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 1934 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1935 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1936 | } |
| 1937 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 1938 | /* |
| 1939 | * Implementation of the ip route summary prefix command. |
| 1940 | * |
| 1941 | * This command prints the primary prefixes that have been installed by various |
| 1942 | * protocols on the box. |
| 1943 | * |
| 1944 | */ |
| 1945 | static void |
| 1946 | vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) |
| 1947 | { |
| 1948 | struct route_node *rn; |
| 1949 | struct rib *rib; |
| 1950 | struct nexthop *nexthop; |
| 1951 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1952 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1953 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1954 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1955 | u_int32_t i; |
| 1956 | int cnt; |
| 1957 | |
| 1958 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1959 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1960 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1961 | RNODE_FOREACH_RIB (rn, rib) |
| 1962 | { |
| 1963 | |
| 1964 | /* |
| 1965 | * In case of ECMP, count only once. |
| 1966 | */ |
| 1967 | cnt = 0; |
| 1968 | for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next) |
| 1969 | { |
| 1970 | cnt++; |
| 1971 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1972 | rib_cnt[rib->type]++; |
| 1973 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1974 | { |
| 1975 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1976 | fib_cnt[rib->type]++; |
| 1977 | } |
| 1978 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1979 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1980 | { |
| 1981 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1982 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1983 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1984 | } |
| 1985 | } |
| 1986 | } |
| 1987 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 1988 | vty_out (vty, "%-20s %-20s %s (vrf %u)%s", |
| 1989 | "Route Source", "Prefix Routes", "FIB", |
| 1990 | ((rib_table_info_t *)table->info)->zvrf->vrf_id, |
| 1991 | VTY_NEWLINE); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 1992 | |
| 1993 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1994 | { |
| 1995 | if (rib_cnt[i] > 0) |
| 1996 | { |
| 1997 | if (i == ZEBRA_ROUTE_BGP) |
| 1998 | { |
| 1999 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 2000 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 2001 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 2002 | VTY_NEWLINE); |
| 2003 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 2004 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 2005 | VTY_NEWLINE); |
| 2006 | } |
| 2007 | else |
| 2008 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 2009 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 2010 | } |
| 2011 | } |
| 2012 | |
| 2013 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 2014 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 2015 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2016 | vty_out (vty, "%s", VTY_NEWLINE); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2017 | } |
| 2018 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2019 | /* Show route summary. */ |
| 2020 | DEFUN (show_ip_route_summary, |
| 2021 | show_ip_route_summary_cmd, |
| 2022 | "show ip route summary", |
| 2023 | SHOW_STR |
| 2024 | IP_STR |
| 2025 | "IP routing table\n" |
| 2026 | "Summary of all routes\n") |
| 2027 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2028 | struct route_table *table; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2029 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2030 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2031 | if (argc > 0) |
| 2032 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 2033 | |
| 2034 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2035 | if (! table) |
| 2036 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2037 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2038 | vty_show_ip_route_summary (vty, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2039 | |
| 2040 | return CMD_SUCCESS; |
| 2041 | } |
| 2042 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2043 | ALIAS (show_ip_route_summary, |
| 2044 | show_ip_route_summary_vrf_cmd, |
| 2045 | "show ip route summary " VRF_CMD_STR, |
| 2046 | SHOW_STR |
| 2047 | IP_STR |
| 2048 | "IP routing table\n" |
| 2049 | "Summary of all routes\n" |
| 2050 | VRF_CMD_HELP_STR) |
| 2051 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2052 | /* Show route summary prefix. */ |
| 2053 | DEFUN (show_ip_route_summary_prefix, |
| 2054 | show_ip_route_summary_prefix_cmd, |
| 2055 | "show ip route summary prefix", |
| 2056 | SHOW_STR |
| 2057 | IP_STR |
| 2058 | "IP routing table\n" |
| 2059 | "Summary of all routes\n" |
| 2060 | "Prefix routes\n") |
| 2061 | { |
| 2062 | struct route_table *table; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2063 | vrf_id_t vrf_id = VRF_DEFAULT; |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2064 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2065 | if (argc > 0) |
| 2066 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 2067 | |
| 2068 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2069 | if (! table) |
| 2070 | return CMD_SUCCESS; |
| 2071 | |
| 2072 | vty_show_ip_route_summary_prefix (vty, table); |
| 2073 | |
| 2074 | return CMD_SUCCESS; |
| 2075 | } |
| 2076 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2077 | ALIAS (show_ip_route_summary_prefix, |
| 2078 | show_ip_route_summary_prefix_vrf_cmd, |
| 2079 | "show ip route summary prefix " VRF_CMD_STR, |
| 2080 | SHOW_STR |
| 2081 | IP_STR |
| 2082 | "IP routing table\n" |
| 2083 | "Summary of all routes\n" |
| 2084 | "Prefix routes\n" |
| 2085 | VRF_CMD_HELP_STR) |
| 2086 | |
| 2087 | DEFUN (show_ip_route_vrf_all, |
| 2088 | show_ip_route_vrf_all_cmd, |
| 2089 | "show ip route " VRF_ALL_CMD_STR, |
| 2090 | SHOW_STR |
| 2091 | IP_STR |
| 2092 | "IP routing table\n" |
| 2093 | VRF_ALL_CMD_HELP_STR) |
| 2094 | { |
| 2095 | struct route_table *table; |
| 2096 | struct route_node *rn; |
| 2097 | struct rib *rib; |
| 2098 | struct zebra_vrf *zvrf; |
| 2099 | vrf_iter_t iter; |
| 2100 | int first = 1; |
| 2101 | |
| 2102 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2103 | { |
| 2104 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2105 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2106 | continue; |
| 2107 | |
| 2108 | /* Show all IPv4 routes. */ |
| 2109 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 2110 | RNODE_FOREACH_RIB (rn, rib) |
| 2111 | { |
| 2112 | if (first) |
| 2113 | { |
| 2114 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2115 | first = 0; |
| 2116 | } |
| 2117 | vty_show_ip_route (vty, rn, rib); |
| 2118 | } |
| 2119 | } |
| 2120 | |
| 2121 | return CMD_SUCCESS; |
| 2122 | } |
| 2123 | |
| 2124 | DEFUN (show_ip_route_prefix_longer_vrf_all, |
| 2125 | show_ip_route_prefix_longer_vrf_all_cmd, |
| 2126 | "show ip route A.B.C.D/M longer-prefixes " VRF_ALL_CMD_STR, |
| 2127 | SHOW_STR |
| 2128 | IP_STR |
| 2129 | "IP routing table\n" |
| 2130 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2131 | "Show route matching the specified Network/Mask pair only\n" |
| 2132 | VRF_ALL_CMD_HELP_STR) |
| 2133 | { |
| 2134 | struct route_table *table; |
| 2135 | struct route_node *rn; |
| 2136 | struct rib *rib; |
| 2137 | struct prefix p; |
| 2138 | struct zebra_vrf *zvrf; |
| 2139 | vrf_iter_t iter; |
| 2140 | int ret; |
| 2141 | int first = 1; |
| 2142 | |
| 2143 | ret = str2prefix (argv[0], &p); |
| 2144 | if (! ret) |
| 2145 | { |
| 2146 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 2147 | return CMD_WARNING; |
| 2148 | } |
| 2149 | |
| 2150 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2151 | { |
| 2152 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2153 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2154 | continue; |
| 2155 | |
| 2156 | /* Show matched type IPv4 routes. */ |
| 2157 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 2158 | RNODE_FOREACH_RIB (rn, rib) |
| 2159 | if (prefix_match (&p, &rn->p)) |
| 2160 | { |
| 2161 | if (first) |
| 2162 | { |
| 2163 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2164 | first = 0; |
| 2165 | } |
| 2166 | vty_show_ip_route (vty, rn, rib); |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | return CMD_SUCCESS; |
| 2171 | } |
| 2172 | |
| 2173 | DEFUN (show_ip_route_supernets_vrf_all, |
| 2174 | show_ip_route_supernets_vrf_all_cmd, |
| 2175 | "show ip route supernets-only " VRF_ALL_CMD_STR, |
| 2176 | SHOW_STR |
| 2177 | IP_STR |
| 2178 | "IP routing table\n" |
| 2179 | "Show supernet entries only\n" |
| 2180 | VRF_ALL_CMD_HELP_STR) |
| 2181 | { |
| 2182 | struct route_table *table; |
| 2183 | struct route_node *rn; |
| 2184 | struct rib *rib; |
| 2185 | struct zebra_vrf *zvrf; |
| 2186 | vrf_iter_t iter; |
| 2187 | u_int32_t addr; |
| 2188 | int first = 1; |
| 2189 | |
| 2190 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2191 | { |
| 2192 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2193 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2194 | continue; |
| 2195 | |
| 2196 | /* Show matched type IPv4 routes. */ |
| 2197 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 2198 | RNODE_FOREACH_RIB (rn, rib) |
| 2199 | { |
| 2200 | addr = ntohl (rn->p.u.prefix4.s_addr); |
| 2201 | |
| 2202 | if ((IN_CLASSC (addr) && rn->p.prefixlen < 24) |
| 2203 | || (IN_CLASSB (addr) && rn->p.prefixlen < 16) |
| 2204 | || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) |
| 2205 | { |
| 2206 | if (first) |
| 2207 | { |
| 2208 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2209 | first = 0; |
| 2210 | } |
| 2211 | vty_show_ip_route (vty, rn, rib); |
| 2212 | } |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | return CMD_SUCCESS; |
| 2217 | } |
| 2218 | |
| 2219 | DEFUN (show_ip_route_protocol_vrf_all, |
| 2220 | show_ip_route_protocol_vrf_all_cmd, |
| 2221 | "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR, |
| 2222 | SHOW_STR |
| 2223 | IP_STR |
| 2224 | "IP routing table\n" |
| 2225 | QUAGGA_IP_REDIST_HELP_STR_ZEBRA |
| 2226 | VRF_ALL_CMD_HELP_STR) |
| 2227 | { |
| 2228 | int type; |
| 2229 | struct route_table *table; |
| 2230 | struct route_node *rn; |
| 2231 | struct rib *rib; |
| 2232 | struct zebra_vrf *zvrf; |
| 2233 | vrf_iter_t iter; |
| 2234 | int first = 1; |
| 2235 | |
| 2236 | type = proto_redistnum (AFI_IP, argv[0]); |
| 2237 | if (type < 0) |
| 2238 | { |
| 2239 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 2240 | return CMD_WARNING; |
| 2241 | } |
| 2242 | |
| 2243 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2244 | { |
| 2245 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2246 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2247 | continue; |
| 2248 | |
| 2249 | /* Show matched type IPv4 routes. */ |
| 2250 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 2251 | RNODE_FOREACH_RIB (rn, rib) |
| 2252 | if (rib->type == type) |
| 2253 | { |
| 2254 | if (first) |
| 2255 | { |
| 2256 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2257 | first = 0; |
| 2258 | } |
| 2259 | vty_show_ip_route (vty, rn, rib); |
| 2260 | } |
| 2261 | } |
| 2262 | |
| 2263 | return CMD_SUCCESS; |
| 2264 | } |
| 2265 | |
| 2266 | DEFUN (show_ip_route_addr_vrf_all, |
| 2267 | show_ip_route_addr_vrf_all_cmd, |
| 2268 | "show ip route A.B.C.D " VRF_ALL_CMD_STR, |
| 2269 | SHOW_STR |
| 2270 | IP_STR |
| 2271 | "IP routing table\n" |
| 2272 | "Network in the IP routing table to display\n" |
| 2273 | VRF_ALL_CMD_HELP_STR) |
| 2274 | { |
| 2275 | int ret; |
| 2276 | struct prefix_ipv4 p; |
| 2277 | struct route_table *table; |
| 2278 | struct route_node *rn; |
| 2279 | struct zebra_vrf *zvrf; |
| 2280 | vrf_iter_t iter; |
| 2281 | |
| 2282 | ret = str2prefix_ipv4 (argv[0], &p); |
| 2283 | if (ret <= 0) |
| 2284 | { |
| 2285 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 2286 | return CMD_WARNING; |
| 2287 | } |
| 2288 | |
| 2289 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2290 | { |
| 2291 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2292 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2293 | continue; |
| 2294 | |
| 2295 | rn = route_node_match (table, (struct prefix *) &p); |
| 2296 | if (! rn) |
| 2297 | continue; |
| 2298 | |
| 2299 | vty_show_ip_route_detail (vty, rn, 0); |
| 2300 | |
| 2301 | route_unlock_node (rn); |
| 2302 | } |
| 2303 | |
| 2304 | return CMD_SUCCESS; |
| 2305 | } |
| 2306 | |
| 2307 | DEFUN (show_ip_route_prefix_vrf_all, |
| 2308 | show_ip_route_prefix_vrf_all_cmd, |
| 2309 | "show ip route A.B.C.D/M " VRF_ALL_CMD_STR, |
| 2310 | SHOW_STR |
| 2311 | IP_STR |
| 2312 | "IP routing table\n" |
| 2313 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 2314 | VRF_ALL_CMD_HELP_STR) |
| 2315 | { |
| 2316 | int ret; |
| 2317 | struct prefix_ipv4 p; |
| 2318 | struct route_table *table; |
| 2319 | struct route_node *rn; |
| 2320 | struct zebra_vrf *zvrf; |
| 2321 | vrf_iter_t iter; |
| 2322 | |
| 2323 | ret = str2prefix_ipv4 (argv[0], &p); |
| 2324 | if (ret <= 0) |
| 2325 | { |
| 2326 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 2327 | return CMD_WARNING; |
| 2328 | } |
| 2329 | |
| 2330 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2331 | { |
| 2332 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2333 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2334 | continue; |
| 2335 | |
| 2336 | rn = route_node_match (table, (struct prefix *) &p); |
| 2337 | if (! rn) |
| 2338 | continue; |
| 2339 | if (rn->p.prefixlen != p.prefixlen) |
| 2340 | { |
| 2341 | route_unlock_node (rn); |
| 2342 | continue; |
| 2343 | } |
| 2344 | |
| 2345 | vty_show_ip_route_detail (vty, rn, 0); |
| 2346 | |
| 2347 | route_unlock_node (rn); |
| 2348 | } |
| 2349 | |
| 2350 | return CMD_SUCCESS; |
| 2351 | } |
| 2352 | |
| 2353 | DEFUN (show_ip_route_summary_vrf_all, |
| 2354 | show_ip_route_summary_vrf_all_cmd, |
| 2355 | "show ip route summary " VRF_ALL_CMD_STR, |
| 2356 | SHOW_STR |
| 2357 | IP_STR |
| 2358 | "IP routing table\n" |
| 2359 | "Summary of all routes\n" |
| 2360 | VRF_ALL_CMD_HELP_STR) |
| 2361 | { |
| 2362 | struct zebra_vrf *zvrf; |
| 2363 | vrf_iter_t iter; |
| 2364 | |
| 2365 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2366 | if ((zvrf = vrf_iter2info (iter)) != NULL) |
| 2367 | vty_show_ip_route_summary (vty, zvrf->table[AFI_IP][SAFI_UNICAST]); |
| 2368 | |
| 2369 | return CMD_SUCCESS; |
| 2370 | } |
| 2371 | |
| 2372 | DEFUN (show_ip_route_summary_prefix_vrf_all, |
| 2373 | show_ip_route_summary_prefix_vrf_all_cmd, |
| 2374 | "show ip route summary prefix " VRF_ALL_CMD_STR, |
| 2375 | SHOW_STR |
| 2376 | IP_STR |
| 2377 | "IP routing table\n" |
| 2378 | "Summary of all routes\n" |
| 2379 | "Prefix routes\n" |
| 2380 | VRF_ALL_CMD_HELP_STR) |
| 2381 | { |
| 2382 | struct zebra_vrf *zvrf; |
| 2383 | vrf_iter_t iter; |
| 2384 | |
| 2385 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2386 | if ((zvrf = vrf_iter2info (iter)) != NULL) |
| 2387 | vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP][SAFI_UNICAST]); |
| 2388 | |
| 2389 | return CMD_SUCCESS; |
| 2390 | } |
| 2391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2392 | /* Write IPv4 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2393 | static int |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 2394 | static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2395 | { |
| 2396 | struct route_node *rn; |
| 2397 | struct static_ipv4 *si; |
| 2398 | struct route_table *stable; |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2399 | struct zebra_vrf *zvrf; |
| 2400 | vrf_iter_t iter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2401 | int write; |
| 2402 | |
| 2403 | write = 0; |
| 2404 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2405 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2406 | { |
| 2407 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2408 | (stable = zvrf->stable[AFI_IP][safi]) == NULL) |
| 2409 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2410 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2411 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 2412 | for (si = rn->info; si; si = si->next) |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 2413 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2414 | vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4), |
| 2415 | rn->p.prefixlen); |
| 2416 | |
| 2417 | switch (si->type) |
| 2418 | { |
| 2419 | case STATIC_IPV4_GATEWAY: |
| 2420 | vty_out (vty, " %s", inet_ntoa (si->gate.ipv4)); |
| 2421 | break; |
| 2422 | case STATIC_IPV4_IFNAME: |
| 2423 | vty_out (vty, " %s", si->gate.ifname); |
| 2424 | break; |
| 2425 | case STATIC_IPV4_BLACKHOLE: |
| 2426 | vty_out (vty, " Null0"); |
| 2427 | break; |
| 2428 | } |
| 2429 | |
| 2430 | /* flags are incompatible with STATIC_IPV4_BLACKHOLE */ |
| 2431 | if (si->type != STATIC_IPV4_BLACKHOLE) |
| 2432 | { |
| 2433 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 2434 | vty_out (vty, " %s", "reject"); |
| 2435 | |
| 2436 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 2437 | vty_out (vty, " %s", "blackhole"); |
| 2438 | } |
| 2439 | |
| 2440 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 2441 | vty_out (vty, " %d", si->distance); |
| 2442 | |
| 2443 | if (si->vrf_id != VRF_DEFAULT) |
| 2444 | vty_out (vty, " vrf %u", si->vrf_id); |
| 2445 | |
| 2446 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2447 | |
| 2448 | write = 1; |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 2449 | } |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2450 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2451 | return write; |
| 2452 | } |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 2453 | |
| 2454 | DEFUN (show_ip_protocol, |
| 2455 | show_ip_protocol_cmd, |
| 2456 | "show ip protocol", |
| 2457 | SHOW_STR |
| 2458 | IP_STR |
| 2459 | "IP protocol filtering status\n") |
| 2460 | { |
| 2461 | int i; |
| 2462 | |
| 2463 | vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE); |
| 2464 | vty_out(vty, "------------------------%s", VTY_NEWLINE); |
| 2465 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 2466 | { |
| 2467 | if (proto_rm[AFI_IP][i]) |
| 2468 | vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i), |
| 2469 | proto_rm[AFI_IP][i], |
| 2470 | VTY_NEWLINE); |
| 2471 | else |
| 2472 | vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE); |
| 2473 | } |
| 2474 | if (proto_rm[AFI_IP][i]) |
| 2475 | vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i], |
| 2476 | VTY_NEWLINE); |
| 2477 | else |
| 2478 | vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE); |
| 2479 | |
| 2480 | return CMD_SUCCESS; |
| 2481 | } |
| 2482 | |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 2483 | /* |
| 2484 | * Show IP mroute command to dump the BGP Multicast |
| 2485 | * routing table |
| 2486 | */ |
| 2487 | DEFUN (show_ip_mroute, |
| 2488 | show_ip_mroute_cmd, |
| 2489 | "show ip mroute", |
| 2490 | SHOW_STR |
| 2491 | IP_STR |
| 2492 | "IP Multicast routing table\n") |
| 2493 | { |
| 2494 | struct route_table *table; |
| 2495 | struct route_node *rn; |
| 2496 | struct rib *rib; |
| 2497 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2498 | vrf_id_t vrf_id = VRF_DEFAULT; |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 2499 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2500 | if (argc > 0) |
| 2501 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 2502 | |
| 2503 | table = zebra_vrf_table (AFI_IP, SAFI_MULTICAST, vrf_id); |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 2504 | if (! table) |
| 2505 | return CMD_SUCCESS; |
| 2506 | |
| 2507 | /* Show all IPv4 routes. */ |
| 2508 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 2509 | RNODE_FOREACH_RIB (rn, rib) |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 2510 | { |
| 2511 | if (first) |
| 2512 | { |
| 2513 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2514 | first = 0; |
| 2515 | } |
| 2516 | vty_show_ip_route (vty, rn, rib); |
| 2517 | } |
| 2518 | return CMD_SUCCESS; |
| 2519 | } |
| 2520 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 2521 | ALIAS (show_ip_mroute, |
| 2522 | show_ip_mroute_vrf_cmd, |
| 2523 | "show ip mroute " VRF_CMD_STR, |
| 2524 | SHOW_STR |
| 2525 | IP_STR |
| 2526 | "IP Multicast routing table\n" |
| 2527 | VRF_CMD_HELP_STR) |
| 2528 | |
| 2529 | DEFUN (show_ip_mroute_vrf_all, |
| 2530 | show_ip_mroute_vrf_all_cmd, |
| 2531 | "show ip mroute " VRF_ALL_CMD_STR, |
| 2532 | SHOW_STR |
| 2533 | IP_STR |
| 2534 | "IP Multicast routing table\n" |
| 2535 | VRF_ALL_CMD_HELP_STR) |
| 2536 | { |
| 2537 | struct route_table *table; |
| 2538 | struct route_node *rn; |
| 2539 | struct rib *rib; |
| 2540 | struct zebra_vrf *zvrf; |
| 2541 | vrf_iter_t iter; |
| 2542 | int first = 1; |
| 2543 | |
| 2544 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 2545 | { |
| 2546 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 2547 | (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL) |
| 2548 | continue; |
| 2549 | |
| 2550 | /* Show all IPv4 routes. */ |
| 2551 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 2552 | RNODE_FOREACH_RIB (rn, rib) |
| 2553 | { |
| 2554 | if (first) |
| 2555 | { |
| 2556 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 2557 | first = 0; |
| 2558 | } |
| 2559 | vty_show_ip_route (vty, rn, rib); |
| 2560 | } |
| 2561 | } |
| 2562 | |
| 2563 | return CMD_SUCCESS; |
| 2564 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | #ifdef HAVE_IPV6 |
| 2567 | /* General fucntion for IPv6 static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2568 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 2569 | static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, |
| 2570 | const char *gate_str, const char *ifname, |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2571 | const char *flag_str, const char *distance_str, |
| 2572 | const char *vrf_id_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2573 | { |
| 2574 | int ret; |
| 2575 | u_char distance; |
| 2576 | struct prefix p; |
| 2577 | struct in6_addr *gate = NULL; |
| 2578 | struct in6_addr gate_addr; |
| 2579 | u_char type = 0; |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2580 | vrf_id_t vrf_id = VRF_DEFAULT; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2581 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2582 | |
| 2583 | ret = str2prefix (dest_str, &p); |
| 2584 | if (ret <= 0) |
| 2585 | { |
| 2586 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 2587 | return CMD_WARNING; |
| 2588 | } |
| 2589 | |
| 2590 | /* Apply mask for given prefix. */ |
| 2591 | apply_mask (&p); |
| 2592 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2593 | /* Route flags */ |
| 2594 | if (flag_str) { |
| 2595 | switch(flag_str[0]) { |
| 2596 | case 'r': |
| 2597 | case 'R': /* XXX */ |
| 2598 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 2599 | break; |
| 2600 | case 'b': |
| 2601 | case 'B': /* XXX */ |
| 2602 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 2603 | break; |
| 2604 | default: |
| 2605 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 2606 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2607 | } |
| 2608 | } |
| 2609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2610 | /* Administrative distance. */ |
| 2611 | if (distance_str) |
| 2612 | distance = atoi (distance_str); |
| 2613 | else |
| 2614 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 2615 | |
| 2616 | /* When gateway is valid IPv6 addrees, then gate is treated as |
| 2617 | nexthop address other case gate is treated as interface name. */ |
| 2618 | ret = inet_pton (AF_INET6, gate_str, &gate_addr); |
| 2619 | |
| 2620 | if (ifname) |
| 2621 | { |
| 2622 | /* When ifname is specified. It must be come with gateway |
| 2623 | address. */ |
| 2624 | if (ret != 1) |
| 2625 | { |
| 2626 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 2627 | return CMD_WARNING; |
| 2628 | } |
| 2629 | type = STATIC_IPV6_GATEWAY_IFNAME; |
| 2630 | gate = &gate_addr; |
| 2631 | } |
| 2632 | else |
| 2633 | { |
| 2634 | if (ret == 1) |
| 2635 | { |
| 2636 | type = STATIC_IPV6_GATEWAY; |
| 2637 | gate = &gate_addr; |
| 2638 | } |
| 2639 | else |
| 2640 | { |
| 2641 | type = STATIC_IPV6_IFNAME; |
| 2642 | ifname = gate_str; |
| 2643 | } |
| 2644 | } |
| 2645 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2646 | /* VRF id */ |
| 2647 | if (vrf_id_str) |
| 2648 | VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str); |
| 2649 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | if (add_cmd) |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2651 | static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2652 | else |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2653 | static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2654 | |
| 2655 | return CMD_SUCCESS; |
| 2656 | } |
| 2657 | |
| 2658 | DEFUN (ipv6_route, |
| 2659 | ipv6_route_cmd, |
| 2660 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 2661 | IP_STR |
| 2662 | "Establish static routes\n" |
| 2663 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2664 | "IPv6 gateway address\n" |
| 2665 | "IPv6 gateway interface name\n") |
| 2666 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2667 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, |
| 2668 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2669 | } |
| 2670 | |
| 2671 | DEFUN (ipv6_route_flags, |
| 2672 | ipv6_route_flags_cmd, |
| 2673 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 2674 | IP_STR |
| 2675 | "Establish static routes\n" |
| 2676 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2677 | "IPv6 gateway address\n" |
| 2678 | "IPv6 gateway interface name\n" |
| 2679 | "Emit an ICMP unreachable when matched\n" |
| 2680 | "Silently discard pkts when matched\n") |
| 2681 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2682 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, |
| 2683 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2684 | } |
| 2685 | |
| 2686 | DEFUN (ipv6_route_ifname, |
| 2687 | ipv6_route_ifname_cmd, |
| 2688 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 2689 | IP_STR |
| 2690 | "Establish static routes\n" |
| 2691 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2692 | "IPv6 gateway address\n" |
| 2693 | "IPv6 gateway interface name\n") |
| 2694 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2695 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, |
| 2696 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2697 | } |
| 2698 | |
| 2699 | DEFUN (ipv6_route_ifname_flags, |
| 2700 | ipv6_route_ifname_flags_cmd, |
| 2701 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 2702 | IP_STR |
| 2703 | "Establish static routes\n" |
| 2704 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2705 | "IPv6 gateway address\n" |
| 2706 | "IPv6 gateway interface name\n" |
| 2707 | "Emit an ICMP unreachable when matched\n" |
| 2708 | "Silently discard pkts when matched\n") |
| 2709 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2710 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, |
| 2711 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | } |
| 2713 | |
| 2714 | DEFUN (ipv6_route_pref, |
| 2715 | ipv6_route_pref_cmd, |
| 2716 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 2717 | IP_STR |
| 2718 | "Establish static routes\n" |
| 2719 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2720 | "IPv6 gateway address\n" |
| 2721 | "IPv6 gateway interface name\n" |
| 2722 | "Distance value for this prefix\n") |
| 2723 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2724 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], |
| 2725 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2726 | } |
| 2727 | |
| 2728 | DEFUN (ipv6_route_flags_pref, |
| 2729 | ipv6_route_flags_pref_cmd, |
| 2730 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 2731 | IP_STR |
| 2732 | "Establish static routes\n" |
| 2733 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2734 | "IPv6 gateway address\n" |
| 2735 | "IPv6 gateway interface name\n" |
| 2736 | "Emit an ICMP unreachable when matched\n" |
| 2737 | "Silently discard pkts when matched\n" |
| 2738 | "Distance value for this prefix\n") |
| 2739 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2740 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], |
| 2741 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2742 | } |
| 2743 | |
| 2744 | DEFUN (ipv6_route_ifname_pref, |
| 2745 | ipv6_route_ifname_pref_cmd, |
| 2746 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 2747 | IP_STR |
| 2748 | "Establish static routes\n" |
| 2749 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2750 | "IPv6 gateway address\n" |
| 2751 | "IPv6 gateway interface name\n" |
| 2752 | "Distance value for this prefix\n") |
| 2753 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2754 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], |
| 2755 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2756 | } |
| 2757 | |
| 2758 | DEFUN (ipv6_route_ifname_flags_pref, |
| 2759 | ipv6_route_ifname_flags_pref_cmd, |
| 2760 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 2761 | IP_STR |
| 2762 | "Establish static routes\n" |
| 2763 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2764 | "IPv6 gateway address\n" |
| 2765 | "IPv6 gateway interface name\n" |
| 2766 | "Emit an ICMP unreachable when matched\n" |
| 2767 | "Silently discard pkts when matched\n" |
| 2768 | "Distance value for this prefix\n") |
| 2769 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2770 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 2771 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2772 | } |
| 2773 | |
| 2774 | DEFUN (no_ipv6_route, |
| 2775 | no_ipv6_route_cmd, |
| 2776 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 2777 | NO_STR |
| 2778 | IP_STR |
| 2779 | "Establish static routes\n" |
| 2780 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2781 | "IPv6 gateway address\n" |
| 2782 | "IPv6 gateway interface name\n") |
| 2783 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2784 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, |
| 2785 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2786 | } |
| 2787 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2788 | ALIAS (no_ipv6_route, |
| 2789 | no_ipv6_route_flags_cmd, |
| 2790 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 2791 | NO_STR |
| 2792 | IP_STR |
| 2793 | "Establish static routes\n" |
| 2794 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2795 | "IPv6 gateway address\n" |
| 2796 | "IPv6 gateway interface name\n" |
| 2797 | "Emit an ICMP unreachable when matched\n" |
| 2798 | "Silently discard pkts when matched\n") |
| 2799 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2800 | DEFUN (no_ipv6_route_ifname, |
| 2801 | no_ipv6_route_ifname_cmd, |
| 2802 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 2803 | NO_STR |
| 2804 | IP_STR |
| 2805 | "Establish static routes\n" |
| 2806 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2807 | "IPv6 gateway address\n" |
| 2808 | "IPv6 gateway interface name\n") |
| 2809 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2810 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, |
| 2811 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2812 | } |
| 2813 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2814 | ALIAS (no_ipv6_route_ifname, |
| 2815 | no_ipv6_route_ifname_flags_cmd, |
| 2816 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 2817 | NO_STR |
| 2818 | IP_STR |
| 2819 | "Establish static routes\n" |
| 2820 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2821 | "IPv6 gateway address\n" |
| 2822 | "IPv6 gateway interface name\n" |
| 2823 | "Emit an ICMP unreachable when matched\n" |
| 2824 | "Silently discard pkts when matched\n") |
| 2825 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2826 | DEFUN (no_ipv6_route_pref, |
| 2827 | no_ipv6_route_pref_cmd, |
| 2828 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 2829 | NO_STR |
| 2830 | IP_STR |
| 2831 | "Establish static routes\n" |
| 2832 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2833 | "IPv6 gateway address\n" |
| 2834 | "IPv6 gateway interface name\n" |
| 2835 | "Distance value for this prefix\n") |
| 2836 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2837 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], |
| 2838 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2839 | } |
| 2840 | |
| 2841 | DEFUN (no_ipv6_route_flags_pref, |
| 2842 | no_ipv6_route_flags_pref_cmd, |
| 2843 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 2844 | NO_STR |
| 2845 | IP_STR |
| 2846 | "Establish static routes\n" |
| 2847 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2848 | "IPv6 gateway address\n" |
| 2849 | "IPv6 gateway interface name\n" |
| 2850 | "Emit an ICMP unreachable when matched\n" |
| 2851 | "Silently discard pkts when matched\n" |
| 2852 | "Distance value for this prefix\n") |
| 2853 | { |
| 2854 | /* We do not care about argv[2] */ |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2855 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], |
| 2856 | NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2857 | } |
| 2858 | |
| 2859 | DEFUN (no_ipv6_route_ifname_pref, |
| 2860 | no_ipv6_route_ifname_pref_cmd, |
| 2861 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 2862 | NO_STR |
| 2863 | IP_STR |
| 2864 | "Establish static routes\n" |
| 2865 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2866 | "IPv6 gateway address\n" |
| 2867 | "IPv6 gateway interface name\n" |
| 2868 | "Distance value for this prefix\n") |
| 2869 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2870 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], |
| 2871 | NULL); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2872 | } |
| 2873 | |
| 2874 | DEFUN (no_ipv6_route_ifname_flags_pref, |
| 2875 | no_ipv6_route_ifname_flags_pref_cmd, |
| 2876 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 2877 | NO_STR |
| 2878 | IP_STR |
| 2879 | "Establish static routes\n" |
| 2880 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2881 | "IPv6 gateway address\n" |
| 2882 | "IPv6 gateway interface name\n" |
| 2883 | "Emit an ICMP unreachable when matched\n" |
| 2884 | "Silently discard pkts when matched\n" |
| 2885 | "Distance value for this prefix\n") |
| 2886 | { |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 2887 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 2888 | NULL); |
| 2889 | } |
| 2890 | |
| 2891 | DEFUN (ipv6_route_vrf, |
| 2892 | ipv6_route_vrf_cmd, |
| 2893 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR, |
| 2894 | IP_STR |
| 2895 | "Establish static routes\n" |
| 2896 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2897 | "IPv6 gateway address\n" |
| 2898 | "IPv6 gateway interface name\n" |
| 2899 | VRF_CMD_HELP_STR) |
| 2900 | { |
| 2901 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, |
| 2902 | argv[2]); |
| 2903 | } |
| 2904 | |
| 2905 | DEFUN (ipv6_route_flags_vrf, |
| 2906 | ipv6_route_flags_vrf_cmd, |
| 2907 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 2908 | IP_STR |
| 2909 | "Establish static routes\n" |
| 2910 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2911 | "IPv6 gateway address\n" |
| 2912 | "IPv6 gateway interface name\n" |
| 2913 | "Emit an ICMP unreachable when matched\n" |
| 2914 | "Silently discard pkts when matched\n" |
| 2915 | VRF_CMD_HELP_STR) |
| 2916 | { |
| 2917 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, |
| 2918 | argv[3]); |
| 2919 | } |
| 2920 | |
| 2921 | DEFUN (ipv6_route_ifname_vrf, |
| 2922 | ipv6_route_ifname_vrf_cmd, |
| 2923 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR, |
| 2924 | IP_STR |
| 2925 | "Establish static routes\n" |
| 2926 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2927 | "IPv6 gateway address\n" |
| 2928 | "IPv6 gateway interface name\n" |
| 2929 | VRF_CMD_HELP_STR) |
| 2930 | { |
| 2931 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, |
| 2932 | argv[3]); |
| 2933 | } |
| 2934 | |
| 2935 | DEFUN (ipv6_route_ifname_flags_vrf, |
| 2936 | ipv6_route_ifname_flags_vrf_cmd, |
| 2937 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR, |
| 2938 | IP_STR |
| 2939 | "Establish static routes\n" |
| 2940 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2941 | "IPv6 gateway address\n" |
| 2942 | "IPv6 gateway interface name\n" |
| 2943 | "Emit an ICMP unreachable when matched\n" |
| 2944 | "Silently discard pkts when matched\n" |
| 2945 | VRF_CMD_HELP_STR) |
| 2946 | { |
| 2947 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, |
| 2948 | argv[4]); |
| 2949 | } |
| 2950 | |
| 2951 | DEFUN (ipv6_route_pref_vrf, |
| 2952 | ipv6_route_pref_vrf_cmd, |
| 2953 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR, |
| 2954 | IP_STR |
| 2955 | "Establish static routes\n" |
| 2956 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2957 | "IPv6 gateway address\n" |
| 2958 | "IPv6 gateway interface name\n" |
| 2959 | "Distance value for this prefix\n" |
| 2960 | VRF_CMD_HELP_STR) |
| 2961 | { |
| 2962 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], |
| 2963 | argv[3]); |
| 2964 | } |
| 2965 | |
| 2966 | DEFUN (ipv6_route_flags_pref_vrf, |
| 2967 | ipv6_route_flags_pref_vrf_cmd, |
| 2968 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 2969 | IP_STR |
| 2970 | "Establish static routes\n" |
| 2971 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2972 | "IPv6 gateway address\n" |
| 2973 | "IPv6 gateway interface name\n" |
| 2974 | "Emit an ICMP unreachable when matched\n" |
| 2975 | "Silently discard pkts when matched\n" |
| 2976 | "Distance value for this prefix\n" |
| 2977 | VRF_CMD_HELP_STR) |
| 2978 | { |
| 2979 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], |
| 2980 | argv[4]); |
| 2981 | } |
| 2982 | |
| 2983 | DEFUN (ipv6_route_ifname_pref_vrf, |
| 2984 | ipv6_route_ifname_pref_vrf_cmd, |
| 2985 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR, |
| 2986 | IP_STR |
| 2987 | "Establish static routes\n" |
| 2988 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 2989 | "IPv6 gateway address\n" |
| 2990 | "IPv6 gateway interface name\n" |
| 2991 | "Distance value for this prefix\n" |
| 2992 | VRF_CMD_HELP_STR) |
| 2993 | { |
| 2994 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], |
| 2995 | argv[4]); |
| 2996 | } |
| 2997 | |
| 2998 | DEFUN (ipv6_route_ifname_flags_pref_vrf, |
| 2999 | ipv6_route_ifname_flags_pref_vrf_cmd, |
| 3000 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 3001 | IP_STR |
| 3002 | "Establish static routes\n" |
| 3003 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3004 | "IPv6 gateway address\n" |
| 3005 | "IPv6 gateway interface name\n" |
| 3006 | "Emit an ICMP unreachable when matched\n" |
| 3007 | "Silently discard pkts when matched\n" |
| 3008 | "Distance value for this prefix\n" |
| 3009 | VRF_CMD_HELP_STR) |
| 3010 | { |
| 3011 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 3012 | argv[5]); |
| 3013 | } |
| 3014 | |
| 3015 | DEFUN (no_ipv6_route_vrf, |
| 3016 | no_ipv6_route_vrf_cmd, |
| 3017 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) " VRF_CMD_STR, |
| 3018 | NO_STR |
| 3019 | IP_STR |
| 3020 | "Establish static routes\n" |
| 3021 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3022 | "IPv6 gateway address\n" |
| 3023 | "IPv6 gateway interface name\n" |
| 3024 | VRF_CMD_HELP_STR) |
| 3025 | { |
| 3026 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, |
| 3027 | (argc > 3) ? argv[3] : argv[2]); |
| 3028 | } |
| 3029 | |
| 3030 | ALIAS (no_ipv6_route_vrf, |
| 3031 | no_ipv6_route_flags_vrf_cmd, |
| 3032 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) " VRF_CMD_STR, |
| 3033 | NO_STR |
| 3034 | IP_STR |
| 3035 | "Establish static routes\n" |
| 3036 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3037 | "IPv6 gateway address\n" |
| 3038 | "IPv6 gateway interface name\n" |
| 3039 | "Emit an ICMP unreachable when matched\n" |
| 3040 | "Silently discard pkts when matched\n" |
| 3041 | VRF_CMD_HELP_STR) |
| 3042 | |
| 3043 | DEFUN (no_ipv6_route_ifname_vrf, |
| 3044 | no_ipv6_route_ifname_vrf_cmd, |
| 3045 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE " VRF_CMD_STR, |
| 3046 | NO_STR |
| 3047 | IP_STR |
| 3048 | "Establish static routes\n" |
| 3049 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3050 | "IPv6 gateway address\n" |
| 3051 | "IPv6 gateway interface name\n" |
| 3052 | VRF_CMD_HELP_STR) |
| 3053 | { |
| 3054 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, |
| 3055 | (argc > 4) ? argv[4] : argv[3]); |
| 3056 | } |
| 3057 | |
| 3058 | ALIAS (no_ipv6_route_ifname_vrf, |
| 3059 | no_ipv6_route_ifname_flags_vrf_cmd, |
| 3060 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) " VRF_CMD_STR, |
| 3061 | NO_STR |
| 3062 | IP_STR |
| 3063 | "Establish static routes\n" |
| 3064 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3065 | "IPv6 gateway address\n" |
| 3066 | "IPv6 gateway interface name\n" |
| 3067 | "Emit an ICMP unreachable when matched\n" |
| 3068 | "Silently discard pkts when matched\n" |
| 3069 | VRF_CMD_HELP_STR) |
| 3070 | |
| 3071 | DEFUN (no_ipv6_route_pref_vrf, |
| 3072 | no_ipv6_route_pref_vrf_cmd, |
| 3073 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> " VRF_CMD_STR, |
| 3074 | NO_STR |
| 3075 | IP_STR |
| 3076 | "Establish static routes\n" |
| 3077 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3078 | "IPv6 gateway address\n" |
| 3079 | "IPv6 gateway interface name\n" |
| 3080 | "Distance value for this prefix\n" |
| 3081 | VRF_CMD_HELP_STR) |
| 3082 | { |
| 3083 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], |
| 3084 | argv[3]); |
| 3085 | } |
| 3086 | |
| 3087 | DEFUN (no_ipv6_route_flags_pref_vrf, |
| 3088 | no_ipv6_route_flags_pref_vrf_cmd, |
| 3089 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 3090 | NO_STR |
| 3091 | IP_STR |
| 3092 | "Establish static routes\n" |
| 3093 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3094 | "IPv6 gateway address\n" |
| 3095 | "IPv6 gateway interface name\n" |
| 3096 | "Emit an ICMP unreachable when matched\n" |
| 3097 | "Silently discard pkts when matched\n" |
| 3098 | "Distance value for this prefix\n" |
| 3099 | VRF_CMD_HELP_STR) |
| 3100 | { |
| 3101 | /* We do not care about argv[2] */ |
| 3102 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], |
| 3103 | argv[4]); |
| 3104 | } |
| 3105 | |
| 3106 | DEFUN (no_ipv6_route_ifname_pref_vrf, |
| 3107 | no_ipv6_route_ifname_pref_vrf_cmd, |
| 3108 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> " VRF_CMD_STR, |
| 3109 | NO_STR |
| 3110 | IP_STR |
| 3111 | "Establish static routes\n" |
| 3112 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3113 | "IPv6 gateway address\n" |
| 3114 | "IPv6 gateway interface name\n" |
| 3115 | "Distance value for this prefix\n" |
| 3116 | VRF_CMD_HELP_STR) |
| 3117 | { |
| 3118 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], |
| 3119 | argv[4]); |
| 3120 | } |
| 3121 | |
| 3122 | DEFUN (no_ipv6_route_ifname_flags_pref_vrf, |
| 3123 | no_ipv6_route_ifname_flags_pref_vrf_cmd, |
| 3124 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255> " VRF_CMD_STR, |
| 3125 | NO_STR |
| 3126 | IP_STR |
| 3127 | "Establish static routes\n" |
| 3128 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 3129 | "IPv6 gateway address\n" |
| 3130 | "IPv6 gateway interface name\n" |
| 3131 | "Emit an ICMP unreachable when matched\n" |
| 3132 | "Silently discard pkts when matched\n" |
| 3133 | "Distance value for this prefix\n" |
| 3134 | VRF_CMD_HELP_STR) |
| 3135 | { |
| 3136 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], |
| 3137 | argv[5]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3138 | } |
| 3139 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3140 | DEFUN (show_ipv6_route, |
| 3141 | show_ipv6_route_cmd, |
| 3142 | "show ipv6 route", |
| 3143 | SHOW_STR |
| 3144 | IP_STR |
| 3145 | "IPv6 routing table\n") |
| 3146 | { |
| 3147 | struct route_table *table; |
| 3148 | struct route_node *rn; |
| 3149 | struct rib *rib; |
| 3150 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3151 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3152 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3153 | if (argc > 0) |
| 3154 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 3155 | |
| 3156 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3157 | if (! table) |
| 3158 | return CMD_SUCCESS; |
| 3159 | |
| 3160 | /* Show all IPv6 route. */ |
| 3161 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 3162 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3163 | { |
| 3164 | if (first) |
| 3165 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3166 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3167 | first = 0; |
| 3168 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3169 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3170 | } |
| 3171 | return CMD_SUCCESS; |
| 3172 | } |
| 3173 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3174 | ALIAS (show_ipv6_route, |
| 3175 | show_ipv6_route_vrf_cmd, |
| 3176 | "show ipv6 route " VRF_CMD_STR, |
| 3177 | SHOW_STR |
| 3178 | IP_STR |
| 3179 | "IPv6 routing table\n" |
| 3180 | VRF_CMD_HELP_STR) |
| 3181 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3182 | DEFUN (show_ipv6_route_prefix_longer, |
| 3183 | show_ipv6_route_prefix_longer_cmd, |
| 3184 | "show ipv6 route X:X::X:X/M longer-prefixes", |
| 3185 | SHOW_STR |
| 3186 | IP_STR |
| 3187 | "IPv6 routing table\n" |
| 3188 | "IPv6 prefix\n" |
| 3189 | "Show route matching the specified Network/Mask pair only\n") |
| 3190 | { |
| 3191 | struct route_table *table; |
| 3192 | struct route_node *rn; |
| 3193 | struct rib *rib; |
| 3194 | struct prefix p; |
| 3195 | int ret; |
| 3196 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3197 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3198 | |
| 3199 | ret = str2prefix (argv[0], &p); |
| 3200 | if (! ret) |
| 3201 | { |
| 3202 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 3203 | return CMD_WARNING; |
| 3204 | } |
| 3205 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3206 | if (argc > 1) |
| 3207 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 3208 | |
| 3209 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
| 3210 | if (! table) |
| 3211 | return CMD_SUCCESS; |
| 3212 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3213 | /* Show matched type IPv6 routes. */ |
| 3214 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 3215 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3216 | if (prefix_match (&p, &rn->p)) |
| 3217 | { |
| 3218 | if (first) |
| 3219 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3220 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3221 | first = 0; |
| 3222 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3223 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3224 | } |
| 3225 | return CMD_SUCCESS; |
| 3226 | } |
| 3227 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3228 | ALIAS (show_ipv6_route_prefix_longer, |
| 3229 | show_ipv6_route_prefix_longer_vrf_cmd, |
| 3230 | "show ipv6 route X:X::X:X/M longer-prefixes " VRF_CMD_STR, |
| 3231 | SHOW_STR |
| 3232 | IP_STR |
| 3233 | "IPv6 routing table\n" |
| 3234 | "IPv6 prefix\n" |
| 3235 | "Show route matching the specified Network/Mask pair only\n" |
| 3236 | VRF_CMD_HELP_STR) |
| 3237 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3238 | DEFUN (show_ipv6_route_protocol, |
| 3239 | show_ipv6_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3240 | "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3241 | SHOW_STR |
| 3242 | IP_STR |
| 3243 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3244 | QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3245 | { |
| 3246 | int type; |
| 3247 | struct route_table *table; |
| 3248 | struct route_node *rn; |
| 3249 | struct rib *rib; |
| 3250 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3251 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3252 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3253 | type = proto_redistnum (AFI_IP6, argv[0]); |
| 3254 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3255 | { |
| 3256 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 3257 | return CMD_WARNING; |
| 3258 | } |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3259 | |
| 3260 | if (argc > 1) |
| 3261 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 3262 | |
| 3263 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3264 | if (! table) |
| 3265 | return CMD_SUCCESS; |
| 3266 | |
| 3267 | /* Show matched type IPv6 routes. */ |
| 3268 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 3269 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3270 | if (rib->type == type) |
| 3271 | { |
| 3272 | if (first) |
| 3273 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 3274 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3275 | first = 0; |
| 3276 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3277 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3278 | } |
| 3279 | return CMD_SUCCESS; |
| 3280 | } |
| 3281 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3282 | ALIAS (show_ipv6_route_protocol, |
| 3283 | show_ipv6_route_protocol_vrf_cmd, |
| 3284 | "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_CMD_STR, |
| 3285 | SHOW_STR |
| 3286 | IP_STR |
| 3287 | "IP routing table\n" |
| 3288 | QUAGGA_IP6_REDIST_HELP_STR_ZEBRA |
| 3289 | VRF_CMD_HELP_STR) |
| 3290 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3291 | DEFUN (show_ipv6_route_addr, |
| 3292 | show_ipv6_route_addr_cmd, |
| 3293 | "show ipv6 route X:X::X:X", |
| 3294 | SHOW_STR |
| 3295 | IP_STR |
| 3296 | "IPv6 routing table\n" |
| 3297 | "IPv6 Address\n") |
| 3298 | { |
| 3299 | int ret; |
| 3300 | struct prefix_ipv6 p; |
| 3301 | struct route_table *table; |
| 3302 | struct route_node *rn; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3303 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3304 | |
| 3305 | ret = str2prefix_ipv6 (argv[0], &p); |
| 3306 | if (ret <= 0) |
| 3307 | { |
| 3308 | vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); |
| 3309 | return CMD_WARNING; |
| 3310 | } |
| 3311 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3312 | if (argc > 1) |
| 3313 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 3314 | |
| 3315 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3316 | if (! table) |
| 3317 | return CMD_SUCCESS; |
| 3318 | |
| 3319 | rn = route_node_match (table, (struct prefix *) &p); |
| 3320 | if (! rn) |
| 3321 | { |
| 3322 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 3323 | return CMD_WARNING; |
| 3324 | } |
| 3325 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3326 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3327 | |
| 3328 | route_unlock_node (rn); |
| 3329 | |
| 3330 | return CMD_SUCCESS; |
| 3331 | } |
| 3332 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3333 | ALIAS (show_ipv6_route_addr, |
| 3334 | show_ipv6_route_addr_vrf_cmd, |
| 3335 | "show ipv6 route X:X::X:X " VRF_CMD_STR, |
| 3336 | SHOW_STR |
| 3337 | IP_STR |
| 3338 | "IPv6 routing table\n" |
| 3339 | "IPv6 Address\n" |
| 3340 | VRF_CMD_HELP_STR) |
| 3341 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3342 | DEFUN (show_ipv6_route_prefix, |
| 3343 | show_ipv6_route_prefix_cmd, |
| 3344 | "show ipv6 route X:X::X:X/M", |
| 3345 | SHOW_STR |
| 3346 | IP_STR |
| 3347 | "IPv6 routing table\n" |
| 3348 | "IPv6 prefix\n") |
| 3349 | { |
| 3350 | int ret; |
| 3351 | struct prefix_ipv6 p; |
| 3352 | struct route_table *table; |
| 3353 | struct route_node *rn; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3354 | vrf_id_t vrf_id = VRF_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3355 | |
| 3356 | ret = str2prefix_ipv6 (argv[0], &p); |
| 3357 | if (ret <= 0) |
| 3358 | { |
| 3359 | vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); |
| 3360 | return CMD_WARNING; |
| 3361 | } |
| 3362 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3363 | if (argc > 1) |
| 3364 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 3365 | |
| 3366 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3367 | if (! table) |
| 3368 | return CMD_SUCCESS; |
| 3369 | |
| 3370 | rn = route_node_match (table, (struct prefix *) &p); |
| 3371 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 3372 | { |
| 3373 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 3374 | if (rn) |
| 3375 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3376 | return CMD_WARNING; |
| 3377 | } |
| 3378 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3379 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3380 | |
| 3381 | route_unlock_node (rn); |
| 3382 | |
| 3383 | return CMD_SUCCESS; |
| 3384 | } |
| 3385 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3386 | ALIAS (show_ipv6_route_prefix, |
| 3387 | show_ipv6_route_prefix_vrf_cmd, |
| 3388 | "show ipv6 route X:X::X:X/M " VRF_CMD_STR, |
| 3389 | SHOW_STR |
| 3390 | IP_STR |
| 3391 | "IPv6 routing table\n" |
| 3392 | "IPv6 prefix\n" |
| 3393 | VRF_CMD_HELP_STR) |
| 3394 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 3395 | /* Show route summary. */ |
| 3396 | DEFUN (show_ipv6_route_summary, |
| 3397 | show_ipv6_route_summary_cmd, |
| 3398 | "show ipv6 route summary", |
| 3399 | SHOW_STR |
| 3400 | IP_STR |
| 3401 | "IPv6 routing table\n" |
| 3402 | "Summary of all IPv6 routes\n") |
| 3403 | { |
| 3404 | struct route_table *table; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3405 | vrf_id_t vrf_id = VRF_DEFAULT; |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 3406 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3407 | if (argc > 0) |
| 3408 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 3409 | |
| 3410 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 3411 | if (! table) |
| 3412 | return CMD_SUCCESS; |
| 3413 | |
| 3414 | vty_show_ip_route_summary (vty, table); |
| 3415 | |
| 3416 | return CMD_SUCCESS; |
| 3417 | } |
| 3418 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3419 | ALIAS (show_ipv6_route_summary, |
| 3420 | show_ipv6_route_summary_vrf_cmd, |
| 3421 | "show ipv6 route summary " VRF_CMD_STR, |
| 3422 | SHOW_STR |
| 3423 | IP_STR |
| 3424 | "IPv6 routing table\n" |
| 3425 | "Summary of all IPv6 routes\n" |
| 3426 | VRF_CMD_HELP_STR) |
| 3427 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 3428 | /* Show ipv6 route summary prefix. */ |
| 3429 | DEFUN (show_ipv6_route_summary_prefix, |
| 3430 | show_ipv6_route_summary_prefix_cmd, |
| 3431 | "show ipv6 route summary prefix", |
| 3432 | SHOW_STR |
| 3433 | IP_STR |
| 3434 | "IPv6 routing table\n" |
| 3435 | "Summary of all IPv6 routes\n" |
| 3436 | "Prefix routes\n") |
| 3437 | { |
| 3438 | struct route_table *table; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3439 | vrf_id_t vrf_id = VRF_DEFAULT; |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 3440 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3441 | if (argc > 0) |
| 3442 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 3443 | |
| 3444 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 3445 | if (! table) |
| 3446 | return CMD_SUCCESS; |
| 3447 | |
| 3448 | vty_show_ip_route_summary_prefix (vty, table); |
| 3449 | |
| 3450 | return CMD_SUCCESS; |
| 3451 | } |
| 3452 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3453 | ALIAS (show_ipv6_route_summary_prefix, |
| 3454 | show_ipv6_route_summary_prefix_vrf_cmd, |
| 3455 | "show ipv6 route summary prefix " VRF_CMD_STR, |
| 3456 | SHOW_STR |
| 3457 | IP_STR |
| 3458 | "IPv6 routing table\n" |
| 3459 | "Summary of all IPv6 routes\n" |
| 3460 | "Prefix routes\n" |
| 3461 | VRF_CMD_HELP_STR) |
| 3462 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3463 | /* |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3464 | * Show IPv6 mroute command.Used to dump |
| 3465 | * the Multicast routing table. |
| 3466 | */ |
| 3467 | |
| 3468 | DEFUN (show_ipv6_mroute, |
| 3469 | show_ipv6_mroute_cmd, |
| 3470 | "show ipv6 mroute", |
| 3471 | SHOW_STR |
| 3472 | IP_STR |
| 3473 | "IPv6 Multicast routing table\n") |
| 3474 | { |
| 3475 | struct route_table *table; |
| 3476 | struct route_node *rn; |
| 3477 | struct rib *rib; |
| 3478 | int first = 1; |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3479 | vrf_id_t vrf_id = VRF_DEFAULT; |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3480 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3481 | if (argc > 0) |
| 3482 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 3483 | |
| 3484 | table = zebra_vrf_table (AFI_IP6, SAFI_MULTICAST, vrf_id); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3485 | if (! table) |
| 3486 | return CMD_SUCCESS; |
| 3487 | |
| 3488 | /* Show all IPv6 route. */ |
| 3489 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 3490 | RNODE_FOREACH_RIB (rn, rib) |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3491 | { |
| 3492 | if (first) |
| 3493 | { |
G.Balaji | cb32fd6 | 2011-11-27 20:09:40 +0530 | [diff] [blame] | 3494 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3495 | first = 0; |
| 3496 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 3497 | vty_show_ip_route (vty, rn, rib); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3498 | } |
| 3499 | return CMD_SUCCESS; |
| 3500 | } |
| 3501 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3502 | ALIAS (show_ipv6_mroute, |
| 3503 | show_ipv6_mroute_vrf_cmd, |
| 3504 | "show ipv6 mroute " VRF_CMD_STR, |
| 3505 | SHOW_STR |
| 3506 | IP_STR |
| 3507 | "IPv6 Multicast routing table\n" |
| 3508 | VRF_CMD_HELP_STR) |
| 3509 | |
| 3510 | DEFUN (show_ipv6_route_vrf_all, |
| 3511 | show_ipv6_route_vrf_all_cmd, |
| 3512 | "show ipv6 route " VRF_ALL_CMD_STR, |
| 3513 | SHOW_STR |
| 3514 | IP_STR |
| 3515 | "IPv6 routing table\n" |
| 3516 | VRF_ALL_CMD_HELP_STR) |
| 3517 | { |
| 3518 | struct route_table *table; |
| 3519 | struct route_node *rn; |
| 3520 | struct rib *rib; |
| 3521 | struct zebra_vrf *zvrf; |
| 3522 | vrf_iter_t iter; |
| 3523 | int first = 1; |
| 3524 | |
| 3525 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3526 | { |
| 3527 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3528 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3529 | continue; |
| 3530 | |
| 3531 | /* Show all IPv6 route. */ |
| 3532 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 3533 | RNODE_FOREACH_RIB (rn, rib) |
| 3534 | { |
| 3535 | if (first) |
| 3536 | { |
| 3537 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
| 3538 | first = 0; |
| 3539 | } |
| 3540 | vty_show_ip_route (vty, rn, rib); |
| 3541 | } |
| 3542 | } |
| 3543 | |
| 3544 | return CMD_SUCCESS; |
| 3545 | } |
| 3546 | |
| 3547 | DEFUN (show_ipv6_route_prefix_longer_vrf_all, |
| 3548 | show_ipv6_route_prefix_longer_vrf_all_cmd, |
| 3549 | "show ipv6 route X:X::X:X/M longer-prefixes " VRF_ALL_CMD_STR, |
| 3550 | SHOW_STR |
| 3551 | IP_STR |
| 3552 | "IPv6 routing table\n" |
| 3553 | "IPv6 prefix\n" |
| 3554 | "Show route matching the specified Network/Mask pair only\n" |
| 3555 | VRF_ALL_CMD_HELP_STR) |
| 3556 | { |
| 3557 | struct route_table *table; |
| 3558 | struct route_node *rn; |
| 3559 | struct rib *rib; |
| 3560 | struct prefix p; |
| 3561 | struct zebra_vrf *zvrf; |
| 3562 | vrf_iter_t iter; |
| 3563 | int ret; |
| 3564 | int first = 1; |
| 3565 | |
| 3566 | ret = str2prefix (argv[0], &p); |
| 3567 | if (! ret) |
| 3568 | { |
| 3569 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 3570 | return CMD_WARNING; |
| 3571 | } |
| 3572 | |
| 3573 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3574 | { |
| 3575 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3576 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3577 | continue; |
| 3578 | |
| 3579 | /* Show matched type IPv6 routes. */ |
| 3580 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 3581 | RNODE_FOREACH_RIB (rn, rib) |
| 3582 | if (prefix_match (&p, &rn->p)) |
| 3583 | { |
| 3584 | if (first) |
| 3585 | { |
| 3586 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
| 3587 | first = 0; |
| 3588 | } |
| 3589 | vty_show_ip_route (vty, rn, rib); |
| 3590 | } |
| 3591 | } |
| 3592 | |
| 3593 | return CMD_SUCCESS; |
| 3594 | } |
| 3595 | |
| 3596 | DEFUN (show_ipv6_route_protocol_vrf_all, |
| 3597 | show_ipv6_route_protocol_vrf_all_cmd, |
| 3598 | "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA " " VRF_ALL_CMD_STR, |
| 3599 | SHOW_STR |
| 3600 | IP_STR |
| 3601 | "IP routing table\n" |
| 3602 | QUAGGA_IP6_REDIST_HELP_STR_ZEBRA |
| 3603 | VRF_ALL_CMD_HELP_STR) |
| 3604 | { |
| 3605 | int type; |
| 3606 | struct route_table *table; |
| 3607 | struct route_node *rn; |
| 3608 | struct rib *rib; |
| 3609 | struct zebra_vrf *zvrf; |
| 3610 | vrf_iter_t iter; |
| 3611 | int first = 1; |
| 3612 | |
| 3613 | type = proto_redistnum (AFI_IP6, argv[0]); |
| 3614 | if (type < 0) |
| 3615 | { |
| 3616 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 3617 | return CMD_WARNING; |
| 3618 | } |
| 3619 | |
| 3620 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3621 | { |
| 3622 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3623 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3624 | continue; |
| 3625 | |
| 3626 | /* Show matched type IPv6 routes. */ |
| 3627 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 3628 | RNODE_FOREACH_RIB (rn, rib) |
| 3629 | if (rib->type == type) |
| 3630 | { |
| 3631 | if (first) |
| 3632 | { |
| 3633 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
| 3634 | first = 0; |
| 3635 | } |
| 3636 | vty_show_ip_route (vty, rn, rib); |
| 3637 | } |
| 3638 | } |
| 3639 | |
| 3640 | return CMD_SUCCESS; |
| 3641 | } |
| 3642 | |
| 3643 | DEFUN (show_ipv6_route_addr_vrf_all, |
| 3644 | show_ipv6_route_addr_vrf_all_cmd, |
| 3645 | "show ipv6 route X:X::X:X " VRF_ALL_CMD_STR, |
| 3646 | SHOW_STR |
| 3647 | IP_STR |
| 3648 | "IPv6 routing table\n" |
| 3649 | "IPv6 Address\n" |
| 3650 | VRF_ALL_CMD_HELP_STR) |
| 3651 | { |
| 3652 | int ret; |
| 3653 | struct prefix_ipv6 p; |
| 3654 | struct route_table *table; |
| 3655 | struct route_node *rn; |
| 3656 | struct zebra_vrf *zvrf; |
| 3657 | vrf_iter_t iter; |
| 3658 | |
| 3659 | ret = str2prefix_ipv6 (argv[0], &p); |
| 3660 | if (ret <= 0) |
| 3661 | { |
| 3662 | vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); |
| 3663 | return CMD_WARNING; |
| 3664 | } |
| 3665 | |
| 3666 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3667 | { |
| 3668 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3669 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3670 | continue; |
| 3671 | |
| 3672 | rn = route_node_match (table, (struct prefix *) &p); |
| 3673 | if (! rn) |
| 3674 | continue; |
| 3675 | |
| 3676 | vty_show_ip_route_detail (vty, rn, 0); |
| 3677 | |
| 3678 | route_unlock_node (rn); |
| 3679 | } |
| 3680 | |
| 3681 | return CMD_SUCCESS; |
| 3682 | } |
| 3683 | |
| 3684 | DEFUN (show_ipv6_route_prefix_vrf_all, |
| 3685 | show_ipv6_route_prefix_vrf_all_cmd, |
| 3686 | "show ipv6 route X:X::X:X/M " VRF_ALL_CMD_STR, |
| 3687 | SHOW_STR |
| 3688 | IP_STR |
| 3689 | "IPv6 routing table\n" |
| 3690 | "IPv6 prefix\n" |
| 3691 | VRF_ALL_CMD_HELP_STR) |
| 3692 | { |
| 3693 | int ret; |
| 3694 | struct prefix_ipv6 p; |
| 3695 | struct route_table *table; |
| 3696 | struct route_node *rn; |
| 3697 | struct zebra_vrf *zvrf; |
| 3698 | vrf_iter_t iter; |
| 3699 | |
| 3700 | ret = str2prefix_ipv6 (argv[0], &p); |
| 3701 | if (ret <= 0) |
| 3702 | { |
| 3703 | vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); |
| 3704 | return CMD_WARNING; |
| 3705 | } |
| 3706 | |
| 3707 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3708 | { |
| 3709 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3710 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3711 | continue; |
| 3712 | |
| 3713 | rn = route_node_match (table, (struct prefix *) &p); |
| 3714 | if (! rn) |
| 3715 | continue; |
| 3716 | if (rn->p.prefixlen != p.prefixlen) |
| 3717 | { |
| 3718 | route_unlock_node (rn); |
| 3719 | continue; |
| 3720 | } |
| 3721 | |
| 3722 | vty_show_ip_route_detail (vty, rn, 0); |
| 3723 | |
| 3724 | route_unlock_node (rn); |
| 3725 | } |
| 3726 | |
| 3727 | return CMD_SUCCESS; |
| 3728 | } |
| 3729 | |
| 3730 | /* Show route summary. */ |
| 3731 | DEFUN (show_ipv6_route_summary_vrf_all, |
| 3732 | show_ipv6_route_summary_vrf_all_cmd, |
| 3733 | "show ipv6 route summary " VRF_ALL_CMD_STR, |
| 3734 | SHOW_STR |
| 3735 | IP_STR |
| 3736 | "IPv6 routing table\n" |
| 3737 | "Summary of all IPv6 routes\n" |
| 3738 | VRF_ALL_CMD_HELP_STR) |
| 3739 | { |
| 3740 | struct zebra_vrf *zvrf; |
| 3741 | vrf_iter_t iter; |
| 3742 | |
| 3743 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3744 | if ((zvrf = vrf_iter2info (iter)) != NULL) |
| 3745 | vty_show_ip_route_summary (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]); |
| 3746 | |
| 3747 | return CMD_SUCCESS; |
| 3748 | } |
| 3749 | |
| 3750 | DEFUN (show_ipv6_mroute_vrf_all, |
| 3751 | show_ipv6_mroute_vrf_all_cmd, |
| 3752 | "show ipv6 mroute " VRF_ALL_CMD_STR, |
| 3753 | SHOW_STR |
| 3754 | IP_STR |
| 3755 | "IPv6 Multicast routing table\n" |
| 3756 | VRF_ALL_CMD_HELP_STR) |
| 3757 | { |
| 3758 | struct route_table *table; |
| 3759 | struct route_node *rn; |
| 3760 | struct rib *rib; |
| 3761 | struct zebra_vrf *zvrf; |
| 3762 | vrf_iter_t iter; |
| 3763 | int first = 1; |
| 3764 | |
| 3765 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3766 | { |
| 3767 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3768 | (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3769 | continue; |
| 3770 | |
| 3771 | /* Show all IPv6 route. */ |
| 3772 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 3773 | RNODE_FOREACH_RIB (rn, rib) |
| 3774 | { |
| 3775 | if (first) |
| 3776 | { |
| 3777 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
| 3778 | first = 0; |
| 3779 | } |
| 3780 | vty_show_ip_route (vty, rn, rib); |
| 3781 | } |
| 3782 | } |
| 3783 | return CMD_SUCCESS; |
| 3784 | } |
| 3785 | |
| 3786 | DEFUN (show_ipv6_route_summary_prefix_vrf_all, |
| 3787 | show_ipv6_route_summary_prefix_vrf_all_cmd, |
| 3788 | "show ipv6 route summary prefix " VRF_ALL_CMD_STR, |
| 3789 | SHOW_STR |
| 3790 | IP_STR |
| 3791 | "IPv6 routing table\n" |
| 3792 | "Summary of all IPv6 routes\n" |
| 3793 | "Prefix routes\n" |
| 3794 | VRF_ALL_CMD_HELP_STR) |
| 3795 | { |
| 3796 | struct zebra_vrf *zvrf; |
| 3797 | vrf_iter_t iter; |
| 3798 | |
| 3799 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3800 | if ((zvrf = vrf_iter2info (iter)) != NULL) |
| 3801 | vty_show_ip_route_summary_prefix (vty, zvrf->table[AFI_IP6][SAFI_UNICAST]); |
| 3802 | |
| 3803 | return CMD_SUCCESS; |
| 3804 | } |
| 3805 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3806 | /* Write IPv6 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 3807 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3808 | static_config_ipv6 (struct vty *vty) |
| 3809 | { |
| 3810 | struct route_node *rn; |
| 3811 | struct static_ipv6 *si; |
| 3812 | int write; |
| 3813 | char buf[BUFSIZ]; |
| 3814 | struct route_table *stable; |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3815 | struct zebra_vrf *zvrf; |
| 3816 | vrf_iter_t iter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3817 | |
| 3818 | write = 0; |
| 3819 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3820 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 3821 | { |
| 3822 | if ((zvrf = vrf_iter2info (iter)) == NULL || |
| 3823 | (stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL) |
| 3824 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3826 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 3827 | for (si = rn->info; si; si = si->next) |
| 3828 | { |
| 3829 | vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3830 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3831 | switch (si->type) |
| 3832 | { |
| 3833 | case STATIC_IPV6_GATEWAY: |
| 3834 | vty_out (vty, " %s", |
| 3835 | inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ)); |
| 3836 | break; |
| 3837 | case STATIC_IPV6_IFNAME: |
| 3838 | vty_out (vty, " %s", si->ifname); |
| 3839 | break; |
| 3840 | case STATIC_IPV6_GATEWAY_IFNAME: |
| 3841 | vty_out (vty, " %s %s", |
| 3842 | inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), |
| 3843 | si->ifname); |
| 3844 | break; |
| 3845 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3846 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3847 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 3848 | vty_out (vty, " %s", "reject"); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3849 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3850 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 3851 | vty_out (vty, " %s", "blackhole"); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3852 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3853 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 3854 | vty_out (vty, " %d", si->distance); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3855 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3856 | if (si->vrf_id != VRF_DEFAULT) |
| 3857 | vty_out (vty, " vrf %u", si->vrf_id); |
| 3858 | |
| 3859 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3860 | |
| 3861 | write = 1; |
| 3862 | } |
| 3863 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3864 | return write; |
| 3865 | } |
| 3866 | #endif /* HAVE_IPV6 */ |
| 3867 | |
| 3868 | /* Static ip route configuration write function. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 3869 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3870 | zebra_ip_config (struct vty *vty) |
| 3871 | { |
| 3872 | int write = 0; |
| 3873 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 3874 | write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route"); |
| 3875 | write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3876 | #ifdef HAVE_IPV6 |
| 3877 | write += static_config_ipv6 (vty); |
| 3878 | #endif /* HAVE_IPV6 */ |
| 3879 | |
| 3880 | return write; |
| 3881 | } |
| 3882 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 3883 | static int config_write_vty(struct vty *vty) |
| 3884 | { |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 3885 | int i; |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 3886 | enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get (); |
| 3887 | |
| 3888 | if (ipv4_multicast_mode != MCAST_NO_CONFIG) |
| 3889 | vty_out (vty, "ip multicast rpf-lookup-mode %s%s", |
| 3890 | ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" : |
| 3891 | ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" : |
| 3892 | ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" : |
| 3893 | ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" : |
| 3894 | "longer-prefix", |
| 3895 | VTY_NEWLINE); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 3896 | |
| 3897 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 3898 | { |
| 3899 | if (proto_rm[AFI_IP][i]) |
| 3900 | vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i), |
| 3901 | proto_rm[AFI_IP][i], VTY_NEWLINE); |
| 3902 | } |
| 3903 | if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX]) |
| 3904 | vty_out (vty, "ip protocol %s route-map %s%s", "any", |
| 3905 | proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE); |
| 3906 | |
| 3907 | return 1; |
| 3908 | } |
| 3909 | |
| 3910 | /* table node for protocol filtering */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 3911 | static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 3912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3913 | /* IP node for static routes. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 3914 | static struct cmd_node ip_node = { IP_NODE, "", 1 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3915 | |
| 3916 | /* Route VTY. */ |
| 3917 | void |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 3918 | zebra_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3919 | { |
| 3920 | install_node (&ip_node, zebra_ip_config); |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 3921 | install_node (&protocol_node, config_write_vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3922 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 3923 | install_element (CONFIG_NODE, &ip_mroute_cmd); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 3924 | install_element (CONFIG_NODE, &ip_mroute_dist_cmd); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 3925 | install_element (CONFIG_NODE, &no_ip_mroute_cmd); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 3926 | install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd); |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 3927 | install_element (CONFIG_NODE, &ip_multicast_mode_cmd); |
| 3928 | install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd); |
| 3929 | install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 3930 | install_element (CONFIG_NODE, &ip_protocol_cmd); |
| 3931 | install_element (CONFIG_NODE, &no_ip_protocol_cmd); |
| 3932 | install_element (VIEW_NODE, &show_ip_protocol_cmd); |
| 3933 | install_element (ENABLE_NODE, &show_ip_protocol_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3934 | install_element (CONFIG_NODE, &ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3935 | install_element (CONFIG_NODE, &ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3936 | install_element (CONFIG_NODE, &ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3937 | install_element (CONFIG_NODE, &ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3938 | install_element (CONFIG_NODE, &ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3939 | install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3940 | install_element (CONFIG_NODE, &no_ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3941 | install_element (CONFIG_NODE, &no_ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3942 | install_element (CONFIG_NODE, &no_ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3943 | install_element (CONFIG_NODE, &no_ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3944 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3945 | install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3946 | install_element (CONFIG_NODE, &ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3947 | install_element (CONFIG_NODE, &ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3948 | install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3949 | install_element (CONFIG_NODE, &ip_route_mask_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3950 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3951 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3952 | install_element (CONFIG_NODE, &no_ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3953 | install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3954 | install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 3955 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 3956 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3957 | |
| 3958 | install_element (VIEW_NODE, &show_ip_route_cmd); |
| 3959 | install_element (VIEW_NODE, &show_ip_route_addr_cmd); |
| 3960 | install_element (VIEW_NODE, &show_ip_route_prefix_cmd); |
| 3961 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd); |
| 3962 | install_element (VIEW_NODE, &show_ip_route_protocol_cmd); |
| 3963 | install_element (VIEW_NODE, &show_ip_route_supernets_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 3964 | install_element (VIEW_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 3965 | install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3966 | install_element (ENABLE_NODE, &show_ip_route_cmd); |
| 3967 | install_element (ENABLE_NODE, &show_ip_route_addr_cmd); |
| 3968 | install_element (ENABLE_NODE, &show_ip_route_prefix_cmd); |
| 3969 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd); |
| 3970 | install_element (ENABLE_NODE, &show_ip_route_protocol_cmd); |
| 3971 | install_element (ENABLE_NODE, &show_ip_route_supernets_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3972 | install_element (ENABLE_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 3973 | install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3974 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3975 | install_element (VIEW_NODE, &show_ip_mroute_cmd); |
| 3976 | install_element (ENABLE_NODE, &show_ip_mroute_cmd); |
| 3977 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 3978 | install_element (VIEW_NODE, &show_ip_rpf_cmd); |
| 3979 | install_element (ENABLE_NODE, &show_ip_rpf_cmd); |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 3980 | install_element (VIEW_NODE, &show_ip_rpf_addr_cmd); |
| 3981 | install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 3982 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 3983 | /* Commands for VRF */ |
| 3984 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 3985 | install_element (CONFIG_NODE, &ip_mroute_vrf_cmd); |
| 3986 | install_element (CONFIG_NODE, &ip_mroute_dist_vrf_cmd); |
| 3987 | install_element (CONFIG_NODE, &no_ip_mroute_vrf_cmd); |
| 3988 | install_element (CONFIG_NODE, &no_ip_mroute_dist_vrf_cmd); |
| 3989 | |
| 3990 | install_element (CONFIG_NODE, &ip_route_vrf_cmd); |
| 3991 | install_element (CONFIG_NODE, &ip_route_flags_vrf_cmd); |
| 3992 | install_element (CONFIG_NODE, &ip_route_flags2_vrf_cmd); |
| 3993 | install_element (CONFIG_NODE, &ip_route_mask_vrf_cmd); |
| 3994 | install_element (CONFIG_NODE, &ip_route_mask_flags_vrf_cmd); |
| 3995 | install_element (CONFIG_NODE, &ip_route_mask_flags2_vrf_cmd); |
| 3996 | install_element (CONFIG_NODE, &no_ip_route_vrf_cmd); |
| 3997 | install_element (CONFIG_NODE, &no_ip_route_flags_vrf_cmd); |
| 3998 | install_element (CONFIG_NODE, &no_ip_route_flags2_vrf_cmd); |
| 3999 | install_element (CONFIG_NODE, &no_ip_route_mask_vrf_cmd); |
| 4000 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_vrf_cmd); |
| 4001 | install_element (CONFIG_NODE, &no_ip_route_mask_flags2_vrf_cmd); |
| 4002 | install_element (CONFIG_NODE, &ip_route_distance_vrf_cmd); |
| 4003 | install_element (CONFIG_NODE, &ip_route_flags_distance_vrf_cmd); |
| 4004 | install_element (CONFIG_NODE, &ip_route_flags_distance2_vrf_cmd); |
| 4005 | install_element (CONFIG_NODE, &ip_route_mask_distance_vrf_cmd); |
| 4006 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance_vrf_cmd); |
| 4007 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_vrf_cmd); |
| 4008 | install_element (CONFIG_NODE, &no_ip_route_distance_vrf_cmd); |
| 4009 | install_element (CONFIG_NODE, &no_ip_route_flags_distance_vrf_cmd); |
| 4010 | install_element (CONFIG_NODE, &no_ip_route_flags_distance2_vrf_cmd); |
| 4011 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_vrf_cmd); |
| 4012 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_vrf_cmd); |
| 4013 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 4014 | install_element (VIEW_NODE, &show_ip_route_vrf_cmd); |
| 4015 | install_element (VIEW_NODE, &show_ip_route_addr_vrf_cmd); |
| 4016 | install_element (VIEW_NODE, &show_ip_route_prefix_vrf_cmd); |
| 4017 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_cmd); |
| 4018 | install_element (VIEW_NODE, &show_ip_route_protocol_vrf_cmd); |
| 4019 | install_element (VIEW_NODE, &show_ip_route_supernets_vrf_cmd); |
| 4020 | install_element (VIEW_NODE, &show_ip_route_summary_vrf_cmd); |
| 4021 | install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_cmd); |
| 4022 | install_element (ENABLE_NODE, &show_ip_route_vrf_cmd); |
| 4023 | install_element (ENABLE_NODE, &show_ip_route_addr_vrf_cmd); |
| 4024 | install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_cmd); |
| 4025 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_cmd); |
| 4026 | install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_cmd); |
| 4027 | install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_cmd); |
| 4028 | install_element (ENABLE_NODE, &show_ip_route_summary_vrf_cmd); |
| 4029 | install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_cmd); |
| 4030 | |
| 4031 | install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd); |
| 4032 | install_element (VIEW_NODE, &show_ip_route_addr_vrf_all_cmd); |
| 4033 | install_element (VIEW_NODE, &show_ip_route_prefix_vrf_all_cmd); |
| 4034 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_vrf_all_cmd); |
| 4035 | install_element (VIEW_NODE, &show_ip_route_protocol_vrf_all_cmd); |
| 4036 | install_element (VIEW_NODE, &show_ip_route_supernets_vrf_all_cmd); |
| 4037 | install_element (VIEW_NODE, &show_ip_route_summary_vrf_all_cmd); |
| 4038 | install_element (VIEW_NODE, &show_ip_route_summary_prefix_vrf_all_cmd); |
| 4039 | install_element (ENABLE_NODE, &show_ip_route_vrf_all_cmd); |
| 4040 | install_element (ENABLE_NODE, &show_ip_route_addr_vrf_all_cmd); |
| 4041 | install_element (ENABLE_NODE, &show_ip_route_prefix_vrf_all_cmd); |
| 4042 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_vrf_all_cmd); |
| 4043 | install_element (ENABLE_NODE, &show_ip_route_protocol_vrf_all_cmd); |
| 4044 | install_element (ENABLE_NODE, &show_ip_route_supernets_vrf_all_cmd); |
| 4045 | install_element (ENABLE_NODE, &show_ip_route_summary_vrf_all_cmd); |
| 4046 | install_element (ENABLE_NODE, &show_ip_route_summary_prefix_vrf_all_cmd); |
| 4047 | |
| 4048 | install_element (VIEW_NODE, &show_ip_mroute_vrf_cmd); |
| 4049 | install_element (ENABLE_NODE, &show_ip_mroute_vrf_cmd); |
| 4050 | |
| 4051 | install_element (VIEW_NODE, &show_ip_mroute_vrf_all_cmd); |
| 4052 | install_element (ENABLE_NODE, &show_ip_mroute_vrf_all_cmd); |
| 4053 | |
| 4054 | install_element (VIEW_NODE, &show_ip_rpf_vrf_cmd); |
| 4055 | install_element (VIEW_NODE, &show_ip_rpf_vrf_all_cmd); |
| 4056 | install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_cmd); |
| 4057 | install_element (VIEW_NODE, &show_ip_rpf_addr_vrf_all_cmd); |
| 4058 | install_element (ENABLE_NODE, &show_ip_rpf_vrf_cmd); |
| 4059 | install_element (ENABLE_NODE, &show_ip_rpf_vrf_all_cmd); |
| 4060 | install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_cmd); |
| 4061 | install_element (ENABLE_NODE, &show_ip_rpf_addr_vrf_all_cmd); |
| 4062 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4063 | #ifdef HAVE_IPV6 |
| 4064 | install_element (CONFIG_NODE, &ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4065 | install_element (CONFIG_NODE, &ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4066 | install_element (CONFIG_NODE, &ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4067 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4068 | install_element (CONFIG_NODE, &no_ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4069 | install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4070 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4071 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4072 | install_element (CONFIG_NODE, &ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4073 | install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4074 | install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4075 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4076 | install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4077 | install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4078 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 4079 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4080 | install_element (VIEW_NODE, &show_ipv6_route_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 4081 | install_element (VIEW_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 4082 | install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4083 | install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd); |
| 4084 | install_element (VIEW_NODE, &show_ipv6_route_addr_cmd); |
| 4085 | install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd); |
| 4086 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd); |
| 4087 | install_element (ENABLE_NODE, &show_ipv6_route_cmd); |
| 4088 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd); |
| 4089 | install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd); |
| 4090 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd); |
| 4091 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 4092 | install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 4093 | install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 4094 | |
| 4095 | install_element (VIEW_NODE, &show_ipv6_mroute_cmd); |
| 4096 | install_element (ENABLE_NODE, &show_ipv6_mroute_cmd); |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 4097 | |
| 4098 | /* Commands for VRF */ |
| 4099 | |
Feng Lu | 7aaf4ea | 2015-05-22 11:40:06 +0200 | [diff] [blame] | 4100 | install_element (CONFIG_NODE, &ipv6_route_vrf_cmd); |
| 4101 | install_element (CONFIG_NODE, &ipv6_route_flags_vrf_cmd); |
| 4102 | install_element (CONFIG_NODE, &ipv6_route_ifname_vrf_cmd); |
| 4103 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_vrf_cmd); |
| 4104 | install_element (CONFIG_NODE, &no_ipv6_route_vrf_cmd); |
| 4105 | install_element (CONFIG_NODE, &no_ipv6_route_flags_vrf_cmd); |
| 4106 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_vrf_cmd); |
| 4107 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_vrf_cmd); |
| 4108 | install_element (CONFIG_NODE, &ipv6_route_pref_vrf_cmd); |
| 4109 | install_element (CONFIG_NODE, &ipv6_route_flags_pref_vrf_cmd); |
| 4110 | install_element (CONFIG_NODE, &ipv6_route_ifname_pref_vrf_cmd); |
| 4111 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_vrf_cmd); |
| 4112 | install_element (CONFIG_NODE, &no_ipv6_route_pref_vrf_cmd); |
| 4113 | install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_vrf_cmd); |
| 4114 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_vrf_cmd); |
| 4115 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_vrf_cmd); |
| 4116 | |
Feng Lu | 4364ee5 | 2015-05-22 11:40:03 +0200 | [diff] [blame] | 4117 | install_element (VIEW_NODE, &show_ipv6_route_vrf_cmd); |
| 4118 | install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_cmd); |
| 4119 | install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_cmd); |
| 4120 | install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_cmd); |
| 4121 | install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_cmd); |
| 4122 | install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_cmd); |
| 4123 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_cmd); |
| 4124 | install_element (ENABLE_NODE, &show_ipv6_route_vrf_cmd); |
| 4125 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_cmd); |
| 4126 | install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_cmd); |
| 4127 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_cmd); |
| 4128 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_cmd); |
| 4129 | install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_cmd); |
| 4130 | install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_cmd); |
| 4131 | |
| 4132 | install_element (VIEW_NODE, &show_ipv6_route_vrf_all_cmd); |
| 4133 | install_element (VIEW_NODE, &show_ipv6_route_summary_vrf_all_cmd); |
| 4134 | install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd); |
| 4135 | install_element (VIEW_NODE, &show_ipv6_route_protocol_vrf_all_cmd); |
| 4136 | install_element (VIEW_NODE, &show_ipv6_route_addr_vrf_all_cmd); |
| 4137 | install_element (VIEW_NODE, &show_ipv6_route_prefix_vrf_all_cmd); |
| 4138 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd); |
| 4139 | install_element (ENABLE_NODE, &show_ipv6_route_vrf_all_cmd); |
| 4140 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_vrf_all_cmd); |
| 4141 | install_element (ENABLE_NODE, &show_ipv6_route_addr_vrf_all_cmd); |
| 4142 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_vrf_all_cmd); |
| 4143 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_vrf_all_cmd); |
| 4144 | install_element (ENABLE_NODE, &show_ipv6_route_summary_vrf_all_cmd); |
| 4145 | install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_vrf_all_cmd); |
| 4146 | |
| 4147 | install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd); |
| 4148 | install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_cmd); |
| 4149 | |
| 4150 | install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd); |
| 4151 | install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4152 | #endif /* HAVE_IPV6 */ |
| 4153 | } |