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" |
| 30 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 31 | #include "zebra/zserv.h" |
| 32 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 33 | static int do_show_ip_route(struct vty *vty, safi_t safi); |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 34 | static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, |
| 35 | int mcast); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 36 | |
| 37 | /* General function for static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 38 | static int |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 39 | zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, |
| 40 | const char *dest_str, const char *mask_str, |
| 41 | const char *gate_str, const char *flag_str, |
| 42 | const char *distance_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 43 | { |
| 44 | int ret; |
| 45 | u_char distance; |
| 46 | struct prefix p; |
| 47 | struct in_addr gate; |
| 48 | struct in_addr mask; |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 49 | const char *ifname; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 50 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | |
| 52 | ret = str2prefix (dest_str, &p); |
| 53 | if (ret <= 0) |
| 54 | { |
| 55 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 56 | return CMD_WARNING; |
| 57 | } |
| 58 | |
| 59 | /* Cisco like mask notation. */ |
| 60 | if (mask_str) |
| 61 | { |
| 62 | ret = inet_aton (mask_str, &mask); |
| 63 | if (ret == 0) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 64 | { |
| 65 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 66 | return CMD_WARNING; |
| 67 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | p.prefixlen = ip_masklen (mask); |
| 69 | } |
| 70 | |
| 71 | /* Apply mask for given prefix. */ |
| 72 | apply_mask (&p); |
| 73 | |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 74 | /* Administrative distance. */ |
| 75 | if (distance_str) |
| 76 | distance = atoi (distance_str); |
| 77 | else |
| 78 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 79 | |
| 80 | /* Null0 static route. */ |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 81 | if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0)) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 82 | { |
| 83 | if (flag_str) |
| 84 | { |
| 85 | vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE); |
| 86 | return CMD_WARNING; |
| 87 | } |
| 88 | if (add_cmd) |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 89 | static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 90 | else |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 91 | static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 92 | return CMD_SUCCESS; |
| 93 | } |
| 94 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 95 | /* Route flags */ |
| 96 | if (flag_str) { |
| 97 | switch(flag_str[0]) { |
| 98 | case 'r': |
| 99 | case 'R': /* XXX */ |
| 100 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 101 | break; |
| 102 | case 'b': |
| 103 | case 'B': /* XXX */ |
| 104 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 105 | break; |
| 106 | default: |
| 107 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 108 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 109 | } |
| 110 | } |
| 111 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 112 | if (gate_str == NULL) |
| 113 | { |
| 114 | if (add_cmd) |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 115 | static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, 0); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 116 | else |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 117 | static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 118 | |
| 119 | return CMD_SUCCESS; |
| 120 | } |
| 121 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | /* When gateway is A.B.C.D format, gate is treated as nexthop |
| 123 | address other case gate is treated as interface name. */ |
| 124 | ret = inet_aton (gate_str, &gate); |
| 125 | if (ret) |
| 126 | ifname = NULL; |
| 127 | else |
| 128 | ifname = gate_str; |
| 129 | |
| 130 | if (add_cmd) |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 131 | static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | else |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 133 | static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | |
| 135 | return CMD_SUCCESS; |
| 136 | } |
| 137 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 138 | static int |
| 139 | zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str, |
| 140 | const char *mask_str, const char *gate_str, |
| 141 | const char *flag_str, const char *distance_str) |
| 142 | { |
| 143 | return zebra_static_ipv4_safi(vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, gate_str, flag_str, distance_str); |
| 144 | } |
| 145 | |
| 146 | /* Static unicast routes for multicast RPF lookup. */ |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 147 | DEFUN (ip_mroute_dist, |
| 148 | ip_mroute_dist_cmd, |
| 149 | "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] | 150 | IP_STR |
| 151 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 152 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 153 | "Nexthop address\n" |
| 154 | "Nexthop interface name\n" |
| 155 | "Distance\n") |
| 156 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 157 | VTY_WARN_EXPERIMENTAL(); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 158 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], |
| 159 | NULL, argc > 2 ? argv[2] : NULL); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 160 | } |
| 161 | |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 162 | ALIAS (ip_mroute_dist, |
| 163 | ip_mroute_cmd, |
| 164 | "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 165 | IP_STR |
| 166 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 167 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 168 | "Nexthop address\n" |
| 169 | "Nexthop interface name\n") |
| 170 | |
| 171 | DEFUN (no_ip_mroute_dist, |
| 172 | no_ip_mroute_dist_cmd, |
| 173 | "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] | 174 | IP_STR |
| 175 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 176 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 177 | "Nexthop address\n" |
| 178 | "Nexthop interface name\n" |
| 179 | "Distance\n") |
| 180 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 181 | VTY_WARN_EXPERIMENTAL(); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 182 | return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], |
| 183 | NULL, argc > 2 ? argv[2] : NULL); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 184 | } |
| 185 | |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 186 | ALIAS (no_ip_mroute_dist, |
| 187 | no_ip_mroute_cmd, |
| 188 | "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 189 | NO_STR |
| 190 | IP_STR |
| 191 | "Configure static unicast route into MRIB for multicast RPF lookup\n" |
| 192 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 193 | "Nexthop address\n" |
| 194 | "Nexthop interface name\n") |
| 195 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 196 | DEFUN (ip_multicast_mode, |
| 197 | ip_multicast_mode_cmd, |
| 198 | "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", |
| 199 | IP_STR |
| 200 | "Multicast options\n" |
| 201 | "RPF lookup behavior\n" |
| 202 | "Lookup in unicast RIB only\n" |
| 203 | "Lookup in multicast RIB only\n" |
| 204 | "Try multicast RIB first, fall back to unicast RIB\n" |
| 205 | "Lookup both, use entry with lower distance\n" |
| 206 | "Lookup both, use entry with longer prefix\n") |
| 207 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 208 | VTY_WARN_EXPERIMENTAL(); |
| 209 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 210 | if (!strncmp (argv[0], "u", 1)) |
| 211 | multicast_mode_ipv4_set (MCAST_URIB_ONLY); |
| 212 | else if (!strncmp (argv[0], "mrib-o", 6)) |
| 213 | multicast_mode_ipv4_set (MCAST_MRIB_ONLY); |
| 214 | else if (!strncmp (argv[0], "mrib-t", 6)) |
| 215 | multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST); |
| 216 | else if (!strncmp (argv[0], "low", 3)) |
| 217 | multicast_mode_ipv4_set (MCAST_MIX_DISTANCE); |
| 218 | else if (!strncmp (argv[0], "lon", 3)) |
| 219 | multicast_mode_ipv4_set (MCAST_MIX_PFXLEN); |
| 220 | else |
| 221 | { |
| 222 | vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE); |
| 223 | return CMD_WARNING; |
| 224 | } |
| 225 | |
| 226 | return CMD_SUCCESS; |
| 227 | } |
| 228 | |
| 229 | DEFUN (no_ip_multicast_mode, |
| 230 | no_ip_multicast_mode_cmd, |
| 231 | "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)", |
| 232 | NO_STR |
| 233 | IP_STR |
| 234 | "Multicast options\n" |
| 235 | "RPF lookup behavior\n" |
| 236 | "Lookup in unicast RIB only\n" |
| 237 | "Lookup in multicast RIB only\n" |
| 238 | "Try multicast RIB first, fall back to unicast RIB\n" |
| 239 | "Lookup both, use entry with lower distance\n" |
| 240 | "Lookup both, use entry with longer prefix\n") |
| 241 | { |
| 242 | multicast_mode_ipv4_set (MCAST_NO_CONFIG); |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
| 246 | ALIAS (no_ip_multicast_mode, |
| 247 | no_ip_multicast_mode_noarg_cmd, |
| 248 | "no ip multicast rpf-lookup-mode", |
| 249 | NO_STR |
| 250 | IP_STR |
| 251 | "Multicast options\n" |
| 252 | "RPF lookup behavior\n") |
| 253 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 254 | DEFUN (show_ip_rpf, |
| 255 | show_ip_rpf_cmd, |
| 256 | "show ip rpf", |
| 257 | SHOW_STR |
| 258 | IP_STR |
| 259 | "Display RPF information for multicast source\n") |
| 260 | { |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 261 | VTY_WARN_EXPERIMENTAL(); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 262 | return do_show_ip_route(vty, SAFI_MULTICAST); |
| 263 | } |
| 264 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 265 | DEFUN (show_ip_rpf_addr, |
| 266 | show_ip_rpf_addr_cmd, |
| 267 | "show ip rpf A.B.C.D", |
| 268 | SHOW_STR |
| 269 | IP_STR |
| 270 | "Display RPF information for multicast source\n" |
| 271 | "IP multicast source address (e.g. 10.0.0.0)\n") |
| 272 | { |
| 273 | struct in_addr addr; |
| 274 | struct route_node *rn; |
| 275 | struct rib *rib; |
| 276 | int ret; |
| 277 | |
David Lamparter | 863f20c | 2015-01-27 20:24:15 +0100 | [diff] [blame] | 278 | VTY_WARN_EXPERIMENTAL(); |
| 279 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 280 | ret = inet_aton (argv[0], &addr); |
| 281 | if (ret == 0) |
| 282 | { |
| 283 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 284 | return CMD_WARNING; |
| 285 | } |
| 286 | |
| 287 | rib = rib_match_ipv4_multicast (addr, &rn); |
| 288 | |
| 289 | if (rib) |
| 290 | vty_show_ip_route_detail (vty, rn, 1); |
| 291 | else |
| 292 | vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE); |
| 293 | |
| 294 | return CMD_SUCCESS; |
| 295 | } |
| 296 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 297 | /* Static route configuration. */ |
| 298 | DEFUN (ip_route, |
| 299 | ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 300 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 301 | IP_STR |
| 302 | "Establish static routes\n" |
| 303 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 304 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 305 | "IP gateway interface name\n" |
| 306 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 307 | { |
| 308 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL); |
| 309 | } |
| 310 | |
| 311 | DEFUN (ip_route_flags, |
| 312 | ip_route_flags_cmd, |
| 313 | "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] | 314 | IP_STR |
| 315 | "Establish static routes\n" |
| 316 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 317 | "IP gateway address\n" |
| 318 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 319 | "Emit an ICMP unreachable when matched\n" |
| 320 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 321 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 322 | 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] | 323 | } |
| 324 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 325 | DEFUN (ip_route_flags2, |
| 326 | ip_route_flags2_cmd, |
| 327 | "ip route A.B.C.D/M (reject|blackhole)", |
| 328 | IP_STR |
| 329 | "Establish static routes\n" |
| 330 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 331 | "Emit an ICMP unreachable when matched\n" |
| 332 | "Silently discard pkts when matched\n") |
| 333 | { |
| 334 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL); |
| 335 | } |
| 336 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 337 | /* Mask as A.B.C.D format. */ |
| 338 | DEFUN (ip_route_mask, |
| 339 | ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 340 | "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] | 341 | IP_STR |
| 342 | "Establish static routes\n" |
| 343 | "IP destination prefix\n" |
| 344 | "IP destination prefix mask\n" |
| 345 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 346 | "IP gateway interface name\n" |
| 347 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 348 | { |
| 349 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 350 | } |
| 351 | |
| 352 | DEFUN (ip_route_mask_flags, |
| 353 | ip_route_mask_flags_cmd, |
| 354 | "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] | 355 | IP_STR |
| 356 | "Establish static routes\n" |
| 357 | "IP destination prefix\n" |
| 358 | "IP destination prefix mask\n" |
| 359 | "IP gateway address\n" |
| 360 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 361 | "Emit an ICMP unreachable when matched\n" |
| 362 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 363 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 364 | 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] | 365 | } |
| 366 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 367 | DEFUN (ip_route_mask_flags2, |
| 368 | ip_route_mask_flags2_cmd, |
| 369 | "ip route A.B.C.D A.B.C.D (reject|blackhole)", |
| 370 | IP_STR |
| 371 | "Establish static routes\n" |
| 372 | "IP destination prefix\n" |
| 373 | "IP destination prefix mask\n" |
| 374 | "Emit an ICMP unreachable when matched\n" |
| 375 | "Silently discard pkts when matched\n") |
| 376 | { |
| 377 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL); |
| 378 | } |
| 379 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 380 | /* Distance option value. */ |
| 381 | DEFUN (ip_route_distance, |
| 382 | ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 383 | "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] | 384 | IP_STR |
| 385 | "Establish static routes\n" |
| 386 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 387 | "IP gateway address\n" |
| 388 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 389 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | "Distance value for this route\n") |
| 391 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 392 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]); |
| 393 | } |
| 394 | |
| 395 | DEFUN (ip_route_flags_distance, |
| 396 | ip_route_flags_distance_cmd, |
| 397 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 398 | IP_STR |
| 399 | "Establish static routes\n" |
| 400 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 401 | "IP gateway address\n" |
| 402 | "IP gateway interface name\n" |
| 403 | "Emit an ICMP unreachable when matched\n" |
| 404 | "Silently discard pkts when matched\n" |
| 405 | "Distance value for this route\n") |
| 406 | { |
| 407 | 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] | 408 | } |
| 409 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 410 | DEFUN (ip_route_flags_distance2, |
| 411 | ip_route_flags_distance2_cmd, |
| 412 | "ip route A.B.C.D/M (reject|blackhole) <1-255>", |
| 413 | IP_STR |
| 414 | "Establish static routes\n" |
| 415 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 416 | "Emit an ICMP unreachable when matched\n" |
| 417 | "Silently discard pkts when matched\n" |
| 418 | "Distance value for this route\n") |
| 419 | { |
| 420 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]); |
| 421 | } |
| 422 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 423 | DEFUN (ip_route_mask_distance, |
| 424 | ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 425 | "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] | 426 | IP_STR |
| 427 | "Establish static routes\n" |
| 428 | "IP destination prefix\n" |
| 429 | "IP destination prefix mask\n" |
| 430 | "IP gateway address\n" |
| 431 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 432 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 433 | "Distance value for this route\n") |
| 434 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 435 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 436 | } |
| 437 | |
| 438 | DEFUN (ip_route_mask_flags_distance, |
| 439 | ip_route_mask_flags_distance_cmd, |
| 440 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 441 | IP_STR |
| 442 | "Establish static routes\n" |
| 443 | "IP destination prefix\n" |
| 444 | "IP destination prefix mask\n" |
| 445 | "IP gateway address\n" |
| 446 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 447 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 448 | "Silently discard pkts when matched\n" |
| 449 | "Distance value for this route\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 450 | { |
| 451 | 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] | 452 | } |
| 453 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 454 | DEFUN (ip_route_mask_flags_distance2, |
| 455 | ip_route_mask_flags_distance2_cmd, |
| 456 | "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", |
| 457 | IP_STR |
| 458 | "Establish static routes\n" |
| 459 | "IP destination prefix\n" |
| 460 | "IP destination prefix mask\n" |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 461 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 462 | "Silently discard pkts when matched\n" |
| 463 | "Distance value for this route\n") |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 464 | { |
| 465 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]); |
| 466 | } |
| 467 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 468 | DEFUN (no_ip_route, |
| 469 | no_ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 470 | "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] | 471 | NO_STR |
| 472 | IP_STR |
| 473 | "Establish static routes\n" |
| 474 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 475 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 476 | "IP gateway interface name\n" |
| 477 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 478 | { |
| 479 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL); |
| 480 | } |
| 481 | |
| 482 | ALIAS (no_ip_route, |
| 483 | no_ip_route_flags_cmd, |
| 484 | "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] | 485 | NO_STR |
| 486 | IP_STR |
| 487 | "Establish static routes\n" |
| 488 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 489 | "IP gateway address\n" |
| 490 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 491 | "Emit an ICMP unreachable when matched\n" |
| 492 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 494 | DEFUN (no_ip_route_flags2, |
| 495 | no_ip_route_flags2_cmd, |
| 496 | "no ip route A.B.C.D/M (reject|blackhole)", |
| 497 | NO_STR |
| 498 | IP_STR |
| 499 | "Establish static routes\n" |
| 500 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 501 | "Emit an ICMP unreachable when matched\n" |
| 502 | "Silently discard pkts when matched\n") |
| 503 | { |
| 504 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL); |
| 505 | } |
| 506 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 507 | DEFUN (no_ip_route_mask, |
| 508 | no_ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 509 | "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] | 510 | NO_STR |
| 511 | IP_STR |
| 512 | "Establish static routes\n" |
| 513 | "IP destination prefix\n" |
| 514 | "IP destination prefix mask\n" |
| 515 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 516 | "IP gateway interface name\n" |
| 517 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 518 | { |
| 519 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL); |
| 520 | } |
| 521 | |
| 522 | ALIAS (no_ip_route_mask, |
| 523 | no_ip_route_mask_flags_cmd, |
| 524 | "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] | 525 | NO_STR |
| 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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 532 | "Emit an ICMP unreachable when matched\n" |
| 533 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 535 | DEFUN (no_ip_route_mask_flags2, |
| 536 | no_ip_route_mask_flags2_cmd, |
| 537 | "no ip route A.B.C.D A.B.C.D (reject|blackhole)", |
| 538 | NO_STR |
| 539 | IP_STR |
| 540 | "Establish static routes\n" |
| 541 | "IP destination prefix\n" |
| 542 | "IP destination prefix mask\n" |
| 543 | "Emit an ICMP unreachable when matched\n" |
| 544 | "Silently discard pkts when matched\n") |
| 545 | { |
| 546 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL); |
| 547 | } |
| 548 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | DEFUN (no_ip_route_distance, |
| 550 | no_ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 551 | "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] | 552 | NO_STR |
| 553 | IP_STR |
| 554 | "Establish static routes\n" |
| 555 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 556 | "IP gateway address\n" |
| 557 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 558 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | "Distance value for this route\n") |
| 560 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 561 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]); |
| 562 | } |
| 563 | |
| 564 | DEFUN (no_ip_route_flags_distance, |
| 565 | no_ip_route_flags_distance_cmd, |
| 566 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 567 | NO_STR |
| 568 | IP_STR |
| 569 | "Establish static routes\n" |
| 570 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 571 | "IP gateway address\n" |
| 572 | "IP gateway interface name\n" |
| 573 | "Emit an ICMP unreachable when matched\n" |
| 574 | "Silently discard pkts when matched\n" |
| 575 | "Distance value for this route\n") |
| 576 | { |
| 577 | 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] | 578 | } |
| 579 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 580 | DEFUN (no_ip_route_flags_distance2, |
| 581 | no_ip_route_flags_distance2_cmd, |
| 582 | "no ip route A.B.C.D/M (reject|blackhole) <1-255>", |
| 583 | NO_STR |
| 584 | IP_STR |
| 585 | "Establish static routes\n" |
| 586 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 587 | "Emit an ICMP unreachable when matched\n" |
| 588 | "Silently discard pkts when matched\n" |
| 589 | "Distance value for this route\n") |
| 590 | { |
| 591 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]); |
| 592 | } |
| 593 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | DEFUN (no_ip_route_mask_distance, |
| 595 | no_ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 596 | "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] | 597 | NO_STR |
| 598 | IP_STR |
| 599 | "Establish static routes\n" |
| 600 | "IP destination prefix\n" |
| 601 | "IP destination prefix mask\n" |
| 602 | "IP gateway address\n" |
| 603 | "IP gateway interface name\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 604 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 605 | "Distance value for this route\n") |
| 606 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 607 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 608 | } |
| 609 | |
| 610 | DEFUN (no_ip_route_mask_flags_distance, |
| 611 | no_ip_route_mask_flags_distance_cmd, |
| 612 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 613 | NO_STR |
| 614 | IP_STR |
| 615 | "Establish static routes\n" |
| 616 | "IP destination prefix\n" |
| 617 | "IP destination prefix mask\n" |
| 618 | "IP gateway address\n" |
| 619 | "IP gateway interface name\n" |
| 620 | "Emit an ICMP unreachable when matched\n" |
| 621 | "Silently discard pkts when matched\n" |
| 622 | "Distance value for this route\n") |
| 623 | { |
| 624 | 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] | 625 | } |
| 626 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 627 | DEFUN (no_ip_route_mask_flags_distance2, |
| 628 | no_ip_route_mask_flags_distance2_cmd, |
| 629 | "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>", |
| 630 | NO_STR |
| 631 | IP_STR |
| 632 | "Establish static routes\n" |
| 633 | "IP destination prefix\n" |
| 634 | "IP destination prefix mask\n" |
| 635 | "Emit an ICMP unreachable when matched\n" |
| 636 | "Silently discard pkts when matched\n" |
| 637 | "Distance value for this route\n") |
| 638 | { |
| 639 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]); |
| 640 | } |
| 641 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 642 | char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */ |
| 643 | |
| 644 | DEFUN (ip_protocol, |
| 645 | ip_protocol_cmd, |
| 646 | "ip protocol PROTO route-map ROUTE-MAP", |
| 647 | NO_STR |
| 648 | "Apply route map to PROTO\n" |
| 649 | "Protocol name\n" |
| 650 | "Route map name\n") |
| 651 | { |
| 652 | int i; |
| 653 | |
| 654 | if (strcasecmp(argv[0], "any") == 0) |
| 655 | i = ZEBRA_ROUTE_MAX; |
| 656 | else |
| 657 | i = proto_name2num(argv[0]); |
| 658 | if (i < 0) |
| 659 | { |
| 660 | vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", |
| 661 | VTY_NEWLINE); |
| 662 | return CMD_WARNING; |
| 663 | } |
| 664 | if (proto_rm[AFI_IP][i]) |
| 665 | XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); |
| 666 | proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]); |
| 667 | return CMD_SUCCESS; |
| 668 | } |
| 669 | |
| 670 | DEFUN (no_ip_protocol, |
| 671 | no_ip_protocol_cmd, |
| 672 | "no ip protocol PROTO", |
| 673 | NO_STR |
| 674 | "Remove route map from PROTO\n" |
| 675 | "Protocol name\n") |
| 676 | { |
| 677 | int i; |
| 678 | |
| 679 | if (strcasecmp(argv[0], "any") == 0) |
| 680 | i = ZEBRA_ROUTE_MAX; |
| 681 | else |
| 682 | i = proto_name2num(argv[0]); |
| 683 | if (i < 0) |
| 684 | { |
| 685 | vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "", |
| 686 | VTY_NEWLINE); |
| 687 | return CMD_WARNING; |
| 688 | } |
| 689 | if (proto_rm[AFI_IP][i]) |
| 690 | XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]); |
| 691 | proto_rm[AFI_IP][i] = NULL; |
| 692 | return CMD_SUCCESS; |
| 693 | } |
| 694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | /* New RIB. Detailed information for IPv4 route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 696 | static void |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 697 | 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] | 698 | { |
| 699 | struct rib *rib; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 700 | struct nexthop *nexthop, *tnexthop; |
| 701 | int recursing; |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 702 | char buf[PREFIX_STRLEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 704 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | { |
David Lamparter | b7cce95 | 2015-03-07 08:40:48 +0100 | [diff] [blame] | 706 | const char *mcast_info = ""; |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 707 | if (mcast) |
| 708 | { |
| 709 | rib_table_info_t *info = rn->table->info; |
| 710 | mcast_info = (info->safi == SAFI_MULTICAST) |
| 711 | ? " using Multicast RIB" |
| 712 | : " using Unicast RIB"; |
| 713 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 714 | vty_out (vty, "Routing entry for %s%s%s", |
| 715 | prefix2str (&rn->p, buf, sizeof(buf)), mcast_info, |
| 716 | VTY_NEWLINE); |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 717 | vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type)); |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 718 | vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 719 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 720 | vty_out (vty, ", best"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | if (rib->refcnt) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 722 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 723 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 724 | vty_out (vty, ", blackhole"); |
| 725 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 726 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 727 | vty_out (vty, "%s", VTY_NEWLINE); |
| 728 | |
| 729 | #define ONE_DAY_SECOND 60*60*24 |
| 730 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 731 | if (rib->type == ZEBRA_ROUTE_RIP |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 732 | || rib->type == ZEBRA_ROUTE_RIPNG |
| 733 | || rib->type == ZEBRA_ROUTE_OSPF |
| 734 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 735 | || rib->type == ZEBRA_ROUTE_BABEL |
| 736 | || rib->type == ZEBRA_ROUTE_ISIS |
| 737 | || rib->type == ZEBRA_ROUTE_BGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 738 | { |
| 739 | time_t uptime; |
| 740 | struct tm *tm; |
| 741 | |
| 742 | uptime = time (NULL); |
| 743 | uptime -= rib->uptime; |
| 744 | tm = gmtime (&uptime); |
| 745 | |
| 746 | vty_out (vty, " Last update "); |
| 747 | |
| 748 | if (uptime < ONE_DAY_SECOND) |
| 749 | vty_out (vty, "%02d:%02d:%02d", |
| 750 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 751 | else if (uptime < ONE_WEEK_SECOND) |
| 752 | vty_out (vty, "%dd%02dh%02dm", |
| 753 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 754 | else |
| 755 | vty_out (vty, "%02dw%dd%02dh", |
| 756 | tm->tm_yday/7, |
| 757 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 758 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 759 | } |
| 760 | |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 761 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 762 | { |
| 763 | vty_out (vty, " %c%s", |
| 764 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', |
| 765 | recursing ? " " : ""); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 766 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 767 | switch (nexthop->type) |
| 768 | { |
| 769 | case NEXTHOP_TYPE_IPV4: |
| 770 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 771 | vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4)); |
| 772 | if (nexthop->ifindex) |
| 773 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 774 | break; |
| 775 | case NEXTHOP_TYPE_IPV6: |
| 776 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 777 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 778 | vty_out (vty, " %s", |
| 779 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, sizeof(buf))); |
| 780 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 781 | vty_out (vty, ", %s", nexthop->ifname); |
| 782 | else if (nexthop->ifindex) |
| 783 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 784 | break; |
| 785 | case NEXTHOP_TYPE_IFINDEX: |
| 786 | vty_out (vty, " directly connected, %s", |
| 787 | ifindex2ifname (nexthop->ifindex)); |
| 788 | break; |
| 789 | case NEXTHOP_TYPE_IFNAME: |
| 790 | vty_out (vty, " directly connected, %s", nexthop->ifname); |
| 791 | break; |
| 792 | case NEXTHOP_TYPE_BLACKHOLE: |
| 793 | vty_out (vty, " directly connected, Null0"); |
| 794 | break; |
| 795 | default: |
| 796 | break; |
| 797 | } |
| 798 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 799 | vty_out (vty, " inactive"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 800 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 801 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
| 802 | vty_out (vty, " onlink"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 804 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 805 | vty_out (vty, " (recursive)"); |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 806 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 807 | switch (nexthop->type) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 808 | { |
| 809 | case NEXTHOP_TYPE_IPV4: |
| 810 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 811 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 812 | if (nexthop->src.ipv4.s_addr) |
| 813 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 814 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf)) |
| 815 | vty_out (vty, ", src %s", buf); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 816 | } |
| 817 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 818 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 819 | case NEXTHOP_TYPE_IPV6: |
| 820 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 821 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 822 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 823 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 824 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf)) |
| 825 | vty_out (vty, ", src %s", buf); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 826 | } |
| 827 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 828 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 829 | default: |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 830 | break; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 831 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 832 | vty_out (vty, "%s", VTY_NEWLINE); |
| 833 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 834 | vty_out (vty, "%s", VTY_NEWLINE); |
| 835 | } |
| 836 | } |
| 837 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 838 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib) |
| 840 | { |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 841 | struct nexthop *nexthop, *tnexthop; |
| 842 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 843 | int len = 0; |
| 844 | char buf[BUFSIZ]; |
| 845 | |
| 846 | /* Nexthop information. */ |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 847 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | { |
| 849 | if (nexthop == rib->nexthop) |
| 850 | { |
| 851 | /* Prefix information. */ |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 852 | len = vty_out (vty, "%c%c%c %s", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 853 | zebra_route_char (rib->type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 855 | ? '>' : ' ', |
| 856 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 857 | ? '*' : ' ', |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 858 | prefix2str (&rn->p, buf, sizeof buf)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | |
| 860 | /* Distance and metric display. */ |
| 861 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 862 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 863 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 864 | rib->metric); |
| 865 | } |
| 866 | else |
| 867 | vty_out (vty, " %c%*c", |
| 868 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 869 | ? '*' : ' ', |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 870 | len - 3 + (2 * recursing), ' '); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 871 | |
| 872 | switch (nexthop->type) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 873 | { |
| 874 | case NEXTHOP_TYPE_IPV4: |
| 875 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 876 | vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4)); |
| 877 | if (nexthop->ifindex) |
| 878 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 879 | break; |
| 880 | case NEXTHOP_TYPE_IPV6: |
| 881 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 882 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 883 | vty_out (vty, " via %s", |
| 884 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 885 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 886 | vty_out (vty, ", %s", nexthop->ifname); |
| 887 | else if (nexthop->ifindex) |
| 888 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 889 | break; |
| 890 | case NEXTHOP_TYPE_IFINDEX: |
| 891 | vty_out (vty, " is directly connected, %s", |
| 892 | ifindex2ifname (nexthop->ifindex)); |
| 893 | break; |
| 894 | case NEXTHOP_TYPE_IFNAME: |
| 895 | vty_out (vty, " is directly connected, %s", nexthop->ifname); |
| 896 | break; |
| 897 | case NEXTHOP_TYPE_BLACKHOLE: |
| 898 | vty_out (vty, " is directly connected, Null0"); |
| 899 | break; |
| 900 | default: |
| 901 | break; |
| 902 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 904 | vty_out (vty, " inactive"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 906 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 907 | vty_out (vty, " onlink"); |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 908 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 910 | vty_out (vty, " (recursive)"); |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 911 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 912 | switch (nexthop->type) |
| 913 | { |
| 914 | case NEXTHOP_TYPE_IPV4: |
| 915 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 916 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 917 | if (nexthop->src.ipv4.s_addr) |
| 918 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 919 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf)) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 920 | vty_out (vty, ", src %s", buf); |
| 921 | } |
| 922 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 923 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 924 | case NEXTHOP_TYPE_IPV6: |
| 925 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 926 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 927 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 928 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 929 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf)) |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 930 | vty_out (vty, ", src %s", buf); |
| 931 | } |
| 932 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 933 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 934 | default: |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 935 | break; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 936 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 937 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 938 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 939 | vty_out (vty, ", bh"); |
| 940 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 941 | vty_out (vty, ", rej"); |
| 942 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 943 | if (rib->type == ZEBRA_ROUTE_RIP |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 944 | || rib->type == ZEBRA_ROUTE_RIPNG |
| 945 | || rib->type == ZEBRA_ROUTE_OSPF |
| 946 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 947 | || rib->type == ZEBRA_ROUTE_BABEL |
| 948 | || rib->type == ZEBRA_ROUTE_ISIS |
| 949 | || rib->type == ZEBRA_ROUTE_BGP) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 950 | { |
| 951 | time_t uptime; |
| 952 | struct tm *tm; |
| 953 | |
| 954 | uptime = time (NULL); |
| 955 | uptime -= rib->uptime; |
| 956 | tm = gmtime (&uptime); |
| 957 | |
| 958 | #define ONE_DAY_SECOND 60*60*24 |
| 959 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 960 | |
| 961 | if (uptime < ONE_DAY_SECOND) |
| 962 | vty_out (vty, ", %02d:%02d:%02d", |
| 963 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 964 | else if (uptime < ONE_WEEK_SECOND) |
| 965 | vty_out (vty, ", %dd%02dh%02dm", |
| 966 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 967 | else |
| 968 | vty_out (vty, ", %02dw%dd%02dh", |
| 969 | tm->tm_yday/7, |
| 970 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 971 | } |
| 972 | vty_out (vty, "%s", VTY_NEWLINE); |
| 973 | } |
| 974 | } |
| 975 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 976 | DEFUN (show_ip_route, |
| 977 | show_ip_route_cmd, |
| 978 | "show ip route", |
| 979 | SHOW_STR |
| 980 | IP_STR |
| 981 | "IP routing table\n") |
| 982 | { |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 983 | return do_show_ip_route(vty, SAFI_UNICAST); |
| 984 | } |
| 985 | |
| 986 | static int do_show_ip_route(struct vty *vty, safi_t safi) { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | struct route_table *table; |
| 988 | struct route_node *rn; |
| 989 | struct rib *rib; |
| 990 | int first = 1; |
| 991 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 992 | table = vrf_table (AFI_IP, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | if (! table) |
| 994 | return CMD_SUCCESS; |
| 995 | |
| 996 | /* Show all IPv4 routes. */ |
| 997 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 998 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 999 | { |
| 1000 | if (first) |
| 1001 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1002 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1003 | first = 0; |
| 1004 | } |
| 1005 | vty_show_ip_route (vty, rn, rib); |
| 1006 | } |
| 1007 | return CMD_SUCCESS; |
| 1008 | } |
| 1009 | |
| 1010 | DEFUN (show_ip_route_prefix_longer, |
| 1011 | show_ip_route_prefix_longer_cmd, |
| 1012 | "show ip route A.B.C.D/M longer-prefixes", |
| 1013 | SHOW_STR |
| 1014 | IP_STR |
| 1015 | "IP routing table\n" |
| 1016 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1017 | "Show route matching the specified Network/Mask pair only\n") |
| 1018 | { |
| 1019 | struct route_table *table; |
| 1020 | struct route_node *rn; |
| 1021 | struct rib *rib; |
| 1022 | struct prefix p; |
| 1023 | int ret; |
| 1024 | int first = 1; |
| 1025 | |
| 1026 | ret = str2prefix (argv[0], &p); |
| 1027 | if (! ret) |
| 1028 | { |
| 1029 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 1030 | return CMD_WARNING; |
| 1031 | } |
| 1032 | |
| 1033 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1034 | if (! table) |
| 1035 | return CMD_SUCCESS; |
| 1036 | |
| 1037 | /* Show matched type IPv4 routes. */ |
| 1038 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1039 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1040 | if (prefix_match (&p, &rn->p)) |
| 1041 | { |
| 1042 | if (first) |
| 1043 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1044 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | first = 0; |
| 1046 | } |
| 1047 | vty_show_ip_route (vty, rn, rib); |
| 1048 | } |
| 1049 | return CMD_SUCCESS; |
| 1050 | } |
| 1051 | |
| 1052 | DEFUN (show_ip_route_supernets, |
| 1053 | show_ip_route_supernets_cmd, |
| 1054 | "show ip route supernets-only", |
| 1055 | SHOW_STR |
| 1056 | IP_STR |
| 1057 | "IP routing table\n" |
| 1058 | "Show supernet entries only\n") |
| 1059 | { |
| 1060 | struct route_table *table; |
| 1061 | struct route_node *rn; |
| 1062 | struct rib *rib; |
| 1063 | u_int32_t addr; |
| 1064 | int first = 1; |
| 1065 | |
| 1066 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1067 | if (! table) |
| 1068 | return CMD_SUCCESS; |
| 1069 | |
| 1070 | /* Show matched type IPv4 routes. */ |
| 1071 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1072 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1073 | { |
| 1074 | addr = ntohl (rn->p.u.prefix4.s_addr); |
| 1075 | |
| 1076 | if ((IN_CLASSC (addr) && rn->p.prefixlen < 24) |
| 1077 | || (IN_CLASSB (addr) && rn->p.prefixlen < 16) |
| 1078 | || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) |
| 1079 | { |
| 1080 | if (first) |
| 1081 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1082 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1083 | first = 0; |
| 1084 | } |
| 1085 | vty_show_ip_route (vty, rn, rib); |
| 1086 | } |
| 1087 | } |
| 1088 | return CMD_SUCCESS; |
| 1089 | } |
| 1090 | |
| 1091 | DEFUN (show_ip_route_protocol, |
| 1092 | show_ip_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1093 | "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1094 | SHOW_STR |
| 1095 | IP_STR |
| 1096 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1097 | QUAGGA_IP_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1098 | { |
| 1099 | int type; |
| 1100 | struct route_table *table; |
| 1101 | struct route_node *rn; |
| 1102 | struct rib *rib; |
| 1103 | int first = 1; |
| 1104 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1105 | type = proto_redistnum (AFI_IP, argv[0]); |
| 1106 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1107 | { |
| 1108 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 1109 | return CMD_WARNING; |
| 1110 | } |
| 1111 | |
| 1112 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1113 | if (! table) |
| 1114 | return CMD_SUCCESS; |
| 1115 | |
| 1116 | /* Show matched type IPv4 routes. */ |
| 1117 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1118 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1119 | if (rib->type == type) |
| 1120 | { |
| 1121 | if (first) |
| 1122 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1123 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1124 | first = 0; |
| 1125 | } |
| 1126 | vty_show_ip_route (vty, rn, rib); |
| 1127 | } |
| 1128 | return CMD_SUCCESS; |
| 1129 | } |
| 1130 | |
| 1131 | DEFUN (show_ip_route_addr, |
| 1132 | show_ip_route_addr_cmd, |
| 1133 | "show ip route A.B.C.D", |
| 1134 | SHOW_STR |
| 1135 | IP_STR |
| 1136 | "IP routing table\n" |
| 1137 | "Network in the IP routing table to display\n") |
| 1138 | { |
| 1139 | int ret; |
| 1140 | struct prefix_ipv4 p; |
| 1141 | struct route_table *table; |
| 1142 | struct route_node *rn; |
| 1143 | |
| 1144 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1145 | if (ret <= 0) |
| 1146 | { |
| 1147 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 1148 | return CMD_WARNING; |
| 1149 | } |
| 1150 | |
| 1151 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1152 | if (! table) |
| 1153 | return CMD_SUCCESS; |
| 1154 | |
| 1155 | rn = route_node_match (table, (struct prefix *) &p); |
| 1156 | if (! rn) |
| 1157 | { |
| 1158 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1159 | return CMD_WARNING; |
| 1160 | } |
| 1161 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1162 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1163 | |
| 1164 | route_unlock_node (rn); |
| 1165 | |
| 1166 | return CMD_SUCCESS; |
| 1167 | } |
| 1168 | |
| 1169 | DEFUN (show_ip_route_prefix, |
| 1170 | show_ip_route_prefix_cmd, |
| 1171 | "show ip route A.B.C.D/M", |
| 1172 | SHOW_STR |
| 1173 | IP_STR |
| 1174 | "IP routing table\n" |
| 1175 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 1176 | { |
| 1177 | int ret; |
| 1178 | struct prefix_ipv4 p; |
| 1179 | struct route_table *table; |
| 1180 | struct route_node *rn; |
| 1181 | |
| 1182 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1183 | if (ret <= 0) |
| 1184 | { |
| 1185 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 1186 | return CMD_WARNING; |
| 1187 | } |
| 1188 | |
| 1189 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1190 | if (! table) |
| 1191 | return CMD_SUCCESS; |
| 1192 | |
| 1193 | rn = route_node_match (table, (struct prefix *) &p); |
| 1194 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 1195 | { |
| 1196 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 1197 | if (rn) |
| 1198 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1199 | return CMD_WARNING; |
| 1200 | } |
| 1201 | |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 1202 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1203 | |
| 1204 | route_unlock_node (rn); |
| 1205 | |
| 1206 | return CMD_SUCCESS; |
| 1207 | } |
| 1208 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1209 | static void |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1210 | vty_show_ip_route_summary (struct vty *vty, struct route_table *table) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1211 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1212 | struct route_node *rn; |
| 1213 | struct rib *rib; |
| 1214 | struct nexthop *nexthop; |
| 1215 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1216 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1217 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1218 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1219 | u_int32_t i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1220 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1221 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1222 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1223 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1224 | RNODE_FOREACH_RIB (rn, rib) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1225 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 1226 | { |
| 1227 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1228 | rib_cnt[rib->type]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1229 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1230 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1231 | { |
| 1232 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1233 | fib_cnt[rib->type]++; |
| 1234 | } |
| 1235 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1236 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1237 | { |
| 1238 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1239 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1240 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1241 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1242 | } |
| 1243 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1244 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1245 | vty_out (vty, "%-20s %-20s %-20s %s", |
| 1246 | "Route Source", "Routes", "FIB", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1248 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1249 | { |
| 1250 | if (rib_cnt[i] > 0) |
| 1251 | { |
| 1252 | if (i == ZEBRA_ROUTE_BGP) |
| 1253 | { |
| 1254 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 1255 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 1256 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1257 | VTY_NEWLINE); |
| 1258 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 1259 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1260 | VTY_NEWLINE); |
| 1261 | } |
| 1262 | else |
| 1263 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 1264 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 1265 | } |
| 1266 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1267 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1268 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 1269 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 1270 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1271 | } |
| 1272 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 1273 | /* |
| 1274 | * Implementation of the ip route summary prefix command. |
| 1275 | * |
| 1276 | * This command prints the primary prefixes that have been installed by various |
| 1277 | * protocols on the box. |
| 1278 | * |
| 1279 | */ |
| 1280 | static void |
| 1281 | vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) |
| 1282 | { |
| 1283 | struct route_node *rn; |
| 1284 | struct rib *rib; |
| 1285 | struct nexthop *nexthop; |
| 1286 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1287 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1288 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1289 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1290 | u_int32_t i; |
| 1291 | int cnt; |
| 1292 | |
| 1293 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1294 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1295 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1296 | RNODE_FOREACH_RIB (rn, rib) |
| 1297 | { |
| 1298 | |
| 1299 | /* |
| 1300 | * In case of ECMP, count only once. |
| 1301 | */ |
| 1302 | cnt = 0; |
| 1303 | for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next) |
| 1304 | { |
| 1305 | cnt++; |
| 1306 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1307 | rib_cnt[rib->type]++; |
| 1308 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1309 | { |
| 1310 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1311 | fib_cnt[rib->type]++; |
| 1312 | } |
| 1313 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1314 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1315 | { |
| 1316 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1317 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1318 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1319 | } |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | vty_out (vty, "%-20s %-20s %-20s %s", |
| 1324 | "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE); |
| 1325 | |
| 1326 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1327 | { |
| 1328 | if (rib_cnt[i] > 0) |
| 1329 | { |
| 1330 | if (i == ZEBRA_ROUTE_BGP) |
| 1331 | { |
| 1332 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 1333 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 1334 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1335 | VTY_NEWLINE); |
| 1336 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 1337 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1338 | VTY_NEWLINE); |
| 1339 | } |
| 1340 | else |
| 1341 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 1342 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 1347 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 1348 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
| 1349 | } |
| 1350 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1351 | /* Show route summary. */ |
| 1352 | DEFUN (show_ip_route_summary, |
| 1353 | show_ip_route_summary_cmd, |
| 1354 | "show ip route summary", |
| 1355 | SHOW_STR |
| 1356 | IP_STR |
| 1357 | "IP routing table\n" |
| 1358 | "Summary of all routes\n") |
| 1359 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1360 | struct route_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1362 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1363 | if (! table) |
| 1364 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1365 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1366 | vty_show_ip_route_summary (vty, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1367 | |
| 1368 | return CMD_SUCCESS; |
| 1369 | } |
| 1370 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 1371 | /* Show route summary prefix. */ |
| 1372 | DEFUN (show_ip_route_summary_prefix, |
| 1373 | show_ip_route_summary_prefix_cmd, |
| 1374 | "show ip route summary prefix", |
| 1375 | SHOW_STR |
| 1376 | IP_STR |
| 1377 | "IP routing table\n" |
| 1378 | "Summary of all routes\n" |
| 1379 | "Prefix routes\n") |
| 1380 | { |
| 1381 | struct route_table *table; |
| 1382 | |
| 1383 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1384 | if (! table) |
| 1385 | return CMD_SUCCESS; |
| 1386 | |
| 1387 | vty_show_ip_route_summary_prefix (vty, table); |
| 1388 | |
| 1389 | return CMD_SUCCESS; |
| 1390 | } |
| 1391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1392 | /* Write IPv4 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1393 | static int |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 1394 | static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | { |
| 1396 | struct route_node *rn; |
| 1397 | struct static_ipv4 *si; |
| 1398 | struct route_table *stable; |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1399 | char buf[PREFIX_STRLEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1400 | int write; |
| 1401 | |
| 1402 | write = 0; |
| 1403 | |
| 1404 | /* Lookup table. */ |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 1405 | stable = vrf_static_table (AFI_IP, safi, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1406 | if (! stable) |
| 1407 | return -1; |
| 1408 | |
| 1409 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 1410 | for (si = rn->info; si; si = si->next) |
| 1411 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1412 | vty_out (vty, "%s %s", cmd, prefix2str (&rn->p, buf, sizeof buf)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1413 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1414 | switch (si->type) |
| 1415 | { |
| 1416 | case STATIC_IPV4_GATEWAY: |
| 1417 | vty_out (vty, " %s", inet_ntoa (si->gate.ipv4)); |
| 1418 | break; |
| 1419 | case STATIC_IPV4_IFNAME: |
| 1420 | vty_out (vty, " %s", si->gate.ifname); |
| 1421 | break; |
| 1422 | case STATIC_IPV4_BLACKHOLE: |
| 1423 | vty_out (vty, " Null0"); |
| 1424 | break; |
| 1425 | } |
| 1426 | |
| 1427 | /* flags are incompatible with STATIC_IPV4_BLACKHOLE */ |
| 1428 | if (si->type != STATIC_IPV4_BLACKHOLE) |
| 1429 | { |
| 1430 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 1431 | vty_out (vty, " %s", "reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1432 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1433 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1434 | vty_out (vty, " %s", "blackhole"); |
| 1435 | } |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1436 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1437 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 1438 | vty_out (vty, " %d", si->distance); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1439 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1440 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1441 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1442 | write = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1443 | } |
| 1444 | return write; |
| 1445 | } |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1446 | |
| 1447 | DEFUN (show_ip_protocol, |
| 1448 | show_ip_protocol_cmd, |
| 1449 | "show ip protocol", |
| 1450 | SHOW_STR |
| 1451 | IP_STR |
| 1452 | "IP protocol filtering status\n") |
| 1453 | { |
| 1454 | int i; |
| 1455 | |
| 1456 | vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE); |
| 1457 | vty_out(vty, "------------------------%s", VTY_NEWLINE); |
| 1458 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 1459 | { |
| 1460 | if (proto_rm[AFI_IP][i]) |
| 1461 | vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i), |
| 1462 | proto_rm[AFI_IP][i], |
| 1463 | VTY_NEWLINE); |
| 1464 | else |
| 1465 | vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE); |
| 1466 | } |
| 1467 | if (proto_rm[AFI_IP][i]) |
| 1468 | vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i], |
| 1469 | VTY_NEWLINE); |
| 1470 | else |
| 1471 | vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE); |
| 1472 | |
| 1473 | return CMD_SUCCESS; |
| 1474 | } |
| 1475 | |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 1476 | /* |
| 1477 | * Show IP mroute command to dump the BGP Multicast |
| 1478 | * routing table |
| 1479 | */ |
| 1480 | DEFUN (show_ip_mroute, |
| 1481 | show_ip_mroute_cmd, |
| 1482 | "show ip mroute", |
| 1483 | SHOW_STR |
| 1484 | IP_STR |
| 1485 | "IP Multicast routing table\n") |
| 1486 | { |
| 1487 | struct route_table *table; |
| 1488 | struct route_node *rn; |
| 1489 | struct rib *rib; |
| 1490 | int first = 1; |
| 1491 | |
| 1492 | table = vrf_table (AFI_IP, SAFI_MULTICAST, 0); |
| 1493 | if (! table) |
| 1494 | return CMD_SUCCESS; |
| 1495 | |
| 1496 | /* Show all IPv4 routes. */ |
| 1497 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1498 | RNODE_FOREACH_RIB (rn, rib) |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 1499 | { |
| 1500 | if (first) |
| 1501 | { |
| 1502 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 1503 | first = 0; |
| 1504 | } |
| 1505 | vty_show_ip_route (vty, rn, rib); |
| 1506 | } |
| 1507 | return CMD_SUCCESS; |
| 1508 | } |
| 1509 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1510 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1511 | #ifdef HAVE_IPV6 |
| 1512 | /* General fucntion for IPv6 static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1513 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1514 | static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, |
| 1515 | const char *gate_str, const char *ifname, |
| 1516 | const char *flag_str, const char *distance_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1517 | { |
| 1518 | int ret; |
| 1519 | u_char distance; |
| 1520 | struct prefix p; |
| 1521 | struct in6_addr *gate = NULL; |
| 1522 | struct in6_addr gate_addr; |
| 1523 | u_char type = 0; |
| 1524 | int table = 0; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1525 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1526 | |
| 1527 | ret = str2prefix (dest_str, &p); |
| 1528 | if (ret <= 0) |
| 1529 | { |
| 1530 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 1531 | return CMD_WARNING; |
| 1532 | } |
| 1533 | |
| 1534 | /* Apply mask for given prefix. */ |
| 1535 | apply_mask (&p); |
| 1536 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1537 | /* Route flags */ |
| 1538 | if (flag_str) { |
| 1539 | switch(flag_str[0]) { |
| 1540 | case 'r': |
| 1541 | case 'R': /* XXX */ |
| 1542 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 1543 | break; |
| 1544 | case 'b': |
| 1545 | case 'B': /* XXX */ |
| 1546 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 1547 | break; |
| 1548 | default: |
| 1549 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 1550 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1551 | } |
| 1552 | } |
| 1553 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1554 | /* Administrative distance. */ |
| 1555 | if (distance_str) |
| 1556 | distance = atoi (distance_str); |
| 1557 | else |
| 1558 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 1559 | |
| 1560 | /* When gateway is valid IPv6 addrees, then gate is treated as |
| 1561 | nexthop address other case gate is treated as interface name. */ |
| 1562 | ret = inet_pton (AF_INET6, gate_str, &gate_addr); |
| 1563 | |
| 1564 | if (ifname) |
| 1565 | { |
| 1566 | /* When ifname is specified. It must be come with gateway |
| 1567 | address. */ |
| 1568 | if (ret != 1) |
| 1569 | { |
| 1570 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 1571 | return CMD_WARNING; |
| 1572 | } |
| 1573 | type = STATIC_IPV6_GATEWAY_IFNAME; |
| 1574 | gate = &gate_addr; |
| 1575 | } |
| 1576 | else |
| 1577 | { |
| 1578 | if (ret == 1) |
| 1579 | { |
| 1580 | type = STATIC_IPV6_GATEWAY; |
| 1581 | gate = &gate_addr; |
| 1582 | } |
| 1583 | else |
| 1584 | { |
| 1585 | type = STATIC_IPV6_IFNAME; |
| 1586 | ifname = gate_str; |
| 1587 | } |
| 1588 | } |
| 1589 | |
| 1590 | if (add_cmd) |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1591 | static_add_ipv6 (&p, type, gate, ifname, flag, distance, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1592 | else |
| 1593 | static_delete_ipv6 (&p, type, gate, ifname, distance, table); |
| 1594 | |
| 1595 | return CMD_SUCCESS; |
| 1596 | } |
| 1597 | |
| 1598 | DEFUN (ipv6_route, |
| 1599 | ipv6_route_cmd, |
| 1600 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1601 | IP_STR |
| 1602 | "Establish static routes\n" |
| 1603 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1604 | "IPv6 gateway address\n" |
| 1605 | "IPv6 gateway interface name\n") |
| 1606 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1607 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL); |
| 1608 | } |
| 1609 | |
| 1610 | DEFUN (ipv6_route_flags, |
| 1611 | ipv6_route_flags_cmd, |
| 1612 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1613 | IP_STR |
| 1614 | "Establish static routes\n" |
| 1615 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1616 | "IPv6 gateway address\n" |
| 1617 | "IPv6 gateway interface name\n" |
| 1618 | "Emit an ICMP unreachable when matched\n" |
| 1619 | "Silently discard pkts when matched\n") |
| 1620 | { |
| 1621 | 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] | 1622 | } |
| 1623 | |
| 1624 | DEFUN (ipv6_route_ifname, |
| 1625 | ipv6_route_ifname_cmd, |
| 1626 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1627 | IP_STR |
| 1628 | "Establish static routes\n" |
| 1629 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1630 | "IPv6 gateway address\n" |
| 1631 | "IPv6 gateway interface name\n") |
| 1632 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1633 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 1634 | } |
| 1635 | |
| 1636 | DEFUN (ipv6_route_ifname_flags, |
| 1637 | ipv6_route_ifname_flags_cmd, |
| 1638 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1639 | IP_STR |
| 1640 | "Establish static routes\n" |
| 1641 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1642 | "IPv6 gateway address\n" |
| 1643 | "IPv6 gateway interface name\n" |
| 1644 | "Emit an ICMP unreachable when matched\n" |
| 1645 | "Silently discard pkts when matched\n") |
| 1646 | { |
| 1647 | 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] | 1648 | } |
| 1649 | |
| 1650 | DEFUN (ipv6_route_pref, |
| 1651 | ipv6_route_pref_cmd, |
| 1652 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1653 | IP_STR |
| 1654 | "Establish static routes\n" |
| 1655 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1656 | "IPv6 gateway address\n" |
| 1657 | "IPv6 gateway interface name\n" |
| 1658 | "Distance value for this prefix\n") |
| 1659 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1660 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1661 | } |
| 1662 | |
| 1663 | DEFUN (ipv6_route_flags_pref, |
| 1664 | ipv6_route_flags_pref_cmd, |
| 1665 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1666 | IP_STR |
| 1667 | "Establish static routes\n" |
| 1668 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1669 | "IPv6 gateway address\n" |
| 1670 | "IPv6 gateway interface name\n" |
| 1671 | "Emit an ICMP unreachable when matched\n" |
| 1672 | "Silently discard pkts when matched\n" |
| 1673 | "Distance value for this prefix\n") |
| 1674 | { |
| 1675 | 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] | 1676 | } |
| 1677 | |
| 1678 | DEFUN (ipv6_route_ifname_pref, |
| 1679 | ipv6_route_ifname_pref_cmd, |
| 1680 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1681 | IP_STR |
| 1682 | "Establish static routes\n" |
| 1683 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1684 | "IPv6 gateway address\n" |
| 1685 | "IPv6 gateway interface name\n" |
| 1686 | "Distance value for this prefix\n") |
| 1687 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1688 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1689 | } |
| 1690 | |
| 1691 | DEFUN (ipv6_route_ifname_flags_pref, |
| 1692 | ipv6_route_ifname_flags_pref_cmd, |
| 1693 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1694 | IP_STR |
| 1695 | "Establish static routes\n" |
| 1696 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1697 | "IPv6 gateway address\n" |
| 1698 | "IPv6 gateway interface name\n" |
| 1699 | "Emit an ICMP unreachable when matched\n" |
| 1700 | "Silently discard pkts when matched\n" |
| 1701 | "Distance value for this prefix\n") |
| 1702 | { |
| 1703 | 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] | 1704 | } |
| 1705 | |
| 1706 | DEFUN (no_ipv6_route, |
| 1707 | no_ipv6_route_cmd, |
| 1708 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1709 | NO_STR |
| 1710 | IP_STR |
| 1711 | "Establish static routes\n" |
| 1712 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1713 | "IPv6 gateway address\n" |
| 1714 | "IPv6 gateway interface name\n") |
| 1715 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1716 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1719 | ALIAS (no_ipv6_route, |
| 1720 | no_ipv6_route_flags_cmd, |
| 1721 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1722 | NO_STR |
| 1723 | IP_STR |
| 1724 | "Establish static routes\n" |
| 1725 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1726 | "IPv6 gateway address\n" |
| 1727 | "IPv6 gateway interface name\n" |
| 1728 | "Emit an ICMP unreachable when matched\n" |
| 1729 | "Silently discard pkts when matched\n") |
| 1730 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1731 | DEFUN (no_ipv6_route_ifname, |
| 1732 | no_ipv6_route_ifname_cmd, |
| 1733 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1734 | NO_STR |
| 1735 | IP_STR |
| 1736 | "Establish static routes\n" |
| 1737 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1738 | "IPv6 gateway address\n" |
| 1739 | "IPv6 gateway interface name\n") |
| 1740 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1741 | 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] | 1742 | } |
| 1743 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1744 | ALIAS (no_ipv6_route_ifname, |
| 1745 | no_ipv6_route_ifname_flags_cmd, |
| 1746 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1747 | NO_STR |
| 1748 | IP_STR |
| 1749 | "Establish static routes\n" |
| 1750 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1751 | "IPv6 gateway address\n" |
| 1752 | "IPv6 gateway interface name\n" |
| 1753 | "Emit an ICMP unreachable when matched\n" |
| 1754 | "Silently discard pkts when matched\n") |
| 1755 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1756 | DEFUN (no_ipv6_route_pref, |
| 1757 | no_ipv6_route_pref_cmd, |
| 1758 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1759 | NO_STR |
| 1760 | IP_STR |
| 1761 | "Establish static routes\n" |
| 1762 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1763 | "IPv6 gateway address\n" |
| 1764 | "IPv6 gateway interface name\n" |
| 1765 | "Distance value for this prefix\n") |
| 1766 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1767 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1768 | } |
| 1769 | |
| 1770 | DEFUN (no_ipv6_route_flags_pref, |
| 1771 | no_ipv6_route_flags_pref_cmd, |
| 1772 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1773 | NO_STR |
| 1774 | IP_STR |
| 1775 | "Establish static routes\n" |
| 1776 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1777 | "IPv6 gateway address\n" |
| 1778 | "IPv6 gateway interface name\n" |
| 1779 | "Emit an ICMP unreachable when matched\n" |
| 1780 | "Silently discard pkts when matched\n" |
| 1781 | "Distance value for this prefix\n") |
| 1782 | { |
| 1783 | /* We do not care about argv[2] */ |
| 1784 | 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] | 1785 | } |
| 1786 | |
| 1787 | DEFUN (no_ipv6_route_ifname_pref, |
| 1788 | no_ipv6_route_ifname_pref_cmd, |
| 1789 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1790 | NO_STR |
| 1791 | IP_STR |
| 1792 | "Establish static routes\n" |
| 1793 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1794 | "IPv6 gateway address\n" |
| 1795 | "IPv6 gateway interface name\n" |
| 1796 | "Distance value for this prefix\n") |
| 1797 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1798 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1799 | } |
| 1800 | |
| 1801 | DEFUN (no_ipv6_route_ifname_flags_pref, |
| 1802 | no_ipv6_route_ifname_flags_pref_cmd, |
| 1803 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1804 | NO_STR |
| 1805 | IP_STR |
| 1806 | "Establish static routes\n" |
| 1807 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1808 | "IPv6 gateway address\n" |
| 1809 | "IPv6 gateway interface name\n" |
| 1810 | "Emit an ICMP unreachable when matched\n" |
| 1811 | "Silently discard pkts when matched\n" |
| 1812 | "Distance value for this prefix\n") |
| 1813 | { |
| 1814 | 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] | 1815 | } |
| 1816 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1817 | DEFUN (show_ipv6_route, |
| 1818 | show_ipv6_route_cmd, |
| 1819 | "show ipv6 route", |
| 1820 | SHOW_STR |
| 1821 | IP_STR |
| 1822 | "IPv6 routing table\n") |
| 1823 | { |
| 1824 | struct route_table *table; |
| 1825 | struct route_node *rn; |
| 1826 | struct rib *rib; |
| 1827 | int first = 1; |
| 1828 | |
| 1829 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1830 | if (! table) |
| 1831 | return CMD_SUCCESS; |
| 1832 | |
| 1833 | /* Show all IPv6 route. */ |
| 1834 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1835 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | { |
| 1837 | if (first) |
| 1838 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1839 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1840 | first = 0; |
| 1841 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1842 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | } |
| 1844 | return CMD_SUCCESS; |
| 1845 | } |
| 1846 | |
| 1847 | DEFUN (show_ipv6_route_prefix_longer, |
| 1848 | show_ipv6_route_prefix_longer_cmd, |
| 1849 | "show ipv6 route X:X::X:X/M longer-prefixes", |
| 1850 | SHOW_STR |
| 1851 | IP_STR |
| 1852 | "IPv6 routing table\n" |
| 1853 | "IPv6 prefix\n" |
| 1854 | "Show route matching the specified Network/Mask pair only\n") |
| 1855 | { |
| 1856 | struct route_table *table; |
| 1857 | struct route_node *rn; |
| 1858 | struct rib *rib; |
| 1859 | struct prefix p; |
| 1860 | int ret; |
| 1861 | int first = 1; |
| 1862 | |
| 1863 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1864 | if (! table) |
| 1865 | return CMD_SUCCESS; |
| 1866 | |
| 1867 | ret = str2prefix (argv[0], &p); |
| 1868 | if (! ret) |
| 1869 | { |
| 1870 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 1871 | return CMD_WARNING; |
| 1872 | } |
| 1873 | |
| 1874 | /* Show matched type IPv6 routes. */ |
| 1875 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1876 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1877 | if (prefix_match (&p, &rn->p)) |
| 1878 | { |
| 1879 | if (first) |
| 1880 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1881 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | first = 0; |
| 1883 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1884 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1885 | } |
| 1886 | return CMD_SUCCESS; |
| 1887 | } |
| 1888 | |
| 1889 | DEFUN (show_ipv6_route_protocol, |
| 1890 | show_ipv6_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1891 | "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1892 | SHOW_STR |
| 1893 | IP_STR |
| 1894 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1895 | QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1896 | { |
| 1897 | int type; |
| 1898 | struct route_table *table; |
| 1899 | struct route_node *rn; |
| 1900 | struct rib *rib; |
| 1901 | int first = 1; |
| 1902 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1903 | type = proto_redistnum (AFI_IP6, argv[0]); |
| 1904 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1905 | { |
| 1906 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 1907 | return CMD_WARNING; |
| 1908 | } |
| 1909 | |
| 1910 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1911 | if (! table) |
| 1912 | return CMD_SUCCESS; |
| 1913 | |
| 1914 | /* Show matched type IPv6 routes. */ |
| 1915 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1916 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1917 | if (rib->type == type) |
| 1918 | { |
| 1919 | if (first) |
| 1920 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1921 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1922 | first = 0; |
| 1923 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1924 | vty_show_ip_route (vty, rn, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1925 | } |
| 1926 | return CMD_SUCCESS; |
| 1927 | } |
| 1928 | |
| 1929 | DEFUN (show_ipv6_route_addr, |
| 1930 | show_ipv6_route_addr_cmd, |
| 1931 | "show ipv6 route X:X::X:X", |
| 1932 | SHOW_STR |
| 1933 | IP_STR |
| 1934 | "IPv6 routing table\n" |
| 1935 | "IPv6 Address\n") |
| 1936 | { |
| 1937 | int ret; |
| 1938 | struct prefix_ipv6 p; |
| 1939 | struct route_table *table; |
| 1940 | struct route_node *rn; |
| 1941 | |
| 1942 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1943 | if (ret <= 0) |
| 1944 | { |
| 1945 | vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); |
| 1946 | return CMD_WARNING; |
| 1947 | } |
| 1948 | |
| 1949 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1950 | if (! table) |
| 1951 | return CMD_SUCCESS; |
| 1952 | |
| 1953 | rn = route_node_match (table, (struct prefix *) &p); |
| 1954 | if (! rn) |
| 1955 | { |
| 1956 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1957 | return CMD_WARNING; |
| 1958 | } |
| 1959 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 1960 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1961 | |
| 1962 | route_unlock_node (rn); |
| 1963 | |
| 1964 | return CMD_SUCCESS; |
| 1965 | } |
| 1966 | |
| 1967 | DEFUN (show_ipv6_route_prefix, |
| 1968 | show_ipv6_route_prefix_cmd, |
| 1969 | "show ipv6 route X:X::X:X/M", |
| 1970 | SHOW_STR |
| 1971 | IP_STR |
| 1972 | "IPv6 routing table\n" |
| 1973 | "IPv6 prefix\n") |
| 1974 | { |
| 1975 | int ret; |
| 1976 | struct prefix_ipv6 p; |
| 1977 | struct route_table *table; |
| 1978 | struct route_node *rn; |
| 1979 | |
| 1980 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1981 | if (ret <= 0) |
| 1982 | { |
| 1983 | vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); |
| 1984 | return CMD_WARNING; |
| 1985 | } |
| 1986 | |
| 1987 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1988 | if (! table) |
| 1989 | return CMD_SUCCESS; |
| 1990 | |
| 1991 | rn = route_node_match (table, (struct prefix *) &p); |
| 1992 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 1993 | { |
| 1994 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 1995 | if (rn) |
| 1996 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1997 | return CMD_WARNING; |
| 1998 | } |
| 1999 | |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 2000 | vty_show_ip_route_detail (vty, rn, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2001 | |
| 2002 | route_unlock_node (rn); |
| 2003 | |
| 2004 | return CMD_SUCCESS; |
| 2005 | } |
| 2006 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2007 | /* Show route summary. */ |
| 2008 | DEFUN (show_ipv6_route_summary, |
| 2009 | show_ipv6_route_summary_cmd, |
| 2010 | "show ipv6 route summary", |
| 2011 | SHOW_STR |
| 2012 | IP_STR |
| 2013 | "IPv6 routing table\n" |
| 2014 | "Summary of all IPv6 routes\n") |
| 2015 | { |
| 2016 | struct route_table *table; |
| 2017 | |
| 2018 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2019 | if (! table) |
| 2020 | return CMD_SUCCESS; |
| 2021 | |
| 2022 | vty_show_ip_route_summary (vty, table); |
| 2023 | |
| 2024 | return CMD_SUCCESS; |
| 2025 | } |
| 2026 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2027 | /* Show ipv6 route summary prefix. */ |
| 2028 | DEFUN (show_ipv6_route_summary_prefix, |
| 2029 | show_ipv6_route_summary_prefix_cmd, |
| 2030 | "show ipv6 route summary prefix", |
| 2031 | SHOW_STR |
| 2032 | IP_STR |
| 2033 | "IPv6 routing table\n" |
| 2034 | "Summary of all IPv6 routes\n" |
| 2035 | "Prefix routes\n") |
| 2036 | { |
| 2037 | struct route_table *table; |
| 2038 | |
| 2039 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2040 | if (! table) |
| 2041 | return CMD_SUCCESS; |
| 2042 | |
| 2043 | vty_show_ip_route_summary_prefix (vty, table); |
| 2044 | |
| 2045 | return CMD_SUCCESS; |
| 2046 | } |
| 2047 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2048 | /* |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2049 | * Show IPv6 mroute command.Used to dump |
| 2050 | * the Multicast routing table. |
| 2051 | */ |
| 2052 | |
| 2053 | DEFUN (show_ipv6_mroute, |
| 2054 | show_ipv6_mroute_cmd, |
| 2055 | "show ipv6 mroute", |
| 2056 | SHOW_STR |
| 2057 | IP_STR |
| 2058 | "IPv6 Multicast routing table\n") |
| 2059 | { |
| 2060 | struct route_table *table; |
| 2061 | struct route_node *rn; |
| 2062 | struct rib *rib; |
| 2063 | int first = 1; |
| 2064 | |
| 2065 | table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0); |
| 2066 | if (! table) |
| 2067 | return CMD_SUCCESS; |
| 2068 | |
| 2069 | /* Show all IPv6 route. */ |
| 2070 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 2071 | RNODE_FOREACH_RIB (rn, rib) |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2072 | { |
| 2073 | if (first) |
| 2074 | { |
G.Balaji | cb32fd6 | 2011-11-27 20:09:40 +0530 | [diff] [blame] | 2075 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2076 | first = 0; |
| 2077 | } |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 2078 | vty_show_ip_route (vty, rn, rib); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2079 | } |
| 2080 | return CMD_SUCCESS; |
| 2081 | } |
| 2082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2083 | /* Write IPv6 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2084 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2085 | static_config_ipv6 (struct vty *vty) |
| 2086 | { |
| 2087 | struct route_node *rn; |
| 2088 | struct static_ipv6 *si; |
| 2089 | int write; |
| 2090 | char buf[BUFSIZ]; |
| 2091 | struct route_table *stable; |
| 2092 | |
| 2093 | write = 0; |
| 2094 | |
| 2095 | /* Lookup table. */ |
| 2096 | stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2097 | if (! stable) |
| 2098 | return -1; |
| 2099 | |
| 2100 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 2101 | for (si = rn->info; si; si = si->next) |
| 2102 | { |
Timo Teräs | 53a5c39 | 2015-05-23 11:08:40 +0300 | [diff] [blame] | 2103 | vty_out (vty, "ipv6 route %s", prefix2str (&rn->p, buf, sizeof buf)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2104 | |
| 2105 | switch (si->type) |
| 2106 | { |
| 2107 | case STATIC_IPV6_GATEWAY: |
| 2108 | vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ)); |
| 2109 | break; |
| 2110 | case STATIC_IPV6_IFNAME: |
| 2111 | vty_out (vty, " %s", si->ifname); |
| 2112 | break; |
| 2113 | case STATIC_IPV6_GATEWAY_IFNAME: |
| 2114 | vty_out (vty, " %s %s", |
| 2115 | inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname); |
| 2116 | break; |
| 2117 | } |
| 2118 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2119 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 2120 | vty_out (vty, " %s", "reject"); |
| 2121 | |
| 2122 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 2123 | vty_out (vty, " %s", "blackhole"); |
| 2124 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2125 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 2126 | vty_out (vty, " %d", si->distance); |
| 2127 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2128 | |
| 2129 | write = 1; |
| 2130 | } |
| 2131 | return write; |
| 2132 | } |
| 2133 | #endif /* HAVE_IPV6 */ |
| 2134 | |
| 2135 | /* Static ip route configuration write function. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2136 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | zebra_ip_config (struct vty *vty) |
| 2138 | { |
| 2139 | int write = 0; |
| 2140 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 2141 | write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route"); |
| 2142 | write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | #ifdef HAVE_IPV6 |
| 2144 | write += static_config_ipv6 (vty); |
| 2145 | #endif /* HAVE_IPV6 */ |
| 2146 | |
| 2147 | return write; |
| 2148 | } |
| 2149 | |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 2150 | static int config_write_vty(struct vty *vty) |
| 2151 | { |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2152 | int i; |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 2153 | enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get (); |
| 2154 | |
| 2155 | if (ipv4_multicast_mode != MCAST_NO_CONFIG) |
| 2156 | vty_out (vty, "ip multicast rpf-lookup-mode %s%s", |
| 2157 | ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" : |
| 2158 | ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" : |
| 2159 | ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" : |
| 2160 | ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" : |
| 2161 | "longer-prefix", |
| 2162 | VTY_NEWLINE); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2163 | |
| 2164 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 2165 | { |
| 2166 | if (proto_rm[AFI_IP][i]) |
| 2167 | vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i), |
| 2168 | proto_rm[AFI_IP][i], VTY_NEWLINE); |
| 2169 | } |
| 2170 | if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX]) |
| 2171 | vty_out (vty, "ip protocol %s route-map %s%s", "any", |
| 2172 | proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE); |
| 2173 | |
| 2174 | return 1; |
| 2175 | } |
| 2176 | |
| 2177 | /* table node for protocol filtering */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 2178 | static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2179 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2180 | /* IP node for static routes. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 2181 | static struct cmd_node ip_node = { IP_NODE, "", 1 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2182 | |
| 2183 | /* Route VTY. */ |
| 2184 | void |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2185 | zebra_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2186 | { |
| 2187 | install_node (&ip_node, zebra_ip_config); |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 2188 | install_node (&protocol_node, config_write_vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2189 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 2190 | install_element (CONFIG_NODE, &ip_mroute_cmd); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 2191 | install_element (CONFIG_NODE, &ip_mroute_dist_cmd); |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 2192 | install_element (CONFIG_NODE, &no_ip_mroute_cmd); |
David Lamparter | a76681b | 2015-01-22 19:03:53 +0100 | [diff] [blame] | 2193 | install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd); |
David Lamparter | bd07812 | 2015-01-06 19:53:24 +0100 | [diff] [blame] | 2194 | install_element (CONFIG_NODE, &ip_multicast_mode_cmd); |
| 2195 | install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd); |
| 2196 | install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2197 | install_element (CONFIG_NODE, &ip_protocol_cmd); |
| 2198 | install_element (CONFIG_NODE, &no_ip_protocol_cmd); |
| 2199 | install_element (VIEW_NODE, &show_ip_protocol_cmd); |
| 2200 | install_element (ENABLE_NODE, &show_ip_protocol_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2201 | install_element (CONFIG_NODE, &ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2202 | install_element (CONFIG_NODE, &ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2203 | install_element (CONFIG_NODE, &ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2204 | install_element (CONFIG_NODE, &ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2205 | install_element (CONFIG_NODE, &ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2206 | install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | install_element (CONFIG_NODE, &no_ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2208 | install_element (CONFIG_NODE, &no_ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2209 | install_element (CONFIG_NODE, &no_ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | install_element (CONFIG_NODE, &no_ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2211 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2212 | install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2213 | install_element (CONFIG_NODE, &ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2214 | install_element (CONFIG_NODE, &ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2215 | install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2216 | install_element (CONFIG_NODE, &ip_route_mask_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2217 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2218 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2219 | install_element (CONFIG_NODE, &no_ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2220 | install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2221 | install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2222 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2223 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2224 | |
| 2225 | install_element (VIEW_NODE, &show_ip_route_cmd); |
| 2226 | install_element (VIEW_NODE, &show_ip_route_addr_cmd); |
| 2227 | install_element (VIEW_NODE, &show_ip_route_prefix_cmd); |
| 2228 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd); |
| 2229 | install_element (VIEW_NODE, &show_ip_route_protocol_cmd); |
| 2230 | install_element (VIEW_NODE, &show_ip_route_supernets_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2231 | install_element (VIEW_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2232 | install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2233 | install_element (ENABLE_NODE, &show_ip_route_cmd); |
| 2234 | install_element (ENABLE_NODE, &show_ip_route_addr_cmd); |
| 2235 | install_element (ENABLE_NODE, &show_ip_route_prefix_cmd); |
| 2236 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd); |
| 2237 | install_element (ENABLE_NODE, &show_ip_route_protocol_cmd); |
| 2238 | install_element (ENABLE_NODE, &show_ip_route_supernets_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2239 | install_element (ENABLE_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2240 | install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2241 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2242 | install_element (VIEW_NODE, &show_ip_mroute_cmd); |
| 2243 | install_element (ENABLE_NODE, &show_ip_mroute_cmd); |
| 2244 | |
Everton Marques | 33d86db | 2014-07-14 11:19:00 -0300 | [diff] [blame] | 2245 | install_element (VIEW_NODE, &show_ip_rpf_cmd); |
| 2246 | install_element (ENABLE_NODE, &show_ip_rpf_cmd); |
David Lamparter | 3b02fe8 | 2015-01-22 19:12:35 +0100 | [diff] [blame] | 2247 | install_element (VIEW_NODE, &show_ip_rpf_addr_cmd); |
| 2248 | install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2249 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | #ifdef HAVE_IPV6 |
| 2251 | install_element (CONFIG_NODE, &ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2252 | install_element (CONFIG_NODE, &ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2253 | install_element (CONFIG_NODE, &ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2254 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2255 | install_element (CONFIG_NODE, &no_ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2256 | install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2258 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2259 | install_element (CONFIG_NODE, &ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2260 | install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2261 | install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2262 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2263 | install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2264 | install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2265 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2266 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | install_element (VIEW_NODE, &show_ipv6_route_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2268 | install_element (VIEW_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2269 | install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd); |
| 2271 | install_element (VIEW_NODE, &show_ipv6_route_addr_cmd); |
| 2272 | install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd); |
| 2273 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd); |
| 2274 | install_element (ENABLE_NODE, &show_ipv6_route_cmd); |
| 2275 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd); |
| 2276 | install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd); |
| 2277 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd); |
| 2278 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2279 | install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame] | 2280 | install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2281 | |
| 2282 | install_element (VIEW_NODE, &show_ipv6_mroute_cmd); |
| 2283 | install_element (ENABLE_NODE, &show_ipv6_mroute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | #endif /* HAVE_IPV6 */ |
| 2285 | } |