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