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