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