paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Interface function. |
| 3 | * Copyright (C) 1997, 1999 Kunihiro Ishiguro |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "if.h" |
| 26 | #include "vty.h" |
| 27 | #include "sockunion.h" |
| 28 | #include "prefix.h" |
| 29 | #include "command.h" |
| 30 | #include "memory.h" |
| 31 | #include "ioctl.h" |
| 32 | #include "connected.h" |
| 33 | #include "log.h" |
| 34 | #include "zclient.h" |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 35 | #include "vrf.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 36 | |
| 37 | #include "zebra/interface.h" |
| 38 | #include "zebra/rtadv.h" |
| 39 | #include "zebra/rib.h" |
| 40 | #include "zebra/zserv.h" |
| 41 | #include "zebra/redistribute.h" |
| 42 | #include "zebra/debug.h" |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 43 | #include "zebra/irdp.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | |
Chris Caputo | b60668d | 2009-05-03 04:40:57 +0000 | [diff] [blame] | 45 | #ifdef RTADV |
| 46 | /* Order is intentional. Matches RFC4191. This array is also used for |
| 47 | command matching, so only modify with care. */ |
| 48 | const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 }; |
| 49 | #endif /* RTADV */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 50 | |
| 51 | /* Called when new interface is added. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 52 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | if_zebra_new_hook (struct interface *ifp) |
| 54 | { |
| 55 | struct zebra_if *zebra_if; |
| 56 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 57 | zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC; |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 60 | zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_OFF; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | |
| 62 | #ifdef RTADV |
| 63 | { |
| 64 | /* Set default router advertise values. */ |
| 65 | struct rtadvconf *rtadv; |
| 66 | |
| 67 | rtadv = &zebra_if->rtadv; |
| 68 | |
| 69 | rtadv->AdvSendAdvertisements = 0; |
| 70 | rtadv->MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL; |
| 71 | rtadv->MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL; |
| 72 | rtadv->AdvIntervalTimer = 0; |
| 73 | rtadv->AdvManagedFlag = 0; |
| 74 | rtadv->AdvOtherConfigFlag = 0; |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 75 | rtadv->AdvHomeAgentFlag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | rtadv->AdvLinkMTU = 0; |
| 77 | rtadv->AdvReachableTime = 0; |
| 78 | rtadv->AdvRetransTimer = 0; |
| 79 | rtadv->AdvCurHopLimit = 0; |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 80 | rtadv->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */ |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 81 | rtadv->HomeAgentPreference = 0; |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 82 | rtadv->HomeAgentLifetime = -1; /* derive from AdvDefaultLifetime */ |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 83 | rtadv->AdvIntervalOption = 0; |
Chris Caputo | b60668d | 2009-05-03 04:40:57 +0000 | [diff] [blame] | 84 | rtadv->DefaultPreference = RTADV_PREF_MEDIUM; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | |
| 86 | rtadv->AdvPrefixList = list_new (); |
| 87 | } |
| 88 | #endif /* RTADV */ |
| 89 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 90 | /* Initialize installed address chains tree. */ |
| 91 | zebra_if->ipv4_subnets = route_table_init (); |
| 92 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 93 | ifp->info = zebra_if; |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | /* Called when interface is deleted. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 98 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 99 | if_zebra_delete_hook (struct interface *ifp) |
| 100 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 101 | struct zebra_if *zebra_if; |
| 102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | if (ifp->info) |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 104 | { |
| 105 | zebra_if = ifp->info; |
| 106 | |
| 107 | /* Free installed address chains tree. */ |
| 108 | if (zebra_if->ipv4_subnets) |
| 109 | route_table_finish (zebra_if->ipv4_subnets); |
| 110 | |
| 111 | XFREE (MTYPE_TMP, zebra_if); |
| 112 | } |
| 113 | |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | /* Tie an interface address to its derived subnet list of addresses. */ |
| 118 | int |
| 119 | if_subnet_add (struct interface *ifp, struct connected *ifc) |
| 120 | { |
| 121 | struct route_node *rn; |
| 122 | struct zebra_if *zebra_if; |
| 123 | struct prefix cp; |
| 124 | struct list *addr_list; |
| 125 | |
| 126 | assert (ifp && ifp->info && ifc); |
| 127 | zebra_if = ifp->info; |
| 128 | |
| 129 | /* Get address derived subnet node and associated address list, while marking |
| 130 | address secondary attribute appropriately. */ |
| 131 | cp = *ifc->address; |
| 132 | apply_mask (&cp); |
| 133 | rn = route_node_get (zebra_if->ipv4_subnets, &cp); |
| 134 | |
| 135 | if ((addr_list = rn->info)) |
| 136 | SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); |
| 137 | else |
| 138 | { |
| 139 | UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); |
| 140 | rn->info = addr_list = list_new (); |
| 141 | route_lock_node (rn); |
| 142 | } |
| 143 | |
| 144 | /* Tie address at the tail of address list. */ |
| 145 | listnode_add (addr_list, ifc); |
| 146 | |
| 147 | /* Return list element count. */ |
| 148 | return (addr_list->count); |
| 149 | } |
| 150 | |
| 151 | /* Untie an interface address from its derived subnet list of addresses. */ |
| 152 | int |
| 153 | if_subnet_delete (struct interface *ifp, struct connected *ifc) |
| 154 | { |
| 155 | struct route_node *rn; |
| 156 | struct zebra_if *zebra_if; |
| 157 | struct list *addr_list; |
| 158 | |
| 159 | assert (ifp && ifp->info && ifc); |
| 160 | zebra_if = ifp->info; |
| 161 | |
| 162 | /* Get address derived subnet node. */ |
| 163 | rn = route_node_lookup (zebra_if->ipv4_subnets, ifc->address); |
| 164 | if (! (rn && rn->info)) |
Christian Franke | 9db047f | 2013-01-24 14:04:44 +0000 | [diff] [blame] | 165 | { |
| 166 | zlog_warn("Trying to remove an address from an unknown subnet." |
| 167 | " (please report this bug)"); |
| 168 | return -1; |
| 169 | } |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 170 | route_unlock_node (rn); |
| 171 | |
| 172 | /* Untie address from subnet's address list. */ |
| 173 | addr_list = rn->info; |
Christian Franke | 9db047f | 2013-01-24 14:04:44 +0000 | [diff] [blame] | 174 | |
| 175 | /* Deleting an address that is not registered is a bug. |
| 176 | * In any case, we shouldn't decrement the lock counter if the address |
| 177 | * is unknown. */ |
| 178 | if (!listnode_lookup(addr_list, ifc)) |
| 179 | { |
| 180 | zlog_warn("Trying to remove an address from a subnet where it is not" |
| 181 | " currently registered. (please report this bug)"); |
| 182 | return -1; |
| 183 | } |
| 184 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 185 | listnode_delete (addr_list, ifc); |
| 186 | route_unlock_node (rn); |
| 187 | |
| 188 | /* Return list element count, if not empty. */ |
| 189 | if (addr_list->count) |
| 190 | { |
| 191 | /* If deleted address is primary, mark subsequent one as such and distribute. */ |
| 192 | if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY)) |
| 193 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 194 | ifc = listgetdata (listhead (addr_list)); |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 195 | zebra_interface_address_delete_update (ifp, ifc); |
| 196 | UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 197 | /* XXX: Linux kernel removes all the secondary addresses when the primary |
| 198 | * address is removed. We could try to work around that, though this is |
| 199 | * non-trivial. */ |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 200 | zebra_interface_address_add_update (ifp, ifc); |
| 201 | } |
| 202 | |
| 203 | return addr_list->count; |
| 204 | } |
| 205 | |
| 206 | /* Otherwise, free list and route node. */ |
| 207 | list_free (addr_list); |
| 208 | rn->info = NULL; |
| 209 | route_unlock_node (rn); |
| 210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| 213 | |
paul | 5c78b3d | 2006-01-25 04:31:40 +0000 | [diff] [blame] | 214 | /* if_flags_mangle: A place for hacks that require mangling |
| 215 | * or tweaking the interface flags. |
| 216 | * |
| 217 | * ******************** Solaris flags hacks ************************** |
| 218 | * |
| 219 | * Solaris IFF_UP flag reflects only the primary interface as the |
| 220 | * routing socket only sends IFINFO for the primary interface. Hence |
| 221 | * ~IFF_UP does not per se imply all the logical interfaces are also |
| 222 | * down - which we only know of as addresses. Instead we must determine |
| 223 | * whether the interface really is up or not according to how many |
| 224 | * addresses are still attached. (Solaris always sends RTM_DELADDR if |
| 225 | * an interface, logical or not, goes ~IFF_UP). |
| 226 | * |
| 227 | * Ie, we mangle IFF_UP to *additionally* reflect whether or not there |
| 228 | * are addresses left in struct connected, not just the actual underlying |
| 229 | * IFF_UP flag. |
| 230 | * |
| 231 | * We must hence remember the real state of IFF_UP, which we do in |
| 232 | * struct zebra_if.primary_state. |
| 233 | * |
| 234 | * Setting IFF_UP within zebra to administratively shutdown the |
| 235 | * interface will affect only the primary interface/address on Solaris. |
| 236 | ************************End Solaris flags hacks *********************** |
| 237 | */ |
Paul Jakma | f63f06d | 2011-04-08 12:44:43 +0100 | [diff] [blame] | 238 | static void |
paul | 5c78b3d | 2006-01-25 04:31:40 +0000 | [diff] [blame] | 239 | if_flags_mangle (struct interface *ifp, uint64_t *newflags) |
| 240 | { |
| 241 | #ifdef SUNOS_5 |
| 242 | struct zebra_if *zif = ifp->info; |
| 243 | |
| 244 | zif->primary_state = *newflags & (IFF_UP & 0xff); |
| 245 | |
| 246 | if (CHECK_FLAG (zif->primary_state, IFF_UP) |
| 247 | || listcount(ifp->connected) > 0) |
| 248 | SET_FLAG (*newflags, IFF_UP); |
| 249 | else |
| 250 | UNSET_FLAG (*newflags, IFF_UP); |
| 251 | #endif /* SUNOS_5 */ |
| 252 | } |
| 253 | |
| 254 | /* Update the flags field of the ifp with the new flag set provided. |
| 255 | * Take whatever actions are required for any changes in flags we care |
| 256 | * about. |
| 257 | * |
| 258 | * newflags should be the raw value, as obtained from the OS. |
| 259 | */ |
| 260 | void |
| 261 | if_flags_update (struct interface *ifp, uint64_t newflags) |
| 262 | { |
| 263 | if_flags_mangle (ifp, &newflags); |
| 264 | |
| 265 | if (if_is_operative (ifp)) |
| 266 | { |
| 267 | /* operative -> inoperative? */ |
| 268 | ifp->flags = newflags; |
| 269 | if (!if_is_operative (ifp)) |
| 270 | if_down (ifp); |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | /* inoperative -> operative? */ |
| 275 | ifp->flags = newflags; |
| 276 | if (if_is_operative (ifp)) |
| 277 | if_up (ifp); |
| 278 | } |
| 279 | } |
| 280 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 281 | /* Wake up configured address if it is not in current kernel |
| 282 | address. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 283 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 284 | if_addr_wakeup (struct interface *ifp) |
| 285 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 286 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 287 | struct connected *ifc; |
| 288 | struct prefix *p; |
| 289 | int ret; |
| 290 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 291 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 292 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 293 | p = ifc->address; |
| 294 | |
| 295 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED) |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 296 | && ! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 297 | { |
| 298 | /* Address check. */ |
| 299 | if (p->family == AF_INET) |
| 300 | { |
| 301 | if (! if_is_up (ifp)) |
| 302 | { |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 303 | /* Assume zebra is configured like following: |
| 304 | * |
| 305 | * interface gre0 |
| 306 | * ip addr 192.0.2.1/24 |
| 307 | * ! |
| 308 | * |
| 309 | * As soon as zebra becomes first aware that gre0 exists in the |
| 310 | * kernel, it will set gre0 up and configure its addresses. |
| 311 | * |
| 312 | * (This may happen at startup when the interface already exists |
| 313 | * or during runtime when the interface is added to the kernel) |
| 314 | * |
| 315 | * XXX: IRDP code is calling here via if_add_update - this seems |
| 316 | * somewhat weird. |
| 317 | * XXX: RUNNING is not a settable flag on any system |
| 318 | * I (paulj) am aware of. |
| 319 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 320 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
| 321 | if_refresh (ifp); |
| 322 | } |
| 323 | |
| 324 | ret = if_set_prefix (ifp, ifc); |
| 325 | if (ret < 0) |
| 326 | { |
| 327 | zlog_warn ("Can't set interface's address: %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 328 | safe_strerror(errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 329 | continue; |
| 330 | } |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 331 | |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 332 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 333 | /* The address will be advertised to zebra clients when the notification |
| 334 | * from the kernel has been received. |
| 335 | * It will also be added to the interface's subnet list then. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 336 | } |
| 337 | #ifdef HAVE_IPV6 |
| 338 | if (p->family == AF_INET6) |
| 339 | { |
| 340 | if (! if_is_up (ifp)) |
| 341 | { |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 342 | /* See long comment above */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
| 344 | if_refresh (ifp); |
| 345 | } |
| 346 | |
| 347 | ret = if_prefix_add_ipv6 (ifp, ifc); |
| 348 | if (ret < 0) |
| 349 | { |
| 350 | zlog_warn ("Can't set interface's address: %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 351 | safe_strerror(errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 352 | continue; |
| 353 | } |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 354 | |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 355 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 356 | /* The address will be advertised to zebra clients when the notification |
| 357 | * from the kernel has been received. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 358 | } |
| 359 | #endif /* HAVE_IPV6 */ |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | /* Handle interface addition */ |
| 365 | void |
| 366 | if_add_update (struct interface *ifp) |
| 367 | { |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 368 | struct zebra_if *if_data; |
| 369 | |
| 370 | if_data = ifp->info; |
| 371 | if (if_data->multicast == IF_ZEBRA_MULTICAST_ON) |
| 372 | if_set_flags (ifp, IFF_MULTICAST); |
| 373 | else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF) |
| 374 | if_unset_flags (ifp, IFF_MULTICAST); |
| 375 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | zebra_interface_add_update (ifp); |
| 377 | |
| 378 | if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
| 379 | { |
| 380 | SET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); |
| 381 | |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 382 | if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) |
| 383 | { |
| 384 | if (IS_ZEBRA_DEBUG_KERNEL) |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 385 | zlog_debug ("interface %s vrf %u index %d is shutdown. " |
| 386 | "Won't wake it up.", |
| 387 | ifp->name, ifp->vrf_id, ifp->ifindex); |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 388 | return; |
| 389 | } |
| 390 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 391 | if_addr_wakeup (ifp); |
| 392 | |
| 393 | if (IS_ZEBRA_DEBUG_KERNEL) |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 394 | zlog_debug ("interface %s vrf %u index %d becomes active.", |
| 395 | ifp->name, ifp->vrf_id, ifp->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | } |
| 397 | else |
| 398 | { |
| 399 | if (IS_ZEBRA_DEBUG_KERNEL) |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 400 | zlog_debug ("interface %s vrf %u index %d is added.", |
| 401 | ifp->name, ifp->vrf_id, ifp->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
paul | 6eb8827 | 2005-07-29 14:36:00 +0000 | [diff] [blame] | 405 | /* Handle an interface delete event */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 406 | void |
| 407 | if_delete_update (struct interface *ifp) |
| 408 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 409 | struct connected *ifc; |
| 410 | struct prefix *p; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 411 | struct route_node *rn; |
| 412 | struct zebra_if *zebra_if; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 413 | |
| 414 | zebra_if = ifp->info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 415 | |
| 416 | if (if_is_up(ifp)) |
| 417 | { |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 418 | zlog_err ("interface %s vrf %u index %d is still up while being deleted.", |
| 419 | ifp->name, ifp->vrf_id, ifp->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 420 | return; |
| 421 | } |
| 422 | |
| 423 | /* Mark interface as inactive */ |
| 424 | UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); |
| 425 | |
| 426 | if (IS_ZEBRA_DEBUG_KERNEL) |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 427 | zlog_debug ("interface %s vrf %u index %d is now inactive.", |
| 428 | ifp->name, ifp->vrf_id, ifp->ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | |
| 430 | /* Delete connected routes from the kernel. */ |
| 431 | if (ifp->connected) |
| 432 | { |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 433 | struct listnode *node; |
| 434 | struct listnode *last = NULL; |
| 435 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 436 | while ((node = (last ? last->next : listhead (ifp->connected)))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 437 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 438 | ifc = listgetdata (node); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | p = ifc->address; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 440 | |
Paul Jakma | beb5633 | 2006-05-11 13:28:05 +0000 | [diff] [blame] | 441 | if (p->family == AF_INET |
| 442 | && (rn = route_node_lookup (zebra_if->ipv4_subnets, p))) |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 443 | { |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 444 | struct listnode *anode; |
| 445 | struct listnode *next; |
| 446 | struct listnode *first; |
| 447 | struct list *addr_list; |
| 448 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 449 | route_unlock_node (rn); |
| 450 | addr_list = (struct list *) rn->info; |
| 451 | |
| 452 | /* Remove addresses, secondaries first. */ |
| 453 | first = listhead (addr_list); |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 454 | for (anode = first->next; anode || first; anode = next) |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 455 | { |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 456 | if (!anode) |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 457 | { |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 458 | anode = first; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 459 | first = NULL; |
| 460 | } |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 461 | next = anode->next; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 462 | |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 463 | ifc = listgetdata (anode); |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 464 | p = ifc->address; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 465 | connected_down_ipv4 (ifp, ifc); |
| 466 | |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 467 | /* XXX: We have to send notifications here explicitly, because we destroy |
| 468 | * the ifc before receiving the notification about the address being deleted. |
| 469 | */ |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 470 | zebra_interface_address_delete_update (ifp, ifc); |
| 471 | |
| 472 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 473 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 474 | |
| 475 | /* Remove from subnet chain. */ |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 476 | list_delete_node (addr_list, anode); |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 477 | route_unlock_node (rn); |
| 478 | |
| 479 | /* Remove from interface address list (unconditionally). */ |
Paul Jakma | d9a18f1 | 2007-04-10 19:30:20 +0000 | [diff] [blame] | 480 | if (!CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 481 | { |
| 482 | listnode_delete (ifp->connected, ifc); |
| 483 | connected_free (ifc); |
| 484 | } |
| 485 | else |
| 486 | last = node; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | /* Free chain list and respective route node. */ |
| 490 | list_delete (addr_list); |
| 491 | rn->info = NULL; |
| 492 | route_unlock_node (rn); |
| 493 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 494 | #ifdef HAVE_IPV6 |
| 495 | else if (p->family == AF_INET6) |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 496 | { |
| 497 | connected_down_ipv6 (ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 498 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 499 | zebra_interface_address_delete_update (ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 500 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 501 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 502 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 503 | |
| 504 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 505 | last = node; |
| 506 | else |
| 507 | { |
| 508 | listnode_delete (ifp->connected, ifc); |
| 509 | connected_free (ifc); |
| 510 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | } |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 512 | #endif /* HAVE_IPV6 */ |
Roman Hoog Antink | e26873f | 2010-05-05 16:00:50 +0200 | [diff] [blame] | 513 | else |
| 514 | { |
| 515 | last = node; |
| 516 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | zebra_interface_delete_update (ifp); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 520 | |
| 521 | /* Update ifindex after distributing the delete message. This is in |
| 522 | case any client needs to have the old value of ifindex available |
| 523 | while processing the deletion. Each client daemon is responsible |
| 524 | for setting ifindex to IFINDEX_INTERNAL after processing the |
| 525 | interface deletion message. */ |
| 526 | ifp->ifindex = IFINDEX_INTERNAL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | /* Interface is up. */ |
| 530 | void |
| 531 | if_up (struct interface *ifp) |
| 532 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 533 | struct listnode *node; |
| 534 | struct listnode *next; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 535 | struct connected *ifc; |
| 536 | struct prefix *p; |
| 537 | |
| 538 | /* Notify the protocol daemons. */ |
| 539 | zebra_interface_up_update (ifp); |
| 540 | |
| 541 | /* Install connected routes to the kernel. */ |
| 542 | if (ifp->connected) |
| 543 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 544 | for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 545 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 546 | p = ifc->address; |
| 547 | |
| 548 | if (p->family == AF_INET) |
| 549 | connected_up_ipv4 (ifp, ifc); |
| 550 | #ifdef HAVE_IPV6 |
| 551 | else if (p->family == AF_INET6) |
| 552 | connected_up_ipv6 (ifp, ifc); |
| 553 | #endif /* HAVE_IPV6 */ |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /* Examine all static routes. */ |
| 558 | rib_update (); |
| 559 | } |
| 560 | |
| 561 | /* Interface goes down. We have to manage different behavior of based |
| 562 | OS. */ |
| 563 | void |
| 564 | if_down (struct interface *ifp) |
| 565 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 566 | struct listnode *node; |
| 567 | struct listnode *next; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 568 | struct connected *ifc; |
| 569 | struct prefix *p; |
| 570 | |
| 571 | /* Notify to the protocol daemons. */ |
| 572 | zebra_interface_down_update (ifp); |
| 573 | |
| 574 | /* Delete connected routes from the kernel. */ |
| 575 | if (ifp->connected) |
| 576 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 577 | for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 578 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 579 | p = ifc->address; |
| 580 | |
| 581 | if (p->family == AF_INET) |
| 582 | connected_down_ipv4 (ifp, ifc); |
| 583 | #ifdef HAVE_IPV6 |
| 584 | else if (p->family == AF_INET6) |
| 585 | connected_down_ipv6 (ifp, ifc); |
| 586 | #endif /* HAVE_IPV6 */ |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* Examine all static routes which direct to the interface. */ |
| 591 | rib_update (); |
| 592 | } |
| 593 | |
| 594 | void |
| 595 | if_refresh (struct interface *ifp) |
| 596 | { |
paul | 5c78b3d | 2006-01-25 04:31:40 +0000 | [diff] [blame] | 597 | if_get_flags (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | } |
| 599 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | /* Output prefix string to vty. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 601 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 602 | prefix_vty_out (struct vty *vty, struct prefix *p) |
| 603 | { |
| 604 | char str[INET6_ADDRSTRLEN]; |
| 605 | |
| 606 | inet_ntop (p->family, &p->u.prefix, str, sizeof (str)); |
| 607 | vty_out (vty, "%s", str); |
| 608 | return strlen (str); |
| 609 | } |
| 610 | |
| 611 | /* Dump if address information to vty. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 612 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 613 | connected_dump_vty (struct vty *vty, struct connected *connected) |
| 614 | { |
| 615 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 616 | |
| 617 | /* Print interface address. */ |
| 618 | p = connected->address; |
| 619 | vty_out (vty, " %s ", prefix_family_str (p)); |
| 620 | prefix_vty_out (vty, p); |
| 621 | vty_out (vty, "/%d", p->prefixlen); |
| 622 | |
| 623 | /* If there is destination address, print it. */ |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 624 | if (connected->destination) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | { |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 626 | vty_out (vty, (CONNECTED_PEER(connected) ? " peer " : " broadcast ")); |
| 627 | prefix_vty_out (vty, connected->destination); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | if (CHECK_FLAG (connected->flags, ZEBRA_IFA_SECONDARY)) |
| 631 | vty_out (vty, " secondary"); |
| 632 | |
| 633 | if (connected->label) |
| 634 | vty_out (vty, " %s", connected->label); |
| 635 | |
| 636 | vty_out (vty, "%s", VTY_NEWLINE); |
| 637 | } |
| 638 | |
| 639 | #ifdef RTADV |
| 640 | /* Dump interface ND information to vty. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 641 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 642 | nd_dump_vty (struct vty *vty, struct interface *ifp) |
| 643 | { |
| 644 | struct zebra_if *zif; |
| 645 | struct rtadvconf *rtadv; |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 646 | int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | |
| 648 | zif = (struct zebra_if *) ifp->info; |
| 649 | rtadv = &zif->rtadv; |
| 650 | |
| 651 | if (rtadv->AdvSendAdvertisements) |
| 652 | { |
| 653 | vty_out (vty, " ND advertised reachable time is %d milliseconds%s", |
| 654 | rtadv->AdvReachableTime, VTY_NEWLINE); |
| 655 | vty_out (vty, " ND advertised retransmit interval is %d milliseconds%s", |
| 656 | rtadv->AdvRetransTimer, VTY_NEWLINE); |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 657 | interval = rtadv->MaxRtrAdvInterval; |
| 658 | if (interval % 1000) |
| 659 | vty_out (vty, " ND router advertisements are sent every " |
| 660 | "%d milliseconds%s", interval, |
| 661 | VTY_NEWLINE); |
| 662 | else |
| 663 | vty_out (vty, " ND router advertisements are sent every " |
| 664 | "%d seconds%s", interval / 1000, |
| 665 | VTY_NEWLINE); |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 666 | if (rtadv->AdvDefaultLifetime != -1) |
| 667 | vty_out (vty, " ND router advertisements live for %d seconds%s", |
| 668 | rtadv->AdvDefaultLifetime, VTY_NEWLINE); |
| 669 | else |
| 670 | vty_out (vty, " ND router advertisements lifetime tracks ra-interval%s", |
| 671 | VTY_NEWLINE); |
Chris Caputo | b60668d | 2009-05-03 04:40:57 +0000 | [diff] [blame] | 672 | vty_out (vty, " ND router advertisement default router preference is " |
| 673 | "%s%s", rtadv_pref_strs[rtadv->DefaultPreference], |
| 674 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | if (rtadv->AdvManagedFlag) |
| 676 | vty_out (vty, " Hosts use DHCP to obtain routable addresses.%s", |
| 677 | VTY_NEWLINE); |
| 678 | else |
| 679 | vty_out (vty, " Hosts use stateless autoconfig for addresses.%s", |
| 680 | VTY_NEWLINE); |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 681 | if (rtadv->AdvHomeAgentFlag) |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 682 | { |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 683 | vty_out (vty, " ND router advertisements with " |
| 684 | "Home Agent flag bit set.%s", |
| 685 | VTY_NEWLINE); |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 686 | if (rtadv->HomeAgentLifetime != -1) |
| 687 | vty_out (vty, " Home Agent lifetime is %u seconds%s", |
| 688 | rtadv->HomeAgentLifetime, VTY_NEWLINE); |
| 689 | else |
| 690 | vty_out (vty, " Home Agent lifetime tracks ra-lifetime%s", |
| 691 | VTY_NEWLINE); |
| 692 | vty_out (vty, " Home Agent preference is %u%s", |
| 693 | rtadv->HomeAgentPreference, VTY_NEWLINE); |
| 694 | } |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 695 | if (rtadv->AdvIntervalOption) |
| 696 | vty_out (vty, " ND router advertisements with Adv. Interval option.%s", |
| 697 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 698 | } |
| 699 | } |
| 700 | #endif /* RTADV */ |
| 701 | |
| 702 | /* Interface's information print out to vty interface. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 703 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 704 | if_dump_vty (struct vty *vty, struct interface *ifp) |
| 705 | { |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 706 | #ifdef HAVE_STRUCT_SOCKADDR_DL |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 707 | struct sockaddr_dl *sdl; |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 708 | #endif /* HAVE_STRUCT_SOCKADDR_DL */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | struct connected *connected; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 710 | struct listnode *node; |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 711 | struct route_node *rn; |
| 712 | struct zebra_if *zebra_if; |
| 713 | |
| 714 | zebra_if = ifp->info; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 716 | vty_out (vty, "Interface %s is ", ifp->name); |
| 717 | if (if_is_up(ifp)) { |
| 718 | vty_out (vty, "up, line protocol "); |
| 719 | |
| 720 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) { |
| 721 | if (if_is_running(ifp)) |
| 722 | vty_out (vty, "is up%s", VTY_NEWLINE); |
| 723 | else |
| 724 | vty_out (vty, "is down%s", VTY_NEWLINE); |
| 725 | } else { |
| 726 | vty_out (vty, "detection is disabled%s", VTY_NEWLINE); |
| 727 | } |
| 728 | } else { |
| 729 | vty_out (vty, "down%s", VTY_NEWLINE); |
| 730 | } |
| 731 | |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 732 | vty_out (vty, " vrf: %u%s", ifp->vrf_id, VTY_NEWLINE); |
| 733 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 734 | if (ifp->desc) |
| 735 | vty_out (vty, " Description: %s%s", ifp->desc, |
| 736 | VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 737 | if (ifp->ifindex == IFINDEX_INTERNAL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 738 | { |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 739 | vty_out(vty, " pseudo interface%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 740 | return; |
| 741 | } |
| 742 | else if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
| 743 | { |
| 744 | vty_out(vty, " index %d inactive interface%s", |
| 745 | ifp->ifindex, |
| 746 | VTY_NEWLINE); |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | vty_out (vty, " index %d metric %d mtu %d ", |
| 751 | ifp->ifindex, ifp->metric, ifp->mtu); |
paul | 44145db | 2004-05-09 11:00:23 +0000 | [diff] [blame] | 752 | #ifdef HAVE_IPV6 |
| 753 | if (ifp->mtu6 != ifp->mtu) |
| 754 | vty_out (vty, "mtu6 %d ", ifp->mtu6); |
| 755 | #endif |
Paul Jakma | 630c97c | 2006-06-15 12:48:17 +0000 | [diff] [blame] | 756 | vty_out (vty, "%s flags: %s%s", VTY_NEWLINE, |
| 757 | if_flag_dump (ifp->flags), VTY_NEWLINE); |
paul | 3a570c8 | 2006-02-02 17:27:13 +0000 | [diff] [blame] | 758 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 759 | /* Hardware address. */ |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 760 | #ifdef HAVE_STRUCT_SOCKADDR_DL |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 761 | sdl = &ifp->sdl; |
| 762 | if (sdl != NULL && sdl->sdl_alen != 0) |
| 763 | { |
| 764 | int i; |
| 765 | u_char *ptr; |
| 766 | |
| 767 | vty_out (vty, " HWaddr: "); |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 768 | for (i = 0, ptr = (u_char *)LLADDR (sdl); i < sdl->sdl_alen; i++, ptr++) |
| 769 | vty_out (vty, "%s%02x", i == 0 ? "" : ":", *ptr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 770 | vty_out (vty, "%s", VTY_NEWLINE); |
| 771 | } |
| 772 | #else |
| 773 | if (ifp->hw_addr_len != 0) |
| 774 | { |
| 775 | int i; |
| 776 | |
| 777 | vty_out (vty, " HWaddr: "); |
| 778 | for (i = 0; i < ifp->hw_addr_len; i++) |
| 779 | vty_out (vty, "%s%02x", i == 0 ? "" : ":", ifp->hw_addr[i]); |
| 780 | vty_out (vty, "%s", VTY_NEWLINE); |
| 781 | } |
Paul Jakma | 6f0e3f6 | 2007-05-10 02:38:51 +0000 | [diff] [blame] | 782 | #endif /* HAVE_STRUCT_SOCKADDR_DL */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 783 | |
| 784 | /* Bandwidth in kbps */ |
| 785 | if (ifp->bandwidth != 0) |
| 786 | { |
| 787 | vty_out(vty, " bandwidth %u kbps", ifp->bandwidth); |
| 788 | vty_out(vty, "%s", VTY_NEWLINE); |
| 789 | } |
| 790 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 791 | for (rn = route_top (zebra_if->ipv4_subnets); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 792 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 793 | if (! rn->info) |
| 794 | continue; |
| 795 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 796 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected)) |
| 797 | connected_dump_vty (vty, connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | } |
| 799 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 800 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 801 | { |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 802 | if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) && |
| 803 | (connected->address->family == AF_INET6)) |
| 804 | connected_dump_vty (vty, connected); |
| 805 | } |
| 806 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 807 | #ifdef RTADV |
| 808 | nd_dump_vty (vty, ifp); |
| 809 | #endif /* RTADV */ |
| 810 | |
| 811 | #ifdef HAVE_PROC_NET_DEV |
| 812 | /* Statistics print out using proc file system. */ |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 813 | vty_out (vty, " %lu input packets (%lu multicast), %lu bytes, " |
| 814 | "%lu dropped%s", |
| 815 | ifp->stats.rx_packets, ifp->stats.rx_multicast, |
| 816 | ifp->stats.rx_bytes, ifp->stats.rx_dropped, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 818 | vty_out (vty, " %lu input errors, %lu length, %lu overrun," |
hasso | 3452d47 | 2005-03-06 13:42:05 +0000 | [diff] [blame] | 819 | " %lu CRC, %lu frame%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 820 | ifp->stats.rx_errors, ifp->stats.rx_length_errors, |
| 821 | ifp->stats.rx_over_errors, ifp->stats.rx_crc_errors, |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 822 | ifp->stats.rx_frame_errors, VTY_NEWLINE); |
| 823 | |
| 824 | vty_out (vty, " %lu fifo, %lu missed%s", ifp->stats.rx_fifo_errors, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 825 | ifp->stats.rx_missed_errors, VTY_NEWLINE); |
| 826 | |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 827 | vty_out (vty, " %lu output packets, %lu bytes, %lu dropped%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | ifp->stats.tx_packets, ifp->stats.tx_bytes, |
| 829 | ifp->stats.tx_dropped, VTY_NEWLINE); |
| 830 | |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 831 | vty_out (vty, " %lu output errors, %lu aborted, %lu carrier," |
| 832 | " %lu fifo, %lu heartbeat%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 833 | ifp->stats.tx_errors, ifp->stats.tx_aborted_errors, |
| 834 | ifp->stats.tx_carrier_errors, ifp->stats.tx_fifo_errors, |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 835 | ifp->stats.tx_heartbeat_errors, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | |
hasso | 6f2c27a | 2005-01-18 13:44:35 +0000 | [diff] [blame] | 837 | vty_out (vty, " %lu window, %lu collisions%s", |
| 838 | ifp->stats.tx_window_errors, ifp->stats.collisions, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | #endif /* HAVE_PROC_NET_DEV */ |
| 840 | |
| 841 | #ifdef HAVE_NET_RT_IFLIST |
| 842 | #if defined (__bsdi__) || defined (__NetBSD__) |
| 843 | /* Statistics print out using sysctl (). */ |
David Lamparter | 193e78f | 2015-04-21 10:42:30 +0200 | [diff] [blame] | 844 | vty_out (vty, " input packets %llu, bytes %llu, dropped %llu," |
| 845 | " multicast packets %llu%s", |
| 846 | (unsigned long long)ifp->stats.ifi_ipackets, |
| 847 | (unsigned long long)ifp->stats.ifi_ibytes, |
| 848 | (unsigned long long)ifp->stats.ifi_iqdrops, |
| 849 | (unsigned long long)ifp->stats.ifi_imcasts, |
| 850 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | |
David Lamparter | 193e78f | 2015-04-21 10:42:30 +0200 | [diff] [blame] | 852 | vty_out (vty, " input errors %llu%s", |
| 853 | (unsigned long long)ifp->stats.ifi_ierrors, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 854 | |
David Lamparter | 193e78f | 2015-04-21 10:42:30 +0200 | [diff] [blame] | 855 | vty_out (vty, " output packets %llu, bytes %llu," |
| 856 | " multicast packets %llu%s", |
| 857 | (unsigned long long)ifp->stats.ifi_opackets, |
| 858 | (unsigned long long)ifp->stats.ifi_obytes, |
| 859 | (unsigned long long)ifp->stats.ifi_omcasts, |
| 860 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 861 | |
David Lamparter | 193e78f | 2015-04-21 10:42:30 +0200 | [diff] [blame] | 862 | vty_out (vty, " output errors %llu%s", |
| 863 | (unsigned long long)ifp->stats.ifi_oerrors, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 864 | |
David Lamparter | 193e78f | 2015-04-21 10:42:30 +0200 | [diff] [blame] | 865 | vty_out (vty, " collisions %llu%s", |
| 866 | (unsigned long long)ifp->stats.ifi_collisions, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 867 | #else |
| 868 | /* Statistics print out using sysctl (). */ |
| 869 | vty_out (vty, " input packets %lu, bytes %lu, dropped %lu," |
| 870 | " multicast packets %lu%s", |
| 871 | ifp->stats.ifi_ipackets, ifp->stats.ifi_ibytes, |
| 872 | ifp->stats.ifi_iqdrops, ifp->stats.ifi_imcasts, |
| 873 | VTY_NEWLINE); |
| 874 | |
| 875 | vty_out (vty, " input errors %lu%s", |
| 876 | ifp->stats.ifi_ierrors, VTY_NEWLINE); |
| 877 | |
| 878 | vty_out (vty, " output packets %lu, bytes %lu, multicast packets %lu%s", |
| 879 | ifp->stats.ifi_opackets, ifp->stats.ifi_obytes, |
| 880 | ifp->stats.ifi_omcasts, VTY_NEWLINE); |
| 881 | |
| 882 | vty_out (vty, " output errors %lu%s", |
| 883 | ifp->stats.ifi_oerrors, VTY_NEWLINE); |
| 884 | |
| 885 | vty_out (vty, " collisions %lu%s", |
| 886 | ifp->stats.ifi_collisions, VTY_NEWLINE); |
| 887 | #endif /* __bsdi__ || __NetBSD__ */ |
| 888 | #endif /* HAVE_NET_RT_IFLIST */ |
| 889 | } |
| 890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | /* Wrapper hook point for zebra daemon so that ifindex can be set |
| 892 | * DEFUN macro not used as extract.pl HAS to ignore this |
| 893 | * See also interface_cmd in lib/if.c |
| 894 | */ |
| 895 | DEFUN_NOSH (zebra_interface, |
| 896 | zebra_interface_cmd, |
| 897 | "interface IFNAME", |
| 898 | "Select an interface to configure\n" |
| 899 | "Interface's name\n") |
| 900 | { |
| 901 | int ret; |
| 902 | struct interface * ifp; |
| 903 | |
| 904 | /* Call lib interface() */ |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 905 | if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS) |
| 906 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 907 | |
| 908 | ifp = vty->index; |
| 909 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 910 | if (ifp->ifindex == IFINDEX_INTERNAL) |
| 911 | /* Is this really necessary? Shouldn't status be initialized to 0 |
| 912 | in that case? */ |
| 913 | UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 914 | |
| 915 | return ret; |
| 916 | } |
| 917 | |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 918 | ALIAS (zebra_interface, |
| 919 | zebra_interface_vrf_cmd, |
| 920 | "interface IFNAME " VRF_CMD_STR, |
| 921 | "Select an interface to configure\n" |
| 922 | "Interface's name\n" |
| 923 | VRF_CMD_HELP_STR) |
| 924 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | struct cmd_node interface_node = |
| 926 | { |
| 927 | INTERFACE_NODE, |
| 928 | "%s(config-if)# ", |
| 929 | 1 |
| 930 | }; |
| 931 | |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 932 | /* Show all interfaces to vty. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 933 | DEFUN (show_interface, show_interface_cmd, |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 934 | "show interface", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 935 | SHOW_STR |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 936 | "Interface status and configuration\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 937 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 938 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | struct interface *ifp; |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 940 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 941 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 942 | #ifdef HAVE_PROC_NET_DEV |
| 943 | /* If system has interface statistics via proc file system, update |
| 944 | statistics. */ |
| 945 | ifstat_update_proc (); |
| 946 | #endif /* HAVE_PROC_NET_DEV */ |
| 947 | #ifdef HAVE_NET_RT_IFLIST |
| 948 | ifstat_update_sysctl (); |
| 949 | #endif /* HAVE_NET_RT_IFLIST */ |
| 950 | |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 951 | if (argc > 0) |
| 952 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 953 | |
| 954 | /* All interface print. */ |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 955 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 956 | if_dump_vty (vty, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | |
| 958 | return CMD_SUCCESS; |
| 959 | } |
| 960 | |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 961 | ALIAS (show_interface, |
| 962 | show_interface_vrf_cmd, |
| 963 | "show interface " VRF_CMD_STR, |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 964 | SHOW_STR |
| 965 | "Interface status and configuration\n" |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 966 | VRF_CMD_HELP_STR) |
| 967 | |
| 968 | /* Show all interfaces to vty. */ |
| 969 | DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd, |
| 970 | "show interface " VRF_ALL_CMD_STR, |
| 971 | SHOW_STR |
| 972 | "Interface status and configuration\n" |
| 973 | VRF_ALL_CMD_HELP_STR) |
| 974 | { |
| 975 | struct listnode *node; |
| 976 | struct interface *ifp; |
| 977 | vrf_iter_t iter; |
| 978 | |
| 979 | #ifdef HAVE_PROC_NET_DEV |
| 980 | /* If system has interface statistics via proc file system, update |
| 981 | statistics. */ |
| 982 | ifstat_update_proc (); |
| 983 | #endif /* HAVE_PROC_NET_DEV */ |
| 984 | #ifdef HAVE_NET_RT_IFLIST |
| 985 | ifstat_update_sysctl (); |
| 986 | #endif /* HAVE_NET_RT_IFLIST */ |
| 987 | |
| 988 | /* All interface print. */ |
| 989 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 990 | for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp)) |
| 991 | if_dump_vty (vty, ifp); |
| 992 | |
| 993 | return CMD_SUCCESS; |
| 994 | } |
| 995 | |
| 996 | /* Show specified interface to vty. */ |
| 997 | DEFUN (show_interface_name, show_interface_name_cmd, |
| 998 | "show interface IFNAME", |
| 999 | SHOW_STR |
| 1000 | "Interface status and configuration\n" |
| 1001 | "Inteface name\n") |
| 1002 | { |
| 1003 | struct interface *ifp; |
| 1004 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 1005 | |
| 1006 | #ifdef HAVE_PROC_NET_DEV |
| 1007 | /* If system has interface statistics via proc file system, update |
| 1008 | statistics. */ |
| 1009 | ifstat_update_proc (); |
| 1010 | #endif /* HAVE_PROC_NET_DEV */ |
| 1011 | #ifdef HAVE_NET_RT_IFLIST |
| 1012 | ifstat_update_sysctl (); |
| 1013 | #endif /* HAVE_NET_RT_IFLIST */ |
| 1014 | |
| 1015 | if (argc > 1) |
| 1016 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[1]); |
| 1017 | |
| 1018 | /* Specified interface print. */ |
| 1019 | ifp = if_lookup_by_name_vrf (argv[0], vrf_id); |
| 1020 | if (ifp == NULL) |
| 1021 | { |
| 1022 | vty_out (vty, "%% Can't find interface %s%s", argv[0], |
| 1023 | VTY_NEWLINE); |
| 1024 | return CMD_WARNING; |
| 1025 | } |
| 1026 | if_dump_vty (vty, ifp); |
| 1027 | |
| 1028 | return CMD_SUCCESS; |
| 1029 | } |
| 1030 | |
| 1031 | ALIAS (show_interface_name, |
| 1032 | show_interface_name_vrf_cmd, |
| 1033 | "show interface IFNAME " VRF_CMD_STR, |
| 1034 | SHOW_STR |
| 1035 | "Interface status and configuration\n" |
| 1036 | "Inteface name\n" |
| 1037 | VRF_CMD_HELP_STR) |
| 1038 | |
| 1039 | /* Show specified interface to vty. */ |
| 1040 | DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd, |
| 1041 | "show interface IFNAME " VRF_ALL_CMD_STR, |
| 1042 | SHOW_STR |
| 1043 | "Interface status and configuration\n" |
| 1044 | "Inteface name\n" |
| 1045 | VRF_ALL_CMD_HELP_STR) |
| 1046 | { |
| 1047 | struct interface *ifp; |
| 1048 | vrf_iter_t iter; |
| 1049 | int found = 0; |
| 1050 | |
| 1051 | #ifdef HAVE_PROC_NET_DEV |
| 1052 | /* If system has interface statistics via proc file system, update |
| 1053 | statistics. */ |
| 1054 | ifstat_update_proc (); |
| 1055 | #endif /* HAVE_PROC_NET_DEV */ |
| 1056 | #ifdef HAVE_NET_RT_IFLIST |
| 1057 | ifstat_update_sysctl (); |
| 1058 | #endif /* HAVE_NET_RT_IFLIST */ |
| 1059 | |
| 1060 | /* All interface print. */ |
| 1061 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 1062 | { |
| 1063 | /* Specified interface print. */ |
| 1064 | ifp = if_lookup_by_name_vrf (argv[0], vrf_iter2id (iter)); |
| 1065 | if (ifp) |
| 1066 | { |
| 1067 | if_dump_vty (vty, ifp); |
| 1068 | found++; |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | if (!found) |
| 1073 | { |
| 1074 | vty_out (vty, "%% Can't find interface %s%s", argv[0], VTY_NEWLINE); |
| 1075 | return CMD_WARNING; |
| 1076 | } |
| 1077 | |
| 1078 | return CMD_SUCCESS; |
| 1079 | } |
| 1080 | |
| 1081 | static void |
| 1082 | if_show_description (struct vty *vty, vrf_id_t vrf_id) |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 1083 | { |
| 1084 | struct listnode *node; |
| 1085 | struct interface *ifp; |
| 1086 | |
| 1087 | vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE); |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 1088 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 1089 | { |
| 1090 | int len; |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 1091 | |
| 1092 | len = vty_out (vty, "%s", ifp->name); |
| 1093 | vty_out (vty, "%*s", (16 - len), " "); |
| 1094 | |
| 1095 | if (if_is_up(ifp)) |
| 1096 | { |
| 1097 | vty_out (vty, "up "); |
| 1098 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) |
| 1099 | { |
| 1100 | if (if_is_running(ifp)) |
| 1101 | vty_out (vty, "up "); |
| 1102 | else |
| 1103 | vty_out (vty, "down "); |
| 1104 | } |
| 1105 | else |
| 1106 | { |
| 1107 | vty_out (vty, "unknown "); |
| 1108 | } |
| 1109 | } |
| 1110 | else |
| 1111 | { |
| 1112 | vty_out (vty, "down down "); |
| 1113 | } |
| 1114 | |
| 1115 | if (ifp->desc) |
| 1116 | vty_out (vty, "%s", ifp->desc); |
| 1117 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1118 | } |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 1119 | } |
| 1120 | |
| 1121 | DEFUN (show_interface_desc, |
| 1122 | show_interface_desc_cmd, |
| 1123 | "show interface description", |
| 1124 | SHOW_STR |
| 1125 | "Interface status and configuration\n" |
| 1126 | "Interface description\n") |
| 1127 | { |
| 1128 | vrf_id_t vrf_id = VRF_DEFAULT; |
| 1129 | |
| 1130 | if (argc > 0) |
| 1131 | VTY_GET_INTEGER ("VRF ID", vrf_id, argv[0]); |
| 1132 | |
| 1133 | if_show_description (vty, vrf_id); |
| 1134 | |
| 1135 | return CMD_SUCCESS; |
| 1136 | } |
| 1137 | |
| 1138 | ALIAS (show_interface_desc, |
| 1139 | show_interface_desc_vrf_cmd, |
| 1140 | "show interface description " VRF_CMD_STR, |
| 1141 | SHOW_STR |
| 1142 | "Interface status and configuration\n" |
| 1143 | "Interface description\n" |
| 1144 | VRF_CMD_HELP_STR) |
| 1145 | |
| 1146 | DEFUN (show_interface_desc_vrf_all, |
| 1147 | show_interface_desc_vrf_all_cmd, |
| 1148 | "show interface description " VRF_ALL_CMD_STR, |
| 1149 | SHOW_STR |
| 1150 | "Interface status and configuration\n" |
| 1151 | "Interface description\n" |
| 1152 | VRF_ALL_CMD_HELP_STR) |
| 1153 | { |
| 1154 | vrf_iter_t iter; |
| 1155 | |
| 1156 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 1157 | if (!list_isempty (vrf_iter2iflist (iter))) |
| 1158 | { |
| 1159 | vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE, |
| 1160 | vrf_iter2id (iter), |
| 1161 | VTY_NEWLINE, VTY_NEWLINE); |
| 1162 | if_show_description (vty, vrf_iter2id (iter)); |
| 1163 | } |
| 1164 | |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 1165 | return CMD_SUCCESS; |
| 1166 | } |
| 1167 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | DEFUN (multicast, |
| 1169 | multicast_cmd, |
| 1170 | "multicast", |
| 1171 | "Set multicast flag to interface\n") |
| 1172 | { |
| 1173 | int ret; |
| 1174 | struct interface *ifp; |
| 1175 | struct zebra_if *if_data; |
| 1176 | |
| 1177 | ifp = (struct interface *) vty->index; |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 1178 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1179 | { |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 1180 | ret = if_set_flags (ifp, IFF_MULTICAST); |
| 1181 | if (ret < 0) |
| 1182 | { |
| 1183 | vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE); |
| 1184 | return CMD_WARNING; |
| 1185 | } |
| 1186 | if_refresh (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1187 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1188 | if_data = ifp->info; |
| 1189 | if_data->multicast = IF_ZEBRA_MULTICAST_ON; |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 1190 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1191 | return CMD_SUCCESS; |
| 1192 | } |
| 1193 | |
| 1194 | DEFUN (no_multicast, |
| 1195 | no_multicast_cmd, |
| 1196 | "no multicast", |
| 1197 | NO_STR |
| 1198 | "Unset multicast flag to interface\n") |
| 1199 | { |
| 1200 | int ret; |
| 1201 | struct interface *ifp; |
| 1202 | struct zebra_if *if_data; |
| 1203 | |
| 1204 | ifp = (struct interface *) vty->index; |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 1205 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1206 | { |
paul | 48b33aa | 2002-12-13 20:52:52 +0000 | [diff] [blame] | 1207 | ret = if_unset_flags (ifp, IFF_MULTICAST); |
| 1208 | if (ret < 0) |
| 1209 | { |
| 1210 | vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE); |
| 1211 | return CMD_WARNING; |
| 1212 | } |
| 1213 | if_refresh (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1215 | if_data = ifp->info; |
| 1216 | if_data->multicast = IF_ZEBRA_MULTICAST_OFF; |
| 1217 | |
| 1218 | return CMD_SUCCESS; |
| 1219 | } |
| 1220 | |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1221 | DEFUN (linkdetect, |
| 1222 | linkdetect_cmd, |
| 1223 | "link-detect", |
| 1224 | "Enable link detection on interface\n") |
| 1225 | { |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1226 | struct interface *ifp; |
| 1227 | int if_was_operative; |
| 1228 | |
| 1229 | ifp = (struct interface *) vty->index; |
| 1230 | if_was_operative = if_is_operative(ifp); |
| 1231 | SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
| 1232 | |
| 1233 | /* When linkdetection is enabled, if might come down */ |
| 1234 | if (!if_is_operative(ifp) && if_was_operative) if_down(ifp); |
| 1235 | |
| 1236 | /* FIXME: Will defer status change forwarding if interface |
| 1237 | does not come down! */ |
| 1238 | |
| 1239 | return CMD_SUCCESS; |
| 1240 | } |
| 1241 | |
| 1242 | |
| 1243 | DEFUN (no_linkdetect, |
| 1244 | no_linkdetect_cmd, |
| 1245 | "no link-detect", |
| 1246 | NO_STR |
| 1247 | "Disable link detection on interface\n") |
| 1248 | { |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1249 | struct interface *ifp; |
| 1250 | int if_was_operative; |
| 1251 | |
| 1252 | ifp = (struct interface *) vty->index; |
| 1253 | if_was_operative = if_is_operative(ifp); |
| 1254 | UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
| 1255 | |
| 1256 | /* Interface may come up after disabling link detection */ |
| 1257 | if (if_is_operative(ifp) && !if_was_operative) if_up(ifp); |
| 1258 | |
| 1259 | /* FIXME: see linkdetect_cmd */ |
| 1260 | |
| 1261 | return CMD_SUCCESS; |
| 1262 | } |
| 1263 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1264 | DEFUN (shutdown_if, |
| 1265 | shutdown_if_cmd, |
| 1266 | "shutdown", |
| 1267 | "Shutdown the selected interface\n") |
| 1268 | { |
| 1269 | int ret; |
| 1270 | struct interface *ifp; |
| 1271 | struct zebra_if *if_data; |
| 1272 | |
| 1273 | ifp = (struct interface *) vty->index; |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1274 | if (ifp->ifindex != IFINDEX_INTERNAL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1275 | { |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1276 | ret = if_unset_flags (ifp, IFF_UP); |
| 1277 | if (ret < 0) |
| 1278 | { |
| 1279 | vty_out (vty, "Can't shutdown interface%s", VTY_NEWLINE); |
| 1280 | return CMD_WARNING; |
| 1281 | } |
| 1282 | if_refresh (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1283 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1284 | if_data = ifp->info; |
| 1285 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_ON; |
| 1286 | |
| 1287 | return CMD_SUCCESS; |
| 1288 | } |
| 1289 | |
| 1290 | DEFUN (no_shutdown_if, |
| 1291 | no_shutdown_if_cmd, |
| 1292 | "no shutdown", |
| 1293 | NO_STR |
| 1294 | "Shutdown the selected interface\n") |
| 1295 | { |
| 1296 | int ret; |
| 1297 | struct interface *ifp; |
| 1298 | struct zebra_if *if_data; |
| 1299 | |
| 1300 | ifp = (struct interface *) vty->index; |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1301 | |
| 1302 | if (ifp->ifindex != IFINDEX_INTERNAL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1303 | { |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1304 | ret = if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
| 1305 | if (ret < 0) |
| 1306 | { |
| 1307 | vty_out (vty, "Can't up interface%s", VTY_NEWLINE); |
| 1308 | return CMD_WARNING; |
| 1309 | } |
| 1310 | if_refresh (ifp); |
| 1311 | |
| 1312 | /* Some addresses (in particular, IPv6 addresses on Linux) get |
| 1313 | * removed when the interface goes down. They need to be readded. |
| 1314 | */ |
| 1315 | if_addr_wakeup(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1316 | } |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1317 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1318 | if_data = ifp->info; |
| 1319 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_OFF; |
| 1320 | |
| 1321 | return CMD_SUCCESS; |
| 1322 | } |
| 1323 | |
| 1324 | DEFUN (bandwidth_if, |
| 1325 | bandwidth_if_cmd, |
| 1326 | "bandwidth <1-10000000>", |
| 1327 | "Set bandwidth informational parameter\n" |
| 1328 | "Bandwidth in kilobits\n") |
| 1329 | { |
| 1330 | struct interface *ifp; |
| 1331 | unsigned int bandwidth; |
| 1332 | |
| 1333 | ifp = (struct interface *) vty->index; |
| 1334 | bandwidth = strtol(argv[0], NULL, 10); |
| 1335 | |
| 1336 | /* bandwidth range is <1-10000000> */ |
| 1337 | if (bandwidth < 1 || bandwidth > 10000000) |
| 1338 | { |
| 1339 | vty_out (vty, "Bandwidth is invalid%s", VTY_NEWLINE); |
| 1340 | return CMD_WARNING; |
| 1341 | } |
| 1342 | |
| 1343 | ifp->bandwidth = bandwidth; |
| 1344 | |
| 1345 | /* force protocols to recalculate routes due to cost change */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1346 | if (if_is_operative (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1347 | zebra_interface_up_update (ifp); |
| 1348 | |
| 1349 | return CMD_SUCCESS; |
| 1350 | } |
| 1351 | |
| 1352 | DEFUN (no_bandwidth_if, |
| 1353 | no_bandwidth_if_cmd, |
| 1354 | "no bandwidth", |
| 1355 | NO_STR |
| 1356 | "Set bandwidth informational parameter\n") |
| 1357 | { |
| 1358 | struct interface *ifp; |
| 1359 | |
| 1360 | ifp = (struct interface *) vty->index; |
| 1361 | |
| 1362 | ifp->bandwidth = 0; |
| 1363 | |
| 1364 | /* force protocols to recalculate routes due to cost change */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1365 | if (if_is_operative (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | zebra_interface_up_update (ifp); |
| 1367 | |
| 1368 | return CMD_SUCCESS; |
| 1369 | } |
| 1370 | |
| 1371 | ALIAS (no_bandwidth_if, |
| 1372 | no_bandwidth_if_val_cmd, |
| 1373 | "no bandwidth <1-10000000>", |
| 1374 | NO_STR |
| 1375 | "Set bandwidth informational parameter\n" |
| 1376 | "Bandwidth in kilobits\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1377 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1378 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1379 | ip_address_install (struct vty *vty, struct interface *ifp, |
| 1380 | const char *addr_str, const char *peer_str, |
| 1381 | const char *label) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1382 | { |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1383 | struct zebra_if *if_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1384 | struct prefix_ipv4 cp; |
| 1385 | struct connected *ifc; |
| 1386 | struct prefix_ipv4 *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1387 | int ret; |
| 1388 | |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1389 | if_data = ifp->info; |
| 1390 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1391 | ret = str2prefix_ipv4 (addr_str, &cp); |
| 1392 | if (ret <= 0) |
| 1393 | { |
| 1394 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1395 | return CMD_WARNING; |
| 1396 | } |
| 1397 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 1398 | ifc = connected_check (ifp, (struct prefix *) &cp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1399 | if (! ifc) |
| 1400 | { |
| 1401 | ifc = connected_new (); |
| 1402 | ifc->ifp = ifp; |
| 1403 | |
| 1404 | /* Address. */ |
| 1405 | p = prefix_ipv4_new (); |
| 1406 | *p = cp; |
| 1407 | ifc->address = (struct prefix *) p; |
| 1408 | |
| 1409 | /* Broadcast. */ |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 1410 | if (p->prefixlen <= IPV4_MAX_PREFIXLEN-2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1411 | { |
| 1412 | p = prefix_ipv4_new (); |
| 1413 | *p = cp; |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 1414 | p->prefix.s_addr = ipv4_broadcast_addr(p->prefix.s_addr,p->prefixlen); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1415 | ifc->destination = (struct prefix *) p; |
| 1416 | } |
| 1417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | /* Label. */ |
| 1419 | if (label) |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 1420 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1421 | |
| 1422 | /* Add to linked list. */ |
| 1423 | listnode_add (ifp->connected, ifc); |
| 1424 | } |
| 1425 | |
| 1426 | /* This address is configured from zebra. */ |
| 1427 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 1428 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 1429 | |
| 1430 | /* In case of this route need to install kernel. */ |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1431 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1432 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
| 1433 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1434 | { |
| 1435 | /* Some system need to up the interface to set IP address. */ |
| 1436 | if (! if_is_up (ifp)) |
| 1437 | { |
| 1438 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
| 1439 | if_refresh (ifp); |
| 1440 | } |
| 1441 | |
| 1442 | ret = if_set_prefix (ifp, ifc); |
| 1443 | if (ret < 0) |
| 1444 | { |
| 1445 | vty_out (vty, "%% Can't set interface IP address: %s.%s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 1446 | safe_strerror(errno), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1447 | return CMD_WARNING; |
| 1448 | } |
| 1449 | |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1450 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 1451 | /* The address will be advertised to zebra clients when the notification |
| 1452 | * from the kernel has been received. |
| 1453 | * It will also be added to the subnet chain list, then. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | return CMD_SUCCESS; |
| 1457 | } |
| 1458 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1459 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1460 | ip_address_uninstall (struct vty *vty, struct interface *ifp, |
| 1461 | const char *addr_str, const char *peer_str, |
| 1462 | const char *label) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1463 | { |
| 1464 | struct prefix_ipv4 cp; |
| 1465 | struct connected *ifc; |
| 1466 | int ret; |
| 1467 | |
| 1468 | /* Convert to prefix structure. */ |
| 1469 | ret = str2prefix_ipv4 (addr_str, &cp); |
| 1470 | if (ret <= 0) |
| 1471 | { |
| 1472 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1473 | return CMD_WARNING; |
| 1474 | } |
| 1475 | |
| 1476 | /* Check current interface address. */ |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 1477 | ifc = connected_check (ifp, (struct prefix *) &cp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1478 | if (! ifc) |
| 1479 | { |
| 1480 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); |
| 1481 | return CMD_WARNING; |
| 1482 | } |
| 1483 | |
| 1484 | /* This is not configured address. */ |
| 1485 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 1486 | return CMD_WARNING; |
| 1487 | |
Paul Jakma | 74ecdc9 | 2006-06-15 18:10:47 +0000 | [diff] [blame] | 1488 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 1489 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1490 | /* This is not real address or interface is not active. */ |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1491 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1492 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
| 1493 | { |
| 1494 | listnode_delete (ifp->connected, ifc); |
| 1495 | connected_free (ifc); |
| 1496 | return CMD_WARNING; |
| 1497 | } |
| 1498 | |
| 1499 | /* This is real route. */ |
| 1500 | ret = if_unset_prefix (ifp, ifc); |
| 1501 | if (ret < 0) |
| 1502 | { |
| 1503 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 1504 | safe_strerror(errno), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1505 | return CMD_WARNING; |
| 1506 | } |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1507 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 1508 | /* we will receive a kernel notification about this route being removed. |
| 1509 | * this will trigger its removal from the connected list. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1510 | return CMD_SUCCESS; |
| 1511 | } |
| 1512 | |
| 1513 | DEFUN (ip_address, |
| 1514 | ip_address_cmd, |
| 1515 | "ip address A.B.C.D/M", |
| 1516 | "Interface Internet Protocol config commands\n" |
| 1517 | "Set the IP address of an interface\n" |
| 1518 | "IP address (e.g. 10.0.0.1/8)\n") |
| 1519 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 1520 | return ip_address_install (vty, vty->index, argv[0], NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | DEFUN (no_ip_address, |
| 1524 | no_ip_address_cmd, |
| 1525 | "no ip address A.B.C.D/M", |
| 1526 | NO_STR |
| 1527 | "Interface Internet Protocol config commands\n" |
| 1528 | "Set the IP address of an interface\n" |
| 1529 | "IP Address (e.g. 10.0.0.1/8)") |
| 1530 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 1531 | return ip_address_uninstall (vty, vty->index, argv[0], NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1532 | } |
| 1533 | |
| 1534 | #ifdef HAVE_NETLINK |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1535 | DEFUN (ip_address_label, |
| 1536 | ip_address_label_cmd, |
| 1537 | "ip address A.B.C.D/M label LINE", |
| 1538 | "Interface Internet Protocol config commands\n" |
| 1539 | "Set the IP address of an interface\n" |
| 1540 | "IP address (e.g. 10.0.0.1/8)\n" |
| 1541 | "Label of this address\n" |
| 1542 | "Label\n") |
| 1543 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 1544 | return ip_address_install (vty, vty->index, argv[0], NULL, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | DEFUN (no_ip_address_label, |
| 1548 | no_ip_address_label_cmd, |
| 1549 | "no ip address A.B.C.D/M label LINE", |
| 1550 | NO_STR |
| 1551 | "Interface Internet Protocol config commands\n" |
| 1552 | "Set the IP address of an interface\n" |
| 1553 | "IP address (e.g. 10.0.0.1/8)\n" |
| 1554 | "Label of this address\n" |
| 1555 | "Label\n") |
| 1556 | { |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 1557 | return ip_address_uninstall (vty, vty->index, argv[0], NULL, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1558 | } |
| 1559 | #endif /* HAVE_NETLINK */ |
| 1560 | |
| 1561 | #ifdef HAVE_IPV6 |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1562 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1563 | ipv6_address_install (struct vty *vty, struct interface *ifp, |
| 1564 | const char *addr_str, const char *peer_str, |
| 1565 | const char *label, int secondary) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1566 | { |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1567 | struct zebra_if *if_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1568 | struct prefix_ipv6 cp; |
| 1569 | struct connected *ifc; |
| 1570 | struct prefix_ipv6 *p; |
| 1571 | int ret; |
| 1572 | |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1573 | if_data = ifp->info; |
| 1574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1575 | ret = str2prefix_ipv6 (addr_str, &cp); |
| 1576 | if (ret <= 0) |
| 1577 | { |
| 1578 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1579 | return CMD_WARNING; |
| 1580 | } |
| 1581 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 1582 | ifc = connected_check (ifp, (struct prefix *) &cp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1583 | if (! ifc) |
| 1584 | { |
| 1585 | ifc = connected_new (); |
| 1586 | ifc->ifp = ifp; |
| 1587 | |
| 1588 | /* Address. */ |
| 1589 | p = prefix_ipv6_new (); |
| 1590 | *p = cp; |
| 1591 | ifc->address = (struct prefix *) p; |
| 1592 | |
| 1593 | /* Secondary. */ |
| 1594 | if (secondary) |
| 1595 | SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); |
| 1596 | |
| 1597 | /* Label. */ |
| 1598 | if (label) |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 1599 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1600 | |
| 1601 | /* Add to linked list. */ |
| 1602 | listnode_add (ifp->connected, ifc); |
| 1603 | } |
| 1604 | |
| 1605 | /* This address is configured from zebra. */ |
| 1606 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 1607 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 1608 | |
| 1609 | /* In case of this route need to install kernel. */ |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1610 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1611 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
| 1612 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | { |
| 1614 | /* Some system need to up the interface to set IP address. */ |
| 1615 | if (! if_is_up (ifp)) |
| 1616 | { |
| 1617 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
| 1618 | if_refresh (ifp); |
| 1619 | } |
| 1620 | |
| 1621 | ret = if_prefix_add_ipv6 (ifp, ifc); |
| 1622 | |
| 1623 | if (ret < 0) |
| 1624 | { |
| 1625 | vty_out (vty, "%% Can't set interface IP address: %s.%s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 1626 | safe_strerror(errno), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1627 | return CMD_WARNING; |
| 1628 | } |
| 1629 | |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1630 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 1631 | /* The address will be advertised to zebra clients when the notification |
| 1632 | * from the kernel has been received. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | return CMD_SUCCESS; |
| 1636 | } |
| 1637 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1638 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1639 | ipv6_address_uninstall (struct vty *vty, struct interface *ifp, |
| 1640 | const char *addr_str, const char *peer_str, |
| 1641 | const char *label, int secondry) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1642 | { |
| 1643 | struct prefix_ipv6 cp; |
| 1644 | struct connected *ifc; |
| 1645 | int ret; |
| 1646 | |
| 1647 | /* Convert to prefix structure. */ |
| 1648 | ret = str2prefix_ipv6 (addr_str, &cp); |
| 1649 | if (ret <= 0) |
| 1650 | { |
| 1651 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); |
| 1652 | return CMD_WARNING; |
| 1653 | } |
| 1654 | |
| 1655 | /* Check current interface address. */ |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 1656 | ifc = connected_check (ifp, (struct prefix *) &cp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1657 | if (! ifc) |
| 1658 | { |
| 1659 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); |
| 1660 | return CMD_WARNING; |
| 1661 | } |
| 1662 | |
| 1663 | /* This is not configured address. */ |
| 1664 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 1665 | return CMD_WARNING; |
| 1666 | |
Christian Franke | 676e1a0 | 2013-01-24 14:04:45 +0000 | [diff] [blame] | 1667 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 1668 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1669 | /* This is not real address or interface is not active. */ |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1670 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1671 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
| 1672 | { |
| 1673 | listnode_delete (ifp->connected, ifc); |
| 1674 | connected_free (ifc); |
| 1675 | return CMD_WARNING; |
| 1676 | } |
| 1677 | |
| 1678 | /* This is real route. */ |
| 1679 | ret = if_prefix_delete_ipv6 (ifp, ifc); |
| 1680 | if (ret < 0) |
| 1681 | { |
| 1682 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 1683 | safe_strerror(errno), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1684 | return CMD_WARNING; |
| 1685 | } |
| 1686 | |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 1687 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
Christian Franke | 02b4805 | 2013-01-24 14:04:49 +0000 | [diff] [blame] | 1688 | /* This information will be propagated to the zclients when the |
| 1689 | * kernel notification is received. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1690 | return CMD_SUCCESS; |
| 1691 | } |
| 1692 | |
| 1693 | DEFUN (ipv6_address, |
| 1694 | ipv6_address_cmd, |
| 1695 | "ipv6 address X:X::X:X/M", |
hasso | e23949c | 2004-03-11 15:54:02 +0000 | [diff] [blame] | 1696 | "Interface IPv6 config commands\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1697 | "Set the IP address of an interface\n" |
| 1698 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 1699 | { |
| 1700 | return ipv6_address_install (vty, vty->index, argv[0], NULL, NULL, 0); |
| 1701 | } |
| 1702 | |
| 1703 | DEFUN (no_ipv6_address, |
| 1704 | no_ipv6_address_cmd, |
| 1705 | "no ipv6 address X:X::X:X/M", |
| 1706 | NO_STR |
hasso | e23949c | 2004-03-11 15:54:02 +0000 | [diff] [blame] | 1707 | "Interface IPv6 config commands\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1708 | "Set the IP address of an interface\n" |
| 1709 | "IPv6 address (e.g. 3ffe:506::1/48)\n") |
| 1710 | { |
| 1711 | return ipv6_address_uninstall (vty, vty->index, argv[0], NULL, NULL, 0); |
| 1712 | } |
| 1713 | #endif /* HAVE_IPV6 */ |
| 1714 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1715 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1716 | if_config_write (struct vty *vty) |
| 1717 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1718 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1719 | struct interface *ifp; |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1720 | vrf_iter_t iter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1722 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 1723 | for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1724 | { |
| 1725 | struct zebra_if *if_data; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1726 | struct listnode *addrnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1727 | struct connected *ifc; |
| 1728 | struct prefix *p; |
| 1729 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1730 | if_data = ifp->info; |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1731 | |
| 1732 | if (ifp->vrf_id == VRF_DEFAULT) |
| 1733 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); |
| 1734 | else |
| 1735 | vty_out (vty, "interface %s vrf %u%s", ifp->name, ifp->vrf_id, |
| 1736 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1737 | |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 1738 | if (if_data) |
| 1739 | { |
| 1740 | if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) |
| 1741 | vty_out (vty, " shutdown%s", VTY_NEWLINE); |
| 1742 | } |
| 1743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1744 | if (ifp->desc) |
| 1745 | vty_out (vty, " description %s%s", ifp->desc, |
| 1746 | VTY_NEWLINE); |
| 1747 | |
| 1748 | /* Assign bandwidth here to avoid unnecessary interface flap |
| 1749 | while processing config script */ |
| 1750 | if (ifp->bandwidth != 0) |
| 1751 | vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE); |
| 1752 | |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1753 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) |
| 1754 | vty_out(vty, " link-detect%s", VTY_NEWLINE); |
David Lamparter | 4c42121 | 2015-03-02 06:42:11 +0100 | [diff] [blame] | 1755 | else |
| 1756 | vty_out(vty, " no link-detect%s", VTY_NEWLINE); |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1757 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1758 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1759 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1760 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 1761 | { |
Stephen Hemminger | 81cce01 | 2009-04-28 14:28:00 -0700 | [diff] [blame] | 1762 | char buf[INET6_ADDRSTRLEN]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1763 | p = ifc->address; |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 1764 | vty_out (vty, " ip%s address %s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1765 | p->family == AF_INET ? "" : "v6", |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 1766 | prefix2str (p, buf, sizeof(buf))); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1767 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1768 | if (ifc->label) |
| 1769 | vty_out (vty, " label %s", ifc->label); |
| 1770 | |
| 1771 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1772 | } |
| 1773 | } |
| 1774 | |
| 1775 | if (if_data) |
| 1776 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1777 | if (if_data->multicast != IF_ZEBRA_MULTICAST_UNSPEC) |
| 1778 | vty_out (vty, " %smulticast%s", |
| 1779 | if_data->multicast == IF_ZEBRA_MULTICAST_ON ? "" : "no ", |
| 1780 | VTY_NEWLINE); |
| 1781 | } |
| 1782 | |
| 1783 | #ifdef RTADV |
| 1784 | rtadv_config_write (vty, ifp); |
| 1785 | #endif /* RTADV */ |
| 1786 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 1787 | #ifdef HAVE_IRDP |
| 1788 | irdp_config_write (vty, ifp); |
| 1789 | #endif /* IRDP */ |
| 1790 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 1792 | } |
| 1793 | return 0; |
| 1794 | } |
| 1795 | |
| 1796 | /* Allocate and initialize interface vector. */ |
| 1797 | void |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1798 | zebra_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1799 | { |
| 1800 | /* Initialize interface and new hook. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | if_add_hook (IF_NEW_HOOK, if_zebra_new_hook); |
| 1802 | if_add_hook (IF_DELETE_HOOK, if_zebra_delete_hook); |
| 1803 | |
| 1804 | /* Install configuration write function. */ |
| 1805 | install_node (&interface_node, if_config_write); |
| 1806 | |
| 1807 | install_element (VIEW_NODE, &show_interface_cmd); |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 1808 | install_element (VIEW_NODE, &show_interface_vrf_cmd); |
| 1809 | install_element (VIEW_NODE, &show_interface_vrf_all_cmd); |
| 1810 | install_element (VIEW_NODE, &show_interface_name_cmd); |
| 1811 | install_element (VIEW_NODE, &show_interface_name_vrf_cmd); |
| 1812 | install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1813 | install_element (ENABLE_NODE, &show_interface_cmd); |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 1814 | install_element (ENABLE_NODE, &show_interface_vrf_cmd); |
| 1815 | install_element (ENABLE_NODE, &show_interface_vrf_all_cmd); |
| 1816 | install_element (ENABLE_NODE, &show_interface_name_cmd); |
| 1817 | install_element (ENABLE_NODE, &show_interface_name_vrf_cmd); |
| 1818 | install_element (ENABLE_NODE, &show_interface_name_vrf_all_cmd); |
hasso | ed9bb6d | 2005-03-13 19:17:21 +0000 | [diff] [blame] | 1819 | install_element (ENABLE_NODE, &show_interface_desc_cmd); |
Feng Lu | a285477 | 2015-05-22 11:40:01 +0200 | [diff] [blame^] | 1820 | install_element (ENABLE_NODE, &show_interface_desc_vrf_cmd); |
| 1821 | install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | install_element (CONFIG_NODE, &zebra_interface_cmd); |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1823 | install_element (CONFIG_NODE, &zebra_interface_vrf_cmd); |
paul | bfc1353 | 2003-05-24 06:40:04 +0000 | [diff] [blame] | 1824 | install_element (CONFIG_NODE, &no_interface_cmd); |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 1825 | install_element (CONFIG_NODE, &no_interface_vrf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1826 | install_default (INTERFACE_NODE); |
| 1827 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1828 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1829 | install_element (INTERFACE_NODE, &multicast_cmd); |
| 1830 | install_element (INTERFACE_NODE, &no_multicast_cmd); |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 1831 | install_element (INTERFACE_NODE, &linkdetect_cmd); |
| 1832 | install_element (INTERFACE_NODE, &no_linkdetect_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1833 | install_element (INTERFACE_NODE, &shutdown_if_cmd); |
| 1834 | install_element (INTERFACE_NODE, &no_shutdown_if_cmd); |
| 1835 | install_element (INTERFACE_NODE, &bandwidth_if_cmd); |
| 1836 | install_element (INTERFACE_NODE, &no_bandwidth_if_cmd); |
| 1837 | install_element (INTERFACE_NODE, &no_bandwidth_if_val_cmd); |
| 1838 | install_element (INTERFACE_NODE, &ip_address_cmd); |
| 1839 | install_element (INTERFACE_NODE, &no_ip_address_cmd); |
| 1840 | #ifdef HAVE_IPV6 |
| 1841 | install_element (INTERFACE_NODE, &ipv6_address_cmd); |
| 1842 | install_element (INTERFACE_NODE, &no_ipv6_address_cmd); |
| 1843 | #endif /* HAVE_IPV6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1844 | #ifdef HAVE_NETLINK |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1845 | install_element (INTERFACE_NODE, &ip_address_label_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1846 | install_element (INTERFACE_NODE, &no_ip_address_label_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1847 | #endif /* HAVE_NETLINK */ |
| 1848 | } |