3 * Copyright (C) 1997, 98 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2, or (at your
10 * option) any later version.
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.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "lib_errors.h"
31 #include "sockunion.h"
37 #include "northbound_cli.h"
38 #ifndef VTYSH_EXTRACT_PL
39 #include "lib/if_clippy.c"
42 DEFINE_MTYPE_STATIC(LIB
, IF
, "Interface")
43 DEFINE_MTYPE_STATIC(LIB
, CONNECTED
, "Connected")
44 DEFINE_MTYPE_STATIC(LIB
, NBR_CONNECTED
, "Neighbor Connected")
45 DEFINE_MTYPE(LIB
, CONNECTED_LABEL
, "Connected interface label")
46 DEFINE_MTYPE_STATIC(LIB
, IF_LINK_PARAMS
, "Informational Link Parameters")
48 static struct interface
*if_lookup_by_ifindex(ifindex_t ifindex
,
50 static int if_cmp_func(const struct interface
*, const struct interface
*);
51 static int if_cmp_index_func(const struct interface
*ifp1
,
52 const struct interface
*ifp2
);
53 RB_GENERATE(if_name_head
, interface
, name_entry
, if_cmp_func
);
54 RB_GENERATE(if_index_head
, interface
, index_entry
, if_cmp_index_func
);
56 DEFINE_QOBJ_TYPE(interface
)
58 DEFINE_HOOK(if_add
, (struct interface
* ifp
), (ifp
))
59 DEFINE_KOOH(if_del
, (struct interface
* ifp
), (ifp
))
61 struct interface_master
{
62 int (*create_hook
)(struct interface
*ifp
);
63 int (*up_hook
)(struct interface
*ifp
);
64 int (*down_hook
)(struct interface
*ifp
);
65 int (*destroy_hook
)(struct interface
*ifp
);
66 } ifp_master
= { 0, };
68 /* Compare interface names, returning an integer greater than, equal to, or
69 * less than 0, (following the strcmp convention), according to the
70 * relationship between ifp1 and ifp2. Interface names consist of an
71 * alphabetic prefix and a numeric suffix. The primary sort key is
72 * lexicographic by name, and then numeric by number. No number sorts
73 * before all numbers. Examples: de0 < de1, de100 < fxp0 < xl0, devpty <
76 int if_cmp_name_func(const char *p1
, const char *p2
)
83 /* look up to any number */
84 l1
= strcspn(p1
, "0123456789");
85 l2
= strcspn(p2
, "0123456789");
87 /* name lengths are different -> compare names */
89 return (strcmp(p1
, p2
));
91 /* Note that this relies on all numbers being less than all
95 res
= strncmp(p1
, p2
, l1
);
97 /* names are different -> compare them */
101 /* with identical name part, go to numeric part */
112 x1
= strtol(p1
, (char **)&p1
, 10);
113 x2
= strtol(p2
, (char **)&p2
, 10);
115 /* let's compare numbers now */
121 /* numbers were equal, lets do it again..
122 (it happens with name like "eth123.456:789") */
131 static int if_cmp_func(const struct interface
*ifp1
,
132 const struct interface
*ifp2
)
134 return if_cmp_name_func(ifp1
->name
, ifp2
->name
);
137 static int if_cmp_index_func(const struct interface
*ifp1
,
138 const struct interface
*ifp2
)
140 return ifp1
->ifindex
- ifp2
->ifindex
;
143 /* Create new interface structure. */
144 static struct interface
*if_create_backend(const char *name
, ifindex_t ifindex
,
147 struct vrf
*vrf
= vrf_get(vrf_id
, NULL
);
148 struct interface
*ifp
;
150 ifp
= XCALLOC(MTYPE_IF
, sizeof(struct interface
));
151 ifp
->vrf_id
= vrf_id
;
154 strlcpy(ifp
->name
, name
, sizeof(ifp
->name
));
155 IFNAME_RB_INSERT(vrf
, ifp
);
159 if (ifindex
!= IFINDEX_INTERNAL
)
160 if_set_index(ifp
, ifindex
);
162 ifp
->ifindex
= ifindex
; /* doesn't add it to the list */
164 ifp
->connected
= list_new();
165 ifp
->connected
->del
= (void (*)(void *))connected_free
;
167 ifp
->nbr_connected
= list_new();
168 ifp
->nbr_connected
->del
= (void (*)(void *))nbr_connected_free
;
170 /* Enable Link-detection by default */
171 SET_FLAG(ifp
->status
, ZEBRA_INTERFACE_LINKDETECTION
);
173 QOBJ_REG(ifp
, interface
);
174 hook_call(if_add
, ifp
);
178 void if_new_via_zapi(struct interface
*ifp
)
180 if (ifp_master
.create_hook
)
181 (*ifp_master
.create_hook
)(ifp
);
184 void if_destroy_via_zapi(struct interface
*ifp
)
186 if (ifp_master
.destroy_hook
)
187 (*ifp_master
.destroy_hook
)(ifp
);
189 if_set_index(ifp
, IFINDEX_INTERNAL
);
192 void if_up_via_zapi(struct interface
*ifp
)
194 if (ifp_master
.up_hook
)
195 (*ifp_master
.up_hook
)(ifp
);
198 void if_down_via_zapi(struct interface
*ifp
)
200 if (ifp_master
.down_hook
)
201 (*ifp_master
.down_hook
)(ifp
);
204 struct interface
*if_create(const char *name
, vrf_id_t vrf_id
)
206 return if_create_backend(name
, IFINDEX_INTERNAL
, vrf_id
);
209 struct interface
*if_create_ifindex(ifindex_t ifindex
, vrf_id_t vrf_id
)
211 return if_create_backend(NULL
, ifindex
, vrf_id
);
214 /* Create new interface structure. */
215 void if_update_to_new_vrf(struct interface
*ifp
, vrf_id_t vrf_id
)
217 struct vrf
*old_vrf
, *vrf
;
219 /* remove interface from old master vrf list */
220 old_vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
222 IFNAME_RB_REMOVE(old_vrf
, ifp
);
223 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
224 IFINDEX_RB_REMOVE(old_vrf
, ifp
);
227 ifp
->vrf_id
= vrf_id
;
228 vrf
= vrf_get(ifp
->vrf_id
, NULL
);
230 IFNAME_RB_INSERT(vrf
, ifp
);
231 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
232 IFINDEX_RB_INSERT(vrf
, ifp
);
235 * HACK: Change the interface VRF in the running configuration directly,
236 * bypassing the northbound layer. This is necessary to avoid deleting
237 * the interface and readding it in the new VRF, which would have
238 * several implications.
240 if (yang_module_find("frr-interface")) {
241 struct lyd_node
*if_dnode
;
243 if_dnode
= yang_dnode_get(
244 running_config
->dnode
,
245 "/frr-interface:lib/interface[name='%s'][vrf='%s']/vrf",
246 ifp
->name
, old_vrf
->name
);
248 yang_dnode_change_leaf(if_dnode
, vrf
->name
);
249 running_config
->version
++;
255 /* Delete interface structure. */
256 void if_delete_retain(struct interface
*ifp
)
258 hook_call(if_del
, ifp
);
261 /* Free connected address list */
262 list_delete_all_node(ifp
->connected
);
264 /* Free connected nbr address list */
265 list_delete_all_node(ifp
->nbr_connected
);
268 /* Delete and free interface structure. */
269 void if_delete(struct interface
*ifp
)
273 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
276 IFNAME_RB_REMOVE(vrf
, ifp
);
277 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
278 IFINDEX_RB_REMOVE(vrf
, ifp
);
280 if_delete_retain(ifp
);
282 list_delete(&ifp
->connected
);
283 list_delete(&ifp
->nbr_connected
);
285 if_link_params_free(ifp
);
287 XFREE(MTYPE_TMP
, ifp
->desc
);
289 XFREE(MTYPE_IF
, ifp
);
292 /* Used only internally to check within VRF only */
293 static struct interface
*if_lookup_by_ifindex(ifindex_t ifindex
,
297 struct interface if_tmp
;
299 vrf
= vrf_lookup_by_id(vrf_id
);
303 if_tmp
.ifindex
= ifindex
;
304 return RB_FIND(if_index_head
, &vrf
->ifaces_by_index
, &if_tmp
);
307 /* Interface existance check by index. */
308 struct interface
*if_lookup_by_index(ifindex_t ifindex
, vrf_id_t vrf_id
)
310 switch (vrf_get_backend()) {
311 case VRF_BACKEND_UNKNOWN
:
312 case VRF_BACKEND_NETNS
:
313 return(if_lookup_by_ifindex(ifindex
, vrf_id
));
314 case VRF_BACKEND_VRF_LITE
:
315 return(if_lookup_by_index_all_vrf(ifindex
));
320 const char *ifindex2ifname(ifindex_t ifindex
, vrf_id_t vrf_id
)
322 struct interface
*ifp
;
324 return ((ifp
= if_lookup_by_index(ifindex
, vrf_id
)) != NULL
)
329 ifindex_t
ifname2ifindex(const char *name
, vrf_id_t vrf_id
)
331 struct interface
*ifp
;
333 return ((ifp
= if_lookup_by_name(name
, vrf_id
)) != NULL
)
338 /* Interface existance check by interface name. */
339 struct interface
*if_lookup_by_name(const char *name
, vrf_id_t vrf_id
)
341 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
342 struct interface if_tmp
;
345 || strnlen(name
, INTERFACE_NAMSIZ
) == INTERFACE_NAMSIZ
)
348 strlcpy(if_tmp
.name
, name
, sizeof(if_tmp
.name
));
349 return RB_FIND(if_name_head
, &vrf
->ifaces_by_name
, &if_tmp
);
352 struct interface
*if_lookup_by_name_all_vrf(const char *name
)
355 struct interface
*ifp
;
357 if (!name
|| strnlen(name
, INTERFACE_NAMSIZ
) == INTERFACE_NAMSIZ
)
360 RB_FOREACH (vrf
, vrf_id_head
, &vrfs_by_id
) {
361 ifp
= if_lookup_by_name(name
, vrf
->vrf_id
);
369 struct interface
*if_lookup_by_index_all_vrf(ifindex_t ifindex
)
372 struct interface
*ifp
;
374 if (ifindex
== IFINDEX_INTERNAL
)
377 RB_FOREACH (vrf
, vrf_id_head
, &vrfs_by_id
) {
378 ifp
= if_lookup_by_ifindex(ifindex
, vrf
->vrf_id
);
386 /* Lookup interface by IP address. */
387 struct interface
*if_lookup_exact_address(void *src
, int family
,
390 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
391 struct listnode
*cnode
;
392 struct interface
*ifp
;
396 FOR_ALL_INTERFACES (vrf
, ifp
) {
397 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, c
)) {
400 if (p
&& (p
->family
== family
)) {
401 if (family
== AF_INET
) {
404 (struct in_addr
*)src
))
406 } else if (family
== AF_INET6
) {
409 (struct in6_addr
*)src
))
418 /* Lookup interface by IP address. */
419 struct connected
*if_lookup_address(void *matchaddr
, int family
,
422 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
425 struct listnode
*cnode
;
426 struct interface
*ifp
;
428 struct connected
*match
;
430 if (family
== AF_INET
) {
431 addr
.family
= AF_INET
;
432 addr
.u
.prefix4
= *((struct in_addr
*)matchaddr
);
433 addr
.prefixlen
= IPV4_MAX_BITLEN
;
434 } else if (family
== AF_INET6
) {
435 addr
.family
= AF_INET6
;
436 addr
.u
.prefix6
= *((struct in6_addr
*)matchaddr
);
437 addr
.prefixlen
= IPV6_MAX_BITLEN
;
442 FOR_ALL_INTERFACES (vrf
, ifp
) {
443 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, c
)) {
444 if (c
->address
&& (c
->address
->family
== AF_INET
)
445 && prefix_match(CONNECTED_PREFIX(c
), &addr
)
446 && (c
->address
->prefixlen
> bestlen
)) {
447 bestlen
= c
->address
->prefixlen
;
455 /* Lookup interface by prefix */
456 struct interface
*if_lookup_prefix(struct prefix
*prefix
, vrf_id_t vrf_id
)
458 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
459 struct listnode
*cnode
;
460 struct interface
*ifp
;
463 FOR_ALL_INTERFACES (vrf
, ifp
) {
464 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, c
)) {
465 if (prefix_cmp(c
->address
, prefix
) == 0) {
473 size_t if_lookup_by_hwaddr(const uint8_t *hw_addr
, size_t addrsz
,
474 struct interface
***result
, vrf_id_t vrf_id
)
476 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
478 struct list
*rs
= list_new();
479 struct interface
*ifp
;
481 FOR_ALL_INTERFACES (vrf
, ifp
) {
482 if (ifp
->hw_addr_len
== (int)addrsz
483 && !memcmp(hw_addr
, ifp
->hw_addr
, addrsz
))
484 listnode_add(rs
, ifp
);
488 *result
= XCALLOC(MTYPE_TMP
,
489 sizeof(struct interface
*) * rs
->count
);
490 list_to_array(rs
, (void **)*result
, rs
->count
);
493 int count
= rs
->count
;
501 /* Get interface by name if given name interface doesn't exist create
503 struct interface
*if_get_by_name(const char *name
, vrf_id_t vrf_id
)
505 struct interface
*ifp
;
507 switch (vrf_get_backend()) {
508 case VRF_BACKEND_UNKNOWN
:
509 case VRF_BACKEND_NETNS
:
510 ifp
= if_lookup_by_name(name
, vrf_id
);
513 return if_create(name
, vrf_id
);
514 case VRF_BACKEND_VRF_LITE
:
515 ifp
= if_lookup_by_name_all_vrf(name
);
517 if (ifp
->vrf_id
== vrf_id
)
519 /* If it came from the kernel or by way of zclient,
520 * believe it and update the ifp accordingly.
522 if_update_to_new_vrf(ifp
, vrf_id
);
525 return if_create(name
, vrf_id
);
531 struct interface
*if_get_by_ifindex(ifindex_t ifindex
, vrf_id_t vrf_id
)
533 struct interface
*ifp
;
535 switch (vrf_get_backend()) {
536 case VRF_BACKEND_UNKNOWN
:
537 case VRF_BACKEND_NETNS
:
538 ifp
= if_lookup_by_ifindex(ifindex
, vrf_id
);
541 return if_create_ifindex(ifindex
, vrf_id
);
542 case VRF_BACKEND_VRF_LITE
:
543 ifp
= if_lookup_by_index_all_vrf(ifindex
);
545 if (ifp
->vrf_id
== vrf_id
)
547 /* If it came from the kernel or by way of zclient,
548 * believe it and update the ifp accordingly.
550 if_update_to_new_vrf(ifp
, vrf_id
);
553 return if_create_ifindex(ifindex
, vrf_id
);
559 void if_set_index(struct interface
*ifp
, ifindex_t ifindex
)
563 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
566 if (ifp
->ifindex
== ifindex
)
569 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
570 IFINDEX_RB_REMOVE(vrf
, ifp
)
572 ifp
->ifindex
= ifindex
;
574 if (ifp
->ifindex
!= IFINDEX_INTERNAL
)
575 IFINDEX_RB_INSERT(vrf
, ifp
)
578 /* Does interface up ? */
579 int if_is_up(const struct interface
*ifp
)
581 return ifp
->flags
& IFF_UP
;
584 /* Is interface running? */
585 int if_is_running(const struct interface
*ifp
)
587 return ifp
->flags
& IFF_RUNNING
;
590 /* Is the interface operative, eg. either UP & RUNNING
591 or UP & !ZEBRA_INTERFACE_LINK_DETECTION and
592 if ptm checking is enabled, then ptm check has passed */
593 int if_is_operative(const struct interface
*ifp
)
595 return ((ifp
->flags
& IFF_UP
)
596 && (((ifp
->flags
& IFF_RUNNING
)
597 && (ifp
->ptm_status
|| !ifp
->ptm_enable
))
598 || !CHECK_FLAG(ifp
->status
,
599 ZEBRA_INTERFACE_LINKDETECTION
)));
602 /* Is the interface operative, eg. either UP & RUNNING
603 or UP & !ZEBRA_INTERFACE_LINK_DETECTION, without PTM check */
604 int if_is_no_ptm_operative(const struct interface
*ifp
)
606 return ((ifp
->flags
& IFF_UP
)
607 && ((ifp
->flags
& IFF_RUNNING
)
608 || !CHECK_FLAG(ifp
->status
,
609 ZEBRA_INTERFACE_LINKDETECTION
)));
612 /* Is this loopback interface ? */
613 int if_is_loopback(const struct interface
*ifp
)
615 /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M
616 * but Y on platform N?
618 return (ifp
->flags
& (IFF_LOOPBACK
| IFF_NOXMIT
| IFF_VIRTUAL
));
621 /* Check interface is VRF */
622 int if_is_vrf(const struct interface
*ifp
)
624 return CHECK_FLAG(ifp
->status
, ZEBRA_INTERFACE_VRF_LOOPBACK
);
627 bool if_is_loopback_or_vrf(const struct interface
*ifp
)
629 if (if_is_loopback(ifp
) || if_is_vrf(ifp
))
635 /* Does this interface support broadcast ? */
636 int if_is_broadcast(const struct interface
*ifp
)
638 return ifp
->flags
& IFF_BROADCAST
;
641 /* Does this interface support broadcast ? */
642 int if_is_pointopoint(const struct interface
*ifp
)
644 return ifp
->flags
& IFF_POINTOPOINT
;
647 /* Does this interface support multicast ? */
648 int if_is_multicast(const struct interface
*ifp
)
650 return ifp
->flags
& IFF_MULTICAST
;
653 /* Printout flag information into log */
654 const char *if_flag_dump(unsigned long flag
)
657 static char logbuf
[BUFSIZ
];
659 #define IFF_OUT_LOG(X, STR) \
662 strlcat(logbuf, ",", sizeof(logbuf)); \
665 strlcat(logbuf, STR, sizeof(logbuf)); \
668 strlcpy(logbuf
, "<", BUFSIZ
);
669 IFF_OUT_LOG(IFF_UP
, "UP");
670 IFF_OUT_LOG(IFF_BROADCAST
, "BROADCAST");
671 IFF_OUT_LOG(IFF_DEBUG
, "DEBUG");
672 IFF_OUT_LOG(IFF_LOOPBACK
, "LOOPBACK");
673 IFF_OUT_LOG(IFF_POINTOPOINT
, "POINTOPOINT");
674 IFF_OUT_LOG(IFF_NOTRAILERS
, "NOTRAILERS");
675 IFF_OUT_LOG(IFF_RUNNING
, "RUNNING");
676 IFF_OUT_LOG(IFF_NOARP
, "NOARP");
677 IFF_OUT_LOG(IFF_PROMISC
, "PROMISC");
678 IFF_OUT_LOG(IFF_ALLMULTI
, "ALLMULTI");
679 IFF_OUT_LOG(IFF_OACTIVE
, "OACTIVE");
680 IFF_OUT_LOG(IFF_SIMPLEX
, "SIMPLEX");
681 IFF_OUT_LOG(IFF_LINK0
, "LINK0");
682 IFF_OUT_LOG(IFF_LINK1
, "LINK1");
683 IFF_OUT_LOG(IFF_LINK2
, "LINK2");
684 IFF_OUT_LOG(IFF_MULTICAST
, "MULTICAST");
685 IFF_OUT_LOG(IFF_NOXMIT
, "NOXMIT");
686 IFF_OUT_LOG(IFF_NORTEXCH
, "NORTEXCH");
687 IFF_OUT_LOG(IFF_VIRTUAL
, "VIRTUAL");
688 IFF_OUT_LOG(IFF_IPV4
, "IPv4");
689 IFF_OUT_LOG(IFF_IPV6
, "IPv6");
691 strlcat(logbuf
, ">", sizeof(logbuf
));
698 static void if_dump(const struct interface
*ifp
)
700 struct listnode
*node
;
701 struct connected
*c
__attribute__((unused
));
703 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, node
, c
))
705 "Interface %s vrf %u index %d metric %d mtu %d "
707 ifp
->name
, ifp
->vrf_id
, ifp
->ifindex
, ifp
->metric
,
708 ifp
->mtu
, ifp
->mtu6
, if_flag_dump(ifp
->flags
));
711 /* Interface printing for all interface. */
712 void if_dump_all(void)
717 RB_FOREACH (vrf
, vrf_id_head
, &vrfs_by_id
)
718 FOR_ALL_INTERFACES (vrf
, ifp
)
723 /* Need to handle upgrade from SUNWzebra to Quagga. SUNWzebra created
724 * a seperate struct interface for each logical interface, so config
725 * file may be full of 'interface fooX:Y'. Solaris however does not
726 * expose logical interfaces via PF_ROUTE, so trying to track logical
727 * interfaces can be fruitless, for that reason Quagga only tracks
728 * the primary IP interface.
730 * We try accomodate SUNWzebra by:
731 * - looking up the interface name, to see whether it exists, if so
733 * - for protocol daemons, this could only because zebra told us of
735 * - for zebra, only because it learnt from kernel
737 * - search the name to see if it contains a sub-ipif / logical interface
738 * seperator, the ':' char. If it does:
739 * - text up to that char must be the primary name - get that name.
741 * - no idea, just get the name in its entirety.
743 static struct interface
*if_sunwzebra_get(const char *name
, vrf_id_t vrf_id
)
745 struct interface
*ifp
;
748 if ((ifp
= if_lookup_by_name(name
, vrf_id
)) != NULL
)
751 /* hunt the primary interface name... */
752 cp
= strchr(name
, ':');
756 return if_get_by_name(name
, vrf_id
);
761 /* For debug purpose. */
764 "show address [vrf NAME]",
770 struct listnode
*node
;
771 struct interface
*ifp
;
772 struct connected
*ifc
;
774 vrf_id_t vrf_id
= VRF_DEFAULT
;
777 VRF_GET_ID (vrf_id
, argv
[idx_vrf
]->arg
);
779 FOR_ALL_INTERFACES (vrf
, ifp
)
781 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, node
, ifc
))
785 if (p
->family
== AF_INET
)
786 vty_out (vty
, "%s/%d\n", inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
792 DEFUN (show_address_vrf_all
,
793 show_address_vrf_all_cmd
,
794 "show address vrf all",
797 VRF_ALL_CMD_HELP_STR
)
800 struct listnode
*node
;
801 struct interface
*ifp
;
802 struct connected
*ifc
;
805 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
)
807 if (RB_EMPTY (if_name_head
, &vrf
->ifaces_by_name
))
810 vty_out (vty
, "\nVRF %u\n\n", vrf
->vrf_id
);
812 FOR_ALL_INTERFACES (vrf
, ifp
)
814 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, node
, ifc
))
818 if (p
->family
== AF_INET
)
819 vty_out (vty
, "%s/%d\n", inet_ntoa (p
->u
.prefix4
), p
->prefixlen
);
827 /* Allocate connected structure. */
828 struct connected
*connected_new(void)
830 return XCALLOC(MTYPE_CONNECTED
, sizeof(struct connected
));
833 /* Allocate nbr connected structure. */
834 struct nbr_connected
*nbr_connected_new(void)
836 return XCALLOC(MTYPE_NBR_CONNECTED
, sizeof(struct nbr_connected
));
839 /* Free connected structure. */
840 void connected_free(struct connected
*connected
)
842 if (connected
->address
)
843 prefix_free(connected
->address
);
845 if (connected
->destination
)
846 prefix_free(connected
->destination
);
848 XFREE(MTYPE_CONNECTED_LABEL
, connected
->label
);
850 XFREE(MTYPE_CONNECTED
, connected
);
853 /* Free nbr connected structure. */
854 void nbr_connected_free(struct nbr_connected
*connected
)
856 if (connected
->address
)
857 prefix_free(connected
->address
);
859 XFREE(MTYPE_NBR_CONNECTED
, connected
);
862 /* If same interface nbr address already exists... */
863 struct nbr_connected
*nbr_connected_check(struct interface
*ifp
,
866 struct nbr_connected
*ifc
;
867 struct listnode
*node
;
869 for (ALL_LIST_ELEMENTS_RO(ifp
->nbr_connected
, node
, ifc
))
870 if (prefix_same(ifc
->address
, p
))
876 /* Print if_addr structure. */
877 static void __attribute__((unused
))
878 connected_log(struct connected
*connected
, char *str
)
881 struct interface
*ifp
;
885 ifp
= connected
->ifp
;
886 p
= connected
->address
;
888 snprintf(logbuf
, BUFSIZ
, "%s interface %s vrf %u %s %s/%d ", str
,
889 ifp
->name
, ifp
->vrf_id
, prefix_family_str(p
),
890 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
892 p
= connected
->destination
;
894 strncat(logbuf
, inet_ntop(p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
895 BUFSIZ
- strlen(logbuf
));
897 zlog_info("%s", logbuf
);
900 /* Print if_addr structure. */
901 static void __attribute__((unused
))
902 nbr_connected_log(struct nbr_connected
*connected
, char *str
)
905 struct interface
*ifp
;
909 ifp
= connected
->ifp
;
910 p
= connected
->address
;
912 snprintf(logbuf
, BUFSIZ
, "%s interface %s %s %s/%d ", str
, ifp
->name
,
913 prefix_family_str(p
),
914 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
916 zlog_info("%s", logbuf
);
919 /* If two connected address has same prefix return 1. */
920 static int connected_same_prefix(struct prefix
*p1
, struct prefix
*p2
)
922 if (p1
->family
== p2
->family
) {
923 if (p1
->family
== AF_INET
924 && IPV4_ADDR_SAME(&p1
->u
.prefix4
, &p2
->u
.prefix4
))
926 if (p1
->family
== AF_INET6
927 && IPV6_ADDR_SAME(&p1
->u
.prefix6
, &p2
->u
.prefix6
))
933 struct connected
*connected_lookup_prefix_exact(struct interface
*ifp
,
936 struct listnode
*node
;
937 struct listnode
*next
;
938 struct connected
*ifc
;
940 for (node
= listhead(ifp
->connected
); node
; node
= next
) {
941 ifc
= listgetdata(node
);
944 if (connected_same_prefix(ifc
->address
, p
))
950 struct connected
*connected_delete_by_prefix(struct interface
*ifp
,
953 struct listnode
*node
;
954 struct listnode
*next
;
955 struct connected
*ifc
;
957 /* In case of same prefix come, replace it with new one. */
958 for (node
= listhead(ifp
->connected
); node
; node
= next
) {
959 ifc
= listgetdata(node
);
962 if (connected_same_prefix(ifc
->address
, p
)) {
963 listnode_delete(ifp
->connected
, ifc
);
970 /* Find the address on our side that will be used when packets
972 struct connected
*connected_lookup_prefix(struct interface
*ifp
,
975 struct listnode
*cnode
;
977 struct connected
*match
;
981 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, cnode
, c
)) {
982 if (c
->address
&& (c
->address
->family
== addr
->family
)
983 && prefix_match(CONNECTED_PREFIX(c
), addr
)
985 || (c
->address
->prefixlen
> match
->address
->prefixlen
)))
991 struct connected
*connected_add_by_prefix(struct interface
*ifp
,
993 struct prefix
*destination
)
995 struct connected
*ifc
;
997 /* Allocate new connected address. */
998 ifc
= connected_new();
1001 /* Fetch interface address */
1002 ifc
->address
= prefix_new();
1003 memcpy(ifc
->address
, p
, sizeof(struct prefix
));
1005 /* Fetch dest address */
1007 ifc
->destination
= prefix_new();
1008 memcpy(ifc
->destination
, destination
, sizeof(struct prefix
));
1011 /* Add connected address to the interface. */
1012 listnode_add(ifp
->connected
, ifc
);
1016 struct connected
*connected_get_linklocal(struct interface
*ifp
)
1019 struct connected
*c
= NULL
;
1021 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, n
, c
)) {
1022 if (c
->address
->family
== AF_INET6
1023 && IN6_IS_ADDR_LINKLOCAL(&c
->address
->u
.prefix6
))
1029 #if 0 /* this route_table of struct connected's is unused \
1030 * however, it would be good to use a route_table rather than \
1033 /* Interface looking up by interface's address. */
1034 /* Interface's IPv4 address reverse lookup table. */
1035 struct route_table
*ifaddr_ipv4_table
;
1036 /* struct route_table *ifaddr_ipv6_table; */
1039 ifaddr_ipv4_add (struct in_addr
*ifaddr
, struct interface
*ifp
)
1041 struct route_node
*rn
;
1042 struct prefix_ipv4 p
;
1045 p
.prefixlen
= IPV4_MAX_PREFIXLEN
;
1048 rn
= route_node_get (ifaddr_ipv4_table
, (struct prefix
*) &p
);
1051 route_unlock_node (rn
);
1052 zlog_info ("ifaddr_ipv4_add(): address %s is already added",
1053 inet_ntoa (*ifaddr
));
1060 ifaddr_ipv4_delete (struct in_addr
*ifaddr
, struct interface
*ifp
)
1062 struct route_node
*rn
;
1063 struct prefix_ipv4 p
;
1066 p
.prefixlen
= IPV4_MAX_PREFIXLEN
;
1069 rn
= route_node_lookup (ifaddr_ipv4_table
, (struct prefix
*) &p
);
1072 zlog_info ("ifaddr_ipv4_delete(): can't find address %s",
1073 inet_ntoa (*ifaddr
));
1077 route_unlock_node (rn
);
1078 route_unlock_node (rn
);
1081 /* Lookup interface by interface's IP address or interface index. */
1082 static struct interface
*
1083 ifaddr_ipv4_lookup (struct in_addr
*addr
, ifindex_t ifindex
)
1085 struct prefix_ipv4 p
;
1086 struct route_node
*rn
;
1087 struct interface
*ifp
;
1092 p
.prefixlen
= IPV4_MAX_PREFIXLEN
;
1095 rn
= route_node_lookup (ifaddr_ipv4_table
, (struct prefix
*) &p
);
1100 route_unlock_node (rn
);
1104 return if_lookup_by_index(ifindex
, VRF_DEFAULT
);
1106 #endif /* ifaddr_ipv4_table */
1108 void if_terminate(struct vrf
*vrf
)
1110 struct interface
*ifp
;
1112 while (!RB_EMPTY(if_name_head
, &vrf
->ifaces_by_name
)) {
1113 ifp
= RB_ROOT(if_name_head
, &vrf
->ifaces_by_name
);
1116 ifp
->node
->info
= NULL
;
1117 route_unlock_node(ifp
->node
);
1123 const char *if_link_type_str(enum zebra_link_type llt
)
1126 #define llts(T,S) case (T): return (S)
1127 llts(ZEBRA_LLT_UNKNOWN
, "Unknown");
1128 llts(ZEBRA_LLT_ETHER
, "Ethernet");
1129 llts(ZEBRA_LLT_EETHER
, "Experimental Ethernet");
1130 llts(ZEBRA_LLT_AX25
, "AX.25 Level 2");
1131 llts(ZEBRA_LLT_PRONET
, "PROnet token ring");
1132 llts(ZEBRA_LLT_IEEE802
, "IEEE 802.2 Ethernet/TR/TB");
1133 llts(ZEBRA_LLT_ARCNET
, "ARCnet");
1134 llts(ZEBRA_LLT_APPLETLK
, "AppleTalk");
1135 llts(ZEBRA_LLT_DLCI
, "Frame Relay DLCI");
1136 llts(ZEBRA_LLT_ATM
, "ATM");
1137 llts(ZEBRA_LLT_METRICOM
, "Metricom STRIP");
1138 llts(ZEBRA_LLT_IEEE1394
, "IEEE 1394 IPv4");
1139 llts(ZEBRA_LLT_EUI64
, "EUI-64");
1140 llts(ZEBRA_LLT_INFINIBAND
, "InfiniBand");
1141 llts(ZEBRA_LLT_SLIP
, "SLIP");
1142 llts(ZEBRA_LLT_CSLIP
, "Compressed SLIP");
1143 llts(ZEBRA_LLT_SLIP6
, "SLIPv6");
1144 llts(ZEBRA_LLT_CSLIP6
, "Compressed SLIPv6");
1145 llts(ZEBRA_LLT_ROSE
, "ROSE packet radio");
1146 llts(ZEBRA_LLT_X25
, "CCITT X.25");
1147 llts(ZEBRA_LLT_PPP
, "PPP");
1148 llts(ZEBRA_LLT_CHDLC
, "Cisco HDLC");
1149 llts(ZEBRA_LLT_RAWHDLC
, "Raw HDLC");
1150 llts(ZEBRA_LLT_LAPB
, "LAPB");
1151 llts(ZEBRA_LLT_IPIP
, "IPIP Tunnel");
1152 llts(ZEBRA_LLT_IPIP6
, "IPIP6 Tunnel");
1153 llts(ZEBRA_LLT_FRAD
, "FRAD");
1154 llts(ZEBRA_LLT_SKIP
, "SKIP vif");
1155 llts(ZEBRA_LLT_LOOPBACK
, "Loopback");
1156 llts(ZEBRA_LLT_LOCALTLK
, "Localtalk");
1157 llts(ZEBRA_LLT_FDDI
, "FDDI");
1158 llts(ZEBRA_LLT_SIT
, "IPv6-in-IPv4 SIT");
1159 llts(ZEBRA_LLT_IPDDP
, "IP-in-DDP tunnel");
1160 llts(ZEBRA_LLT_IPGRE
, "GRE over IP");
1161 llts(ZEBRA_LLT_PIMREG
, "PIMSM registration");
1162 llts(ZEBRA_LLT_HIPPI
, "HiPPI");
1163 llts(ZEBRA_LLT_IRDA
, "IrDA");
1164 llts(ZEBRA_LLT_FCPP
, "Fibre-Channel PtP");
1165 llts(ZEBRA_LLT_FCAL
, "Fibre-Channel Arbitrated Loop");
1166 llts(ZEBRA_LLT_FCPL
, "Fibre-Channel Public Loop");
1167 llts(ZEBRA_LLT_FCFABRIC
, "Fibre-Channel Fabric");
1168 llts(ZEBRA_LLT_IEEE802_TR
, "IEEE 802.2 Token Ring");
1169 llts(ZEBRA_LLT_IEEE80211
, "IEEE 802.11");
1170 llts(ZEBRA_LLT_IEEE80211_RADIOTAP
, "IEEE 802.11 Radiotap");
1171 llts(ZEBRA_LLT_IEEE802154
, "IEEE 802.15.4");
1172 llts(ZEBRA_LLT_IEEE802154_PHY
, "IEEE 802.15.4 Phy");
1174 flog_err(EC_LIB_DEVELOPMENT
, "Unknown value %d", llt
);
1175 return "Unknown type!";
1181 struct if_link_params
*if_link_params_get(struct interface
*ifp
)
1185 if (ifp
->link_params
!= NULL
)
1186 return ifp
->link_params
;
1188 struct if_link_params
*iflp
=
1189 XCALLOC(MTYPE_IF_LINK_PARAMS
, sizeof(struct if_link_params
));
1193 /* Set TE metric equal to standard metric */
1194 iflp
->te_metric
= ifp
->metric
;
1196 /* Compute default bandwidth based on interface */
1198 ((ifp
->bandwidth
? ifp
->bandwidth
: DEFAULT_BANDWIDTH
)
1199 * TE_KILO_BIT
/ TE_BYTE
);
1201 /* Set Max, Reservable and Unreserved Bandwidth */
1202 iflp
->max_bw
= iflp
->default_bw
;
1203 iflp
->max_rsv_bw
= iflp
->default_bw
;
1204 for (i
= 0; i
< MAX_CLASS_TYPE
; i
++)
1205 iflp
->unrsv_bw
[i
] = iflp
->default_bw
;
1207 /* Update Link parameters status */
1209 LP_TE_METRIC
| LP_MAX_BW
| LP_MAX_RSV_BW
| LP_UNRSV_BW
;
1211 /* Finally attach newly created Link Parameters */
1212 ifp
->link_params
= iflp
;
1217 void if_link_params_free(struct interface
*ifp
)
1219 if (ifp
->link_params
== NULL
)
1221 XFREE(MTYPE_IF_LINK_PARAMS
, ifp
->link_params
);
1222 ifp
->link_params
= NULL
;
1225 /* ----------- CLI commands ----------- */
1228 * XPath: /frr-interface:lib/interface
1230 DEFPY_NOSH (interface
,
1232 "interface IFNAME [vrf NAME$vrfname]",
1233 "Select an interface to configure\n"
1234 "Interface's name\n"
1237 char xpath_list
[XPATH_MAXLEN
];
1239 struct interface
*ifp
;
1243 vrfname
= VRF_DEFAULT_NAME
;
1246 * This command requires special handling to maintain backward
1247 * compatibility. If a VRF name is not specified, it means we're willing
1248 * to accept any interface with the given name on any VRF. If no
1249 * interface is found, then a new one should be created on the default
1252 VRF_GET_ID(vrf_id
, vrfname
, false);
1253 ifp
= if_lookup_by_name_all_vrf(ifname
);
1254 if (ifp
&& ifp
->vrf_id
!= vrf_id
) {
1258 * Special case 1: a VRF name was specified, but the found
1259 * interface is associated to different VRF. Reject the command.
1261 if (vrf_id
!= VRF_DEFAULT
) {
1262 vty_out(vty
, "%% interface %s not in %s vrf\n", ifname
,
1264 return CMD_WARNING_CONFIG_FAILED
;
1268 * Special case 2: a VRF name was *not* specified, and the found
1269 * interface is associated to a VRF other than the default one.
1270 * Update vrf_id and vrfname to account for that.
1272 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
1274 vrf_id
= ifp
->vrf_id
;
1275 vrfname
= vrf
->name
;
1278 snprintf(xpath_list
, sizeof(xpath_list
),
1279 "/frr-interface:lib/interface[name='%s'][vrf='%s']", ifname
,
1282 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1283 ret
= nb_cli_apply_changes(vty
, xpath_list
);
1284 if (ret
== CMD_SUCCESS
) {
1285 VTY_PUSH_XPATH(INTERFACE_NODE
, xpath_list
);
1288 * For backward compatibility with old commands we still need
1289 * to use the qobj infrastructure. This can be removed once
1290 * all interface-level commands are converted to the new
1293 ifp
= if_lookup_by_name(ifname
, vrf_id
);
1295 VTY_PUSH_CONTEXT(INTERFACE_NODE
, ifp
);
1301 DEFPY (no_interface
,
1303 "no interface IFNAME [vrf NAME$vrfname]",
1305 "Delete a pseudo interface's configuration\n"
1306 "Interface's name\n"
1310 vrfname
= VRF_DEFAULT_NAME
;
1312 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1314 return nb_cli_apply_changes(
1315 vty
, "/frr-interface:lib/interface[name='%s'][vrf='%s']",
1319 static void cli_show_interface(struct vty
*vty
, struct lyd_node
*dnode
,
1324 vrf
= yang_dnode_get_string(dnode
, "./vrf");
1326 vty_out(vty
, "!\n");
1327 vty_out(vty
, "interface %s", yang_dnode_get_string(dnode
, "./name"));
1328 if (!strmatch(vrf
, VRF_DEFAULT_NAME
))
1329 vty_out(vty
, " vrf %s", vrf
);
1334 * XPath: /frr-interface:lib/interface/description
1336 DEFPY (interface_desc
,
1338 "description LINE...",
1339 "Interface specific description\n"
1340 "Characters describing this interface\n")
1345 desc
= argv_concat(argv
, argc
, 1);
1346 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, desc
);
1347 ret
= nb_cli_apply_changes(vty
, NULL
);
1348 XFREE(MTYPE_TMP
, desc
);
1353 DEFPY (no_interface_desc
,
1354 no_interface_desc_cmd
,
1357 "Interface specific description\n")
1359 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
1361 return nb_cli_apply_changes(vty
, NULL
);
1364 static void cli_show_interface_desc(struct vty
*vty
, struct lyd_node
*dnode
,
1367 vty_out(vty
, " description %s\n", yang_dnode_get_string(dnode
, NULL
));
1370 /* Interface autocomplete. */
1371 static void if_autocomplete(vector comps
, struct cmd_token
*token
)
1373 struct interface
*ifp
;
1376 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
1377 FOR_ALL_INTERFACES (vrf
, ifp
) {
1378 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, ifp
->name
));
1383 static const struct cmd_variable_handler if_var_handlers
[] = {
1384 {/* "interface NAME" */
1385 .varname
= "interface",
1386 .completions
= if_autocomplete
},
1387 {.tokenname
= "IFNAME", .completions
= if_autocomplete
},
1388 {.tokenname
= "INTERFACE", .completions
= if_autocomplete
},
1389 {.completions
= NULL
}};
1391 void if_cmd_init(void)
1393 cmd_variable_handler_register(if_var_handlers
);
1395 install_element(CONFIG_NODE
, &interface_cmd
);
1396 install_element(CONFIG_NODE
, &no_interface_cmd
);
1398 install_default(INTERFACE_NODE
);
1399 install_element(INTERFACE_NODE
, &interface_desc_cmd
);
1400 install_element(INTERFACE_NODE
, &no_interface_desc_cmd
);
1403 void if_zapi_callbacks(int (*create
)(struct interface
*ifp
),
1404 int (*up
)(struct interface
*ifp
),
1405 int (*down
)(struct interface
*ifp
),
1406 int (*destroy
)(struct interface
*ifp
))
1408 ifp_master
.create_hook
= create
;
1409 ifp_master
.up_hook
= up
;
1410 ifp_master
.down_hook
= down
;
1411 ifp_master
.destroy_hook
= destroy
;
1414 /* ------- Northbound callbacks ------- */
1417 * XPath: /frr-interface:lib/interface
1419 static int lib_interface_create(enum nb_event event
,
1420 const struct lyd_node
*dnode
,
1421 union nb_resource
*resource
)
1424 const char *vrfname
;
1426 struct interface
*ifp
;
1428 ifname
= yang_dnode_get_string(dnode
, "./name");
1429 vrfname
= yang_dnode_get_string(dnode
, "./vrf");
1432 case NB_EV_VALIDATE
:
1433 vrf
= vrf_lookup_by_name(vrfname
);
1435 zlog_warn("%s: VRF %s doesn't exist", __func__
,
1437 return NB_ERR_VALIDATION
;
1439 if (vrf
->vrf_id
== VRF_UNKNOWN
) {
1440 zlog_warn("%s: VRF %s is not active", __func__
,
1442 return NB_ERR_VALIDATION
;
1445 /* if VRF is netns or not yet known - init for instance
1446 * then assumption is that passed config is exact
1447 * then the user intent was not to use an other iface
1449 if (vrf_get_backend() == VRF_BACKEND_VRF_LITE
) {
1450 ifp
= if_lookup_by_name_all_vrf(ifname
);
1451 if (ifp
&& ifp
->vrf_id
!= vrf
->vrf_id
) {
1453 "%s: interface %s already exists in another VRF",
1454 __func__
, ifp
->name
);
1455 return NB_ERR_VALIDATION
;
1463 vrf
= vrf_lookup_by_name(vrfname
);
1466 ifp
= if_sunwzebra_get(ifname
, vrf
->vrf_id
);
1468 ifp
= if_get_by_name(ifname
, vrf
->vrf_id
);
1469 #endif /* SUNOS_5 */
1471 ifp
->configured
= true;
1472 nb_running_set_entry(dnode
, ifp
);
1479 static int lib_interface_destroy(enum nb_event event
,
1480 const struct lyd_node
*dnode
)
1482 struct interface
*ifp
;
1486 case NB_EV_VALIDATE
:
1487 ifp
= nb_running_get_entry(dnode
, NULL
, true);
1488 if (CHECK_FLAG(ifp
->status
, ZEBRA_INTERFACE_ACTIVE
)) {
1489 zlog_warn("%s: only inactive interfaces can be deleted",
1491 return NB_ERR_VALIDATION
;
1498 ifp
= nb_running_unset_entry(dnode
);
1500 ifp
->configured
= false;
1509 * XPath: /frr-interface:lib/interface
1511 static const void *lib_interface_get_next(const void *parent_list_entry
,
1512 const void *list_entry
)
1515 struct interface
*pif
= (struct interface
*)list_entry
;
1517 if (list_entry
== NULL
) {
1518 vrf
= RB_MIN(vrf_name_head
, &vrfs_by_name
);
1520 pif
= RB_MIN(if_name_head
, &vrf
->ifaces_by_name
);
1522 vrf
= vrf_lookup_by_id(pif
->vrf_id
);
1523 pif
= RB_NEXT(if_name_head
, pif
);
1524 /* if no more interfaces, switch to next vrf */
1525 while (pif
== NULL
) {
1526 vrf
= RB_NEXT(vrf_name_head
, vrf
);
1529 pif
= RB_MIN(if_name_head
, &vrf
->ifaces_by_name
);
1536 static int lib_interface_get_keys(const void *list_entry
,
1537 struct yang_list_keys
*keys
)
1539 const struct interface
*ifp
= list_entry
;
1541 struct vrf
*vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
1546 strlcpy(keys
->key
[0], ifp
->name
, sizeof(keys
->key
[0]));
1547 strlcpy(keys
->key
[1], vrf
->name
, sizeof(keys
->key
[1]));
1552 static const void *lib_interface_lookup_entry(const void *parent_list_entry
,
1553 const struct yang_list_keys
*keys
)
1555 const char *ifname
= keys
->key
[0];
1556 const char *vrfname
= keys
->key
[1];
1557 struct vrf
*vrf
= vrf_lookup_by_name(vrfname
);
1559 return if_lookup_by_name(ifname
, vrf
->vrf_id
);
1563 * XPath: /frr-interface:lib/interface/description
1565 static int lib_interface_description_modify(enum nb_event event
,
1566 const struct lyd_node
*dnode
,
1567 union nb_resource
*resource
)
1569 struct interface
*ifp
;
1570 const char *description
;
1572 if (event
!= NB_EV_APPLY
)
1575 ifp
= nb_running_get_entry(dnode
, NULL
, true);
1576 XFREE(MTYPE_TMP
, ifp
->desc
);
1577 description
= yang_dnode_get_string(dnode
, NULL
);
1578 ifp
->desc
= XSTRDUP(MTYPE_TMP
, description
);
1583 static int lib_interface_description_destroy(enum nb_event event
,
1584 const struct lyd_node
*dnode
)
1586 struct interface
*ifp
;
1588 if (event
!= NB_EV_APPLY
)
1591 ifp
= nb_running_get_entry(dnode
, NULL
, true);
1592 XFREE(MTYPE_TMP
, ifp
->desc
);
1597 /* clang-format off */
1598 const struct frr_yang_module_info frr_interface_info
= {
1599 .name
= "frr-interface",
1602 .xpath
= "/frr-interface:lib/interface",
1604 .create
= lib_interface_create
,
1605 .destroy
= lib_interface_destroy
,
1606 .cli_show
= cli_show_interface
,
1607 .get_next
= lib_interface_get_next
,
1608 .get_keys
= lib_interface_get_keys
,
1609 .lookup_entry
= lib_interface_lookup_entry
,
1613 .xpath
= "/frr-interface:lib/interface/description",
1615 .modify
= lib_interface_description_modify
,
1616 .destroy
= lib_interface_description_destroy
,
1617 .cli_show
= cli_show_interface_desc
,