]>
Commit | Line | Data |
---|---|---|
718e3744 | 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" | |
4a1ab8e4 | 31 | #include "zebra_memory.h" |
718e3744 | 32 | #include "ioctl.h" |
33 | #include "connected.h" | |
34 | #include "log.h" | |
35 | #include "zclient.h" | |
cd2a8a42 | 36 | #include "vrf.h" |
718e3744 | 37 | |
718e3744 | 38 | #include "zebra/rtadv.h" |
7c551956 | 39 | #include "zebra_ns.h" |
c1c747a8 | 40 | #include "zebra_vrf.h" |
7c551956 | 41 | #include "zebra/interface.h" |
718e3744 | 42 | #include "zebra/rib.h" |
6b8a5694 | 43 | #include "zebra/rt.h" |
718e3744 | 44 | #include "zebra/zserv.h" |
45 | #include "zebra/redistribute.h" | |
46 | #include "zebra/debug.h" | |
ca776988 | 47 | #include "zebra/irdp.h" |
244c1cdc | 48 | #include "zebra/zebra_ptm.h" |
5c610faf | 49 | #include "zebra/rt_netlink.h" |
88177fe3 | 50 | #include "zebra/interface.h" |
244c1cdc DS |
51 | |
52 | #define ZEBRA_PTM_SUPPORT | |
718e3744 | 53 | |
8da4e946 | 54 | #if defined (HAVE_RTADV) |
b60668d0 CC |
55 | /* Order is intentional. Matches RFC4191. This array is also used for |
56 | command matching, so only modify with care. */ | |
57 | const char *rtadv_pref_strs[] = { "medium", "high", "INVALID", "low", 0 }; | |
8da4e946 | 58 | #endif /* HAVE_RTADV */ |
718e3744 | 59 | |
c8e264b6 | 60 | static void if_down_del_nbr_connected (struct interface *ifp); |
61 | ||
718e3744 | 62 | /* Called when new interface is added. */ |
a1ac18c4 | 63 | static int |
718e3744 | 64 | if_zebra_new_hook (struct interface *ifp) |
65 | { | |
66 | struct zebra_if *zebra_if; | |
67 | ||
393deb9b | 68 | zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if)); |
718e3744 | 69 | |
70 | zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC; | |
bfac8dcd | 71 | zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_OFF; |
986aa00f | 72 | zebra_ptm_if_init(zebra_if); |
718e3744 | 73 | |
c8ed14dd | 74 | ifp->ptm_enable = zebra_ptm_get_enable_state(); |
8da4e946 | 75 | #if defined (HAVE_RTADV) |
718e3744 | 76 | { |
77 | /* Set default router advertise values. */ | |
78 | struct rtadvconf *rtadv; | |
79 | ||
80 | rtadv = &zebra_if->rtadv; | |
81 | ||
82 | rtadv->AdvSendAdvertisements = 0; | |
83 | rtadv->MaxRtrAdvInterval = RTADV_MAX_RTR_ADV_INTERVAL; | |
84 | rtadv->MinRtrAdvInterval = RTADV_MIN_RTR_ADV_INTERVAL; | |
85 | rtadv->AdvIntervalTimer = 0; | |
86 | rtadv->AdvManagedFlag = 0; | |
87 | rtadv->AdvOtherConfigFlag = 0; | |
7cee1bb1 | 88 | rtadv->AdvHomeAgentFlag = 0; |
718e3744 | 89 | rtadv->AdvLinkMTU = 0; |
90 | rtadv->AdvReachableTime = 0; | |
91 | rtadv->AdvRetransTimer = 0; | |
92 | rtadv->AdvCurHopLimit = 0; | |
d660f698 | 93 | rtadv->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */ |
7cee1bb1 | 94 | rtadv->HomeAgentPreference = 0; |
d660f698 | 95 | rtadv->HomeAgentLifetime = -1; /* derive from AdvDefaultLifetime */ |
7cee1bb1 | 96 | rtadv->AdvIntervalOption = 0; |
b60668d0 | 97 | rtadv->DefaultPreference = RTADV_PREF_MEDIUM; |
718e3744 | 98 | |
99 | rtadv->AdvPrefixList = list_new (); | |
100 | } | |
8da4e946 | 101 | #endif /* HAVE_RTADV */ |
718e3744 | 102 | |
eef1fe11 | 103 | /* Initialize installed address chains tree. */ |
104 | zebra_if->ipv4_subnets = route_table_init (); | |
105 | ||
718e3744 | 106 | ifp->info = zebra_if; |
a3d21ef3 DS |
107 | |
108 | zebra_vrf_static_route_interface_fixup (ifp); | |
718e3744 | 109 | return 0; |
110 | } | |
111 | ||
112 | /* Called when interface is deleted. */ | |
a1ac18c4 | 113 | static int |
718e3744 | 114 | if_zebra_delete_hook (struct interface *ifp) |
115 | { | |
eef1fe11 | 116 | struct zebra_if *zebra_if; |
117 | ||
718e3744 | 118 | if (ifp->info) |
eef1fe11 | 119 | { |
120 | zebra_if = ifp->info; | |
121 | ||
122 | /* Free installed address chains tree. */ | |
123 | if (zebra_if->ipv4_subnets) | |
124 | route_table_finish (zebra_if->ipv4_subnets); | |
3f6d6a5d DS |
125 | #if defined (HAVE_RTADV) |
126 | ||
127 | struct rtadvconf *rtadv; | |
128 | ||
129 | rtadv = &zebra_if->rtadv; | |
130 | list_free (rtadv->AdvPrefixList); | |
131 | #endif /* HAVE_RTADV */ | |
eef1fe11 | 132 | |
133 | XFREE (MTYPE_TMP, zebra_if); | |
134 | } | |
135 | ||
136 | return 0; | |
137 | } | |
138 | ||
12f6fb97 DS |
139 | /* Build the table key */ |
140 | static void | |
141 | if_build_key (u_int32_t ifindex, struct prefix *p) | |
142 | { | |
143 | p->family = AF_INET; | |
144 | p->prefixlen = IPV4_MAX_BITLEN; | |
145 | p->u.prefix4.s_addr = ifindex; | |
146 | } | |
147 | ||
148 | /* Link an interface in a per NS interface tree */ | |
149 | struct interface * | |
150 | if_link_per_ns (struct zebra_ns *ns, struct interface *ifp) | |
151 | { | |
152 | struct prefix p; | |
153 | struct route_node *rn; | |
154 | ||
155 | if (ifp->ifindex == IFINDEX_INTERNAL) | |
156 | return NULL; | |
157 | ||
158 | if_build_key (ifp->ifindex, &p); | |
159 | rn = route_node_get (ns->if_table, &p); | |
160 | if (rn->info) | |
161 | { | |
162 | ifp = (struct interface *)rn->info; | |
163 | route_unlock_node (rn); /* get */ | |
164 | return ifp; | |
165 | } | |
166 | ||
167 | rn->info = ifp; | |
168 | ifp->node = rn; | |
169 | ||
170 | return ifp; | |
171 | } | |
172 | ||
173 | /* Delete a VRF. This is called in vrf_terminate(). */ | |
174 | void | |
175 | if_unlink_per_ns (struct interface *ifp) | |
176 | { | |
177 | ifp->node->info = NULL; | |
178 | route_unlock_node(ifp->node); | |
179 | } | |
180 | ||
181 | /* Look up an interface by identifier within a NS */ | |
182 | struct interface * | |
183 | if_lookup_by_index_per_ns (struct zebra_ns *ns, u_int32_t ifindex) | |
184 | { | |
185 | struct prefix p; | |
186 | struct route_node *rn; | |
187 | struct interface *ifp = NULL; | |
188 | ||
189 | if_build_key (ifindex, &p); | |
190 | rn = route_node_lookup (ns->if_table, &p); | |
191 | if (rn) | |
192 | { | |
193 | ifp = (struct interface *)rn->info; | |
194 | route_unlock_node (rn); /* lookup */ | |
195 | } | |
196 | return ifp; | |
197 | } | |
198 | ||
a815b788 | 199 | const char * |
200 | ifindex2ifname_per_ns (struct zebra_ns *zns, unsigned int ifindex) | |
201 | { | |
202 | struct interface *ifp; | |
203 | ||
204 | return ((ifp = if_lookup_by_index_per_ns (zns, ifindex)) != NULL) ? | |
205 | ifp->name : "unknown"; | |
206 | } | |
12f6fb97 | 207 | |
eef1fe11 | 208 | /* Tie an interface address to its derived subnet list of addresses. */ |
209 | int | |
210 | if_subnet_add (struct interface *ifp, struct connected *ifc) | |
211 | { | |
212 | struct route_node *rn; | |
213 | struct zebra_if *zebra_if; | |
214 | struct prefix cp; | |
215 | struct list *addr_list; | |
216 | ||
217 | assert (ifp && ifp->info && ifc); | |
218 | zebra_if = ifp->info; | |
219 | ||
220 | /* Get address derived subnet node and associated address list, while marking | |
221 | address secondary attribute appropriately. */ | |
222 | cp = *ifc->address; | |
223 | apply_mask (&cp); | |
224 | rn = route_node_get (zebra_if->ipv4_subnets, &cp); | |
225 | ||
226 | if ((addr_list = rn->info)) | |
227 | SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); | |
228 | else | |
229 | { | |
230 | UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); | |
231 | rn->info = addr_list = list_new (); | |
232 | route_lock_node (rn); | |
233 | } | |
234 | ||
235 | /* Tie address at the tail of address list. */ | |
236 | listnode_add (addr_list, ifc); | |
237 | ||
238 | /* Return list element count. */ | |
239 | return (addr_list->count); | |
240 | } | |
241 | ||
242 | /* Untie an interface address from its derived subnet list of addresses. */ | |
243 | int | |
244 | if_subnet_delete (struct interface *ifp, struct connected *ifc) | |
245 | { | |
246 | struct route_node *rn; | |
247 | struct zebra_if *zebra_if; | |
248 | struct list *addr_list; | |
249 | ||
250 | assert (ifp && ifp->info && ifc); | |
251 | zebra_if = ifp->info; | |
252 | ||
253 | /* Get address derived subnet node. */ | |
254 | rn = route_node_lookup (zebra_if->ipv4_subnets, ifc->address); | |
255 | if (! (rn && rn->info)) | |
9db047fc CF |
256 | { |
257 | zlog_warn("Trying to remove an address from an unknown subnet." | |
258 | " (please report this bug)"); | |
259 | return -1; | |
260 | } | |
eef1fe11 | 261 | route_unlock_node (rn); |
262 | ||
263 | /* Untie address from subnet's address list. */ | |
264 | addr_list = rn->info; | |
9db047fc CF |
265 | |
266 | /* Deleting an address that is not registered is a bug. | |
267 | * In any case, we shouldn't decrement the lock counter if the address | |
268 | * is unknown. */ | |
269 | if (!listnode_lookup(addr_list, ifc)) | |
270 | { | |
271 | zlog_warn("Trying to remove an address from a subnet where it is not" | |
272 | " currently registered. (please report this bug)"); | |
273 | return -1; | |
274 | } | |
275 | ||
eef1fe11 | 276 | listnode_delete (addr_list, ifc); |
277 | route_unlock_node (rn); | |
278 | ||
279 | /* Return list element count, if not empty. */ | |
280 | if (addr_list->count) | |
281 | { | |
282 | /* If deleted address is primary, mark subsequent one as such and distribute. */ | |
283 | if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY)) | |
284 | { | |
16f1b9ee | 285 | ifc = listgetdata ((struct listnode *)listhead (addr_list)); |
eef1fe11 | 286 | zebra_interface_address_delete_update (ifp, ifc); |
287 | UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); | |
02b4805f CF |
288 | /* XXX: Linux kernel removes all the secondary addresses when the primary |
289 | * address is removed. We could try to work around that, though this is | |
290 | * non-trivial. */ | |
eef1fe11 | 291 | zebra_interface_address_add_update (ifp, ifc); |
292 | } | |
293 | ||
294 | return addr_list->count; | |
295 | } | |
296 | ||
297 | /* Otherwise, free list and route node. */ | |
298 | list_free (addr_list); | |
299 | rn->info = NULL; | |
300 | route_unlock_node (rn); | |
301 | ||
718e3744 | 302 | return 0; |
303 | } | |
304 | ||
5c78b3d0 | 305 | /* if_flags_mangle: A place for hacks that require mangling |
306 | * or tweaking the interface flags. | |
307 | * | |
308 | * ******************** Solaris flags hacks ************************** | |
309 | * | |
310 | * Solaris IFF_UP flag reflects only the primary interface as the | |
311 | * routing socket only sends IFINFO for the primary interface. Hence | |
312 | * ~IFF_UP does not per se imply all the logical interfaces are also | |
313 | * down - which we only know of as addresses. Instead we must determine | |
314 | * whether the interface really is up or not according to how many | |
315 | * addresses are still attached. (Solaris always sends RTM_DELADDR if | |
316 | * an interface, logical or not, goes ~IFF_UP). | |
317 | * | |
318 | * Ie, we mangle IFF_UP to *additionally* reflect whether or not there | |
319 | * are addresses left in struct connected, not just the actual underlying | |
320 | * IFF_UP flag. | |
321 | * | |
322 | * We must hence remember the real state of IFF_UP, which we do in | |
323 | * struct zebra_if.primary_state. | |
324 | * | |
325 | * Setting IFF_UP within zebra to administratively shutdown the | |
326 | * interface will affect only the primary interface/address on Solaris. | |
327 | ************************End Solaris flags hacks *********************** | |
328 | */ | |
f63f06da | 329 | static void |
5c78b3d0 | 330 | if_flags_mangle (struct interface *ifp, uint64_t *newflags) |
331 | { | |
332 | #ifdef SUNOS_5 | |
333 | struct zebra_if *zif = ifp->info; | |
334 | ||
335 | zif->primary_state = *newflags & (IFF_UP & 0xff); | |
336 | ||
337 | if (CHECK_FLAG (zif->primary_state, IFF_UP) | |
338 | || listcount(ifp->connected) > 0) | |
339 | SET_FLAG (*newflags, IFF_UP); | |
340 | else | |
341 | UNSET_FLAG (*newflags, IFF_UP); | |
342 | #endif /* SUNOS_5 */ | |
343 | } | |
344 | ||
345 | /* Update the flags field of the ifp with the new flag set provided. | |
346 | * Take whatever actions are required for any changes in flags we care | |
347 | * about. | |
348 | * | |
349 | * newflags should be the raw value, as obtained from the OS. | |
350 | */ | |
351 | void | |
352 | if_flags_update (struct interface *ifp, uint64_t newflags) | |
353 | { | |
354 | if_flags_mangle (ifp, &newflags); | |
355 | ||
244c1cdc | 356 | if (if_is_no_ptm_operative (ifp)) |
5c78b3d0 | 357 | { |
358 | /* operative -> inoperative? */ | |
359 | ifp->flags = newflags; | |
360 | if (!if_is_operative (ifp)) | |
361 | if_down (ifp); | |
362 | } | |
363 | else | |
364 | { | |
365 | /* inoperative -> operative? */ | |
366 | ifp->flags = newflags; | |
367 | if (if_is_operative (ifp)) | |
368 | if_up (ifp); | |
369 | } | |
370 | } | |
371 | ||
718e3744 | 372 | /* Wake up configured address if it is not in current kernel |
373 | address. */ | |
a1ac18c4 | 374 | static void |
718e3744 | 375 | if_addr_wakeup (struct interface *ifp) |
376 | { | |
1eb8ef25 | 377 | struct listnode *node, *nnode; |
718e3744 | 378 | struct connected *ifc; |
379 | struct prefix *p; | |
380 | int ret; | |
381 | ||
1eb8ef25 | 382 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc)) |
718e3744 | 383 | { |
718e3744 | 384 | p = ifc->address; |
385 | ||
386 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED) | |
f7f740fe | 387 | && ! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED)) |
718e3744 | 388 | { |
389 | /* Address check. */ | |
390 | if (p->family == AF_INET) | |
391 | { | |
392 | if (! if_is_up (ifp)) | |
393 | { | |
02b4805f CF |
394 | /* Assume zebra is configured like following: |
395 | * | |
396 | * interface gre0 | |
397 | * ip addr 192.0.2.1/24 | |
398 | * ! | |
399 | * | |
400 | * As soon as zebra becomes first aware that gre0 exists in the | |
401 | * kernel, it will set gre0 up and configure its addresses. | |
402 | * | |
403 | * (This may happen at startup when the interface already exists | |
404 | * or during runtime when the interface is added to the kernel) | |
405 | * | |
406 | * XXX: IRDP code is calling here via if_add_update - this seems | |
407 | * somewhat weird. | |
408 | * XXX: RUNNING is not a settable flag on any system | |
409 | * I (paulj) am aware of. | |
410 | */ | |
718e3744 | 411 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
412 | if_refresh (ifp); | |
413 | } | |
414 | ||
415 | ret = if_set_prefix (ifp, ifc); | |
416 | if (ret < 0) | |
417 | { | |
418 | zlog_warn ("Can't set interface's address: %s", | |
6099b3b5 | 419 | safe_strerror(errno)); |
718e3744 | 420 | continue; |
421 | } | |
eef1fe11 | 422 | |
f7f740fe | 423 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
424 | /* The address will be advertised to zebra clients when the notification |
425 | * from the kernel has been received. | |
426 | * It will also be added to the interface's subnet list then. */ | |
718e3744 | 427 | } |
428 | #ifdef HAVE_IPV6 | |
429 | if (p->family == AF_INET6) | |
430 | { | |
431 | if (! if_is_up (ifp)) | |
432 | { | |
02b4805f | 433 | /* See long comment above */ |
718e3744 | 434 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
435 | if_refresh (ifp); | |
436 | } | |
437 | ||
438 | ret = if_prefix_add_ipv6 (ifp, ifc); | |
439 | if (ret < 0) | |
440 | { | |
441 | zlog_warn ("Can't set interface's address: %s", | |
6099b3b5 | 442 | safe_strerror(errno)); |
718e3744 | 443 | continue; |
444 | } | |
718e3744 | 445 | |
02b4805f CF |
446 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
447 | /* The address will be advertised to zebra clients when the notification | |
448 | * from the kernel has been received. */ | |
718e3744 | 449 | } |
450 | #endif /* HAVE_IPV6 */ | |
451 | } | |
452 | } | |
453 | } | |
454 | ||
455 | /* Handle interface addition */ | |
456 | void | |
457 | if_add_update (struct interface *ifp) | |
458 | { | |
48b33aaf | 459 | struct zebra_if *if_data; |
460 | ||
fe18ee2d | 461 | if_link_per_ns(zebra_ns_lookup (NS_DEFAULT), ifp); |
12f6fb97 | 462 | |
48b33aaf | 463 | if_data = ifp->info; |
06b420a4 MS |
464 | assert(if_data); |
465 | ||
48b33aaf | 466 | if (if_data->multicast == IF_ZEBRA_MULTICAST_ON) |
467 | if_set_flags (ifp, IFF_MULTICAST); | |
468 | else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF) | |
469 | if_unset_flags (ifp, IFF_MULTICAST); | |
470 | ||
986aa00f | 471 | zebra_ptm_if_set_ptm_state(ifp, if_data); |
472 | ||
718e3744 | 473 | zebra_interface_add_update (ifp); |
474 | ||
475 | if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) | |
476 | { | |
477 | SET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); | |
478 | ||
bfac8dcd CF |
479 | if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) |
480 | { | |
481 | if (IS_ZEBRA_DEBUG_KERNEL) | |
3968dbf8 FL |
482 | zlog_debug ("interface %s vrf %u index %d is shutdown. " |
483 | "Won't wake it up.", | |
484 | ifp->name, ifp->vrf_id, ifp->ifindex); | |
bfac8dcd CF |
485 | return; |
486 | } | |
487 | ||
718e3744 | 488 | if_addr_wakeup (ifp); |
489 | ||
490 | if (IS_ZEBRA_DEBUG_KERNEL) | |
3968dbf8 FL |
491 | zlog_debug ("interface %s vrf %u index %d becomes active.", |
492 | ifp->name, ifp->vrf_id, ifp->ifindex); | |
718e3744 | 493 | } |
494 | else | |
495 | { | |
496 | if (IS_ZEBRA_DEBUG_KERNEL) | |
3968dbf8 FL |
497 | zlog_debug ("interface %s vrf %u index %d is added.", |
498 | ifp->name, ifp->vrf_id, ifp->ifindex); | |
718e3744 | 499 | } |
500 | } | |
501 | ||
c8e264b6 | 502 | /* Install connected routes corresponding to an interface. */ |
503 | static void | |
504 | if_install_connected (struct interface *ifp) | |
718e3744 | 505 | { |
c8e264b6 | 506 | struct listnode *node; |
507 | struct listnode *next; | |
718e3744 | 508 | struct connected *ifc; |
509 | struct prefix *p; | |
eef1fe11 | 510 | |
c8e264b6 | 511 | if (ifp->connected) |
512 | { | |
513 | for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) | |
514 | { | |
515 | p = ifc->address; | |
99ffac18 | 516 | zebra_interface_address_add_update (ifp, ifc); |
718e3744 | 517 | |
c8e264b6 | 518 | if (p->family == AF_INET) |
519 | connected_up_ipv4 (ifp, ifc); | |
520 | else if (p->family == AF_INET6) | |
521 | connected_up_ipv6 (ifp, ifc); | |
522 | } | |
523 | } | |
524 | } | |
525 | ||
526 | /* Uninstall connected routes corresponding to an interface. */ | |
527 | static void | |
528 | if_uninstall_connected (struct interface *ifp) | |
529 | { | |
530 | struct listnode *node; | |
531 | struct listnode *next; | |
532 | struct connected *ifc; | |
533 | struct prefix *p; | |
534 | ||
535 | if (ifp->connected) | |
718e3744 | 536 | { |
c8e264b6 | 537 | for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) |
538 | { | |
539 | p = ifc->address; | |
99ffac18 | 540 | zebra_interface_address_delete_update (ifp, ifc); |
c8e264b6 | 541 | |
542 | if (p->family == AF_INET) | |
543 | connected_down_ipv4 (ifp, ifc); | |
544 | else if (p->family == AF_INET6) | |
545 | connected_down_ipv6 (ifp, ifc); | |
546 | } | |
718e3744 | 547 | } |
c8e264b6 | 548 | } |
718e3744 | 549 | |
c8e264b6 | 550 | /* Uninstall and delete connected routes corresponding to an interface. */ |
551 | /* TODO - Check why IPv4 handling here is different from install or if_down */ | |
552 | static void | |
553 | if_delete_connected (struct interface *ifp) | |
554 | { | |
555 | struct connected *ifc; | |
556 | struct prefix *p; | |
557 | struct route_node *rn; | |
558 | struct zebra_if *zebra_if; | |
559 | ||
560 | zebra_if = ifp->info; | |
718e3744 | 561 | |
718e3744 | 562 | if (ifp->connected) |
563 | { | |
d9a18f11 PJ |
564 | struct listnode *node; |
565 | struct listnode *last = NULL; | |
566 | ||
eef1fe11 | 567 | while ((node = (last ? last->next : listhead (ifp->connected)))) |
718e3744 | 568 | { |
1eb8ef25 | 569 | ifc = listgetdata (node); |
718e3744 | 570 | p = ifc->address; |
eef1fe11 | 571 | |
beb56336 PJ |
572 | if (p->family == AF_INET |
573 | && (rn = route_node_lookup (zebra_if->ipv4_subnets, p))) | |
eef1fe11 | 574 | { |
d9a18f11 PJ |
575 | struct listnode *anode; |
576 | struct listnode *next; | |
577 | struct listnode *first; | |
578 | struct list *addr_list; | |
579 | ||
eef1fe11 | 580 | route_unlock_node (rn); |
581 | addr_list = (struct list *) rn->info; | |
582 | ||
583 | /* Remove addresses, secondaries first. */ | |
584 | first = listhead (addr_list); | |
d9a18f11 | 585 | for (anode = first->next; anode || first; anode = next) |
eef1fe11 | 586 | { |
d9a18f11 | 587 | if (!anode) |
eef1fe11 | 588 | { |
d9a18f11 | 589 | anode = first; |
eef1fe11 | 590 | first = NULL; |
591 | } | |
d9a18f11 | 592 | next = anode->next; |
eef1fe11 | 593 | |
d9a18f11 | 594 | ifc = listgetdata (anode); |
eef1fe11 | 595 | connected_down_ipv4 (ifp, ifc); |
596 | ||
02b4805f CF |
597 | /* XXX: We have to send notifications here explicitly, because we destroy |
598 | * the ifc before receiving the notification about the address being deleted. | |
599 | */ | |
eef1fe11 | 600 | zebra_interface_address_delete_update (ifp, ifc); |
601 | ||
602 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); | |
f7f740fe | 603 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
eef1fe11 | 604 | |
605 | /* Remove from subnet chain. */ | |
d9a18f11 | 606 | list_delete_node (addr_list, anode); |
eef1fe11 | 607 | route_unlock_node (rn); |
608 | ||
609 | /* Remove from interface address list (unconditionally). */ | |
d9a18f11 PJ |
610 | if (!CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
611 | { | |
612 | listnode_delete (ifp->connected, ifc); | |
613 | connected_free (ifc); | |
614 | } | |
615 | else | |
616 | last = node; | |
eef1fe11 | 617 | } |
618 | ||
619 | /* Free chain list and respective route node. */ | |
620 | list_delete (addr_list); | |
621 | rn->info = NULL; | |
622 | route_unlock_node (rn); | |
623 | } | |
718e3744 | 624 | else if (p->family == AF_INET6) |
eef1fe11 | 625 | { |
626 | connected_down_ipv6 (ifp, ifc); | |
718e3744 | 627 | |
eef1fe11 | 628 | zebra_interface_address_delete_update (ifp, ifc); |
718e3744 | 629 | |
eef1fe11 | 630 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); |
f7f740fe | 631 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
eef1fe11 | 632 | |
633 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
634 | last = node; | |
635 | else | |
636 | { | |
637 | listnode_delete (ifp->connected, ifc); | |
638 | connected_free (ifc); | |
639 | } | |
718e3744 | 640 | } |
e26873fd RHA |
641 | else |
642 | { | |
643 | last = node; | |
644 | } | |
718e3744 | 645 | } |
646 | } | |
c8e264b6 | 647 | } |
648 | ||
649 | /* Handle an interface delete event */ | |
650 | void | |
651 | if_delete_update (struct interface *ifp) | |
652 | { | |
653 | if (if_is_up(ifp)) | |
654 | { | |
655 | zlog_err ("interface %s vrf %u index %d is still up while being deleted.", | |
656 | ifp->name, ifp->vrf_id, ifp->ifindex); | |
657 | return; | |
658 | } | |
659 | ||
660 | /* Mark interface as inactive */ | |
661 | UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); | |
662 | ||
663 | if (IS_ZEBRA_DEBUG_KERNEL) | |
664 | zlog_debug ("interface %s vrf %u index %d is now inactive.", | |
665 | ifp->name, ifp->vrf_id, ifp->ifindex); | |
666 | ||
667 | /* Delete connected routes from the kernel. */ | |
668 | if_delete_connected (ifp); | |
669 | ||
670 | /* Send out notification on interface delete. */ | |
718e3744 | 671 | zebra_interface_delete_update (ifp); |
d2fc8896 | 672 | |
12f6fb97 DS |
673 | if_unlink_per_ns(ifp); |
674 | ||
d2fc8896 | 675 | /* Update ifindex after distributing the delete message. This is in |
676 | case any client needs to have the old value of ifindex available | |
677 | while processing the deletion. Each client daemon is responsible | |
678 | for setting ifindex to IFINDEX_INTERNAL after processing the | |
679 | interface deletion message. */ | |
680 | ifp->ifindex = IFINDEX_INTERNAL; | |
718e3744 | 681 | } |
682 | ||
c8e264b6 | 683 | /* VRF change for an interface */ |
684 | void | |
685 | if_handle_vrf_change (struct interface *ifp, vrf_id_t vrf_id) | |
686 | { | |
687 | vrf_id_t old_vrf_id; | |
688 | ||
689 | old_vrf_id = ifp->vrf_id; | |
690 | ||
691 | /* Uninstall connected routes. */ | |
692 | if_uninstall_connected (ifp); | |
693 | ||
694 | /* Delete any IPv4 neighbors created to implement RFC 5549 */ | |
695 | if_nbr_ipv6ll_to_ipv4ll_neigh_del_all (ifp); | |
696 | ||
697 | /* Delete all neighbor addresses learnt through IPv6 RA */ | |
698 | if_down_del_nbr_connected (ifp); | |
699 | ||
c8e264b6 | 700 | /* Send out notification on interface VRF change. */ |
701 | /* This is to issue an UPDATE or a DELETE, as appropriate. */ | |
702 | zebra_interface_vrf_update_del (ifp, vrf_id); | |
703 | ||
704 | /* update VRF */ | |
705 | if_update_vrf (ifp, ifp->name, strlen (ifp->name), vrf_id); | |
706 | ||
707 | /* Send out notification on interface VRF change. */ | |
708 | /* This is to issue an ADD, if needed. */ | |
709 | zebra_interface_vrf_update_add (ifp, old_vrf_id); | |
710 | ||
711 | /* Install connected routes (in new VRF). */ | |
712 | if_install_connected (ifp); | |
713 | ||
c8e264b6 | 714 | /* Due to connected route change, schedule RIB processing for both old |
715 | * and new VRF. | |
716 | */ | |
717 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) | |
718 | zlog_debug ("%u: IF %s VRF change, scheduling RIB processing", | |
719 | ifp->vrf_id, ifp->name); | |
720 | rib_update (old_vrf_id, RIB_UPDATE_IF_CHANGE); | |
721 | rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
fb148af4 DS |
722 | |
723 | zebra_vrf_static_route_interface_fixup (ifp); | |
c8e264b6 | 724 | } |
725 | ||
88177fe3 | 726 | static void |
5c610faf DS |
727 | ipv6_ll_address_to_mac (struct in6_addr *address, u_char *mac) |
728 | { | |
eb4b1830 | 729 | mac[0] = address->s6_addr[8] ^ 0x02; |
5c610faf DS |
730 | mac[1] = address->s6_addr[9]; |
731 | mac[2] = address->s6_addr[10]; | |
732 | mac[3] = address->s6_addr[13]; | |
733 | mac[4] = address->s6_addr[14]; | |
734 | mac[5] = address->s6_addr[15]; | |
735 | } | |
736 | ||
737 | void | |
738 | if_nbr_ipv6ll_to_ipv4ll_neigh_update (struct interface *ifp, | |
739 | struct in6_addr *address, | |
740 | int add) | |
741 | { | |
742 | char buf[16] = "169.254.0.1"; | |
743 | struct in_addr ipv4_ll; | |
88177fe3 | 744 | char mac[6]; |
5c610faf DS |
745 | |
746 | inet_pton (AF_INET, buf, &ipv4_ll); | |
747 | ||
88177fe3 | 748 | ipv6_ll_address_to_mac(address, (u_char *)mac); |
6b8a5694 | 749 | kernel_neigh_update (add, ifp->ifindex, ipv4_ll.s_addr, mac, 6); |
5c610faf DS |
750 | } |
751 | ||
88177fe3 | 752 | static void |
5c610faf DS |
753 | if_nbr_ipv6ll_to_ipv4ll_neigh_add_all (struct interface *ifp) |
754 | { | |
755 | if (listhead(ifp->nbr_connected)) | |
756 | { | |
757 | struct nbr_connected *nbr_connected; | |
758 | struct listnode *node; | |
759 | ||
760 | for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, nbr_connected)) | |
761 | if_nbr_ipv6ll_to_ipv4ll_neigh_update (ifp, | |
762 | &nbr_connected->address->u.prefix6, | |
763 | 1); | |
764 | } | |
765 | } | |
766 | ||
767 | void | |
768 | if_nbr_ipv6ll_to_ipv4ll_neigh_del_all (struct interface *ifp) | |
769 | { | |
770 | if (listhead(ifp->nbr_connected)) | |
771 | { | |
772 | struct nbr_connected *nbr_connected; | |
773 | struct listnode *node; | |
774 | ||
775 | for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, nbr_connected)) | |
776 | if_nbr_ipv6ll_to_ipv4ll_neigh_update (ifp, | |
777 | &nbr_connected->address->u.prefix6, | |
778 | 0); | |
779 | } | |
780 | } | |
781 | ||
88177fe3 | 782 | static void |
a197c47c DS |
783 | if_down_del_nbr_connected (struct interface *ifp) |
784 | { | |
785 | struct nbr_connected *nbr_connected; | |
786 | struct listnode *node, *nnode; | |
787 | ||
788 | for (ALL_LIST_ELEMENTS (ifp->nbr_connected, node, nnode, nbr_connected)) | |
789 | { | |
790 | listnode_delete (ifp->nbr_connected, nbr_connected); | |
791 | nbr_connected_free (nbr_connected); | |
792 | } | |
793 | } | |
794 | ||
718e3744 | 795 | /* Interface is up. */ |
796 | void | |
797 | if_up (struct interface *ifp) | |
798 | { | |
55ce4d3a CF |
799 | struct zebra_if *zif; |
800 | ||
801 | zif = ifp->info; | |
802 | zif->up_count++; | |
803 | quagga_timestamp (2, zif->up_last, sizeof (zif->up_last)); | |
804 | ||
718e3744 | 805 | /* Notify the protocol daemons. */ |
950bd436 | 806 | if (ifp->ptm_enable && (ifp->ptm_status == ZEBRA_PTM_STATUS_DOWN)) { |
244c1cdc DS |
807 | zlog_warn("%s: interface %s hasn't passed ptm check\n", __func__, |
808 | ifp->name); | |
809 | return; | |
810 | } | |
718e3744 | 811 | zebra_interface_up_update (ifp); |
812 | ||
5c610faf | 813 | if_nbr_ipv6ll_to_ipv4ll_neigh_add_all (ifp); |
244c1cdc | 814 | |
6c9678b4 DD |
815 | /* Enable fast tx of RA if enabled && RA interval is not in msecs */ |
816 | if (zif->rtadv.AdvSendAdvertisements && | |
817 | (zif->rtadv.MaxRtrAdvInterval >= 1000)) | |
818 | { | |
819 | zif->rtadv.inFastRexmit = 1; | |
820 | zif->rtadv.NumFastReXmitsRemain = RTADV_NUM_FAST_REXMITS; | |
821 | } | |
822 | ||
718e3744 | 823 | /* Install connected routes to the kernel. */ |
c8e264b6 | 824 | if_install_connected (ifp); |
718e3744 | 825 | |
41ec9222 | 826 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) |
1c848137 | 827 | zlog_debug ("%u: IF %s up, scheduling RIB processing", |
828 | ifp->vrf_id, ifp->name); | |
829 | rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
a3d21ef3 DS |
830 | |
831 | zebra_vrf_static_route_interface_fixup (ifp); | |
718e3744 | 832 | } |
833 | ||
834 | /* Interface goes down. We have to manage different behavior of based | |
835 | OS. */ | |
836 | void | |
837 | if_down (struct interface *ifp) | |
838 | { | |
55ce4d3a CF |
839 | struct zebra_if *zif; |
840 | ||
841 | zif = ifp->info; | |
842 | zif->down_count++; | |
843 | quagga_timestamp (2, zif->down_last, sizeof (zif->down_last)); | |
844 | ||
718e3744 | 845 | /* Notify to the protocol daemons. */ |
846 | zebra_interface_down_update (ifp); | |
847 | ||
c8e264b6 | 848 | /* Uninstall connected routes from the kernel. */ |
849 | if_uninstall_connected (ifp); | |
718e3744 | 850 | |
41ec9222 | 851 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) |
1c848137 | 852 | zlog_debug ("%u: IF %s down, scheduling RIB processing", |
853 | ifp->vrf_id, ifp->name); | |
854 | rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
5c610faf DS |
855 | |
856 | if_nbr_ipv6ll_to_ipv4ll_neigh_del_all (ifp); | |
a197c47c DS |
857 | |
858 | /* Delete all neighbor addresses learnt through IPv6 RA */ | |
859 | if_down_del_nbr_connected (ifp); | |
718e3744 | 860 | } |
861 | ||
862 | void | |
863 | if_refresh (struct interface *ifp) | |
864 | { | |
5c78b3d0 | 865 | if_get_flags (ifp); |
718e3744 | 866 | } |
867 | ||
d5a5c8f0 | 868 | |
718e3744 | 869 | /* Output prefix string to vty. */ |
a1ac18c4 | 870 | static int |
718e3744 | 871 | prefix_vty_out (struct vty *vty, struct prefix *p) |
872 | { | |
873 | char str[INET6_ADDRSTRLEN]; | |
874 | ||
875 | inet_ntop (p->family, &p->u.prefix, str, sizeof (str)); | |
876 | vty_out (vty, "%s", str); | |
877 | return strlen (str); | |
878 | } | |
879 | ||
880 | /* Dump if address information to vty. */ | |
a1ac18c4 | 881 | static void |
718e3744 | 882 | connected_dump_vty (struct vty *vty, struct connected *connected) |
883 | { | |
884 | struct prefix *p; | |
718e3744 | 885 | |
886 | /* Print interface address. */ | |
887 | p = connected->address; | |
888 | vty_out (vty, " %s ", prefix_family_str (p)); | |
889 | prefix_vty_out (vty, p); | |
890 | vty_out (vty, "/%d", p->prefixlen); | |
891 | ||
892 | /* If there is destination address, print it. */ | |
e4529636 | 893 | if (connected->destination) |
718e3744 | 894 | { |
e4529636 AS |
895 | vty_out (vty, (CONNECTED_PEER(connected) ? " peer " : " broadcast ")); |
896 | prefix_vty_out (vty, connected->destination); | |
718e3744 | 897 | } |
898 | ||
899 | if (CHECK_FLAG (connected->flags, ZEBRA_IFA_SECONDARY)) | |
900 | vty_out (vty, " secondary"); | |
901 | ||
525c1839 DS |
902 | if (CHECK_FLAG (connected->flags, ZEBRA_IFA_UNNUMBERED)) |
903 | vty_out (vty, " unnumbered"); | |
904 | ||
718e3744 | 905 | if (connected->label) |
906 | vty_out (vty, " %s", connected->label); | |
907 | ||
908 | vty_out (vty, "%s", VTY_NEWLINE); | |
909 | } | |
910 | ||
a80beece DS |
911 | /* Dump interface neighbor address information to vty. */ |
912 | static void | |
913 | nbr_connected_dump_vty (struct vty *vty, struct nbr_connected *connected) | |
914 | { | |
915 | struct prefix *p; | |
916 | ||
917 | /* Print interface address. */ | |
918 | p = connected->address; | |
919 | vty_out (vty, " %s ", prefix_family_str (p)); | |
920 | prefix_vty_out (vty, p); | |
921 | vty_out (vty, "/%d", p->prefixlen); | |
922 | ||
923 | vty_out (vty, "%s", VTY_NEWLINE); | |
924 | } | |
925 | ||
8da4e946 | 926 | #if defined (HAVE_RTADV) |
718e3744 | 927 | /* Dump interface ND information to vty. */ |
a1ac18c4 | 928 | static void |
718e3744 | 929 | nd_dump_vty (struct vty *vty, struct interface *ifp) |
930 | { | |
931 | struct zebra_if *zif; | |
932 | struct rtadvconf *rtadv; | |
7cee1bb1 | 933 | int interval; |
718e3744 | 934 | |
935 | zif = (struct zebra_if *) ifp->info; | |
936 | rtadv = &zif->rtadv; | |
937 | ||
938 | if (rtadv->AdvSendAdvertisements) | |
939 | { | |
940 | vty_out (vty, " ND advertised reachable time is %d milliseconds%s", | |
941 | rtadv->AdvReachableTime, VTY_NEWLINE); | |
942 | vty_out (vty, " ND advertised retransmit interval is %d milliseconds%s", | |
943 | rtadv->AdvRetransTimer, VTY_NEWLINE); | |
795b5abf QY |
944 | vty_out (vty, " ND router advertisements sent: %d rcvd: %d%s", |
945 | zif->ra_sent, zif->ra_rcvd, VTY_NEWLINE); | |
7cee1bb1 | 946 | interval = rtadv->MaxRtrAdvInterval; |
947 | if (interval % 1000) | |
948 | vty_out (vty, " ND router advertisements are sent every " | |
949 | "%d milliseconds%s", interval, | |
950 | VTY_NEWLINE); | |
951 | else | |
952 | vty_out (vty, " ND router advertisements are sent every " | |
953 | "%d seconds%s", interval / 1000, | |
954 | VTY_NEWLINE); | |
d660f698 DO |
955 | if (rtadv->AdvDefaultLifetime != -1) |
956 | vty_out (vty, " ND router advertisements live for %d seconds%s", | |
957 | rtadv->AdvDefaultLifetime, VTY_NEWLINE); | |
958 | else | |
959 | vty_out (vty, " ND router advertisements lifetime tracks ra-interval%s", | |
960 | VTY_NEWLINE); | |
b60668d0 CC |
961 | vty_out (vty, " ND router advertisement default router preference is " |
962 | "%s%s", rtadv_pref_strs[rtadv->DefaultPreference], | |
963 | VTY_NEWLINE); | |
718e3744 | 964 | if (rtadv->AdvManagedFlag) |
965 | vty_out (vty, " Hosts use DHCP to obtain routable addresses.%s", | |
966 | VTY_NEWLINE); | |
967 | else | |
968 | vty_out (vty, " Hosts use stateless autoconfig for addresses.%s", | |
969 | VTY_NEWLINE); | |
7cee1bb1 | 970 | if (rtadv->AdvHomeAgentFlag) |
d660f698 | 971 | { |
7cee1bb1 | 972 | vty_out (vty, " ND router advertisements with " |
973 | "Home Agent flag bit set.%s", | |
974 | VTY_NEWLINE); | |
d660f698 DO |
975 | if (rtadv->HomeAgentLifetime != -1) |
976 | vty_out (vty, " Home Agent lifetime is %u seconds%s", | |
977 | rtadv->HomeAgentLifetime, VTY_NEWLINE); | |
978 | else | |
979 | vty_out (vty, " Home Agent lifetime tracks ra-lifetime%s", | |
980 | VTY_NEWLINE); | |
981 | vty_out (vty, " Home Agent preference is %u%s", | |
982 | rtadv->HomeAgentPreference, VTY_NEWLINE); | |
983 | } | |
7cee1bb1 | 984 | if (rtadv->AdvIntervalOption) |
985 | vty_out (vty, " ND router advertisements with Adv. Interval option.%s", | |
986 | VTY_NEWLINE); | |
718e3744 | 987 | } |
988 | } | |
8da4e946 | 989 | #endif /* HAVE_RTADV */ |
718e3744 | 990 | |
991 | /* Interface's information print out to vty interface. */ | |
a1ac18c4 | 992 | static void |
718e3744 | 993 | if_dump_vty (struct vty *vty, struct interface *ifp) |
994 | { | |
718e3744 | 995 | struct connected *connected; |
a80beece | 996 | struct nbr_connected *nbr_connected; |
52dc7ee6 | 997 | struct listnode *node; |
eef1fe11 | 998 | struct route_node *rn; |
999 | struct zebra_if *zebra_if; | |
e6a59b35 | 1000 | struct vrf *vrf; |
eef1fe11 | 1001 | |
1002 | zebra_if = ifp->info; | |
718e3744 | 1003 | |
2e3b2e47 | 1004 | vty_out (vty, "Interface %s is ", ifp->name); |
1005 | if (if_is_up(ifp)) { | |
1006 | vty_out (vty, "up, line protocol "); | |
1007 | ||
1008 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) { | |
1009 | if (if_is_running(ifp)) | |
1010 | vty_out (vty, "is up%s", VTY_NEWLINE); | |
1011 | else | |
1012 | vty_out (vty, "is down%s", VTY_NEWLINE); | |
1013 | } else { | |
1014 | vty_out (vty, "detection is disabled%s", VTY_NEWLINE); | |
1015 | } | |
1016 | } else { | |
1017 | vty_out (vty, "down%s", VTY_NEWLINE); | |
1018 | } | |
1019 | ||
55ce4d3a CF |
1020 | vty_out (vty, " Link ups: %5u last: %s%s", zebra_if->up_count, |
1021 | zebra_if->up_last[0] ? zebra_if->up_last : "(never)", VTY_NEWLINE); | |
1022 | vty_out (vty, " Link downs: %5u last: %s%s", zebra_if->down_count, | |
1023 | zebra_if->down_last[0] ? zebra_if->down_last : "(never)", VTY_NEWLINE); | |
1024 | ||
950bd436 | 1025 | zebra_ptm_show_status(vty, ifp); |
244c1cdc | 1026 | |
e6a59b35 DS |
1027 | vrf = vrf_lookup(ifp->vrf_id); |
1028 | vty_out (vty, " vrf: %s%s", vrf->name, VTY_NEWLINE); | |
3968dbf8 | 1029 | |
718e3744 | 1030 | if (ifp->desc) |
1031 | vty_out (vty, " Description: %s%s", ifp->desc, | |
1032 | VTY_NEWLINE); | |
d2fc8896 | 1033 | if (ifp->ifindex == IFINDEX_INTERNAL) |
718e3744 | 1034 | { |
d2fc8896 | 1035 | vty_out(vty, " pseudo interface%s", VTY_NEWLINE); |
718e3744 | 1036 | return; |
1037 | } | |
1038 | else if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) | |
1039 | { | |
1040 | vty_out(vty, " index %d inactive interface%s", | |
1041 | ifp->ifindex, | |
1042 | VTY_NEWLINE); | |
1043 | return; | |
1044 | } | |
1045 | ||
1046 | vty_out (vty, " index %d metric %d mtu %d ", | |
1047 | ifp->ifindex, ifp->metric, ifp->mtu); | |
44145db3 | 1048 | #ifdef HAVE_IPV6 |
1049 | if (ifp->mtu6 != ifp->mtu) | |
1050 | vty_out (vty, "mtu6 %d ", ifp->mtu6); | |
1051 | #endif | |
630c97ce PJ |
1052 | vty_out (vty, "%s flags: %s%s", VTY_NEWLINE, |
1053 | if_flag_dump (ifp->flags), VTY_NEWLINE); | |
3a570c8b | 1054 | |
718e3744 | 1055 | /* Hardware address. */ |
8ccc7e80 | 1056 | vty_out (vty, " Type: %s%s", if_link_type_str (ifp->ll_type), VTY_NEWLINE); |
718e3744 | 1057 | if (ifp->hw_addr_len != 0) |
1058 | { | |
1059 | int i; | |
1060 | ||
1061 | vty_out (vty, " HWaddr: "); | |
1062 | for (i = 0; i < ifp->hw_addr_len; i++) | |
1063 | vty_out (vty, "%s%02x", i == 0 ? "" : ":", ifp->hw_addr[i]); | |
1064 | vty_out (vty, "%s", VTY_NEWLINE); | |
1065 | } | |
718e3744 | 1066 | |
70bd3c43 | 1067 | /* Bandwidth in Mbps */ |
718e3744 | 1068 | if (ifp->bandwidth != 0) |
1069 | { | |
70bd3c43 | 1070 | vty_out(vty, " bandwidth %u Mbps", ifp->bandwidth); |
718e3744 | 1071 | vty_out(vty, "%s", VTY_NEWLINE); |
1072 | } | |
1073 | ||
eef1fe11 | 1074 | for (rn = route_top (zebra_if->ipv4_subnets); rn; rn = route_next (rn)) |
718e3744 | 1075 | { |
eef1fe11 | 1076 | if (! rn->info) |
1077 | continue; | |
16f1b9ee | 1078 | |
1eb8ef25 | 1079 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected)) |
1080 | connected_dump_vty (vty, connected); | |
718e3744 | 1081 | } |
1082 | ||
1eb8ef25 | 1083 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) |
39db97e4 | 1084 | { |
39db97e4 | 1085 | if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) && |
1086 | (connected->address->family == AF_INET6)) | |
1087 | connected_dump_vty (vty, connected); | |
1088 | } | |
1089 | ||
16f1b9ee OD |
1090 | if (HAS_LINK_PARAMS(ifp)) |
1091 | { | |
1092 | int i; | |
1093 | struct if_link_params *iflp = ifp->link_params; | |
1094 | vty_out(vty, " Traffic Engineering Link Parameters:%s", VTY_NEWLINE); | |
1095 | if (IS_PARAM_SET(iflp, LP_TE)) | |
1096 | vty_out(vty, " TE metric %u%s",iflp->te_metric, VTY_NEWLINE); | |
1097 | if (IS_PARAM_SET(iflp, LP_MAX_BW)) | |
1098 | vty_out(vty, " Maximum Bandwidth %g (Byte/s)%s", iflp->max_bw, VTY_NEWLINE); | |
1099 | if (IS_PARAM_SET(iflp, LP_MAX_RSV_BW)) | |
1100 | vty_out(vty, " Maximum Reservable Bandwidth %g (Byte/s)%s", iflp->max_rsv_bw, VTY_NEWLINE); | |
1101 | if (IS_PARAM_SET(iflp, LP_UNRSV_BW)) { | |
1102 | vty_out(vty, " Unreserved Bandwidth per Class Type in Byte/s:%s", VTY_NEWLINE); | |
1103 | for (i = 0; i < MAX_CLASS_TYPE; i+=2) | |
1104 | vty_out(vty, " [%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)%s", | |
1105 | i, iflp->unrsv_bw[i], i+1, iflp->unrsv_bw[i+1], VTY_NEWLINE); | |
1106 | } | |
1107 | ||
1108 | if (IS_PARAM_SET(iflp, LP_ADM_GRP)) | |
1109 | vty_out(vty, " Administrative Group:%u%s", iflp->admin_grp, VTY_NEWLINE); | |
1110 | if (IS_PARAM_SET(iflp, LP_DELAY)) | |
1111 | { | |
1112 | vty_out(vty, " Link Delay Average: %u (micro-sec.)", iflp->av_delay); | |
1113 | if (IS_PARAM_SET(iflp, LP_MM_DELAY)) | |
1114 | { | |
1115 | vty_out(vty, " Min: %u (micro-sec.)", iflp->min_delay); | |
1116 | vty_out(vty, " Max: %u (micro-sec.)", iflp->max_delay); | |
1117 | } | |
1118 | vty_out(vty, "%s", VTY_NEWLINE); | |
1119 | } | |
1120 | if (IS_PARAM_SET(iflp, LP_DELAY_VAR)) | |
1121 | vty_out(vty, " Link Delay Variation %u (micro-sec.)%s", iflp->delay_var, VTY_NEWLINE); | |
1122 | if (IS_PARAM_SET(iflp, LP_PKT_LOSS)) | |
1123 | vty_out(vty, " Link Packet Loss %g (in %%)%s", iflp->pkt_loss, VTY_NEWLINE); | |
1124 | if (IS_PARAM_SET(iflp, LP_AVA_BW)) | |
1125 | vty_out(vty, " Available Bandwidth %g (Byte/s)%s", iflp->ava_bw, VTY_NEWLINE); | |
1126 | if (IS_PARAM_SET(iflp, LP_RES_BW)) | |
1127 | vty_out(vty, " Residual Bandwidth %g (Byte/s)%s", iflp->res_bw, VTY_NEWLINE); | |
1128 | if (IS_PARAM_SET(iflp, LP_USE_BW)) | |
1129 | vty_out(vty, " Utilized Bandwidth %g (Byte/s)%s", iflp->use_bw, VTY_NEWLINE); | |
1130 | if (IS_PARAM_SET(iflp, LP_RMT_AS)) | |
1131 | vty_out(vty, " Neighbor ASBR IP: %s AS: %u %s", inet_ntoa(iflp->rmt_ip), iflp->rmt_as, VTY_NEWLINE); | |
1132 | } | |
1133 | ||
1134 | #ifdef RTADV | |
1135 | nd_dump_vty (vty, ifp); | |
1136 | #endif /* RTADV */ | |
8da4e946 | 1137 | #if defined (HAVE_RTADV) |
718e3744 | 1138 | nd_dump_vty (vty, ifp); |
8da4e946 | 1139 | #endif /* HAVE_RTADV */ |
a80beece DS |
1140 | if (listhead(ifp->nbr_connected)) |
1141 | vty_out (vty, " Neighbor address(s):%s", VTY_NEWLINE); | |
1142 | for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, nbr_connected)) | |
1143 | nbr_connected_dump_vty (vty, nbr_connected); | |
718e3744 | 1144 | |
1145 | #ifdef HAVE_PROC_NET_DEV | |
1146 | /* Statistics print out using proc file system. */ | |
6f2c27af | 1147 | vty_out (vty, " %lu input packets (%lu multicast), %lu bytes, " |
1148 | "%lu dropped%s", | |
1149 | ifp->stats.rx_packets, ifp->stats.rx_multicast, | |
1150 | ifp->stats.rx_bytes, ifp->stats.rx_dropped, VTY_NEWLINE); | |
718e3744 | 1151 | |
6f2c27af | 1152 | vty_out (vty, " %lu input errors, %lu length, %lu overrun," |
3452d475 | 1153 | " %lu CRC, %lu frame%s", |
718e3744 | 1154 | ifp->stats.rx_errors, ifp->stats.rx_length_errors, |
1155 | ifp->stats.rx_over_errors, ifp->stats.rx_crc_errors, | |
6f2c27af | 1156 | ifp->stats.rx_frame_errors, VTY_NEWLINE); |
1157 | ||
1158 | vty_out (vty, " %lu fifo, %lu missed%s", ifp->stats.rx_fifo_errors, | |
718e3744 | 1159 | ifp->stats.rx_missed_errors, VTY_NEWLINE); |
1160 | ||
6f2c27af | 1161 | vty_out (vty, " %lu output packets, %lu bytes, %lu dropped%s", |
718e3744 | 1162 | ifp->stats.tx_packets, ifp->stats.tx_bytes, |
1163 | ifp->stats.tx_dropped, VTY_NEWLINE); | |
1164 | ||
6f2c27af | 1165 | vty_out (vty, " %lu output errors, %lu aborted, %lu carrier," |
1166 | " %lu fifo, %lu heartbeat%s", | |
718e3744 | 1167 | ifp->stats.tx_errors, ifp->stats.tx_aborted_errors, |
1168 | ifp->stats.tx_carrier_errors, ifp->stats.tx_fifo_errors, | |
6f2c27af | 1169 | ifp->stats.tx_heartbeat_errors, VTY_NEWLINE); |
718e3744 | 1170 | |
6f2c27af | 1171 | vty_out (vty, " %lu window, %lu collisions%s", |
1172 | ifp->stats.tx_window_errors, ifp->stats.collisions, VTY_NEWLINE); | |
718e3744 | 1173 | #endif /* HAVE_PROC_NET_DEV */ |
1174 | ||
1175 | #ifdef HAVE_NET_RT_IFLIST | |
1176 | #if defined (__bsdi__) || defined (__NetBSD__) | |
1177 | /* Statistics print out using sysctl (). */ | |
24b46333 DL |
1178 | vty_out (vty, " input packets %llu, bytes %llu, dropped %llu," |
1179 | " multicast packets %llu%s", | |
1180 | (unsigned long long)ifp->stats.ifi_ipackets, | |
1181 | (unsigned long long)ifp->stats.ifi_ibytes, | |
1182 | (unsigned long long)ifp->stats.ifi_iqdrops, | |
1183 | (unsigned long long)ifp->stats.ifi_imcasts, | |
1184 | VTY_NEWLINE); | |
1185 | ||
1186 | vty_out (vty, " input errors %llu%s", | |
1187 | (unsigned long long)ifp->stats.ifi_ierrors, VTY_NEWLINE); | |
1188 | ||
1189 | vty_out (vty, " output packets %llu, bytes %llu," | |
1190 | " multicast packets %llu%s", | |
1191 | (unsigned long long)ifp->stats.ifi_opackets, | |
1192 | (unsigned long long)ifp->stats.ifi_obytes, | |
1193 | (unsigned long long)ifp->stats.ifi_omcasts, | |
1194 | VTY_NEWLINE); | |
1195 | ||
1196 | vty_out (vty, " output errors %llu%s", | |
1197 | (unsigned long long)ifp->stats.ifi_oerrors, VTY_NEWLINE); | |
1198 | ||
1199 | vty_out (vty, " collisions %llu%s", | |
1200 | (unsigned long long)ifp->stats.ifi_collisions, VTY_NEWLINE); | |
718e3744 | 1201 | #else |
1202 | /* Statistics print out using sysctl (). */ | |
1203 | vty_out (vty, " input packets %lu, bytes %lu, dropped %lu," | |
1204 | " multicast packets %lu%s", | |
1205 | ifp->stats.ifi_ipackets, ifp->stats.ifi_ibytes, | |
1206 | ifp->stats.ifi_iqdrops, ifp->stats.ifi_imcasts, | |
1207 | VTY_NEWLINE); | |
1208 | ||
1209 | vty_out (vty, " input errors %lu%s", | |
1210 | ifp->stats.ifi_ierrors, VTY_NEWLINE); | |
1211 | ||
1212 | vty_out (vty, " output packets %lu, bytes %lu, multicast packets %lu%s", | |
1213 | ifp->stats.ifi_opackets, ifp->stats.ifi_obytes, | |
1214 | ifp->stats.ifi_omcasts, VTY_NEWLINE); | |
1215 | ||
1216 | vty_out (vty, " output errors %lu%s", | |
1217 | ifp->stats.ifi_oerrors, VTY_NEWLINE); | |
1218 | ||
1219 | vty_out (vty, " collisions %lu%s", | |
1220 | ifp->stats.ifi_collisions, VTY_NEWLINE); | |
1221 | #endif /* __bsdi__ || __NetBSD__ */ | |
1222 | #endif /* HAVE_NET_RT_IFLIST */ | |
1223 | } | |
1224 | ||
718e3744 | 1225 | /* Wrapper hook point for zebra daemon so that ifindex can be set |
1226 | * DEFUN macro not used as extract.pl HAS to ignore this | |
1227 | * See also interface_cmd in lib/if.c | |
1228 | */ | |
1229 | DEFUN_NOSH (zebra_interface, | |
1230 | zebra_interface_cmd, | |
1231 | "interface IFNAME", | |
1232 | "Select an interface to configure\n" | |
1233 | "Interface's name\n") | |
1234 | { | |
1235 | int ret; | |
16f1b9ee | 1236 | struct interface *ifp; |
718e3744 | 1237 | |
1238 | /* Call lib interface() */ | |
d2fc8896 | 1239 | if ((ret = interface_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS) |
1240 | return ret; | |
718e3744 | 1241 | |
16f1b9ee | 1242 | ifp = vty->index; |
718e3744 | 1243 | |
d2fc8896 | 1244 | if (ifp->ifindex == IFINDEX_INTERNAL) |
1245 | /* Is this really necessary? Shouldn't status be initialized to 0 | |
1246 | in that case? */ | |
1247 | UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE); | |
718e3744 | 1248 | |
1249 | return ret; | |
1250 | } | |
1251 | ||
78860b9f DS |
1252 | static void |
1253 | interface_update_stats (void) | |
1254 | { | |
1255 | #ifdef HAVE_PROC_NET_DEV | |
1256 | /* If system has interface statistics via proc file system, update | |
1257 | statistics. */ | |
1258 | ifstat_update_proc (); | |
1259 | #endif /* HAVE_PROC_NET_DEV */ | |
1260 | #ifdef HAVE_NET_RT_IFLIST | |
1261 | ifstat_update_sysctl (); | |
1262 | #endif /* HAVE_NET_RT_IFLIST */ | |
1263 | } | |
1264 | ||
718e3744 | 1265 | struct cmd_node interface_node = |
1266 | { | |
1267 | INTERFACE_NODE, | |
1268 | "%s(config-if)# ", | |
1269 | 1 | |
1270 | }; | |
1271 | ||
12f6fb97 DS |
1272 | /* Wrapper hook point for zebra daemon so that ifindex can be set |
1273 | * DEFUN macro not used as extract.pl HAS to ignore this | |
1274 | * See also interface_cmd in lib/if.c | |
1275 | */ | |
1276 | DEFUN_NOSH (zebra_vrf, | |
1277 | zebra_vrf_cmd, | |
1278 | "vrf NAME", | |
1279 | "Select a VRF to configure\n" | |
1280 | "VRF's name\n") | |
1281 | { | |
1282 | int ret; | |
1283 | ||
1284 | /* Call lib vrf() */ | |
1285 | if ((ret = vrf_cmd.func (self, vty, argc, argv)) != CMD_SUCCESS) | |
1286 | return ret; | |
1287 | ||
1288 | // vrfp = vty->index; | |
1289 | ||
1290 | return ret; | |
1291 | } | |
1292 | ||
1293 | struct cmd_node vrf_node = | |
1294 | { | |
1295 | VRF_NODE, | |
1296 | "%s(config-vrf)# ", | |
1297 | 1 | |
1298 | }; | |
1299 | ||
8b87bdf4 | 1300 | /* Show all interfaces to vty. */ |
f412b39a DW |
1301 | /* |
1302 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1303 | * "show interface " VRF_CMD_STR, | |
1304 | * SHOW_STR | |
1305 | * "Interface status and configuration\n" | |
1306 | * VRF_CMD_HELP_STR | |
1307 | * | |
1308 | */ | |
8b3f0677 DW |
1309 | DEFUN (show_interface, |
1310 | show_interface_cmd, | |
8b87bdf4 FL |
1311 | "show interface", |
1312 | SHOW_STR | |
1313 | "Interface status and configuration\n") | |
1314 | { | |
1315 | struct listnode *node; | |
1316 | struct interface *ifp; | |
1317 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1318 | ||
78860b9f | 1319 | interface_update_stats (); |
8b87bdf4 FL |
1320 | |
1321 | if (argc > 0) | |
8b3f0677 | 1322 | VRF_GET_ID (vrf_id, argv[2]->arg); |
8b87bdf4 FL |
1323 | |
1324 | /* All interface print. */ | |
1325 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) | |
1326 | if_dump_vty (vty, ifp); | |
1327 | ||
1328 | return CMD_SUCCESS; | |
1329 | } | |
1330 | ||
8b87bdf4 FL |
1331 | |
1332 | /* Show all interfaces to vty. */ | |
8b3f0677 DW |
1333 | DEFUN (show_interface_vrf_all, |
1334 | show_interface_vrf_all_cmd, | |
8b87bdf4 FL |
1335 | "show interface " VRF_ALL_CMD_STR, |
1336 | SHOW_STR | |
1337 | "Interface status and configuration\n" | |
1338 | VRF_ALL_CMD_HELP_STR) | |
718e3744 | 1339 | { |
52dc7ee6 | 1340 | struct listnode *node; |
718e3744 | 1341 | struct interface *ifp; |
8b87bdf4 FL |
1342 | vrf_iter_t iter; |
1343 | ||
78860b9f | 1344 | interface_update_stats (); |
718e3744 | 1345 | |
8b87bdf4 FL |
1346 | /* All interface print. */ |
1347 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) | |
1348 | for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp)) | |
1349 | if_dump_vty (vty, ifp); | |
1350 | ||
1351 | return CMD_SUCCESS; | |
1352 | } | |
1353 | ||
1354 | /* Show specified interface to vty. */ | |
1721646e DS |
1355 | |
1356 | DEFUN (show_interface_name_vrf, | |
1357 | show_interface_name_vrf_cmd, | |
1358 | "show interface IFNAME " VRF_CMD_STR, | |
8b87bdf4 FL |
1359 | SHOW_STR |
1360 | "Interface status and configuration\n" | |
1721646e DS |
1361 | "Interface name\n" |
1362 | VRF_CMD_HELP_STR) | |
8b87bdf4 FL |
1363 | { |
1364 | struct interface *ifp; | |
1365 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1366 | ||
78860b9f | 1367 | interface_update_stats (); |
8b87bdf4 FL |
1368 | |
1369 | if (argc > 1) | |
6147e2c6 | 1370 | VRF_GET_ID (vrf_id, argv[4]->arg); |
8b87bdf4 | 1371 | |
718e3744 | 1372 | /* Specified interface print. */ |
8b3f0677 | 1373 | ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_id); |
8b87bdf4 | 1374 | if (ifp == NULL) |
718e3744 | 1375 | { |
8b3f0677 | 1376 | vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, |
8b87bdf4 FL |
1377 | VTY_NEWLINE); |
1378 | return CMD_WARNING; | |
718e3744 | 1379 | } |
8b87bdf4 | 1380 | if_dump_vty (vty, ifp); |
718e3744 | 1381 | |
1382 | return CMD_SUCCESS; | |
1383 | } | |
1384 | ||
8b87bdf4 | 1385 | /* Show specified interface to vty. */ |
f412b39a DW |
1386 | /* |
1387 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1388 | * "show interface IFNAME", | |
1389 | * SHOW_STR | |
1390 | * "Interface status and configuration\n" | |
1391 | * "Interface name\n" | |
1392 | * | |
1393 | */ | |
8b3f0677 DW |
1394 | DEFUN (show_interface_name_vrf_all, |
1395 | show_interface_name_vrf_all_cmd, | |
8b87bdf4 FL |
1396 | "show interface IFNAME " VRF_ALL_CMD_STR, |
1397 | SHOW_STR | |
1398 | "Interface status and configuration\n" | |
1721646e | 1399 | "Interface name\n" |
8b87bdf4 FL |
1400 | VRF_ALL_CMD_HELP_STR) |
1401 | { | |
1402 | struct interface *ifp; | |
1403 | vrf_iter_t iter; | |
1404 | int found = 0; | |
1405 | ||
78860b9f | 1406 | interface_update_stats (); |
8b87bdf4 FL |
1407 | |
1408 | /* All interface print. */ | |
1409 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) | |
1410 | { | |
1411 | /* Specified interface print. */ | |
8b3f0677 | 1412 | ifp = if_lookup_by_name_vrf (argv[2]->arg, vrf_iter2id (iter)); |
8b87bdf4 FL |
1413 | if (ifp) |
1414 | { | |
1415 | if_dump_vty (vty, ifp); | |
1416 | found++; | |
1417 | } | |
1418 | } | |
1419 | ||
1420 | if (!found) | |
1421 | { | |
8b3f0677 | 1422 | vty_out (vty, "%% Can't find interface %s%s", argv[2]->arg, VTY_NEWLINE); |
8b87bdf4 FL |
1423 | return CMD_WARNING; |
1424 | } | |
1425 | ||
1426 | return CMD_SUCCESS; | |
1427 | } | |
1428 | ||
1721646e | 1429 | |
8b87bdf4 FL |
1430 | static void |
1431 | if_show_description (struct vty *vty, vrf_id_t vrf_id) | |
ed9bb6d5 | 1432 | { |
1433 | struct listnode *node; | |
1434 | struct interface *ifp; | |
1435 | ||
1436 | vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE); | |
8b87bdf4 | 1437 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) |
ed9bb6d5 | 1438 | { |
1439 | int len; | |
ed9bb6d5 | 1440 | |
1441 | len = vty_out (vty, "%s", ifp->name); | |
1442 | vty_out (vty, "%*s", (16 - len), " "); | |
1443 | ||
1444 | if (if_is_up(ifp)) | |
1445 | { | |
1446 | vty_out (vty, "up "); | |
1447 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) | |
1448 | { | |
1449 | if (if_is_running(ifp)) | |
1450 | vty_out (vty, "up "); | |
1451 | else | |
1452 | vty_out (vty, "down "); | |
1453 | } | |
1454 | else | |
1455 | { | |
1456 | vty_out (vty, "unknown "); | |
1457 | } | |
1458 | } | |
1459 | else | |
1460 | { | |
1461 | vty_out (vty, "down down "); | |
1462 | } | |
1463 | ||
1464 | if (ifp->desc) | |
1465 | vty_out (vty, "%s", ifp->desc); | |
1466 | vty_out (vty, "%s", VTY_NEWLINE); | |
1467 | } | |
8b87bdf4 FL |
1468 | } |
1469 | ||
f412b39a DW |
1470 | /* |
1471 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1472 | * "show interface description " VRF_CMD_STR, | |
1473 | * SHOW_STR | |
1474 | * "Interface status and configuration\n" | |
1475 | * "Interface description\n" | |
1476 | * VRF_CMD_HELP_STR | |
1477 | * | |
1478 | */ | |
8b87bdf4 FL |
1479 | DEFUN (show_interface_desc, |
1480 | show_interface_desc_cmd, | |
1481 | "show interface description", | |
1482 | SHOW_STR | |
1483 | "Interface status and configuration\n" | |
1484 | "Interface description\n") | |
1485 | { | |
1486 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1487 | ||
1488 | if (argc > 0) | |
8b3f0677 | 1489 | VRF_GET_ID (vrf_id, argv[3]->arg); |
8b87bdf4 FL |
1490 | |
1491 | if_show_description (vty, vrf_id); | |
1492 | ||
1493 | return CMD_SUCCESS; | |
1494 | } | |
1495 | ||
8b87bdf4 FL |
1496 | |
1497 | DEFUN (show_interface_desc_vrf_all, | |
1498 | show_interface_desc_vrf_all_cmd, | |
1499 | "show interface description " VRF_ALL_CMD_STR, | |
1500 | SHOW_STR | |
1501 | "Interface status and configuration\n" | |
1502 | "Interface description\n" | |
1503 | VRF_ALL_CMD_HELP_STR) | |
1504 | { | |
1505 | vrf_iter_t iter; | |
1506 | ||
1507 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) | |
1508 | if (!list_isempty (vrf_iter2iflist (iter))) | |
1509 | { | |
1510 | vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE, | |
1511 | vrf_iter2id (iter), | |
1512 | VTY_NEWLINE, VTY_NEWLINE); | |
1513 | if_show_description (vty, vrf_iter2id (iter)); | |
1514 | } | |
1515 | ||
ed9bb6d5 | 1516 | return CMD_SUCCESS; |
1517 | } | |
1518 | ||
718e3744 | 1519 | DEFUN (multicast, |
1520 | multicast_cmd, | |
1521 | "multicast", | |
1522 | "Set multicast flag to interface\n") | |
1523 | { | |
1524 | int ret; | |
1525 | struct interface *ifp; | |
1526 | struct zebra_if *if_data; | |
1527 | ||
1528 | ifp = (struct interface *) vty->index; | |
48b33aaf | 1529 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
718e3744 | 1530 | { |
48b33aaf | 1531 | ret = if_set_flags (ifp, IFF_MULTICAST); |
1532 | if (ret < 0) | |
1533 | { | |
1534 | vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE); | |
1535 | return CMD_WARNING; | |
1536 | } | |
1537 | if_refresh (ifp); | |
718e3744 | 1538 | } |
718e3744 | 1539 | if_data = ifp->info; |
1540 | if_data->multicast = IF_ZEBRA_MULTICAST_ON; | |
48b33aaf | 1541 | |
718e3744 | 1542 | return CMD_SUCCESS; |
1543 | } | |
1544 | ||
1545 | DEFUN (no_multicast, | |
1546 | no_multicast_cmd, | |
1547 | "no multicast", | |
1548 | NO_STR | |
1549 | "Unset multicast flag to interface\n") | |
1550 | { | |
1551 | int ret; | |
1552 | struct interface *ifp; | |
1553 | struct zebra_if *if_data; | |
1554 | ||
1555 | ifp = (struct interface *) vty->index; | |
48b33aaf | 1556 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
718e3744 | 1557 | { |
48b33aaf | 1558 | ret = if_unset_flags (ifp, IFF_MULTICAST); |
1559 | if (ret < 0) | |
1560 | { | |
1561 | vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE); | |
1562 | return CMD_WARNING; | |
1563 | } | |
1564 | if_refresh (ifp); | |
718e3744 | 1565 | } |
718e3744 | 1566 | if_data = ifp->info; |
1567 | if_data->multicast = IF_ZEBRA_MULTICAST_OFF; | |
1568 | ||
1569 | return CMD_SUCCESS; | |
1570 | } | |
1571 | ||
2e3b2e47 | 1572 | DEFUN (linkdetect, |
1573 | linkdetect_cmd, | |
1574 | "link-detect", | |
1575 | "Enable link detection on interface\n") | |
1576 | { | |
2e3b2e47 | 1577 | struct interface *ifp; |
1578 | int if_was_operative; | |
1579 | ||
1580 | ifp = (struct interface *) vty->index; | |
244c1cdc | 1581 | if_was_operative = if_is_no_ptm_operative(ifp); |
2e3b2e47 | 1582 | SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
1583 | ||
1584 | /* When linkdetection is enabled, if might come down */ | |
244c1cdc | 1585 | if (!if_is_no_ptm_operative(ifp) && if_was_operative) if_down(ifp); |
2e3b2e47 | 1586 | |
1587 | /* FIXME: Will defer status change forwarding if interface | |
1588 | does not come down! */ | |
1589 | ||
1590 | return CMD_SUCCESS; | |
1591 | } | |
1592 | ||
1593 | ||
1594 | DEFUN (no_linkdetect, | |
1595 | no_linkdetect_cmd, | |
1596 | "no link-detect", | |
1597 | NO_STR | |
1598 | "Disable link detection on interface\n") | |
1599 | { | |
2e3b2e47 | 1600 | struct interface *ifp; |
1601 | int if_was_operative; | |
1602 | ||
1603 | ifp = (struct interface *) vty->index; | |
244c1cdc | 1604 | if_was_operative = if_is_no_ptm_operative(ifp); |
2e3b2e47 | 1605 | UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
1606 | ||
1607 | /* Interface may come up after disabling link detection */ | |
1608 | if (if_is_operative(ifp) && !if_was_operative) if_up(ifp); | |
1609 | ||
1610 | /* FIXME: see linkdetect_cmd */ | |
1611 | ||
1612 | return CMD_SUCCESS; | |
1613 | } | |
1614 | ||
718e3744 | 1615 | DEFUN (shutdown_if, |
1616 | shutdown_if_cmd, | |
1617 | "shutdown", | |
1618 | "Shutdown the selected interface\n") | |
1619 | { | |
1620 | int ret; | |
1621 | struct interface *ifp; | |
1622 | struct zebra_if *if_data; | |
1623 | ||
1624 | ifp = (struct interface *) vty->index; | |
bfac8dcd | 1625 | if (ifp->ifindex != IFINDEX_INTERNAL) |
718e3744 | 1626 | { |
bfac8dcd CF |
1627 | ret = if_unset_flags (ifp, IFF_UP); |
1628 | if (ret < 0) | |
1629 | { | |
1630 | vty_out (vty, "Can't shutdown interface%s", VTY_NEWLINE); | |
1631 | return CMD_WARNING; | |
1632 | } | |
1633 | if_refresh (ifp); | |
718e3744 | 1634 | } |
718e3744 | 1635 | if_data = ifp->info; |
1636 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_ON; | |
1637 | ||
1638 | return CMD_SUCCESS; | |
1639 | } | |
1640 | ||
1641 | DEFUN (no_shutdown_if, | |
1642 | no_shutdown_if_cmd, | |
1643 | "no shutdown", | |
1644 | NO_STR | |
1645 | "Shutdown the selected interface\n") | |
1646 | { | |
1647 | int ret; | |
1648 | struct interface *ifp; | |
1649 | struct zebra_if *if_data; | |
1650 | ||
1651 | ifp = (struct interface *) vty->index; | |
bfac8dcd CF |
1652 | |
1653 | if (ifp->ifindex != IFINDEX_INTERNAL) | |
718e3744 | 1654 | { |
bfac8dcd CF |
1655 | ret = if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
1656 | if (ret < 0) | |
1657 | { | |
1658 | vty_out (vty, "Can't up interface%s", VTY_NEWLINE); | |
1659 | return CMD_WARNING; | |
1660 | } | |
1661 | if_refresh (ifp); | |
1662 | ||
1663 | /* Some addresses (in particular, IPv6 addresses on Linux) get | |
1664 | * removed when the interface goes down. They need to be readded. | |
1665 | */ | |
1666 | if_addr_wakeup(ifp); | |
718e3744 | 1667 | } |
bfac8dcd | 1668 | |
718e3744 | 1669 | if_data = ifp->info; |
1670 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_OFF; | |
1671 | ||
1672 | return CMD_SUCCESS; | |
1673 | } | |
1674 | ||
1675 | DEFUN (bandwidth_if, | |
1676 | bandwidth_if_cmd, | |
6147e2c6 | 1677 | "bandwidth (1-100000)", |
718e3744 | 1678 | "Set bandwidth informational parameter\n" |
70bd3c43 | 1679 | "Bandwidth in megabits\n") |
718e3744 | 1680 | { |
1681 | struct interface *ifp; | |
1682 | unsigned int bandwidth; | |
1683 | ||
1684 | ifp = (struct interface *) vty->index; | |
8b3f0677 | 1685 | bandwidth = strtol(argv[1]->arg, NULL, 10); |
718e3744 | 1686 | |
70bd3c43 DS |
1687 | /* bandwidth range is <1-100000> */ |
1688 | if (bandwidth < 1 || bandwidth > 100000) | |
718e3744 | 1689 | { |
1690 | vty_out (vty, "Bandwidth is invalid%s", VTY_NEWLINE); | |
1691 | return CMD_WARNING; | |
1692 | } | |
1693 | ||
1694 | ifp->bandwidth = bandwidth; | |
1695 | ||
1696 | /* force protocols to recalculate routes due to cost change */ | |
2e3b2e47 | 1697 | if (if_is_operative (ifp)) |
718e3744 | 1698 | zebra_interface_up_update (ifp); |
1699 | ||
1700 | return CMD_SUCCESS; | |
1701 | } | |
1702 | ||
f412b39a DW |
1703 | /* |
1704 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1705 | * "no bandwidth <1-100000>", | |
1706 | * NO_STR | |
1707 | * "Set bandwidth informational parameter\n" | |
1708 | * "Bandwidth in megabits\n" | |
1709 | * | |
1710 | */ | |
718e3744 | 1711 | DEFUN (no_bandwidth_if, |
1712 | no_bandwidth_if_cmd, | |
1713 | "no bandwidth", | |
1714 | NO_STR | |
1715 | "Set bandwidth informational parameter\n") | |
1716 | { | |
1717 | struct interface *ifp; | |
1718 | ||
1719 | ifp = (struct interface *) vty->index; | |
1720 | ||
1721 | ifp->bandwidth = 0; | |
1722 | ||
1723 | /* force protocols to recalculate routes due to cost change */ | |
2e3b2e47 | 1724 | if (if_is_operative (ifp)) |
718e3744 | 1725 | zebra_interface_up_update (ifp); |
1726 | ||
1727 | return CMD_SUCCESS; | |
1728 | } | |
1729 | ||
6b0655a2 | 1730 | |
16f1b9ee OD |
1731 | struct cmd_node link_params_node = |
1732 | { | |
1733 | LINK_PARAMS_NODE, | |
1734 | "%s(config-link-params)# ", | |
1735 | 1, | |
1736 | }; | |
1737 | ||
1738 | static void | |
1739 | link_param_cmd_set_uint32 (struct interface *ifp, uint32_t *field, | |
1740 | uint32_t type, uint32_t value) | |
1741 | { | |
1742 | /* Update field as needed */ | |
1743 | if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) | |
1744 | { | |
1745 | *field = value; | |
1746 | SET_PARAM(ifp->link_params, type); | |
1747 | ||
1748 | /* force protocols to update LINK STATE due to parameters change */ | |
1749 | if (if_is_operative (ifp)) | |
1750 | zebra_interface_parameters_update (ifp); | |
1751 | } | |
1752 | } | |
1753 | static void | |
1754 | link_param_cmd_set_float (struct interface *ifp, float *field, | |
1755 | uint32_t type, float value) | |
1756 | { | |
1757 | ||
1758 | /* Update field as needed */ | |
1759 | if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) | |
1760 | { | |
1761 | *field = value; | |
1762 | SET_PARAM(ifp->link_params, type); | |
1763 | ||
1764 | /* force protocols to update LINK STATE due to parameters change */ | |
1765 | if (if_is_operative (ifp)) | |
1766 | zebra_interface_parameters_update (ifp); | |
1767 | } | |
1768 | } | |
1769 | ||
1770 | static void | |
1771 | link_param_cmd_unset (struct interface *ifp, uint32_t type) | |
1772 | { | |
1773 | ||
1774 | /* Unset field */ | |
1775 | UNSET_PARAM(ifp->link_params, type); | |
1776 | ||
1777 | /* force protocols to update LINK STATE due to parameters change */ | |
1778 | if (if_is_operative (ifp)) | |
1779 | zebra_interface_parameters_update (ifp); | |
1780 | } | |
1781 | ||
1782 | DEFUN (link_params, | |
1783 | link_params_cmd, | |
1784 | "link-params", | |
1785 | LINK_PARAMS_STR) | |
1786 | { | |
1787 | vty->node = LINK_PARAMS_NODE; | |
1788 | ||
1789 | return CMD_SUCCESS; | |
1790 | } | |
1791 | ||
1792 | /* Specific Traffic Engineering parameters commands */ | |
1793 | DEFUN (link_params_enable, | |
1794 | link_params_enable_cmd, | |
1795 | "enable", | |
1796 | "Activate link parameters on this interface\n") | |
1797 | { | |
1798 | struct interface *ifp = (struct interface *) vty->index; | |
1799 | ||
1800 | /* This command could be issue at startup, when activate MPLS TE */ | |
1801 | /* on a new interface or after a ON / OFF / ON toggle */ | |
1802 | /* In all case, TE parameters are reset to their default factory */ | |
1803 | if (IS_ZEBRA_DEBUG_EVENT) | |
1804 | zlog_debug ("Link-params: enable TE link parameters on interface %s", ifp->name); | |
1805 | ||
1806 | if (!if_link_params_get (ifp)) | |
1807 | { | |
1808 | if (IS_ZEBRA_DEBUG_EVENT) | |
1809 | zlog_debug ("Link-params: failed to init TE link parameters %s", ifp->name); | |
1810 | ||
1811 | return CMD_WARNING; | |
1812 | } | |
1813 | ||
1814 | /* force protocols to update LINK STATE due to parameters change */ | |
1815 | if (if_is_operative (ifp)) | |
1816 | zebra_interface_parameters_update (ifp); | |
1817 | ||
1818 | return CMD_SUCCESS; | |
1819 | } | |
1820 | ||
1821 | DEFUN (no_link_params_enable, | |
1822 | no_link_params_enable_cmd, | |
1823 | "no enable", | |
1824 | NO_STR | |
1825 | "Disable link parameters on this interface\n") | |
1826 | { | |
1827 | struct interface *ifp = (struct interface *) vty->index; | |
1828 | ||
1829 | zlog_debug ("MPLS-TE: disable TE link parameters on interface %s", ifp->name); | |
1830 | ||
1831 | if_link_params_free (ifp); | |
1832 | ||
1833 | /* force protocols to update LINK STATE due to parameters change */ | |
1834 | if (if_is_operative (ifp)) | |
1835 | zebra_interface_parameters_update (ifp); | |
1836 | ||
1837 | return CMD_SUCCESS; | |
1838 | } | |
1839 | ||
1840 | /* STANDARD TE metrics */ | |
1841 | DEFUN (link_params_metric, | |
1842 | link_params_metric_cmd, | |
6147e2c6 | 1843 | "metric (0-4294967295)", |
16f1b9ee OD |
1844 | "Link metric for MPLS-TE purpose\n" |
1845 | "Metric value in decimal\n") | |
1846 | { | |
1847 | struct interface *ifp = (struct interface *) vty->index; | |
1848 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1849 | u_int32_t metric; | |
1850 | ||
8b3f0677 | 1851 | VTY_GET_ULONG("metric", metric, argv[1]->arg); |
16f1b9ee OD |
1852 | |
1853 | /* Update TE metric if needed */ | |
1854 | link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric); | |
1855 | ||
1856 | return CMD_SUCCESS; | |
1857 | } | |
1858 | ||
1859 | DEFUN (no_link_params_metric, | |
1860 | no_link_params_metric_cmd, | |
1861 | "no metric", | |
1862 | NO_STR | |
1863 | "Disbale Link Metric on this interface\n") | |
1864 | { | |
1865 | struct interface *ifp = (struct interface *) vty->index; | |
1866 | ||
1867 | /* Unset TE Metric */ | |
1868 | link_param_cmd_unset(ifp, LP_TE); | |
1869 | ||
1870 | return CMD_SUCCESS; | |
1871 | } | |
1872 | ||
1873 | DEFUN (link_params_maxbw, | |
1874 | link_params_maxbw_cmd, | |
1875 | "max-bw BANDWIDTH", | |
1876 | "Maximum bandwidth that can be used\n" | |
1877 | "Bytes/second (IEEE floating point format)\n") | |
1878 | { | |
1879 | struct interface *ifp = (struct interface *) vty->index; | |
1880 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1881 | ||
1882 | float bw; | |
1883 | ||
8b3f0677 | 1884 | if (sscanf (argv[1]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1885 | { |
1886 | vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno), | |
1887 | VTY_NEWLINE); | |
1888 | return CMD_WARNING; | |
1889 | } | |
1890 | ||
1891 | /* Check that Maximum bandwidth is not lower than other bandwidth parameters */ | |
1892 | if ((bw <= iflp->max_rsv_bw) | |
1893 | || (bw <= iflp->unrsv_bw[0]) | |
1894 | || (bw <= iflp->unrsv_bw[1]) | |
1895 | || (bw <= iflp->unrsv_bw[2]) | |
1896 | || (bw <= iflp->unrsv_bw[3]) | |
1897 | || (bw <= iflp->unrsv_bw[4]) | |
1898 | || (bw <= iflp->unrsv_bw[5]) | |
1899 | || (bw <= iflp->unrsv_bw[6]) | |
1900 | || (bw <= iflp->unrsv_bw[7]) | |
1901 | || (bw <= iflp->ava_bw) | |
1902 | || (bw <= iflp->res_bw) | |
1903 | || (bw <= iflp->use_bw)) | |
1904 | { | |
1905 | vty_out (vty, | |
1906 | "Maximum Bandwidth could not be lower than others bandwidth%s", | |
1907 | VTY_NEWLINE); | |
1908 | return CMD_WARNING; | |
1909 | } | |
1910 | ||
1911 | /* Update Maximum Bandwidth if needed */ | |
1912 | link_param_cmd_set_float (ifp, &iflp->max_bw, LP_MAX_BW, bw); | |
1913 | ||
1914 | return CMD_SUCCESS; | |
1915 | } | |
1916 | ||
1917 | DEFUN (link_params_max_rsv_bw, | |
1918 | link_params_max_rsv_bw_cmd, | |
1919 | "max-rsv-bw BANDWIDTH", | |
1920 | "Maximum bandwidth that may be reserved\n" | |
1921 | "Bytes/second (IEEE floating point format)\n") | |
1922 | { | |
1923 | struct interface *ifp = (struct interface *) vty->index; | |
1924 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1925 | float bw; | |
1926 | ||
8b3f0677 | 1927 | if (sscanf (argv[1]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1928 | { |
1929 | vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1930 | VTY_NEWLINE); | |
1931 | return CMD_WARNING; | |
1932 | } | |
1933 | ||
1934 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
1935 | if (bw > iflp->max_bw) | |
1936 | { | |
1937 | vty_out (vty, | |
1938 | "Maximum Reservable Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
1939 | iflp->max_bw, VTY_NEWLINE); | |
1940 | return CMD_WARNING; | |
1941 | } | |
1942 | ||
1943 | /* Update Maximum Reservable Bandwidth if needed */ | |
1944 | link_param_cmd_set_float (ifp, &iflp->max_rsv_bw, LP_MAX_RSV_BW, bw); | |
1945 | ||
1946 | return CMD_SUCCESS; | |
1947 | } | |
1948 | ||
1949 | DEFUN (link_params_unrsv_bw, | |
1950 | link_params_unrsv_bw_cmd, | |
6147e2c6 | 1951 | "unrsv-bw (0-7) BANDWIDTH", |
16f1b9ee OD |
1952 | "Unreserved bandwidth at each priority level\n" |
1953 | "Priority\n" | |
1954 | "Bytes/second (IEEE floating point format)\n") | |
1955 | { | |
1956 | struct interface *ifp = (struct interface *) vty->index; | |
1957 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1958 | int priority; | |
1959 | float bw; | |
1960 | ||
1961 | /* We don't have to consider about range check here. */ | |
8b3f0677 | 1962 | if (sscanf (argv[1]->arg, "%d", &priority) != 1) |
16f1b9ee OD |
1963 | { |
1964 | vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1965 | VTY_NEWLINE); | |
1966 | return CMD_WARNING; | |
1967 | } | |
1968 | ||
8b3f0677 | 1969 | if (sscanf (argv[2]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1970 | { |
1971 | vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1972 | VTY_NEWLINE); | |
1973 | return CMD_WARNING; | |
1974 | } | |
1975 | ||
1976 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
1977 | if (bw > iflp->max_bw) | |
1978 | { | |
1979 | vty_out (vty, | |
1980 | "UnReserved Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
1981 | iflp->max_bw, VTY_NEWLINE); | |
1982 | return CMD_WARNING; | |
1983 | } | |
1984 | ||
1985 | /* Update Unreserved Bandwidth if needed */ | |
1986 | link_param_cmd_set_float (ifp, &iflp->unrsv_bw[priority], LP_UNRSV_BW, bw); | |
1987 | ||
1988 | return CMD_SUCCESS; | |
1989 | } | |
1990 | ||
1991 | DEFUN (link_params_admin_grp, | |
1992 | link_params_admin_grp_cmd, | |
1993 | "admin-grp BITPATTERN", | |
1994 | "Administrative group membership\n" | |
1995 | "32-bit Hexadecimal value (e.g. 0xa1)\n") | |
1996 | { | |
1997 | struct interface *ifp = (struct interface *) vty->index; | |
1998 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1999 | unsigned long value; | |
2000 | ||
8b3f0677 | 2001 | if (sscanf (argv[1]->arg, "0x%lx", &value) != 1) |
16f1b9ee OD |
2002 | { |
2003 | vty_out (vty, "link_params_admin_grp: fscanf: %s%s", | |
2004 | safe_strerror (errno), VTY_NEWLINE); | |
2005 | return CMD_WARNING; | |
2006 | } | |
2007 | ||
2008 | /* Update Administrative Group if needed */ | |
2009 | link_param_cmd_set_uint32 (ifp, &iflp->admin_grp, LP_ADM_GRP, value); | |
2010 | ||
2011 | return CMD_SUCCESS; | |
2012 | } | |
2013 | ||
2014 | DEFUN (no_link_params_admin_grp, | |
2015 | no_link_params_admin_grp_cmd, | |
2016 | "no admin-grp", | |
2017 | NO_STR | |
2018 | "Disbale Administrative group membership on this interface\n") | |
2019 | { | |
2020 | struct interface *ifp = (struct interface *) vty->index; | |
2021 | ||
2022 | /* Unset Admin Group */ | |
2023 | link_param_cmd_unset(ifp, LP_ADM_GRP); | |
2024 | ||
2025 | return CMD_SUCCESS; | |
2026 | } | |
2027 | ||
2028 | /* RFC5392 & RFC5316: INTER-AS */ | |
2029 | DEFUN (link_params_inter_as, | |
2030 | link_params_inter_as_cmd, | |
6147e2c6 | 2031 | "neighbor A.B.C.D as (1-4294967295)", |
16f1b9ee OD |
2032 | "Configure remote ASBR information (Neighbor IP address and AS number)\n" |
2033 | "Remote IP address in dot decimal A.B.C.D\n" | |
2034 | "Remote AS number\n" | |
2035 | "AS number in the range <1-4294967295>\n") | |
2036 | { | |
2037 | ||
2038 | struct interface *ifp = (struct interface *) vty->index; | |
2039 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2040 | struct in_addr addr; | |
2041 | u_int32_t as; | |
2042 | ||
8b3f0677 | 2043 | if (!inet_aton (argv[1]->arg, &addr)) |
16f1b9ee OD |
2044 | { |
2045 | vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); | |
2046 | return CMD_WARNING; | |
2047 | } | |
2048 | ||
8b3f0677 | 2049 | VTY_GET_ULONG("AS number", as, argv[3]->arg); |
16f1b9ee OD |
2050 | |
2051 | /* Update Remote IP and Remote AS fields if needed */ | |
2052 | if (IS_PARAM_UNSET(iflp, LP_RMT_AS) | |
2053 | || iflp->rmt_as != as | |
2054 | || iflp->rmt_ip.s_addr != addr.s_addr) | |
2055 | { | |
2056 | ||
2057 | iflp->rmt_as = as; | |
2058 | iflp->rmt_ip.s_addr = addr.s_addr; | |
2059 | SET_PARAM(iflp, LP_RMT_AS); | |
2060 | ||
2061 | /* force protocols to update LINK STATE due to parameters change */ | |
2062 | if (if_is_operative (ifp)) | |
2063 | zebra_interface_parameters_update (ifp); | |
2064 | } | |
2065 | return CMD_SUCCESS; | |
2066 | } | |
2067 | ||
2068 | DEFUN (no_link_params_inter_as, | |
2069 | no_link_params_inter_as_cmd, | |
2070 | "no neighbor", | |
2071 | NO_STR | |
2072 | "Remove Neighbor IP address and AS number for Inter-AS TE\n") | |
2073 | { | |
2074 | ||
2075 | struct interface *ifp = (struct interface *) vty->index; | |
2076 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2077 | ||
2078 | /* Reset Remote IP and AS neighbor */ | |
2079 | iflp->rmt_as = 0; | |
2080 | iflp->rmt_ip.s_addr = 0; | |
2081 | UNSET_PARAM(iflp, LP_RMT_AS); | |
2082 | ||
2083 | /* force protocols to update LINK STATE due to parameters change */ | |
2084 | if (if_is_operative (ifp)) | |
2085 | zebra_interface_parameters_update (ifp); | |
2086 | ||
2087 | return CMD_SUCCESS; | |
2088 | } | |
2089 | ||
2090 | /* RFC7471: OSPF Traffic Engineering (TE) Metric extensions & draft-ietf-isis-metric-extensions-07.txt */ | |
f412b39a DW |
2091 | /* |
2092 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2093 | * "delay <0-16777215> min <0-16777215> max <0-16777215>", | |
2094 | * "Unidirectional Average Link Delay (optionally Minimum and Maximum delays)\n" | |
2095 | * "Average delay in micro-second as decimal (0...16777215)\n" | |
2096 | * "Minimum delay\n" | |
2097 | * "Minimum delay in micro-second as decimal (0...16777215)\n" | |
2098 | * "Maximum delay\n" | |
2099 | * "Maximum delay in micro-second as decimal (0...16777215)\n" | |
2100 | * | |
2101 | */ | |
16f1b9ee OD |
2102 | DEFUN (link_params_delay, |
2103 | link_params_delay_cmd, | |
6147e2c6 | 2104 | "delay (0-16777215)", |
16f1b9ee OD |
2105 | "Unidirectional Average Link Delay\n" |
2106 | "Average delay in micro-second as decimal (0...16777215)\n") | |
2107 | { | |
2108 | ||
2109 | struct interface *ifp = (struct interface *) vty->index; | |
2110 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2111 | u_int32_t delay = 0, low = 0, high = 0; | |
2112 | u_int8_t update = 0; | |
2113 | ||
2114 | /* Get and Check new delay values */ | |
8b3f0677 | 2115 | VTY_GET_ULONG("delay", delay, argv[1]->arg); |
16f1b9ee OD |
2116 | switch (argc) |
2117 | { | |
2118 | case 1: | |
2119 | /* Check new delay value against old Min and Max delays if set */ | |
2120 | if (IS_PARAM_SET(iflp, LP_MM_DELAY) | |
2121 | && (delay <= iflp->min_delay || delay >= iflp->max_delay)) | |
2122 | { | |
2123 | vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", | |
2124 | iflp->min_delay, iflp->max_delay, VTY_NEWLINE); | |
2125 | return CMD_WARNING; | |
2126 | } | |
2127 | /* Update delay if value is not set or change */ | |
2128 | if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay) | |
2129 | { | |
2130 | iflp->av_delay = delay; | |
2131 | SET_PARAM(iflp, LP_DELAY); | |
2132 | update = 1; | |
2133 | } | |
2134 | /* Unset Min and Max delays if already set */ | |
2135 | if (IS_PARAM_SET(iflp, LP_MM_DELAY)) | |
2136 | { | |
2137 | iflp->min_delay = 0; | |
2138 | iflp->max_delay = 0; | |
2139 | UNSET_PARAM(iflp, LP_MM_DELAY); | |
2140 | update = 1; | |
2141 | } | |
2142 | break; | |
2143 | case 2: | |
2144 | vty_out (vty, "You should specify both Minimum and Maximum delay with Average delay%s", | |
2145 | VTY_NEWLINE); | |
2146 | return CMD_WARNING; | |
2147 | break; | |
2148 | case 3: | |
8b3f0677 DW |
2149 | VTY_GET_ULONG("minimum delay", low, argv[3]->arg); |
2150 | VTY_GET_ULONG("maximum delay", high, argv[5]->arg); | |
16f1b9ee OD |
2151 | /* Check new delays value coherency */ |
2152 | if (delay <= low || delay >= high) | |
2153 | { | |
2154 | vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", | |
2155 | low, high, VTY_NEWLINE); | |
2156 | return CMD_WARNING; | |
2157 | } | |
2158 | /* Update Delays if needed */ | |
2159 | if (IS_PARAM_UNSET(iflp, LP_DELAY) | |
2160 | || IS_PARAM_UNSET(iflp, LP_MM_DELAY) | |
2161 | || iflp->av_delay != delay | |
2162 | || iflp->min_delay != low | |
2163 | || iflp->max_delay != high) | |
2164 | { | |
2165 | iflp->av_delay = delay; | |
2166 | SET_PARAM(iflp, LP_DELAY); | |
2167 | iflp->min_delay = low; | |
2168 | iflp->max_delay = high; | |
2169 | SET_PARAM(iflp, LP_MM_DELAY); | |
2170 | update = 1; | |
2171 | } | |
2172 | break; | |
2173 | default: | |
2174 | return CMD_WARNING; | |
2175 | break; | |
2176 | } | |
2177 | ||
2178 | /* force protocols to update LINK STATE due to parameters change */ | |
2179 | if (update == 1 && if_is_operative (ifp)) | |
2180 | zebra_interface_parameters_update (ifp); | |
2181 | ||
2182 | return CMD_SUCCESS; | |
2183 | } | |
2184 | ||
16f1b9ee OD |
2185 | |
2186 | DEFUN (no_link_params_delay, | |
2187 | no_link_params_delay_cmd, | |
2188 | "no delay", | |
2189 | NO_STR | |
2190 | "Disbale Unidirectional Average, Min & Max Link Delay on this interface\n") | |
2191 | { | |
2192 | struct interface *ifp = (struct interface *) vty->index; | |
2193 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2194 | ||
2195 | /* Unset Delays */ | |
2196 | iflp->av_delay = 0; | |
2197 | UNSET_PARAM(iflp, LP_DELAY); | |
2198 | iflp->min_delay = 0; | |
2199 | iflp->max_delay = 0; | |
2200 | UNSET_PARAM(iflp, LP_MM_DELAY); | |
2201 | ||
2202 | /* force protocols to update LINK STATE due to parameters change */ | |
2203 | if (if_is_operative (ifp)) | |
2204 | zebra_interface_parameters_update (ifp); | |
2205 | ||
2206 | return CMD_SUCCESS; | |
2207 | } | |
2208 | ||
2209 | DEFUN (link_params_delay_var, | |
2210 | link_params_delay_var_cmd, | |
6147e2c6 | 2211 | "delay-variation (0-16777215)", |
16f1b9ee OD |
2212 | "Unidirectional Link Delay Variation\n" |
2213 | "delay variation in micro-second as decimal (0...16777215)\n") | |
2214 | { | |
2215 | struct interface *ifp = (struct interface *) vty->index; | |
2216 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2217 | u_int32_t value; | |
2218 | ||
8b3f0677 | 2219 | VTY_GET_ULONG("delay variation", value, argv[1]->arg); |
16f1b9ee OD |
2220 | |
2221 | /* Update Delay Variation if needed */ | |
2222 | link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value); | |
2223 | ||
2224 | return CMD_SUCCESS; | |
2225 | } | |
2226 | ||
2227 | DEFUN (no_link_params_delay_var, | |
2228 | no_link_params_delay_var_cmd, | |
2229 | "no delay-variation", | |
2230 | NO_STR | |
2231 | "Disbale Unidirectional Delay Variation on this interface\n") | |
2232 | { | |
2233 | struct interface *ifp = (struct interface *) vty->index; | |
2234 | ||
2235 | /* Unset Delay Variation */ | |
2236 | link_param_cmd_unset(ifp, LP_DELAY_VAR); | |
2237 | ||
2238 | return CMD_SUCCESS; | |
2239 | } | |
2240 | ||
2241 | DEFUN (link_params_pkt_loss, | |
2242 | link_params_pkt_loss_cmd, | |
2243 | "packet-loss PERCENTAGE", | |
2244 | "Unidirectional Link Packet Loss\n" | |
2245 | "percentage of total traffic by 0.000003% step and less than 50.331642%\n") | |
2246 | { | |
2247 | struct interface *ifp = (struct interface *) vty->index; | |
2248 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2249 | float fval; | |
2250 | ||
8b3f0677 | 2251 | if (sscanf (argv[1]->arg, "%g", &fval) != 1) |
16f1b9ee OD |
2252 | { |
2253 | vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno), | |
2254 | VTY_NEWLINE); | |
2255 | return CMD_WARNING; | |
2256 | } | |
2257 | ||
2258 | if (fval > MAX_PKT_LOSS) | |
2259 | fval = MAX_PKT_LOSS; | |
2260 | ||
2261 | /* Update Packet Loss if needed */ | |
2262 | link_param_cmd_set_float (ifp, &iflp->pkt_loss, LP_PKT_LOSS, fval); | |
2263 | ||
2264 | return CMD_SUCCESS; | |
2265 | } | |
2266 | ||
2267 | DEFUN (no_link_params_pkt_loss, | |
2268 | no_link_params_pkt_loss_cmd, | |
2269 | "no packet-loss", | |
2270 | NO_STR | |
2271 | "Disbale Unidirectional Link Packet Loss on this interface\n") | |
2272 | { | |
2273 | struct interface *ifp = (struct interface *) vty->index; | |
2274 | ||
2275 | /* Unset Packet Loss */ | |
2276 | link_param_cmd_unset(ifp, LP_PKT_LOSS); | |
2277 | ||
2278 | return CMD_SUCCESS; | |
2279 | } | |
2280 | ||
2281 | DEFUN (link_params_res_bw, | |
2282 | link_params_res_bw_cmd, | |
2283 | "res-bw BANDWIDTH", | |
2284 | "Unidirectional Residual Bandwidth\n" | |
2285 | "Bytes/second (IEEE floating point format)\n") | |
2286 | { | |
2287 | struct interface *ifp = (struct interface *) vty->index; | |
2288 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2289 | float bw; | |
2290 | ||
8b3f0677 | 2291 | if (sscanf (argv[1]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2292 | { |
2293 | vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno), | |
2294 | VTY_NEWLINE); | |
2295 | return CMD_WARNING; | |
2296 | } | |
2297 | ||
2298 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2299 | if (bw > iflp->max_bw) | |
2300 | { | |
2301 | vty_out (vty, | |
2302 | "Residual Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2303 | iflp->max_bw, VTY_NEWLINE); | |
2304 | return CMD_WARNING; | |
2305 | } | |
2306 | ||
2307 | /* Update Residual Bandwidth if needed */ | |
2308 | link_param_cmd_set_float (ifp, &iflp->res_bw, LP_RES_BW, bw); | |
2309 | ||
2310 | return CMD_SUCCESS; | |
2311 | } | |
2312 | ||
2313 | DEFUN (no_link_params_res_bw, | |
2314 | no_link_params_res_bw_cmd, | |
2315 | "no res-bw", | |
2316 | NO_STR | |
2317 | "Disbale Unidirectional Residual Bandwidth on this interface\n") | |
2318 | { | |
2319 | struct interface *ifp = (struct interface *) vty->index; | |
2320 | ||
2321 | /* Unset Residual Bandwidth */ | |
2322 | link_param_cmd_unset(ifp, LP_RES_BW); | |
2323 | ||
2324 | return CMD_SUCCESS; | |
2325 | } | |
2326 | ||
2327 | DEFUN (link_params_ava_bw, | |
2328 | link_params_ava_bw_cmd, | |
2329 | "ava-bw BANDWIDTH", | |
2330 | "Unidirectional Available Bandwidth\n" | |
2331 | "Bytes/second (IEEE floating point format)\n") | |
2332 | { | |
2333 | struct interface *ifp = (struct interface *) vty->index; | |
2334 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2335 | float bw; | |
2336 | ||
8b3f0677 | 2337 | if (sscanf (argv[1]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2338 | { |
2339 | vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno), | |
2340 | VTY_NEWLINE); | |
2341 | return CMD_WARNING; | |
2342 | } | |
2343 | ||
2344 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2345 | if (bw > iflp->max_bw) | |
2346 | { | |
2347 | vty_out (vty, | |
2348 | "Available Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2349 | iflp->max_bw, VTY_NEWLINE); | |
2350 | return CMD_WARNING; | |
2351 | } | |
2352 | ||
2353 | /* Update Residual Bandwidth if needed */ | |
2354 | link_param_cmd_set_float (ifp, &iflp->ava_bw, LP_AVA_BW, bw); | |
2355 | ||
2356 | return CMD_SUCCESS; | |
2357 | } | |
2358 | ||
2359 | DEFUN (no_link_params_ava_bw, | |
2360 | no_link_params_ava_bw_cmd, | |
2361 | "no ava-bw", | |
2362 | NO_STR | |
2363 | "Disbale Unidirectional Available Bandwidth on this interface\n") | |
2364 | { | |
2365 | struct interface *ifp = (struct interface *) vty->index; | |
2366 | ||
2367 | /* Unset Available Bandwidth */ | |
2368 | link_param_cmd_unset(ifp, LP_AVA_BW); | |
2369 | ||
2370 | return CMD_SUCCESS; | |
2371 | } | |
2372 | ||
2373 | DEFUN (link_params_use_bw, | |
2374 | link_params_use_bw_cmd, | |
2375 | "use-bw BANDWIDTH", | |
2376 | "Unidirectional Utilised Bandwidth\n" | |
2377 | "Bytes/second (IEEE floating point format)\n") | |
2378 | { | |
2379 | struct interface *ifp = (struct interface *) vty->index; | |
2380 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2381 | float bw; | |
2382 | ||
8b3f0677 | 2383 | if (sscanf (argv[1]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2384 | { |
2385 | vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno), | |
2386 | VTY_NEWLINE); | |
2387 | return CMD_WARNING; | |
2388 | } | |
2389 | ||
2390 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2391 | if (bw > iflp->max_bw) | |
2392 | { | |
2393 | vty_out (vty, | |
2394 | "Utilised Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2395 | iflp->max_bw, VTY_NEWLINE); | |
2396 | return CMD_WARNING; | |
2397 | } | |
2398 | ||
2399 | /* Update Utilized Bandwidth if needed */ | |
2400 | link_param_cmd_set_float (ifp, &iflp->use_bw, LP_USE_BW, bw); | |
2401 | ||
2402 | return CMD_SUCCESS; | |
2403 | } | |
2404 | ||
2405 | DEFUN (no_link_params_use_bw, | |
2406 | no_link_params_use_bw_cmd, | |
2407 | "no use-bw", | |
2408 | NO_STR | |
2409 | "Disbale Unidirectional Utilised Bandwidth on this interface\n") | |
2410 | { | |
2411 | struct interface *ifp = (struct interface *) vty->index; | |
2412 | ||
2413 | /* Unset Utilised Bandwidth */ | |
2414 | link_param_cmd_unset(ifp, LP_USE_BW); | |
2415 | ||
2416 | return CMD_SUCCESS; | |
2417 | } | |
2418 | ||
a1ac18c4 | 2419 | static int |
39db97e4 | 2420 | ip_address_install (struct vty *vty, struct interface *ifp, |
2421 | const char *addr_str, const char *peer_str, | |
2422 | const char *label) | |
718e3744 | 2423 | { |
bfac8dcd | 2424 | struct zebra_if *if_data; |
718e3744 | 2425 | struct prefix_ipv4 cp; |
2426 | struct connected *ifc; | |
2427 | struct prefix_ipv4 *p; | |
718e3744 | 2428 | int ret; |
2429 | ||
bfac8dcd CF |
2430 | if_data = ifp->info; |
2431 | ||
718e3744 | 2432 | ret = str2prefix_ipv4 (addr_str, &cp); |
2433 | if (ret <= 0) | |
2434 | { | |
2435 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2436 | return CMD_WARNING; | |
2437 | } | |
2438 | ||
d914d5ff DS |
2439 | if (ipv4_martian(&cp.prefix)) |
2440 | { | |
2441 | vty_out (vty, "%% Invalid address%s", VTY_NEWLINE); | |
2442 | return CMD_WARNING; | |
2443 | } | |
2444 | ||
ca16218d | 2445 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2446 | if (! ifc) |
2447 | { | |
2448 | ifc = connected_new (); | |
2449 | ifc->ifp = ifp; | |
2450 | ||
2451 | /* Address. */ | |
2452 | p = prefix_ipv4_new (); | |
2453 | *p = cp; | |
2454 | ifc->address = (struct prefix *) p; | |
2455 | ||
2456 | /* Broadcast. */ | |
3fb9cd6e | 2457 | if (p->prefixlen <= IPV4_MAX_PREFIXLEN-2) |
718e3744 | 2458 | { |
2459 | p = prefix_ipv4_new (); | |
2460 | *p = cp; | |
3fb9cd6e | 2461 | p->prefix.s_addr = ipv4_broadcast_addr(p->prefix.s_addr,p->prefixlen); |
718e3744 | 2462 | ifc->destination = (struct prefix *) p; |
2463 | } | |
2464 | ||
718e3744 | 2465 | /* Label. */ |
2466 | if (label) | |
0752ef0b | 2467 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
718e3744 | 2468 | |
2469 | /* Add to linked list. */ | |
2470 | listnode_add (ifp->connected, ifc); | |
2471 | } | |
2472 | ||
2473 | /* This address is configured from zebra. */ | |
2474 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2475 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); | |
2476 | ||
2477 | /* In case of this route need to install kernel. */ | |
f7f740fe | 2478 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
bfac8dcd CF |
2479 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
2480 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) | |
718e3744 | 2481 | { |
2482 | /* Some system need to up the interface to set IP address. */ | |
2483 | if (! if_is_up (ifp)) | |
2484 | { | |
2485 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); | |
2486 | if_refresh (ifp); | |
2487 | } | |
2488 | ||
2489 | ret = if_set_prefix (ifp, ifc); | |
2490 | if (ret < 0) | |
2491 | { | |
2492 | vty_out (vty, "%% Can't set interface IP address: %s.%s", | |
6099b3b5 | 2493 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2494 | return CMD_WARNING; |
2495 | } | |
2496 | ||
f7f740fe | 2497 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2498 | /* The address will be advertised to zebra clients when the notification |
2499 | * from the kernel has been received. | |
2500 | * It will also be added to the subnet chain list, then. */ | |
718e3744 | 2501 | } |
2502 | ||
2503 | return CMD_SUCCESS; | |
2504 | } | |
2505 | ||
a1ac18c4 | 2506 | static int |
39db97e4 | 2507 | ip_address_uninstall (struct vty *vty, struct interface *ifp, |
2508 | const char *addr_str, const char *peer_str, | |
2509 | const char *label) | |
718e3744 | 2510 | { |
2511 | struct prefix_ipv4 cp; | |
2512 | struct connected *ifc; | |
2513 | int ret; | |
2514 | ||
2515 | /* Convert to prefix structure. */ | |
2516 | ret = str2prefix_ipv4 (addr_str, &cp); | |
2517 | if (ret <= 0) | |
2518 | { | |
2519 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2520 | return CMD_WARNING; | |
2521 | } | |
2522 | ||
2523 | /* Check current interface address. */ | |
ca16218d | 2524 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2525 | if (! ifc) |
2526 | { | |
2527 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); | |
2528 | return CMD_WARNING; | |
2529 | } | |
2530 | ||
2531 | /* This is not configured address. */ | |
2532 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2533 | return CMD_WARNING; | |
2534 | ||
74ecdc9e PJ |
2535 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
2536 | ||
718e3744 | 2537 | /* This is not real address or interface is not active. */ |
f7f740fe | 2538 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
718e3744 | 2539 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
2540 | { | |
2541 | listnode_delete (ifp->connected, ifc); | |
2542 | connected_free (ifc); | |
2543 | return CMD_WARNING; | |
2544 | } | |
2545 | ||
2546 | /* This is real route. */ | |
2547 | ret = if_unset_prefix (ifp, ifc); | |
2548 | if (ret < 0) | |
2549 | { | |
2550 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", | |
6099b3b5 | 2551 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2552 | return CMD_WARNING; |
2553 | } | |
f7f740fe | 2554 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2555 | /* we will receive a kernel notification about this route being removed. |
2556 | * this will trigger its removal from the connected list. */ | |
718e3744 | 2557 | return CMD_SUCCESS; |
2558 | } | |
2559 | ||
2560 | DEFUN (ip_address, | |
2561 | ip_address_cmd, | |
2562 | "ip address A.B.C.D/M", | |
2563 | "Interface Internet Protocol config commands\n" | |
2564 | "Set the IP address of an interface\n" | |
2565 | "IP address (e.g. 10.0.0.1/8)\n") | |
2566 | { | |
8b3f0677 | 2567 | return ip_address_install (vty, vty->index, argv[2]->arg, NULL, NULL); |
718e3744 | 2568 | } |
2569 | ||
2570 | DEFUN (no_ip_address, | |
2571 | no_ip_address_cmd, | |
2572 | "no ip address A.B.C.D/M", | |
2573 | NO_STR | |
2574 | "Interface Internet Protocol config commands\n" | |
2575 | "Set the IP address of an interface\n" | |
2576 | "IP Address (e.g. 10.0.0.1/8)") | |
2577 | { | |
8b3f0677 | 2578 | return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL); |
718e3744 | 2579 | } |
2580 | ||
986aa00f | 2581 | |
718e3744 | 2582 | #ifdef HAVE_NETLINK |
718e3744 | 2583 | DEFUN (ip_address_label, |
2584 | ip_address_label_cmd, | |
2585 | "ip address A.B.C.D/M label LINE", | |
2586 | "Interface Internet Protocol config commands\n" | |
2587 | "Set the IP address of an interface\n" | |
2588 | "IP address (e.g. 10.0.0.1/8)\n" | |
2589 | "Label of this address\n" | |
2590 | "Label\n") | |
2591 | { | |
8b3f0677 | 2592 | return ip_address_install (vty, vty->index, argv[2]->arg, NULL, argv[4]->arg); |
718e3744 | 2593 | } |
2594 | ||
2595 | DEFUN (no_ip_address_label, | |
2596 | no_ip_address_label_cmd, | |
2597 | "no ip address A.B.C.D/M label LINE", | |
2598 | NO_STR | |
2599 | "Interface Internet Protocol config commands\n" | |
2600 | "Set the IP address of an interface\n" | |
2601 | "IP address (e.g. 10.0.0.1/8)\n" | |
2602 | "Label of this address\n" | |
2603 | "Label\n") | |
2604 | { | |
8b3f0677 | 2605 | return ip_address_uninstall (vty, vty->index, argv[3]->arg, NULL, argv[5]->arg); |
718e3744 | 2606 | } |
2607 | #endif /* HAVE_NETLINK */ | |
2608 | ||
2609 | #ifdef HAVE_IPV6 | |
a1ac18c4 | 2610 | static int |
39db97e4 | 2611 | ipv6_address_install (struct vty *vty, struct interface *ifp, |
2612 | const char *addr_str, const char *peer_str, | |
2613 | const char *label, int secondary) | |
718e3744 | 2614 | { |
bfac8dcd | 2615 | struct zebra_if *if_data; |
718e3744 | 2616 | struct prefix_ipv6 cp; |
2617 | struct connected *ifc; | |
2618 | struct prefix_ipv6 *p; | |
2619 | int ret; | |
2620 | ||
bfac8dcd CF |
2621 | if_data = ifp->info; |
2622 | ||
718e3744 | 2623 | ret = str2prefix_ipv6 (addr_str, &cp); |
2624 | if (ret <= 0) | |
2625 | { | |
2626 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2627 | return CMD_WARNING; | |
2628 | } | |
2629 | ||
d914d5ff DS |
2630 | if (ipv6_martian(&cp.prefix)) |
2631 | { | |
2632 | vty_out (vty, "%% Invalid address%s", VTY_NEWLINE); | |
2633 | return CMD_WARNING; | |
2634 | } | |
2635 | ||
ca16218d | 2636 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2637 | if (! ifc) |
2638 | { | |
2639 | ifc = connected_new (); | |
2640 | ifc->ifp = ifp; | |
2641 | ||
2642 | /* Address. */ | |
2643 | p = prefix_ipv6_new (); | |
2644 | *p = cp; | |
2645 | ifc->address = (struct prefix *) p; | |
2646 | ||
2647 | /* Secondary. */ | |
2648 | if (secondary) | |
2649 | SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); | |
2650 | ||
2651 | /* Label. */ | |
2652 | if (label) | |
0752ef0b | 2653 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
718e3744 | 2654 | |
2655 | /* Add to linked list. */ | |
2656 | listnode_add (ifp->connected, ifc); | |
2657 | } | |
2658 | ||
2659 | /* This address is configured from zebra. */ | |
2660 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2661 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); | |
2662 | ||
2663 | /* In case of this route need to install kernel. */ | |
f7f740fe | 2664 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
bfac8dcd CF |
2665 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
2666 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) | |
718e3744 | 2667 | { |
2668 | /* Some system need to up the interface to set IP address. */ | |
2669 | if (! if_is_up (ifp)) | |
2670 | { | |
2671 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); | |
2672 | if_refresh (ifp); | |
2673 | } | |
2674 | ||
2675 | ret = if_prefix_add_ipv6 (ifp, ifc); | |
2676 | ||
2677 | if (ret < 0) | |
2678 | { | |
2679 | vty_out (vty, "%% Can't set interface IP address: %s.%s", | |
6099b3b5 | 2680 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2681 | return CMD_WARNING; |
2682 | } | |
2683 | ||
f7f740fe | 2684 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2685 | /* The address will be advertised to zebra clients when the notification |
2686 | * from the kernel has been received. */ | |
718e3744 | 2687 | } |
2688 | ||
2689 | return CMD_SUCCESS; | |
2690 | } | |
2691 | ||
b6120505 DW |
2692 | /* Return true if an ipv6 address is configured on ifp */ |
2693 | int | |
2694 | ipv6_address_configured (struct interface *ifp) | |
2695 | { | |
2696 | struct connected *connected; | |
2697 | struct listnode *node; | |
2698 | ||
2699 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) | |
2700 | if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) && (connected->address->family == AF_INET6)) | |
2701 | return 1; | |
2702 | ||
2703 | return 0; | |
2704 | } | |
2705 | ||
a1ac18c4 | 2706 | static int |
39db97e4 | 2707 | ipv6_address_uninstall (struct vty *vty, struct interface *ifp, |
2708 | const char *addr_str, const char *peer_str, | |
2709 | const char *label, int secondry) | |
718e3744 | 2710 | { |
2711 | struct prefix_ipv6 cp; | |
2712 | struct connected *ifc; | |
2713 | int ret; | |
2714 | ||
2715 | /* Convert to prefix structure. */ | |
2716 | ret = str2prefix_ipv6 (addr_str, &cp); | |
2717 | if (ret <= 0) | |
2718 | { | |
2719 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2720 | return CMD_WARNING; | |
2721 | } | |
2722 | ||
2723 | /* Check current interface address. */ | |
ca16218d | 2724 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2725 | if (! ifc) |
2726 | { | |
2727 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); | |
2728 | return CMD_WARNING; | |
2729 | } | |
2730 | ||
2731 | /* This is not configured address. */ | |
2732 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2733 | return CMD_WARNING; | |
2734 | ||
676e1a01 CF |
2735 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
2736 | ||
718e3744 | 2737 | /* This is not real address or interface is not active. */ |
f7f740fe | 2738 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
718e3744 | 2739 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
2740 | { | |
2741 | listnode_delete (ifp->connected, ifc); | |
2742 | connected_free (ifc); | |
2743 | return CMD_WARNING; | |
2744 | } | |
2745 | ||
2746 | /* This is real route. */ | |
2747 | ret = if_prefix_delete_ipv6 (ifp, ifc); | |
2748 | if (ret < 0) | |
2749 | { | |
2750 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", | |
6099b3b5 | 2751 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2752 | return CMD_WARNING; |
2753 | } | |
2754 | ||
f7f740fe | 2755 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2756 | /* This information will be propagated to the zclients when the |
2757 | * kernel notification is received. */ | |
718e3744 | 2758 | return CMD_SUCCESS; |
2759 | } | |
2760 | ||
2761 | DEFUN (ipv6_address, | |
2762 | ipv6_address_cmd, | |
2763 | "ipv6 address X:X::X:X/M", | |
e23949c0 | 2764 | "Interface IPv6 config commands\n" |
718e3744 | 2765 | "Set the IP address of an interface\n" |
2766 | "IPv6 address (e.g. 3ffe:506::1/48)\n") | |
2767 | { | |
8b3f0677 | 2768 | return ipv6_address_install (vty, vty->index, argv[2]->arg, NULL, NULL, 0); |
718e3744 | 2769 | } |
2770 | ||
2771 | DEFUN (no_ipv6_address, | |
2772 | no_ipv6_address_cmd, | |
2773 | "no ipv6 address X:X::X:X/M", | |
2774 | NO_STR | |
e23949c0 | 2775 | "Interface IPv6 config commands\n" |
718e3744 | 2776 | "Set the IP address of an interface\n" |
2777 | "IPv6 address (e.g. 3ffe:506::1/48)\n") | |
2778 | { | |
8b3f0677 | 2779 | return ipv6_address_uninstall (vty, vty->index, argv[3]->arg, NULL, NULL, 0); |
718e3744 | 2780 | } |
2781 | #endif /* HAVE_IPV6 */ | |
2782 | ||
16f1b9ee OD |
2783 | static int |
2784 | link_params_config_write (struct vty *vty, struct interface *ifp) | |
2785 | { | |
2786 | int i; | |
2787 | ||
2788 | if ((ifp == NULL) || !HAS_LINK_PARAMS(ifp)) | |
2789 | return -1; | |
2790 | ||
2791 | struct if_link_params *iflp = ifp->link_params; | |
2792 | ||
2793 | vty_out (vty, " link-params%s", VTY_NEWLINE); | |
2794 | vty_out(vty, " enable%s", VTY_NEWLINE); | |
2795 | if (IS_PARAM_SET(iflp, LP_TE)) | |
2796 | vty_out(vty, " metric %u%s",iflp->te_metric, VTY_NEWLINE); | |
2797 | if (IS_PARAM_SET(iflp, LP_MAX_BW)) | |
2798 | vty_out(vty, " max-bw %g%s", iflp->max_bw, VTY_NEWLINE); | |
2799 | if (IS_PARAM_SET(iflp, LP_MAX_RSV_BW)) | |
2800 | vty_out(vty, " max-rsv-bw %g%s", iflp->max_rsv_bw, VTY_NEWLINE); | |
2801 | if (IS_PARAM_SET(iflp, LP_UNRSV_BW)) | |
2802 | { | |
2803 | for (i = 0; i < 8; i++) | |
2804 | vty_out(vty, " unrsv-bw %d %g%s", | |
2805 | i, iflp->unrsv_bw[i], VTY_NEWLINE); | |
2806 | } | |
2807 | if (IS_PARAM_SET(iflp, LP_ADM_GRP)) | |
2808 | vty_out(vty, " admin-grp %u%s", iflp->admin_grp, VTY_NEWLINE); | |
2809 | if (IS_PARAM_SET(iflp, LP_DELAY)) | |
2810 | { | |
2811 | vty_out(vty, " delay %u", iflp->av_delay); | |
2812 | if (IS_PARAM_SET(iflp, LP_MM_DELAY)) | |
2813 | { | |
2814 | vty_out(vty, " min %u", iflp->min_delay); | |
2815 | vty_out(vty, " max %u", iflp->max_delay); | |
2816 | } | |
2817 | vty_out(vty, "%s", VTY_NEWLINE); | |
2818 | } | |
2819 | if (IS_PARAM_SET(iflp, LP_DELAY_VAR)) | |
2820 | vty_out(vty, " delay-variation %u%s", iflp->delay_var, VTY_NEWLINE); | |
2821 | if (IS_PARAM_SET(iflp, LP_PKT_LOSS)) | |
2822 | vty_out(vty, " packet-loss %g%s", iflp->pkt_loss, VTY_NEWLINE); | |
2823 | if (IS_PARAM_SET(iflp, LP_AVA_BW)) | |
2824 | vty_out(vty, " ava-bw %g%s", iflp->ava_bw, VTY_NEWLINE); | |
2825 | if (IS_PARAM_SET(iflp, LP_RES_BW)) | |
2826 | vty_out(vty, " res-bw %g%s", iflp->res_bw, VTY_NEWLINE); | |
2827 | if (IS_PARAM_SET(iflp, LP_USE_BW)) | |
2828 | vty_out(vty, " use-bw %g%s", iflp->use_bw, VTY_NEWLINE); | |
2829 | if (IS_PARAM_SET(iflp, LP_RMT_AS)) | |
2830 | vty_out(vty, " neighbor %s as %u%s", inet_ntoa(iflp->rmt_ip), | |
2831 | iflp->rmt_as, VTY_NEWLINE); | |
2832 | return 0; | |
2833 | } | |
2834 | ||
a1ac18c4 | 2835 | static int |
718e3744 | 2836 | if_config_write (struct vty *vty) |
2837 | { | |
52dc7ee6 | 2838 | struct listnode *node; |
718e3744 | 2839 | struct interface *ifp; |
cd2a8a42 | 2840 | vrf_iter_t iter; |
718e3744 | 2841 | |
244c1cdc DS |
2842 | zebra_ptm_write (vty); |
2843 | ||
cd2a8a42 FL |
2844 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
2845 | for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp)) | |
718e3744 | 2846 | { |
2847 | struct zebra_if *if_data; | |
52dc7ee6 | 2848 | struct listnode *addrnode; |
718e3744 | 2849 | struct connected *ifc; |
2850 | struct prefix *p; | |
12f6fb97 | 2851 | struct vrf *vrf; |
718e3744 | 2852 | |
718e3744 | 2853 | if_data = ifp->info; |
12f6fb97 | 2854 | vrf = vrf_lookup(ifp->vrf_id); |
cd2a8a42 FL |
2855 | |
2856 | if (ifp->vrf_id == VRF_DEFAULT) | |
2857 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); | |
2858 | else | |
12f6fb97 | 2859 | vty_out (vty, "interface %s vrf %s%s", ifp->name, vrf->name, |
cd2a8a42 | 2860 | VTY_NEWLINE); |
718e3744 | 2861 | |
bfac8dcd CF |
2862 | if (if_data) |
2863 | { | |
2864 | if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) | |
2865 | vty_out (vty, " shutdown%s", VTY_NEWLINE); | |
986aa00f | 2866 | |
2867 | zebra_ptm_if_write(vty, if_data); | |
bfac8dcd CF |
2868 | } |
2869 | ||
718e3744 | 2870 | if (ifp->desc) |
2871 | vty_out (vty, " description %s%s", ifp->desc, | |
2872 | VTY_NEWLINE); | |
2873 | ||
2874 | /* Assign bandwidth here to avoid unnecessary interface flap | |
2875 | while processing config script */ | |
2876 | if (ifp->bandwidth != 0) | |
2877 | vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE); | |
2878 | ||
07fc1596 DD |
2879 | if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) |
2880 | vty_out(vty, " no link-detect%s", VTY_NEWLINE); | |
2e3b2e47 | 2881 | |
1eb8ef25 | 2882 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc)) |
718e3744 | 2883 | { |
718e3744 | 2884 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
2885 | { | |
81cce018 | 2886 | char buf[INET6_ADDRSTRLEN]; |
718e3744 | 2887 | p = ifc->address; |
35d921cc | 2888 | vty_out (vty, " ip%s address %s", |
718e3744 | 2889 | p->family == AF_INET ? "" : "v6", |
35d921cc | 2890 | prefix2str (p, buf, sizeof(buf))); |
718e3744 | 2891 | |
718e3744 | 2892 | if (ifc->label) |
2893 | vty_out (vty, " label %s", ifc->label); | |
2894 | ||
2895 | vty_out (vty, "%s", VTY_NEWLINE); | |
2896 | } | |
2897 | } | |
2898 | ||
2899 | if (if_data) | |
2900 | { | |
718e3744 | 2901 | if (if_data->multicast != IF_ZEBRA_MULTICAST_UNSPEC) |
2902 | vty_out (vty, " %smulticast%s", | |
2903 | if_data->multicast == IF_ZEBRA_MULTICAST_ON ? "" : "no ", | |
2904 | VTY_NEWLINE); | |
2905 | } | |
2906 | ||
8da4e946 | 2907 | #if defined (HAVE_RTADV) |
718e3744 | 2908 | rtadv_config_write (vty, ifp); |
8da4e946 | 2909 | #endif /* HAVE_RTADV */ |
718e3744 | 2910 | |
ca776988 | 2911 | #ifdef HAVE_IRDP |
2912 | irdp_config_write (vty, ifp); | |
2913 | #endif /* IRDP */ | |
2914 | ||
16f1b9ee OD |
2915 | link_params_config_write (vty, ifp); |
2916 | ||
718e3744 | 2917 | vty_out (vty, "!%s", VTY_NEWLINE); |
2918 | } | |
2919 | return 0; | |
2920 | } | |
2921 | ||
12f6fb97 DS |
2922 | static int |
2923 | vrf_config_write (struct vty *vty) | |
2924 | { | |
2925 | struct listnode *node; | |
c1c747a8 | 2926 | struct zebra_vrf *zvrf; |
12f6fb97 | 2927 | |
c1c747a8 | 2928 | for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) |
12f6fb97 | 2929 | { |
c1c747a8 | 2930 | if (strcmp(zvrf->name, VRF_DEFAULT_NAME)) |
12f6fb97 | 2931 | { |
c1c747a8 | 2932 | vty_out (vty, "vrf %s%s", zvrf->name, VTY_NEWLINE); |
12f6fb97 DS |
2933 | vty_out (vty, "!%s", VTY_NEWLINE); |
2934 | } | |
2935 | } | |
2936 | return 0; | |
2937 | } | |
2938 | ||
718e3744 | 2939 | /* Allocate and initialize interface vector. */ |
2940 | void | |
a1ac18c4 | 2941 | zebra_if_init (void) |
718e3744 | 2942 | { |
2943 | /* Initialize interface and new hook. */ | |
718e3744 | 2944 | if_add_hook (IF_NEW_HOOK, if_zebra_new_hook); |
2945 | if_add_hook (IF_DELETE_HOOK, if_zebra_delete_hook); | |
2946 | ||
2947 | /* Install configuration write function. */ | |
2948 | install_node (&interface_node, if_config_write); | |
16f1b9ee | 2949 | install_node (&link_params_node, NULL); |
12f6fb97 | 2950 | install_node (&vrf_node, vrf_config_write); |
718e3744 | 2951 | |
2952 | install_element (VIEW_NODE, &show_interface_cmd); | |
8b87bdf4 | 2953 | install_element (VIEW_NODE, &show_interface_vrf_all_cmd); |
8b87bdf4 FL |
2954 | install_element (VIEW_NODE, &show_interface_name_vrf_cmd); |
2955 | install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd); | |
718e3744 | 2956 | install_element (ENABLE_NODE, &show_interface_cmd); |
8b87bdf4 | 2957 | install_element (ENABLE_NODE, &show_interface_vrf_all_cmd); |
8b87bdf4 FL |
2958 | install_element (ENABLE_NODE, &show_interface_name_vrf_cmd); |
2959 | install_element (ENABLE_NODE, &show_interface_name_vrf_all_cmd); | |
ed9bb6d5 | 2960 | install_element (ENABLE_NODE, &show_interface_desc_cmd); |
8b87bdf4 | 2961 | install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd); |
718e3744 | 2962 | install_element (CONFIG_NODE, &zebra_interface_cmd); |
bfc13532 | 2963 | install_element (CONFIG_NODE, &no_interface_cmd); |
bcff2289 | 2964 | install_element (CONFIG_NODE, &no_interface_vrf_cmd); |
718e3744 | 2965 | install_default (INTERFACE_NODE); |
2966 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
2967 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
2968 | install_element (INTERFACE_NODE, &multicast_cmd); | |
2969 | install_element (INTERFACE_NODE, &no_multicast_cmd); | |
2e3b2e47 | 2970 | install_element (INTERFACE_NODE, &linkdetect_cmd); |
2971 | install_element (INTERFACE_NODE, &no_linkdetect_cmd); | |
718e3744 | 2972 | install_element (INTERFACE_NODE, &shutdown_if_cmd); |
2973 | install_element (INTERFACE_NODE, &no_shutdown_if_cmd); | |
2974 | install_element (INTERFACE_NODE, &bandwidth_if_cmd); | |
2975 | install_element (INTERFACE_NODE, &no_bandwidth_if_cmd); | |
718e3744 | 2976 | install_element (INTERFACE_NODE, &ip_address_cmd); |
2977 | install_element (INTERFACE_NODE, &no_ip_address_cmd); | |
2978 | #ifdef HAVE_IPV6 | |
2979 | install_element (INTERFACE_NODE, &ipv6_address_cmd); | |
2980 | install_element (INTERFACE_NODE, &no_ipv6_address_cmd); | |
2981 | #endif /* HAVE_IPV6 */ | |
718e3744 | 2982 | #ifdef HAVE_NETLINK |
718e3744 | 2983 | install_element (INTERFACE_NODE, &ip_address_label_cmd); |
718e3744 | 2984 | install_element (INTERFACE_NODE, &no_ip_address_label_cmd); |
2985 | #endif /* HAVE_NETLINK */ | |
16f1b9ee OD |
2986 | install_element(INTERFACE_NODE, &link_params_cmd); |
2987 | install_default(LINK_PARAMS_NODE); | |
2988 | install_element(LINK_PARAMS_NODE, &link_params_enable_cmd); | |
2989 | install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd); | |
2990 | install_element(LINK_PARAMS_NODE, &link_params_metric_cmd); | |
2991 | install_element(LINK_PARAMS_NODE, &link_params_maxbw_cmd); | |
2992 | install_element(LINK_PARAMS_NODE, &link_params_max_rsv_bw_cmd); | |
2993 | install_element(LINK_PARAMS_NODE, &link_params_unrsv_bw_cmd); | |
2994 | install_element(LINK_PARAMS_NODE, &link_params_admin_grp_cmd); | |
2995 | install_element(LINK_PARAMS_NODE, &link_params_inter_as_cmd); | |
2996 | install_element(LINK_PARAMS_NODE, &no_link_params_inter_as_cmd); | |
2997 | install_element(LINK_PARAMS_NODE, &link_params_delay_cmd); | |
16f1b9ee OD |
2998 | install_element(LINK_PARAMS_NODE, &link_params_delay_var_cmd); |
2999 | install_element(LINK_PARAMS_NODE, &link_params_pkt_loss_cmd); | |
3000 | install_element(LINK_PARAMS_NODE, &link_params_ava_bw_cmd); | |
3001 | install_element(LINK_PARAMS_NODE, &link_params_res_bw_cmd); | |
3002 | install_element(LINK_PARAMS_NODE, &link_params_use_bw_cmd); | |
3003 | ||
12f6fb97 DS |
3004 | install_element (CONFIG_NODE, &zebra_vrf_cmd); |
3005 | install_element (CONFIG_NODE, &no_vrf_cmd); | |
3006 | install_default (VRF_NODE); | |
718e3744 | 3007 | } |