]>
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 | |
9ccf14f7 | 1303 | * "show interface vrf NAME", |
f412b39a DW |
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, | |
9ccf14f7 | 1335 | "show interface vrf all", |
8b87bdf4 FL |
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, | |
9ccf14f7 | 1358 | "show interface IFNAME vrf NAME", |
8b87bdf4 FL |
1359 | SHOW_STR |
1360 | "Interface status and configuration\n" | |
1721646e DS |
1361 | "Interface name\n" |
1362 | VRF_CMD_HELP_STR) | |
8b87bdf4 | 1363 | { |
7c022376 DW |
1364 | int idx_ifname = 2; |
1365 | int idx_name = 4; | |
8b87bdf4 FL |
1366 | struct interface *ifp; |
1367 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1368 | ||
78860b9f | 1369 | interface_update_stats (); |
8b87bdf4 FL |
1370 | |
1371 | if (argc > 1) | |
7c022376 | 1372 | VRF_GET_ID (vrf_id, argv[idx_name]->arg); |
8b87bdf4 | 1373 | |
718e3744 | 1374 | /* Specified interface print. */ |
7c022376 | 1375 | ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_id); |
8b87bdf4 | 1376 | if (ifp == NULL) |
718e3744 | 1377 | { |
7c022376 | 1378 | vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, |
8b87bdf4 FL |
1379 | VTY_NEWLINE); |
1380 | return CMD_WARNING; | |
718e3744 | 1381 | } |
8b87bdf4 | 1382 | if_dump_vty (vty, ifp); |
718e3744 | 1383 | |
1384 | return CMD_SUCCESS; | |
1385 | } | |
1386 | ||
8b87bdf4 | 1387 | /* Show specified interface to vty. */ |
f412b39a DW |
1388 | /* |
1389 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1390 | * "show interface IFNAME", | |
1391 | * SHOW_STR | |
1392 | * "Interface status and configuration\n" | |
1393 | * "Interface name\n" | |
1394 | * | |
1395 | */ | |
8b3f0677 DW |
1396 | DEFUN (show_interface_name_vrf_all, |
1397 | show_interface_name_vrf_all_cmd, | |
9ccf14f7 | 1398 | "show interface IFNAME vrf all", |
8b87bdf4 FL |
1399 | SHOW_STR |
1400 | "Interface status and configuration\n" | |
1721646e | 1401 | "Interface name\n" |
8b87bdf4 FL |
1402 | VRF_ALL_CMD_HELP_STR) |
1403 | { | |
7c022376 | 1404 | int idx_ifname = 2; |
8b87bdf4 FL |
1405 | struct interface *ifp; |
1406 | vrf_iter_t iter; | |
1407 | int found = 0; | |
1408 | ||
78860b9f | 1409 | interface_update_stats (); |
8b87bdf4 FL |
1410 | |
1411 | /* All interface print. */ | |
1412 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) | |
1413 | { | |
1414 | /* Specified interface print. */ | |
7c022376 | 1415 | ifp = if_lookup_by_name_vrf (argv[idx_ifname]->arg, vrf_iter2id (iter)); |
8b87bdf4 FL |
1416 | if (ifp) |
1417 | { | |
1418 | if_dump_vty (vty, ifp); | |
1419 | found++; | |
1420 | } | |
1421 | } | |
1422 | ||
1423 | if (!found) | |
1424 | { | |
7c022376 | 1425 | vty_out (vty, "%% Can't find interface %s%s", argv[idx_ifname]->arg, VTY_NEWLINE); |
8b87bdf4 FL |
1426 | return CMD_WARNING; |
1427 | } | |
1428 | ||
1429 | return CMD_SUCCESS; | |
1430 | } | |
1431 | ||
1721646e | 1432 | |
8b87bdf4 FL |
1433 | static void |
1434 | if_show_description (struct vty *vty, vrf_id_t vrf_id) | |
ed9bb6d5 | 1435 | { |
1436 | struct listnode *node; | |
1437 | struct interface *ifp; | |
1438 | ||
1439 | vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE); | |
8b87bdf4 | 1440 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) |
ed9bb6d5 | 1441 | { |
1442 | int len; | |
ed9bb6d5 | 1443 | |
1444 | len = vty_out (vty, "%s", ifp->name); | |
1445 | vty_out (vty, "%*s", (16 - len), " "); | |
1446 | ||
1447 | if (if_is_up(ifp)) | |
1448 | { | |
1449 | vty_out (vty, "up "); | |
1450 | if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) | |
1451 | { | |
1452 | if (if_is_running(ifp)) | |
1453 | vty_out (vty, "up "); | |
1454 | else | |
1455 | vty_out (vty, "down "); | |
1456 | } | |
1457 | else | |
1458 | { | |
1459 | vty_out (vty, "unknown "); | |
1460 | } | |
1461 | } | |
1462 | else | |
1463 | { | |
1464 | vty_out (vty, "down down "); | |
1465 | } | |
1466 | ||
1467 | if (ifp->desc) | |
1468 | vty_out (vty, "%s", ifp->desc); | |
1469 | vty_out (vty, "%s", VTY_NEWLINE); | |
1470 | } | |
8b87bdf4 FL |
1471 | } |
1472 | ||
f412b39a DW |
1473 | /* |
1474 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
9ccf14f7 | 1475 | * "show interface description vrf NAME", |
f412b39a DW |
1476 | * SHOW_STR |
1477 | * "Interface status and configuration\n" | |
1478 | * "Interface description\n" | |
1479 | * VRF_CMD_HELP_STR | |
1480 | * | |
1481 | */ | |
8b87bdf4 FL |
1482 | DEFUN (show_interface_desc, |
1483 | show_interface_desc_cmd, | |
1484 | "show interface description", | |
1485 | SHOW_STR | |
1486 | "Interface status and configuration\n" | |
1487 | "Interface description\n") | |
1488 | { | |
1489 | vrf_id_t vrf_id = VRF_DEFAULT; | |
1490 | ||
1491 | if (argc > 0) | |
8b3f0677 | 1492 | VRF_GET_ID (vrf_id, argv[3]->arg); |
8b87bdf4 FL |
1493 | |
1494 | if_show_description (vty, vrf_id); | |
1495 | ||
1496 | return CMD_SUCCESS; | |
1497 | } | |
1498 | ||
8b87bdf4 FL |
1499 | |
1500 | DEFUN (show_interface_desc_vrf_all, | |
1501 | show_interface_desc_vrf_all_cmd, | |
9ccf14f7 | 1502 | "show interface description vrf all", |
8b87bdf4 FL |
1503 | SHOW_STR |
1504 | "Interface status and configuration\n" | |
1505 | "Interface description\n" | |
1506 | VRF_ALL_CMD_HELP_STR) | |
1507 | { | |
1508 | vrf_iter_t iter; | |
1509 | ||
1510 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) | |
1511 | if (!list_isempty (vrf_iter2iflist (iter))) | |
1512 | { | |
1513 | vty_out (vty, "%s\tVRF %u%s%s", VTY_NEWLINE, | |
1514 | vrf_iter2id (iter), | |
1515 | VTY_NEWLINE, VTY_NEWLINE); | |
1516 | if_show_description (vty, vrf_iter2id (iter)); | |
1517 | } | |
1518 | ||
ed9bb6d5 | 1519 | return CMD_SUCCESS; |
1520 | } | |
1521 | ||
718e3744 | 1522 | DEFUN (multicast, |
1523 | multicast_cmd, | |
1524 | "multicast", | |
1525 | "Set multicast flag to interface\n") | |
1526 | { | |
1527 | int ret; | |
1528 | struct interface *ifp; | |
1529 | struct zebra_if *if_data; | |
1530 | ||
1531 | ifp = (struct interface *) vty->index; | |
48b33aaf | 1532 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
718e3744 | 1533 | { |
48b33aaf | 1534 | ret = if_set_flags (ifp, IFF_MULTICAST); |
1535 | if (ret < 0) | |
1536 | { | |
1537 | vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE); | |
1538 | return CMD_WARNING; | |
1539 | } | |
1540 | if_refresh (ifp); | |
718e3744 | 1541 | } |
718e3744 | 1542 | if_data = ifp->info; |
1543 | if_data->multicast = IF_ZEBRA_MULTICAST_ON; | |
48b33aaf | 1544 | |
718e3744 | 1545 | return CMD_SUCCESS; |
1546 | } | |
1547 | ||
1548 | DEFUN (no_multicast, | |
1549 | no_multicast_cmd, | |
1550 | "no multicast", | |
1551 | NO_STR | |
1552 | "Unset multicast flag to interface\n") | |
1553 | { | |
1554 | int ret; | |
1555 | struct interface *ifp; | |
1556 | struct zebra_if *if_data; | |
1557 | ||
1558 | ifp = (struct interface *) vty->index; | |
48b33aaf | 1559 | if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
718e3744 | 1560 | { |
48b33aaf | 1561 | ret = if_unset_flags (ifp, IFF_MULTICAST); |
1562 | if (ret < 0) | |
1563 | { | |
1564 | vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE); | |
1565 | return CMD_WARNING; | |
1566 | } | |
1567 | if_refresh (ifp); | |
718e3744 | 1568 | } |
718e3744 | 1569 | if_data = ifp->info; |
1570 | if_data->multicast = IF_ZEBRA_MULTICAST_OFF; | |
1571 | ||
1572 | return CMD_SUCCESS; | |
1573 | } | |
1574 | ||
2e3b2e47 | 1575 | DEFUN (linkdetect, |
1576 | linkdetect_cmd, | |
1577 | "link-detect", | |
1578 | "Enable link detection on interface\n") | |
1579 | { | |
2e3b2e47 | 1580 | struct interface *ifp; |
1581 | int if_was_operative; | |
1582 | ||
1583 | ifp = (struct interface *) vty->index; | |
244c1cdc | 1584 | if_was_operative = if_is_no_ptm_operative(ifp); |
2e3b2e47 | 1585 | SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
1586 | ||
1587 | /* When linkdetection is enabled, if might come down */ | |
244c1cdc | 1588 | if (!if_is_no_ptm_operative(ifp) && if_was_operative) if_down(ifp); |
2e3b2e47 | 1589 | |
1590 | /* FIXME: Will defer status change forwarding if interface | |
1591 | does not come down! */ | |
1592 | ||
1593 | return CMD_SUCCESS; | |
1594 | } | |
1595 | ||
1596 | ||
1597 | DEFUN (no_linkdetect, | |
1598 | no_linkdetect_cmd, | |
1599 | "no link-detect", | |
1600 | NO_STR | |
1601 | "Disable link detection on interface\n") | |
1602 | { | |
2e3b2e47 | 1603 | struct interface *ifp; |
1604 | int if_was_operative; | |
1605 | ||
1606 | ifp = (struct interface *) vty->index; | |
244c1cdc | 1607 | if_was_operative = if_is_no_ptm_operative(ifp); |
2e3b2e47 | 1608 | UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); |
1609 | ||
1610 | /* Interface may come up after disabling link detection */ | |
1611 | if (if_is_operative(ifp) && !if_was_operative) if_up(ifp); | |
1612 | ||
1613 | /* FIXME: see linkdetect_cmd */ | |
1614 | ||
1615 | return CMD_SUCCESS; | |
1616 | } | |
1617 | ||
718e3744 | 1618 | DEFUN (shutdown_if, |
1619 | shutdown_if_cmd, | |
1620 | "shutdown", | |
1621 | "Shutdown the selected interface\n") | |
1622 | { | |
1623 | int ret; | |
1624 | struct interface *ifp; | |
1625 | struct zebra_if *if_data; | |
1626 | ||
1627 | ifp = (struct interface *) vty->index; | |
bfac8dcd | 1628 | if (ifp->ifindex != IFINDEX_INTERNAL) |
718e3744 | 1629 | { |
bfac8dcd CF |
1630 | ret = if_unset_flags (ifp, IFF_UP); |
1631 | if (ret < 0) | |
1632 | { | |
1633 | vty_out (vty, "Can't shutdown interface%s", VTY_NEWLINE); | |
1634 | return CMD_WARNING; | |
1635 | } | |
1636 | if_refresh (ifp); | |
718e3744 | 1637 | } |
718e3744 | 1638 | if_data = ifp->info; |
1639 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_ON; | |
1640 | ||
1641 | return CMD_SUCCESS; | |
1642 | } | |
1643 | ||
1644 | DEFUN (no_shutdown_if, | |
1645 | no_shutdown_if_cmd, | |
1646 | "no shutdown", | |
1647 | NO_STR | |
1648 | "Shutdown the selected interface\n") | |
1649 | { | |
1650 | int ret; | |
1651 | struct interface *ifp; | |
1652 | struct zebra_if *if_data; | |
1653 | ||
1654 | ifp = (struct interface *) vty->index; | |
bfac8dcd CF |
1655 | |
1656 | if (ifp->ifindex != IFINDEX_INTERNAL) | |
718e3744 | 1657 | { |
bfac8dcd CF |
1658 | ret = if_set_flags (ifp, IFF_UP | IFF_RUNNING); |
1659 | if (ret < 0) | |
1660 | { | |
1661 | vty_out (vty, "Can't up interface%s", VTY_NEWLINE); | |
1662 | return CMD_WARNING; | |
1663 | } | |
1664 | if_refresh (ifp); | |
1665 | ||
1666 | /* Some addresses (in particular, IPv6 addresses on Linux) get | |
1667 | * removed when the interface goes down. They need to be readded. | |
1668 | */ | |
1669 | if_addr_wakeup(ifp); | |
718e3744 | 1670 | } |
bfac8dcd | 1671 | |
718e3744 | 1672 | if_data = ifp->info; |
1673 | if_data->shutdown = IF_ZEBRA_SHUTDOWN_OFF; | |
1674 | ||
1675 | return CMD_SUCCESS; | |
1676 | } | |
1677 | ||
1678 | DEFUN (bandwidth_if, | |
1679 | bandwidth_if_cmd, | |
6147e2c6 | 1680 | "bandwidth (1-100000)", |
718e3744 | 1681 | "Set bandwidth informational parameter\n" |
70bd3c43 | 1682 | "Bandwidth in megabits\n") |
718e3744 | 1683 | { |
7c022376 | 1684 | int idx_number = 1; |
718e3744 | 1685 | struct interface *ifp; |
1686 | unsigned int bandwidth; | |
1687 | ||
1688 | ifp = (struct interface *) vty->index; | |
7c022376 | 1689 | bandwidth = strtol(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1690 | |
70bd3c43 DS |
1691 | /* bandwidth range is <1-100000> */ |
1692 | if (bandwidth < 1 || bandwidth > 100000) | |
718e3744 | 1693 | { |
1694 | vty_out (vty, "Bandwidth is invalid%s", VTY_NEWLINE); | |
1695 | return CMD_WARNING; | |
1696 | } | |
1697 | ||
1698 | ifp->bandwidth = bandwidth; | |
1699 | ||
1700 | /* force protocols to recalculate routes due to cost change */ | |
2e3b2e47 | 1701 | if (if_is_operative (ifp)) |
718e3744 | 1702 | zebra_interface_up_update (ifp); |
1703 | ||
1704 | return CMD_SUCCESS; | |
1705 | } | |
1706 | ||
f412b39a DW |
1707 | /* |
1708 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1709 | * "no bandwidth <1-100000>", | |
1710 | * NO_STR | |
1711 | * "Set bandwidth informational parameter\n" | |
1712 | * "Bandwidth in megabits\n" | |
1713 | * | |
1714 | */ | |
718e3744 | 1715 | DEFUN (no_bandwidth_if, |
1716 | no_bandwidth_if_cmd, | |
1717 | "no bandwidth", | |
1718 | NO_STR | |
1719 | "Set bandwidth informational parameter\n") | |
1720 | { | |
1721 | struct interface *ifp; | |
1722 | ||
1723 | ifp = (struct interface *) vty->index; | |
1724 | ||
1725 | ifp->bandwidth = 0; | |
1726 | ||
1727 | /* force protocols to recalculate routes due to cost change */ | |
2e3b2e47 | 1728 | if (if_is_operative (ifp)) |
718e3744 | 1729 | zebra_interface_up_update (ifp); |
1730 | ||
1731 | return CMD_SUCCESS; | |
1732 | } | |
1733 | ||
6b0655a2 | 1734 | |
16f1b9ee OD |
1735 | struct cmd_node link_params_node = |
1736 | { | |
1737 | LINK_PARAMS_NODE, | |
1738 | "%s(config-link-params)# ", | |
1739 | 1, | |
1740 | }; | |
1741 | ||
1742 | static void | |
1743 | link_param_cmd_set_uint32 (struct interface *ifp, uint32_t *field, | |
1744 | uint32_t type, uint32_t value) | |
1745 | { | |
1746 | /* Update field as needed */ | |
1747 | if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) | |
1748 | { | |
1749 | *field = value; | |
1750 | SET_PARAM(ifp->link_params, type); | |
1751 | ||
1752 | /* force protocols to update LINK STATE due to parameters change */ | |
1753 | if (if_is_operative (ifp)) | |
1754 | zebra_interface_parameters_update (ifp); | |
1755 | } | |
1756 | } | |
1757 | static void | |
1758 | link_param_cmd_set_float (struct interface *ifp, float *field, | |
1759 | uint32_t type, float value) | |
1760 | { | |
1761 | ||
1762 | /* Update field as needed */ | |
1763 | if (IS_PARAM_UNSET(ifp->link_params, type) || *field != value) | |
1764 | { | |
1765 | *field = value; | |
1766 | SET_PARAM(ifp->link_params, type); | |
1767 | ||
1768 | /* force protocols to update LINK STATE due to parameters change */ | |
1769 | if (if_is_operative (ifp)) | |
1770 | zebra_interface_parameters_update (ifp); | |
1771 | } | |
1772 | } | |
1773 | ||
1774 | static void | |
1775 | link_param_cmd_unset (struct interface *ifp, uint32_t type) | |
1776 | { | |
1777 | ||
1778 | /* Unset field */ | |
1779 | UNSET_PARAM(ifp->link_params, type); | |
1780 | ||
1781 | /* force protocols to update LINK STATE due to parameters change */ | |
1782 | if (if_is_operative (ifp)) | |
1783 | zebra_interface_parameters_update (ifp); | |
1784 | } | |
1785 | ||
1786 | DEFUN (link_params, | |
1787 | link_params_cmd, | |
1788 | "link-params", | |
1789 | LINK_PARAMS_STR) | |
1790 | { | |
1791 | vty->node = LINK_PARAMS_NODE; | |
1792 | ||
1793 | return CMD_SUCCESS; | |
1794 | } | |
1795 | ||
1796 | /* Specific Traffic Engineering parameters commands */ | |
1797 | DEFUN (link_params_enable, | |
1798 | link_params_enable_cmd, | |
1799 | "enable", | |
1800 | "Activate link parameters on this interface\n") | |
1801 | { | |
1802 | struct interface *ifp = (struct interface *) vty->index; | |
1803 | ||
1804 | /* This command could be issue at startup, when activate MPLS TE */ | |
1805 | /* on a new interface or after a ON / OFF / ON toggle */ | |
1806 | /* In all case, TE parameters are reset to their default factory */ | |
1807 | if (IS_ZEBRA_DEBUG_EVENT) | |
1808 | zlog_debug ("Link-params: enable TE link parameters on interface %s", ifp->name); | |
1809 | ||
1810 | if (!if_link_params_get (ifp)) | |
1811 | { | |
1812 | if (IS_ZEBRA_DEBUG_EVENT) | |
1813 | zlog_debug ("Link-params: failed to init TE link parameters %s", ifp->name); | |
1814 | ||
1815 | return CMD_WARNING; | |
1816 | } | |
1817 | ||
1818 | /* force protocols to update LINK STATE due to parameters change */ | |
1819 | if (if_is_operative (ifp)) | |
1820 | zebra_interface_parameters_update (ifp); | |
1821 | ||
1822 | return CMD_SUCCESS; | |
1823 | } | |
1824 | ||
1825 | DEFUN (no_link_params_enable, | |
1826 | no_link_params_enable_cmd, | |
1827 | "no enable", | |
1828 | NO_STR | |
1829 | "Disable link parameters on this interface\n") | |
1830 | { | |
1831 | struct interface *ifp = (struct interface *) vty->index; | |
1832 | ||
1833 | zlog_debug ("MPLS-TE: disable TE link parameters on interface %s", ifp->name); | |
1834 | ||
1835 | if_link_params_free (ifp); | |
1836 | ||
1837 | /* force protocols to update LINK STATE due to parameters change */ | |
1838 | if (if_is_operative (ifp)) | |
1839 | zebra_interface_parameters_update (ifp); | |
1840 | ||
1841 | return CMD_SUCCESS; | |
1842 | } | |
1843 | ||
1844 | /* STANDARD TE metrics */ | |
1845 | DEFUN (link_params_metric, | |
1846 | link_params_metric_cmd, | |
6147e2c6 | 1847 | "metric (0-4294967295)", |
16f1b9ee OD |
1848 | "Link metric for MPLS-TE purpose\n" |
1849 | "Metric value in decimal\n") | |
1850 | { | |
7c022376 | 1851 | int idx_number = 1; |
16f1b9ee OD |
1852 | struct interface *ifp = (struct interface *) vty->index; |
1853 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1854 | u_int32_t metric; | |
1855 | ||
7c022376 | 1856 | VTY_GET_ULONG("metric", metric, argv[idx_number]->arg); |
16f1b9ee OD |
1857 | |
1858 | /* Update TE metric if needed */ | |
1859 | link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE, metric); | |
1860 | ||
1861 | return CMD_SUCCESS; | |
1862 | } | |
1863 | ||
1864 | DEFUN (no_link_params_metric, | |
1865 | no_link_params_metric_cmd, | |
1866 | "no metric", | |
1867 | NO_STR | |
1868 | "Disbale Link Metric on this interface\n") | |
1869 | { | |
1870 | struct interface *ifp = (struct interface *) vty->index; | |
1871 | ||
1872 | /* Unset TE Metric */ | |
1873 | link_param_cmd_unset(ifp, LP_TE); | |
1874 | ||
1875 | return CMD_SUCCESS; | |
1876 | } | |
1877 | ||
1878 | DEFUN (link_params_maxbw, | |
1879 | link_params_maxbw_cmd, | |
1880 | "max-bw BANDWIDTH", | |
1881 | "Maximum bandwidth that can be used\n" | |
1882 | "Bytes/second (IEEE floating point format)\n") | |
1883 | { | |
7c022376 | 1884 | int idx_bandwidth = 1; |
16f1b9ee OD |
1885 | struct interface *ifp = (struct interface *) vty->index; |
1886 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1887 | ||
1888 | float bw; | |
1889 | ||
7c022376 | 1890 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1891 | { |
1892 | vty_out (vty, "link_params_maxbw: fscanf: %s%s", safe_strerror (errno), | |
1893 | VTY_NEWLINE); | |
1894 | return CMD_WARNING; | |
1895 | } | |
1896 | ||
1897 | /* Check that Maximum bandwidth is not lower than other bandwidth parameters */ | |
1898 | if ((bw <= iflp->max_rsv_bw) | |
1899 | || (bw <= iflp->unrsv_bw[0]) | |
1900 | || (bw <= iflp->unrsv_bw[1]) | |
1901 | || (bw <= iflp->unrsv_bw[2]) | |
1902 | || (bw <= iflp->unrsv_bw[3]) | |
1903 | || (bw <= iflp->unrsv_bw[4]) | |
1904 | || (bw <= iflp->unrsv_bw[5]) | |
1905 | || (bw <= iflp->unrsv_bw[6]) | |
1906 | || (bw <= iflp->unrsv_bw[7]) | |
1907 | || (bw <= iflp->ava_bw) | |
1908 | || (bw <= iflp->res_bw) | |
1909 | || (bw <= iflp->use_bw)) | |
1910 | { | |
1911 | vty_out (vty, | |
1912 | "Maximum Bandwidth could not be lower than others bandwidth%s", | |
1913 | VTY_NEWLINE); | |
1914 | return CMD_WARNING; | |
1915 | } | |
1916 | ||
1917 | /* Update Maximum Bandwidth if needed */ | |
1918 | link_param_cmd_set_float (ifp, &iflp->max_bw, LP_MAX_BW, bw); | |
1919 | ||
1920 | return CMD_SUCCESS; | |
1921 | } | |
1922 | ||
1923 | DEFUN (link_params_max_rsv_bw, | |
1924 | link_params_max_rsv_bw_cmd, | |
1925 | "max-rsv-bw BANDWIDTH", | |
1926 | "Maximum bandwidth that may be reserved\n" | |
1927 | "Bytes/second (IEEE floating point format)\n") | |
1928 | { | |
7c022376 | 1929 | int idx_bandwidth = 1; |
16f1b9ee OD |
1930 | struct interface *ifp = (struct interface *) vty->index; |
1931 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1932 | float bw; | |
1933 | ||
7c022376 | 1934 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1935 | { |
1936 | vty_out (vty, "link_params_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1937 | VTY_NEWLINE); | |
1938 | return CMD_WARNING; | |
1939 | } | |
1940 | ||
1941 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
1942 | if (bw > iflp->max_bw) | |
1943 | { | |
1944 | vty_out (vty, | |
1945 | "Maximum Reservable Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
1946 | iflp->max_bw, VTY_NEWLINE); | |
1947 | return CMD_WARNING; | |
1948 | } | |
1949 | ||
1950 | /* Update Maximum Reservable Bandwidth if needed */ | |
1951 | link_param_cmd_set_float (ifp, &iflp->max_rsv_bw, LP_MAX_RSV_BW, bw); | |
1952 | ||
1953 | return CMD_SUCCESS; | |
1954 | } | |
1955 | ||
1956 | DEFUN (link_params_unrsv_bw, | |
1957 | link_params_unrsv_bw_cmd, | |
6147e2c6 | 1958 | "unrsv-bw (0-7) BANDWIDTH", |
16f1b9ee OD |
1959 | "Unreserved bandwidth at each priority level\n" |
1960 | "Priority\n" | |
1961 | "Bytes/second (IEEE floating point format)\n") | |
1962 | { | |
7c022376 DW |
1963 | int idx_number = 1; |
1964 | int idx_bandwidth = 2; | |
16f1b9ee OD |
1965 | struct interface *ifp = (struct interface *) vty->index; |
1966 | struct if_link_params *iflp = if_link_params_get (ifp); | |
1967 | int priority; | |
1968 | float bw; | |
1969 | ||
1970 | /* We don't have to consider about range check here. */ | |
7c022376 | 1971 | if (sscanf (argv[idx_number]->arg, "%d", &priority) != 1) |
16f1b9ee OD |
1972 | { |
1973 | vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1974 | VTY_NEWLINE); | |
1975 | return CMD_WARNING; | |
1976 | } | |
1977 | ||
7c022376 | 1978 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
1979 | { |
1980 | vty_out (vty, "link_params_unrsv_bw: fscanf: %s%s", safe_strerror (errno), | |
1981 | VTY_NEWLINE); | |
1982 | return CMD_WARNING; | |
1983 | } | |
1984 | ||
1985 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
1986 | if (bw > iflp->max_bw) | |
1987 | { | |
1988 | vty_out (vty, | |
1989 | "UnReserved Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
1990 | iflp->max_bw, VTY_NEWLINE); | |
1991 | return CMD_WARNING; | |
1992 | } | |
1993 | ||
1994 | /* Update Unreserved Bandwidth if needed */ | |
1995 | link_param_cmd_set_float (ifp, &iflp->unrsv_bw[priority], LP_UNRSV_BW, bw); | |
1996 | ||
1997 | return CMD_SUCCESS; | |
1998 | } | |
1999 | ||
2000 | DEFUN (link_params_admin_grp, | |
2001 | link_params_admin_grp_cmd, | |
2002 | "admin-grp BITPATTERN", | |
2003 | "Administrative group membership\n" | |
2004 | "32-bit Hexadecimal value (e.g. 0xa1)\n") | |
2005 | { | |
7c022376 | 2006 | int idx_bitpattern = 1; |
16f1b9ee OD |
2007 | struct interface *ifp = (struct interface *) vty->index; |
2008 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2009 | unsigned long value; | |
2010 | ||
7c022376 | 2011 | if (sscanf (argv[idx_bitpattern]->arg, "0x%lx", &value) != 1) |
16f1b9ee OD |
2012 | { |
2013 | vty_out (vty, "link_params_admin_grp: fscanf: %s%s", | |
2014 | safe_strerror (errno), VTY_NEWLINE); | |
2015 | return CMD_WARNING; | |
2016 | } | |
2017 | ||
2018 | /* Update Administrative Group if needed */ | |
2019 | link_param_cmd_set_uint32 (ifp, &iflp->admin_grp, LP_ADM_GRP, value); | |
2020 | ||
2021 | return CMD_SUCCESS; | |
2022 | } | |
2023 | ||
2024 | DEFUN (no_link_params_admin_grp, | |
2025 | no_link_params_admin_grp_cmd, | |
2026 | "no admin-grp", | |
2027 | NO_STR | |
2028 | "Disbale Administrative group membership on this interface\n") | |
2029 | { | |
2030 | struct interface *ifp = (struct interface *) vty->index; | |
2031 | ||
2032 | /* Unset Admin Group */ | |
2033 | link_param_cmd_unset(ifp, LP_ADM_GRP); | |
2034 | ||
2035 | return CMD_SUCCESS; | |
2036 | } | |
2037 | ||
2038 | /* RFC5392 & RFC5316: INTER-AS */ | |
2039 | DEFUN (link_params_inter_as, | |
2040 | link_params_inter_as_cmd, | |
6147e2c6 | 2041 | "neighbor A.B.C.D as (1-4294967295)", |
16f1b9ee OD |
2042 | "Configure remote ASBR information (Neighbor IP address and AS number)\n" |
2043 | "Remote IP address in dot decimal A.B.C.D\n" | |
2044 | "Remote AS number\n" | |
2045 | "AS number in the range <1-4294967295>\n") | |
2046 | { | |
7c022376 DW |
2047 | int idx_ipv4 = 1; |
2048 | int idx_number = 3; | |
16f1b9ee OD |
2049 | |
2050 | struct interface *ifp = (struct interface *) vty->index; | |
2051 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2052 | struct in_addr addr; | |
2053 | u_int32_t as; | |
2054 | ||
7c022376 | 2055 | if (!inet_aton (argv[idx_ipv4]->arg, &addr)) |
16f1b9ee OD |
2056 | { |
2057 | vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); | |
2058 | return CMD_WARNING; | |
2059 | } | |
2060 | ||
7c022376 | 2061 | VTY_GET_ULONG("AS number", as, argv[idx_number]->arg); |
16f1b9ee OD |
2062 | |
2063 | /* Update Remote IP and Remote AS fields if needed */ | |
2064 | if (IS_PARAM_UNSET(iflp, LP_RMT_AS) | |
2065 | || iflp->rmt_as != as | |
2066 | || iflp->rmt_ip.s_addr != addr.s_addr) | |
2067 | { | |
2068 | ||
2069 | iflp->rmt_as = as; | |
2070 | iflp->rmt_ip.s_addr = addr.s_addr; | |
2071 | SET_PARAM(iflp, LP_RMT_AS); | |
2072 | ||
2073 | /* force protocols to update LINK STATE due to parameters change */ | |
2074 | if (if_is_operative (ifp)) | |
2075 | zebra_interface_parameters_update (ifp); | |
2076 | } | |
2077 | return CMD_SUCCESS; | |
2078 | } | |
2079 | ||
2080 | DEFUN (no_link_params_inter_as, | |
2081 | no_link_params_inter_as_cmd, | |
2082 | "no neighbor", | |
2083 | NO_STR | |
2084 | "Remove Neighbor IP address and AS number for Inter-AS TE\n") | |
2085 | { | |
2086 | ||
2087 | struct interface *ifp = (struct interface *) vty->index; | |
2088 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2089 | ||
2090 | /* Reset Remote IP and AS neighbor */ | |
2091 | iflp->rmt_as = 0; | |
2092 | iflp->rmt_ip.s_addr = 0; | |
2093 | UNSET_PARAM(iflp, LP_RMT_AS); | |
2094 | ||
2095 | /* force protocols to update LINK STATE due to parameters change */ | |
2096 | if (if_is_operative (ifp)) | |
2097 | zebra_interface_parameters_update (ifp); | |
2098 | ||
2099 | return CMD_SUCCESS; | |
2100 | } | |
2101 | ||
2102 | /* RFC7471: OSPF Traffic Engineering (TE) Metric extensions & draft-ietf-isis-metric-extensions-07.txt */ | |
f412b39a DW |
2103 | /* |
2104 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2105 | * "delay <0-16777215> min <0-16777215> max <0-16777215>", | |
2106 | * "Unidirectional Average Link Delay (optionally Minimum and Maximum delays)\n" | |
2107 | * "Average delay in micro-second as decimal (0...16777215)\n" | |
2108 | * "Minimum delay\n" | |
2109 | * "Minimum delay in micro-second as decimal (0...16777215)\n" | |
2110 | * "Maximum delay\n" | |
2111 | * "Maximum delay in micro-second as decimal (0...16777215)\n" | |
2112 | * | |
2113 | */ | |
16f1b9ee OD |
2114 | DEFUN (link_params_delay, |
2115 | link_params_delay_cmd, | |
6147e2c6 | 2116 | "delay (0-16777215)", |
16f1b9ee OD |
2117 | "Unidirectional Average Link Delay\n" |
2118 | "Average delay in micro-second as decimal (0...16777215)\n") | |
2119 | { | |
7c022376 | 2120 | int idx_number = 1; |
16f1b9ee OD |
2121 | |
2122 | struct interface *ifp = (struct interface *) vty->index; | |
2123 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2124 | u_int32_t delay = 0, low = 0, high = 0; | |
2125 | u_int8_t update = 0; | |
2126 | ||
2127 | /* Get and Check new delay values */ | |
7c022376 | 2128 | VTY_GET_ULONG("delay", delay, argv[idx_number]->arg); |
16f1b9ee OD |
2129 | switch (argc) |
2130 | { | |
2131 | case 1: | |
2132 | /* Check new delay value against old Min and Max delays if set */ | |
2133 | if (IS_PARAM_SET(iflp, LP_MM_DELAY) | |
2134 | && (delay <= iflp->min_delay || delay >= iflp->max_delay)) | |
2135 | { | |
2136 | vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", | |
2137 | iflp->min_delay, iflp->max_delay, VTY_NEWLINE); | |
2138 | return CMD_WARNING; | |
2139 | } | |
2140 | /* Update delay if value is not set or change */ | |
2141 | if (IS_PARAM_UNSET(iflp, LP_DELAY)|| iflp->av_delay != delay) | |
2142 | { | |
2143 | iflp->av_delay = delay; | |
2144 | SET_PARAM(iflp, LP_DELAY); | |
2145 | update = 1; | |
2146 | } | |
2147 | /* Unset Min and Max delays if already set */ | |
2148 | if (IS_PARAM_SET(iflp, LP_MM_DELAY)) | |
2149 | { | |
2150 | iflp->min_delay = 0; | |
2151 | iflp->max_delay = 0; | |
2152 | UNSET_PARAM(iflp, LP_MM_DELAY); | |
2153 | update = 1; | |
2154 | } | |
2155 | break; | |
2156 | case 2: | |
2157 | vty_out (vty, "You should specify both Minimum and Maximum delay with Average delay%s", | |
2158 | VTY_NEWLINE); | |
2159 | return CMD_WARNING; | |
2160 | break; | |
2161 | case 3: | |
8b3f0677 DW |
2162 | VTY_GET_ULONG("minimum delay", low, argv[3]->arg); |
2163 | VTY_GET_ULONG("maximum delay", high, argv[5]->arg); | |
16f1b9ee OD |
2164 | /* Check new delays value coherency */ |
2165 | if (delay <= low || delay >= high) | |
2166 | { | |
2167 | vty_out (vty, "Average delay should be comprise between Min (%d) and Max (%d) delay%s", | |
2168 | low, high, VTY_NEWLINE); | |
2169 | return CMD_WARNING; | |
2170 | } | |
2171 | /* Update Delays if needed */ | |
2172 | if (IS_PARAM_UNSET(iflp, LP_DELAY) | |
2173 | || IS_PARAM_UNSET(iflp, LP_MM_DELAY) | |
2174 | || iflp->av_delay != delay | |
2175 | || iflp->min_delay != low | |
2176 | || iflp->max_delay != high) | |
2177 | { | |
2178 | iflp->av_delay = delay; | |
2179 | SET_PARAM(iflp, LP_DELAY); | |
2180 | iflp->min_delay = low; | |
2181 | iflp->max_delay = high; | |
2182 | SET_PARAM(iflp, LP_MM_DELAY); | |
2183 | update = 1; | |
2184 | } | |
2185 | break; | |
2186 | default: | |
2187 | return CMD_WARNING; | |
2188 | break; | |
2189 | } | |
2190 | ||
2191 | /* force protocols to update LINK STATE due to parameters change */ | |
2192 | if (update == 1 && if_is_operative (ifp)) | |
2193 | zebra_interface_parameters_update (ifp); | |
2194 | ||
2195 | return CMD_SUCCESS; | |
2196 | } | |
2197 | ||
16f1b9ee OD |
2198 | |
2199 | DEFUN (no_link_params_delay, | |
2200 | no_link_params_delay_cmd, | |
2201 | "no delay", | |
2202 | NO_STR | |
2203 | "Disbale Unidirectional Average, Min & Max Link Delay on this interface\n") | |
2204 | { | |
2205 | struct interface *ifp = (struct interface *) vty->index; | |
2206 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2207 | ||
2208 | /* Unset Delays */ | |
2209 | iflp->av_delay = 0; | |
2210 | UNSET_PARAM(iflp, LP_DELAY); | |
2211 | iflp->min_delay = 0; | |
2212 | iflp->max_delay = 0; | |
2213 | UNSET_PARAM(iflp, LP_MM_DELAY); | |
2214 | ||
2215 | /* force protocols to update LINK STATE due to parameters change */ | |
2216 | if (if_is_operative (ifp)) | |
2217 | zebra_interface_parameters_update (ifp); | |
2218 | ||
2219 | return CMD_SUCCESS; | |
2220 | } | |
2221 | ||
2222 | DEFUN (link_params_delay_var, | |
2223 | link_params_delay_var_cmd, | |
6147e2c6 | 2224 | "delay-variation (0-16777215)", |
16f1b9ee OD |
2225 | "Unidirectional Link Delay Variation\n" |
2226 | "delay variation in micro-second as decimal (0...16777215)\n") | |
2227 | { | |
7c022376 | 2228 | int idx_number = 1; |
16f1b9ee OD |
2229 | struct interface *ifp = (struct interface *) vty->index; |
2230 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2231 | u_int32_t value; | |
2232 | ||
7c022376 | 2233 | VTY_GET_ULONG("delay variation", value, argv[idx_number]->arg); |
16f1b9ee OD |
2234 | |
2235 | /* Update Delay Variation if needed */ | |
2236 | link_param_cmd_set_uint32 (ifp, &iflp->delay_var, LP_DELAY_VAR, value); | |
2237 | ||
2238 | return CMD_SUCCESS; | |
2239 | } | |
2240 | ||
2241 | DEFUN (no_link_params_delay_var, | |
2242 | no_link_params_delay_var_cmd, | |
2243 | "no delay-variation", | |
2244 | NO_STR | |
2245 | "Disbale Unidirectional Delay Variation on this interface\n") | |
2246 | { | |
2247 | struct interface *ifp = (struct interface *) vty->index; | |
2248 | ||
2249 | /* Unset Delay Variation */ | |
2250 | link_param_cmd_unset(ifp, LP_DELAY_VAR); | |
2251 | ||
2252 | return CMD_SUCCESS; | |
2253 | } | |
2254 | ||
2255 | DEFUN (link_params_pkt_loss, | |
2256 | link_params_pkt_loss_cmd, | |
2257 | "packet-loss PERCENTAGE", | |
2258 | "Unidirectional Link Packet Loss\n" | |
2259 | "percentage of total traffic by 0.000003% step and less than 50.331642%\n") | |
2260 | { | |
7c022376 | 2261 | int idx_percentage = 1; |
16f1b9ee OD |
2262 | struct interface *ifp = (struct interface *) vty->index; |
2263 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2264 | float fval; | |
2265 | ||
7c022376 | 2266 | if (sscanf (argv[idx_percentage]->arg, "%g", &fval) != 1) |
16f1b9ee OD |
2267 | { |
2268 | vty_out (vty, "link_params_pkt_loss: fscanf: %s%s", safe_strerror (errno), | |
2269 | VTY_NEWLINE); | |
2270 | return CMD_WARNING; | |
2271 | } | |
2272 | ||
2273 | if (fval > MAX_PKT_LOSS) | |
2274 | fval = MAX_PKT_LOSS; | |
2275 | ||
2276 | /* Update Packet Loss if needed */ | |
2277 | link_param_cmd_set_float (ifp, &iflp->pkt_loss, LP_PKT_LOSS, fval); | |
2278 | ||
2279 | return CMD_SUCCESS; | |
2280 | } | |
2281 | ||
2282 | DEFUN (no_link_params_pkt_loss, | |
2283 | no_link_params_pkt_loss_cmd, | |
2284 | "no packet-loss", | |
2285 | NO_STR | |
2286 | "Disbale Unidirectional Link Packet Loss on this interface\n") | |
2287 | { | |
2288 | struct interface *ifp = (struct interface *) vty->index; | |
2289 | ||
2290 | /* Unset Packet Loss */ | |
2291 | link_param_cmd_unset(ifp, LP_PKT_LOSS); | |
2292 | ||
2293 | return CMD_SUCCESS; | |
2294 | } | |
2295 | ||
2296 | DEFUN (link_params_res_bw, | |
2297 | link_params_res_bw_cmd, | |
2298 | "res-bw BANDWIDTH", | |
2299 | "Unidirectional Residual Bandwidth\n" | |
2300 | "Bytes/second (IEEE floating point format)\n") | |
2301 | { | |
7c022376 | 2302 | int idx_bandwidth = 1; |
16f1b9ee OD |
2303 | struct interface *ifp = (struct interface *) vty->index; |
2304 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2305 | float bw; | |
2306 | ||
7c022376 | 2307 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2308 | { |
2309 | vty_out (vty, "link_params_res_bw: fscanf: %s%s", safe_strerror (errno), | |
2310 | VTY_NEWLINE); | |
2311 | return CMD_WARNING; | |
2312 | } | |
2313 | ||
2314 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2315 | if (bw > iflp->max_bw) | |
2316 | { | |
2317 | vty_out (vty, | |
2318 | "Residual Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2319 | iflp->max_bw, VTY_NEWLINE); | |
2320 | return CMD_WARNING; | |
2321 | } | |
2322 | ||
2323 | /* Update Residual Bandwidth if needed */ | |
2324 | link_param_cmd_set_float (ifp, &iflp->res_bw, LP_RES_BW, bw); | |
2325 | ||
2326 | return CMD_SUCCESS; | |
2327 | } | |
2328 | ||
2329 | DEFUN (no_link_params_res_bw, | |
2330 | no_link_params_res_bw_cmd, | |
2331 | "no res-bw", | |
2332 | NO_STR | |
2333 | "Disbale Unidirectional Residual Bandwidth on this interface\n") | |
2334 | { | |
2335 | struct interface *ifp = (struct interface *) vty->index; | |
2336 | ||
2337 | /* Unset Residual Bandwidth */ | |
2338 | link_param_cmd_unset(ifp, LP_RES_BW); | |
2339 | ||
2340 | return CMD_SUCCESS; | |
2341 | } | |
2342 | ||
2343 | DEFUN (link_params_ava_bw, | |
2344 | link_params_ava_bw_cmd, | |
2345 | "ava-bw BANDWIDTH", | |
2346 | "Unidirectional Available Bandwidth\n" | |
2347 | "Bytes/second (IEEE floating point format)\n") | |
2348 | { | |
7c022376 | 2349 | int idx_bandwidth = 1; |
16f1b9ee OD |
2350 | struct interface *ifp = (struct interface *) vty->index; |
2351 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2352 | float bw; | |
2353 | ||
7c022376 | 2354 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2355 | { |
2356 | vty_out (vty, "link_params_ava_bw: fscanf: %s%s", safe_strerror (errno), | |
2357 | VTY_NEWLINE); | |
2358 | return CMD_WARNING; | |
2359 | } | |
2360 | ||
2361 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2362 | if (bw > iflp->max_bw) | |
2363 | { | |
2364 | vty_out (vty, | |
2365 | "Available Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2366 | iflp->max_bw, VTY_NEWLINE); | |
2367 | return CMD_WARNING; | |
2368 | } | |
2369 | ||
2370 | /* Update Residual Bandwidth if needed */ | |
2371 | link_param_cmd_set_float (ifp, &iflp->ava_bw, LP_AVA_BW, bw); | |
2372 | ||
2373 | return CMD_SUCCESS; | |
2374 | } | |
2375 | ||
2376 | DEFUN (no_link_params_ava_bw, | |
2377 | no_link_params_ava_bw_cmd, | |
2378 | "no ava-bw", | |
2379 | NO_STR | |
2380 | "Disbale Unidirectional Available Bandwidth on this interface\n") | |
2381 | { | |
2382 | struct interface *ifp = (struct interface *) vty->index; | |
2383 | ||
2384 | /* Unset Available Bandwidth */ | |
2385 | link_param_cmd_unset(ifp, LP_AVA_BW); | |
2386 | ||
2387 | return CMD_SUCCESS; | |
2388 | } | |
2389 | ||
2390 | DEFUN (link_params_use_bw, | |
2391 | link_params_use_bw_cmd, | |
2392 | "use-bw BANDWIDTH", | |
2393 | "Unidirectional Utilised Bandwidth\n" | |
2394 | "Bytes/second (IEEE floating point format)\n") | |
2395 | { | |
7c022376 | 2396 | int idx_bandwidth = 1; |
16f1b9ee OD |
2397 | struct interface *ifp = (struct interface *) vty->index; |
2398 | struct if_link_params *iflp = if_link_params_get (ifp); | |
2399 | float bw; | |
2400 | ||
7c022376 | 2401 | if (sscanf (argv[idx_bandwidth]->arg, "%g", &bw) != 1) |
16f1b9ee OD |
2402 | { |
2403 | vty_out (vty, "link_params_use_bw: fscanf: %s%s", safe_strerror (errno), | |
2404 | VTY_NEWLINE); | |
2405 | return CMD_WARNING; | |
2406 | } | |
2407 | ||
2408 | /* Check that bandwidth is not greater than maximum bandwidth parameter */ | |
2409 | if (bw > iflp->max_bw) | |
2410 | { | |
2411 | vty_out (vty, | |
2412 | "Utilised Bandwidth could not be greater than Maximum Bandwidth (%g)%s", | |
2413 | iflp->max_bw, VTY_NEWLINE); | |
2414 | return CMD_WARNING; | |
2415 | } | |
2416 | ||
2417 | /* Update Utilized Bandwidth if needed */ | |
2418 | link_param_cmd_set_float (ifp, &iflp->use_bw, LP_USE_BW, bw); | |
2419 | ||
2420 | return CMD_SUCCESS; | |
2421 | } | |
2422 | ||
2423 | DEFUN (no_link_params_use_bw, | |
2424 | no_link_params_use_bw_cmd, | |
2425 | "no use-bw", | |
2426 | NO_STR | |
2427 | "Disbale Unidirectional Utilised Bandwidth on this interface\n") | |
2428 | { | |
2429 | struct interface *ifp = (struct interface *) vty->index; | |
2430 | ||
2431 | /* Unset Utilised Bandwidth */ | |
2432 | link_param_cmd_unset(ifp, LP_USE_BW); | |
2433 | ||
2434 | return CMD_SUCCESS; | |
2435 | } | |
2436 | ||
a1ac18c4 | 2437 | static int |
39db97e4 | 2438 | ip_address_install (struct vty *vty, struct interface *ifp, |
2439 | const char *addr_str, const char *peer_str, | |
2440 | const char *label) | |
718e3744 | 2441 | { |
bfac8dcd | 2442 | struct zebra_if *if_data; |
718e3744 | 2443 | struct prefix_ipv4 cp; |
2444 | struct connected *ifc; | |
2445 | struct prefix_ipv4 *p; | |
718e3744 | 2446 | int ret; |
2447 | ||
bfac8dcd CF |
2448 | if_data = ifp->info; |
2449 | ||
718e3744 | 2450 | ret = str2prefix_ipv4 (addr_str, &cp); |
2451 | if (ret <= 0) | |
2452 | { | |
2453 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2454 | return CMD_WARNING; | |
2455 | } | |
2456 | ||
d914d5ff DS |
2457 | if (ipv4_martian(&cp.prefix)) |
2458 | { | |
2459 | vty_out (vty, "%% Invalid address%s", VTY_NEWLINE); | |
2460 | return CMD_WARNING; | |
2461 | } | |
2462 | ||
ca16218d | 2463 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2464 | if (! ifc) |
2465 | { | |
2466 | ifc = connected_new (); | |
2467 | ifc->ifp = ifp; | |
2468 | ||
2469 | /* Address. */ | |
2470 | p = prefix_ipv4_new (); | |
2471 | *p = cp; | |
2472 | ifc->address = (struct prefix *) p; | |
2473 | ||
2474 | /* Broadcast. */ | |
3fb9cd6e | 2475 | if (p->prefixlen <= IPV4_MAX_PREFIXLEN-2) |
718e3744 | 2476 | { |
2477 | p = prefix_ipv4_new (); | |
2478 | *p = cp; | |
3fb9cd6e | 2479 | p->prefix.s_addr = ipv4_broadcast_addr(p->prefix.s_addr,p->prefixlen); |
718e3744 | 2480 | ifc->destination = (struct prefix *) p; |
2481 | } | |
2482 | ||
718e3744 | 2483 | /* Label. */ |
2484 | if (label) | |
0752ef0b | 2485 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
718e3744 | 2486 | |
2487 | /* Add to linked list. */ | |
2488 | listnode_add (ifp->connected, ifc); | |
2489 | } | |
2490 | ||
2491 | /* This address is configured from zebra. */ | |
2492 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2493 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); | |
2494 | ||
2495 | /* In case of this route need to install kernel. */ | |
f7f740fe | 2496 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
bfac8dcd CF |
2497 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
2498 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) | |
718e3744 | 2499 | { |
2500 | /* Some system need to up the interface to set IP address. */ | |
2501 | if (! if_is_up (ifp)) | |
2502 | { | |
2503 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); | |
2504 | if_refresh (ifp); | |
2505 | } | |
2506 | ||
2507 | ret = if_set_prefix (ifp, ifc); | |
2508 | if (ret < 0) | |
2509 | { | |
2510 | vty_out (vty, "%% Can't set interface IP address: %s.%s", | |
6099b3b5 | 2511 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2512 | return CMD_WARNING; |
2513 | } | |
2514 | ||
f7f740fe | 2515 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2516 | /* The address will be advertised to zebra clients when the notification |
2517 | * from the kernel has been received. | |
2518 | * It will also be added to the subnet chain list, then. */ | |
718e3744 | 2519 | } |
2520 | ||
2521 | return CMD_SUCCESS; | |
2522 | } | |
2523 | ||
a1ac18c4 | 2524 | static int |
39db97e4 | 2525 | ip_address_uninstall (struct vty *vty, struct interface *ifp, |
2526 | const char *addr_str, const char *peer_str, | |
2527 | const char *label) | |
718e3744 | 2528 | { |
2529 | struct prefix_ipv4 cp; | |
2530 | struct connected *ifc; | |
2531 | int ret; | |
2532 | ||
2533 | /* Convert to prefix structure. */ | |
2534 | ret = str2prefix_ipv4 (addr_str, &cp); | |
2535 | if (ret <= 0) | |
2536 | { | |
2537 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2538 | return CMD_WARNING; | |
2539 | } | |
2540 | ||
2541 | /* Check current interface address. */ | |
ca16218d | 2542 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2543 | if (! ifc) |
2544 | { | |
2545 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); | |
2546 | return CMD_WARNING; | |
2547 | } | |
2548 | ||
2549 | /* This is not configured address. */ | |
2550 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2551 | return CMD_WARNING; | |
2552 | ||
74ecdc9e PJ |
2553 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
2554 | ||
718e3744 | 2555 | /* This is not real address or interface is not active. */ |
f7f740fe | 2556 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
718e3744 | 2557 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
2558 | { | |
2559 | listnode_delete (ifp->connected, ifc); | |
2560 | connected_free (ifc); | |
2561 | return CMD_WARNING; | |
2562 | } | |
2563 | ||
2564 | /* This is real route. */ | |
2565 | ret = if_unset_prefix (ifp, ifc); | |
2566 | if (ret < 0) | |
2567 | { | |
2568 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", | |
6099b3b5 | 2569 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2570 | return CMD_WARNING; |
2571 | } | |
f7f740fe | 2572 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2573 | /* we will receive a kernel notification about this route being removed. |
2574 | * this will trigger its removal from the connected list. */ | |
718e3744 | 2575 | return CMD_SUCCESS; |
2576 | } | |
2577 | ||
2578 | DEFUN (ip_address, | |
2579 | ip_address_cmd, | |
2580 | "ip address A.B.C.D/M", | |
2581 | "Interface Internet Protocol config commands\n" | |
2582 | "Set the IP address of an interface\n" | |
2583 | "IP address (e.g. 10.0.0.1/8)\n") | |
2584 | { | |
7c022376 DW |
2585 | int idx_ipv4_prefixlen = 2; |
2586 | return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); | |
718e3744 | 2587 | } |
2588 | ||
2589 | DEFUN (no_ip_address, | |
2590 | no_ip_address_cmd, | |
2591 | "no ip address A.B.C.D/M", | |
2592 | NO_STR | |
2593 | "Interface Internet Protocol config commands\n" | |
2594 | "Set the IP address of an interface\n" | |
2595 | "IP Address (e.g. 10.0.0.1/8)") | |
2596 | { | |
7c022376 DW |
2597 | int idx_ipv4_prefixlen = 3; |
2598 | return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, NULL); | |
718e3744 | 2599 | } |
2600 | ||
986aa00f | 2601 | |
718e3744 | 2602 | #ifdef HAVE_NETLINK |
718e3744 | 2603 | DEFUN (ip_address_label, |
2604 | ip_address_label_cmd, | |
2605 | "ip address A.B.C.D/M label LINE", | |
2606 | "Interface Internet Protocol config commands\n" | |
2607 | "Set the IP address of an interface\n" | |
2608 | "IP address (e.g. 10.0.0.1/8)\n" | |
2609 | "Label of this address\n" | |
2610 | "Label\n") | |
2611 | { | |
7c022376 DW |
2612 | int idx_ipv4_prefixlen = 2; |
2613 | int idx_line = 4; | |
2614 | return ip_address_install (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); | |
718e3744 | 2615 | } |
2616 | ||
2617 | DEFUN (no_ip_address_label, | |
2618 | no_ip_address_label_cmd, | |
2619 | "no ip address A.B.C.D/M label LINE", | |
2620 | NO_STR | |
2621 | "Interface Internet Protocol config commands\n" | |
2622 | "Set the IP address of an interface\n" | |
2623 | "IP address (e.g. 10.0.0.1/8)\n" | |
2624 | "Label of this address\n" | |
2625 | "Label\n") | |
2626 | { | |
7c022376 DW |
2627 | int idx_ipv4_prefixlen = 3; |
2628 | int idx_line = 5; | |
2629 | return ip_address_uninstall (vty, vty->index, argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_line]->arg); | |
718e3744 | 2630 | } |
2631 | #endif /* HAVE_NETLINK */ | |
2632 | ||
2633 | #ifdef HAVE_IPV6 | |
a1ac18c4 | 2634 | static int |
39db97e4 | 2635 | ipv6_address_install (struct vty *vty, struct interface *ifp, |
2636 | const char *addr_str, const char *peer_str, | |
2637 | const char *label, int secondary) | |
718e3744 | 2638 | { |
bfac8dcd | 2639 | struct zebra_if *if_data; |
718e3744 | 2640 | struct prefix_ipv6 cp; |
2641 | struct connected *ifc; | |
2642 | struct prefix_ipv6 *p; | |
2643 | int ret; | |
2644 | ||
bfac8dcd CF |
2645 | if_data = ifp->info; |
2646 | ||
718e3744 | 2647 | ret = str2prefix_ipv6 (addr_str, &cp); |
2648 | if (ret <= 0) | |
2649 | { | |
2650 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2651 | return CMD_WARNING; | |
2652 | } | |
2653 | ||
d914d5ff DS |
2654 | if (ipv6_martian(&cp.prefix)) |
2655 | { | |
2656 | vty_out (vty, "%% Invalid address%s", VTY_NEWLINE); | |
2657 | return CMD_WARNING; | |
2658 | } | |
2659 | ||
ca16218d | 2660 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2661 | if (! ifc) |
2662 | { | |
2663 | ifc = connected_new (); | |
2664 | ifc->ifp = ifp; | |
2665 | ||
2666 | /* Address. */ | |
2667 | p = prefix_ipv6_new (); | |
2668 | *p = cp; | |
2669 | ifc->address = (struct prefix *) p; | |
2670 | ||
2671 | /* Secondary. */ | |
2672 | if (secondary) | |
2673 | SET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); | |
2674 | ||
2675 | /* Label. */ | |
2676 | if (label) | |
0752ef0b | 2677 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
718e3744 | 2678 | |
2679 | /* Add to linked list. */ | |
2680 | listnode_add (ifp->connected, ifc); | |
2681 | } | |
2682 | ||
2683 | /* This address is configured from zebra. */ | |
2684 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2685 | SET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); | |
2686 | ||
2687 | /* In case of this route need to install kernel. */ | |
f7f740fe | 2688 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
bfac8dcd CF |
2689 | && CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE) |
2690 | && !(if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)) | |
718e3744 | 2691 | { |
2692 | /* Some system need to up the interface to set IP address. */ | |
2693 | if (! if_is_up (ifp)) | |
2694 | { | |
2695 | if_set_flags (ifp, IFF_UP | IFF_RUNNING); | |
2696 | if_refresh (ifp); | |
2697 | } | |
2698 | ||
2699 | ret = if_prefix_add_ipv6 (ifp, ifc); | |
2700 | ||
2701 | if (ret < 0) | |
2702 | { | |
2703 | vty_out (vty, "%% Can't set interface IP address: %s.%s", | |
6099b3b5 | 2704 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2705 | return CMD_WARNING; |
2706 | } | |
2707 | ||
f7f740fe | 2708 | SET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2709 | /* The address will be advertised to zebra clients when the notification |
2710 | * from the kernel has been received. */ | |
718e3744 | 2711 | } |
2712 | ||
2713 | return CMD_SUCCESS; | |
2714 | } | |
2715 | ||
b6120505 DW |
2716 | /* Return true if an ipv6 address is configured on ifp */ |
2717 | int | |
2718 | ipv6_address_configured (struct interface *ifp) | |
2719 | { | |
2720 | struct connected *connected; | |
2721 | struct listnode *node; | |
2722 | ||
2723 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) | |
2724 | if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) && (connected->address->family == AF_INET6)) | |
2725 | return 1; | |
2726 | ||
2727 | return 0; | |
2728 | } | |
2729 | ||
a1ac18c4 | 2730 | static int |
39db97e4 | 2731 | ipv6_address_uninstall (struct vty *vty, struct interface *ifp, |
2732 | const char *addr_str, const char *peer_str, | |
2733 | const char *label, int secondry) | |
718e3744 | 2734 | { |
2735 | struct prefix_ipv6 cp; | |
2736 | struct connected *ifc; | |
2737 | int ret; | |
2738 | ||
2739 | /* Convert to prefix structure. */ | |
2740 | ret = str2prefix_ipv6 (addr_str, &cp); | |
2741 | if (ret <= 0) | |
2742 | { | |
2743 | vty_out (vty, "%% Malformed address %s", VTY_NEWLINE); | |
2744 | return CMD_WARNING; | |
2745 | } | |
2746 | ||
2747 | /* Check current interface address. */ | |
ca16218d | 2748 | ifc = connected_check (ifp, (struct prefix *) &cp); |
718e3744 | 2749 | if (! ifc) |
2750 | { | |
2751 | vty_out (vty, "%% Can't find address%s", VTY_NEWLINE); | |
2752 | return CMD_WARNING; | |
2753 | } | |
2754 | ||
2755 | /* This is not configured address. */ | |
2756 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) | |
2757 | return CMD_WARNING; | |
2758 | ||
676e1a01 CF |
2759 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED); |
2760 | ||
718e3744 | 2761 | /* This is not real address or interface is not active. */ |
f7f740fe | 2762 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_QUEUED) |
718e3744 | 2763 | || ! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) |
2764 | { | |
2765 | listnode_delete (ifp->connected, ifc); | |
2766 | connected_free (ifc); | |
2767 | return CMD_WARNING; | |
2768 | } | |
2769 | ||
2770 | /* This is real route. */ | |
2771 | ret = if_prefix_delete_ipv6 (ifp, ifc); | |
2772 | if (ret < 0) | |
2773 | { | |
2774 | vty_out (vty, "%% Can't unset interface IP address: %s.%s", | |
6099b3b5 | 2775 | safe_strerror(errno), VTY_NEWLINE); |
718e3744 | 2776 | return CMD_WARNING; |
2777 | } | |
2778 | ||
f7f740fe | 2779 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_QUEUED); |
02b4805f CF |
2780 | /* This information will be propagated to the zclients when the |
2781 | * kernel notification is received. */ | |
718e3744 | 2782 | return CMD_SUCCESS; |
2783 | } | |
2784 | ||
2785 | DEFUN (ipv6_address, | |
2786 | ipv6_address_cmd, | |
2787 | "ipv6 address X:X::X:X/M", | |
e23949c0 | 2788 | "Interface IPv6 config commands\n" |
718e3744 | 2789 | "Set the IP address of an interface\n" |
2790 | "IPv6 address (e.g. 3ffe:506::1/48)\n") | |
2791 | { | |
7c022376 DW |
2792 | int idx_ipv6_prefixlen = 2; |
2793 | return ipv6_address_install (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); | |
718e3744 | 2794 | } |
2795 | ||
2796 | DEFUN (no_ipv6_address, | |
2797 | no_ipv6_address_cmd, | |
2798 | "no ipv6 address X:X::X:X/M", | |
2799 | NO_STR | |
e23949c0 | 2800 | "Interface IPv6 config commands\n" |
718e3744 | 2801 | "Set the IP address of an interface\n" |
2802 | "IPv6 address (e.g. 3ffe:506::1/48)\n") | |
2803 | { | |
7c022376 DW |
2804 | int idx_ipv6_prefixlen = 3; |
2805 | return ipv6_address_uninstall (vty, vty->index, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); | |
718e3744 | 2806 | } |
2807 | #endif /* HAVE_IPV6 */ | |
2808 | ||
16f1b9ee OD |
2809 | static int |
2810 | link_params_config_write (struct vty *vty, struct interface *ifp) | |
2811 | { | |
2812 | int i; | |
2813 | ||
2814 | if ((ifp == NULL) || !HAS_LINK_PARAMS(ifp)) | |
2815 | return -1; | |
2816 | ||
2817 | struct if_link_params *iflp = ifp->link_params; | |
2818 | ||
2819 | vty_out (vty, " link-params%s", VTY_NEWLINE); | |
2820 | vty_out(vty, " enable%s", VTY_NEWLINE); | |
2821 | if (IS_PARAM_SET(iflp, LP_TE)) | |
2822 | vty_out(vty, " metric %u%s",iflp->te_metric, VTY_NEWLINE); | |
2823 | if (IS_PARAM_SET(iflp, LP_MAX_BW)) | |
2824 | vty_out(vty, " max-bw %g%s", iflp->max_bw, VTY_NEWLINE); | |
2825 | if (IS_PARAM_SET(iflp, LP_MAX_RSV_BW)) | |
2826 | vty_out(vty, " max-rsv-bw %g%s", iflp->max_rsv_bw, VTY_NEWLINE); | |
2827 | if (IS_PARAM_SET(iflp, LP_UNRSV_BW)) | |
2828 | { | |
2829 | for (i = 0; i < 8; i++) | |
2830 | vty_out(vty, " unrsv-bw %d %g%s", | |
2831 | i, iflp->unrsv_bw[i], VTY_NEWLINE); | |
2832 | } | |
2833 | if (IS_PARAM_SET(iflp, LP_ADM_GRP)) | |
2834 | vty_out(vty, " admin-grp %u%s", iflp->admin_grp, VTY_NEWLINE); | |
2835 | if (IS_PARAM_SET(iflp, LP_DELAY)) | |
2836 | { | |
2837 | vty_out(vty, " delay %u", iflp->av_delay); | |
2838 | if (IS_PARAM_SET(iflp, LP_MM_DELAY)) | |
2839 | { | |
2840 | vty_out(vty, " min %u", iflp->min_delay); | |
2841 | vty_out(vty, " max %u", iflp->max_delay); | |
2842 | } | |
2843 | vty_out(vty, "%s", VTY_NEWLINE); | |
2844 | } | |
2845 | if (IS_PARAM_SET(iflp, LP_DELAY_VAR)) | |
2846 | vty_out(vty, " delay-variation %u%s", iflp->delay_var, VTY_NEWLINE); | |
2847 | if (IS_PARAM_SET(iflp, LP_PKT_LOSS)) | |
2848 | vty_out(vty, " packet-loss %g%s", iflp->pkt_loss, VTY_NEWLINE); | |
2849 | if (IS_PARAM_SET(iflp, LP_AVA_BW)) | |
2850 | vty_out(vty, " ava-bw %g%s", iflp->ava_bw, VTY_NEWLINE); | |
2851 | if (IS_PARAM_SET(iflp, LP_RES_BW)) | |
2852 | vty_out(vty, " res-bw %g%s", iflp->res_bw, VTY_NEWLINE); | |
2853 | if (IS_PARAM_SET(iflp, LP_USE_BW)) | |
2854 | vty_out(vty, " use-bw %g%s", iflp->use_bw, VTY_NEWLINE); | |
2855 | if (IS_PARAM_SET(iflp, LP_RMT_AS)) | |
2856 | vty_out(vty, " neighbor %s as %u%s", inet_ntoa(iflp->rmt_ip), | |
2857 | iflp->rmt_as, VTY_NEWLINE); | |
2858 | return 0; | |
2859 | } | |
2860 | ||
a1ac18c4 | 2861 | static int |
718e3744 | 2862 | if_config_write (struct vty *vty) |
2863 | { | |
52dc7ee6 | 2864 | struct listnode *node; |
718e3744 | 2865 | struct interface *ifp; |
cd2a8a42 | 2866 | vrf_iter_t iter; |
718e3744 | 2867 | |
244c1cdc DS |
2868 | zebra_ptm_write (vty); |
2869 | ||
cd2a8a42 FL |
2870 | for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
2871 | for (ALL_LIST_ELEMENTS_RO (vrf_iter2iflist (iter), node, ifp)) | |
718e3744 | 2872 | { |
2873 | struct zebra_if *if_data; | |
52dc7ee6 | 2874 | struct listnode *addrnode; |
718e3744 | 2875 | struct connected *ifc; |
2876 | struct prefix *p; | |
12f6fb97 | 2877 | struct vrf *vrf; |
718e3744 | 2878 | |
718e3744 | 2879 | if_data = ifp->info; |
12f6fb97 | 2880 | vrf = vrf_lookup(ifp->vrf_id); |
cd2a8a42 FL |
2881 | |
2882 | if (ifp->vrf_id == VRF_DEFAULT) | |
2883 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); | |
2884 | else | |
12f6fb97 | 2885 | vty_out (vty, "interface %s vrf %s%s", ifp->name, vrf->name, |
cd2a8a42 | 2886 | VTY_NEWLINE); |
718e3744 | 2887 | |
bfac8dcd CF |
2888 | if (if_data) |
2889 | { | |
2890 | if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) | |
2891 | vty_out (vty, " shutdown%s", VTY_NEWLINE); | |
986aa00f | 2892 | |
2893 | zebra_ptm_if_write(vty, if_data); | |
bfac8dcd CF |
2894 | } |
2895 | ||
718e3744 | 2896 | if (ifp->desc) |
2897 | vty_out (vty, " description %s%s", ifp->desc, | |
2898 | VTY_NEWLINE); | |
2899 | ||
2900 | /* Assign bandwidth here to avoid unnecessary interface flap | |
2901 | while processing config script */ | |
2902 | if (ifp->bandwidth != 0) | |
2903 | vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE); | |
2904 | ||
07fc1596 DD |
2905 | if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) |
2906 | vty_out(vty, " no link-detect%s", VTY_NEWLINE); | |
2e3b2e47 | 2907 | |
1eb8ef25 | 2908 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc)) |
718e3744 | 2909 | { |
718e3744 | 2910 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
2911 | { | |
81cce018 | 2912 | char buf[INET6_ADDRSTRLEN]; |
718e3744 | 2913 | p = ifc->address; |
35d921cc | 2914 | vty_out (vty, " ip%s address %s", |
718e3744 | 2915 | p->family == AF_INET ? "" : "v6", |
35d921cc | 2916 | prefix2str (p, buf, sizeof(buf))); |
718e3744 | 2917 | |
718e3744 | 2918 | if (ifc->label) |
2919 | vty_out (vty, " label %s", ifc->label); | |
2920 | ||
2921 | vty_out (vty, "%s", VTY_NEWLINE); | |
2922 | } | |
2923 | } | |
2924 | ||
2925 | if (if_data) | |
2926 | { | |
718e3744 | 2927 | if (if_data->multicast != IF_ZEBRA_MULTICAST_UNSPEC) |
2928 | vty_out (vty, " %smulticast%s", | |
2929 | if_data->multicast == IF_ZEBRA_MULTICAST_ON ? "" : "no ", | |
2930 | VTY_NEWLINE); | |
2931 | } | |
2932 | ||
8da4e946 | 2933 | #if defined (HAVE_RTADV) |
718e3744 | 2934 | rtadv_config_write (vty, ifp); |
8da4e946 | 2935 | #endif /* HAVE_RTADV */ |
718e3744 | 2936 | |
ca776988 | 2937 | #ifdef HAVE_IRDP |
2938 | irdp_config_write (vty, ifp); | |
2939 | #endif /* IRDP */ | |
2940 | ||
16f1b9ee OD |
2941 | link_params_config_write (vty, ifp); |
2942 | ||
718e3744 | 2943 | vty_out (vty, "!%s", VTY_NEWLINE); |
2944 | } | |
2945 | return 0; | |
2946 | } | |
2947 | ||
12f6fb97 DS |
2948 | static int |
2949 | vrf_config_write (struct vty *vty) | |
2950 | { | |
2951 | struct listnode *node; | |
c1c747a8 | 2952 | struct zebra_vrf *zvrf; |
12f6fb97 | 2953 | |
c1c747a8 | 2954 | for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) |
12f6fb97 | 2955 | { |
c1c747a8 | 2956 | if (strcmp(zvrf->name, VRF_DEFAULT_NAME)) |
12f6fb97 | 2957 | { |
c1c747a8 | 2958 | vty_out (vty, "vrf %s%s", zvrf->name, VTY_NEWLINE); |
12f6fb97 DS |
2959 | vty_out (vty, "!%s", VTY_NEWLINE); |
2960 | } | |
2961 | } | |
2962 | return 0; | |
2963 | } | |
2964 | ||
718e3744 | 2965 | /* Allocate and initialize interface vector. */ |
2966 | void | |
a1ac18c4 | 2967 | zebra_if_init (void) |
718e3744 | 2968 | { |
2969 | /* Initialize interface and new hook. */ | |
718e3744 | 2970 | if_add_hook (IF_NEW_HOOK, if_zebra_new_hook); |
2971 | if_add_hook (IF_DELETE_HOOK, if_zebra_delete_hook); | |
2972 | ||
2973 | /* Install configuration write function. */ | |
2974 | install_node (&interface_node, if_config_write); | |
16f1b9ee | 2975 | install_node (&link_params_node, NULL); |
12f6fb97 | 2976 | install_node (&vrf_node, vrf_config_write); |
718e3744 | 2977 | |
2978 | install_element (VIEW_NODE, &show_interface_cmd); | |
8b87bdf4 | 2979 | install_element (VIEW_NODE, &show_interface_vrf_all_cmd); |
8b87bdf4 FL |
2980 | install_element (VIEW_NODE, &show_interface_name_vrf_cmd); |
2981 | install_element (VIEW_NODE, &show_interface_name_vrf_all_cmd); | |
718e3744 | 2982 | install_element (ENABLE_NODE, &show_interface_cmd); |
8b87bdf4 | 2983 | install_element (ENABLE_NODE, &show_interface_vrf_all_cmd); |
8b87bdf4 FL |
2984 | install_element (ENABLE_NODE, &show_interface_name_vrf_cmd); |
2985 | install_element (ENABLE_NODE, &show_interface_name_vrf_all_cmd); | |
ed9bb6d5 | 2986 | install_element (ENABLE_NODE, &show_interface_desc_cmd); |
8b87bdf4 | 2987 | install_element (ENABLE_NODE, &show_interface_desc_vrf_all_cmd); |
718e3744 | 2988 | install_element (CONFIG_NODE, &zebra_interface_cmd); |
bfc13532 | 2989 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 2990 | install_default (INTERFACE_NODE); |
2991 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
2992 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
2993 | install_element (INTERFACE_NODE, &multicast_cmd); | |
2994 | install_element (INTERFACE_NODE, &no_multicast_cmd); | |
2e3b2e47 | 2995 | install_element (INTERFACE_NODE, &linkdetect_cmd); |
2996 | install_element (INTERFACE_NODE, &no_linkdetect_cmd); | |
718e3744 | 2997 | install_element (INTERFACE_NODE, &shutdown_if_cmd); |
2998 | install_element (INTERFACE_NODE, &no_shutdown_if_cmd); | |
2999 | install_element (INTERFACE_NODE, &bandwidth_if_cmd); | |
3000 | install_element (INTERFACE_NODE, &no_bandwidth_if_cmd); | |
718e3744 | 3001 | install_element (INTERFACE_NODE, &ip_address_cmd); |
3002 | install_element (INTERFACE_NODE, &no_ip_address_cmd); | |
3003 | #ifdef HAVE_IPV6 | |
3004 | install_element (INTERFACE_NODE, &ipv6_address_cmd); | |
3005 | install_element (INTERFACE_NODE, &no_ipv6_address_cmd); | |
3006 | #endif /* HAVE_IPV6 */ | |
718e3744 | 3007 | #ifdef HAVE_NETLINK |
718e3744 | 3008 | install_element (INTERFACE_NODE, &ip_address_label_cmd); |
718e3744 | 3009 | install_element (INTERFACE_NODE, &no_ip_address_label_cmd); |
3010 | #endif /* HAVE_NETLINK */ | |
16f1b9ee OD |
3011 | install_element(INTERFACE_NODE, &link_params_cmd); |
3012 | install_default(LINK_PARAMS_NODE); | |
3013 | install_element(LINK_PARAMS_NODE, &link_params_enable_cmd); | |
3014 | install_element(LINK_PARAMS_NODE, &no_link_params_enable_cmd); | |
3015 | install_element(LINK_PARAMS_NODE, &link_params_metric_cmd); | |
3016 | install_element(LINK_PARAMS_NODE, &link_params_maxbw_cmd); | |
3017 | install_element(LINK_PARAMS_NODE, &link_params_max_rsv_bw_cmd); | |
3018 | install_element(LINK_PARAMS_NODE, &link_params_unrsv_bw_cmd); | |
3019 | install_element(LINK_PARAMS_NODE, &link_params_admin_grp_cmd); | |
3020 | install_element(LINK_PARAMS_NODE, &link_params_inter_as_cmd); | |
3021 | install_element(LINK_PARAMS_NODE, &no_link_params_inter_as_cmd); | |
3022 | install_element(LINK_PARAMS_NODE, &link_params_delay_cmd); | |
16f1b9ee OD |
3023 | install_element(LINK_PARAMS_NODE, &link_params_delay_var_cmd); |
3024 | install_element(LINK_PARAMS_NODE, &link_params_pkt_loss_cmd); | |
3025 | install_element(LINK_PARAMS_NODE, &link_params_ava_bw_cmd); | |
3026 | install_element(LINK_PARAMS_NODE, &link_params_res_bw_cmd); | |
3027 | install_element(LINK_PARAMS_NODE, &link_params_use_bw_cmd); | |
3028 | ||
12f6fb97 DS |
3029 | install_element (CONFIG_NODE, &zebra_vrf_cmd); |
3030 | install_element (CONFIG_NODE, &no_vrf_cmd); | |
3031 | install_default (VRF_NODE); | |
718e3744 | 3032 | } |