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