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