2 * Interface related function for RIPng.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
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
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
34 #include "agg_table.h"
38 #include "lib_errors.h"
39 #include "northbound_cli.h"
41 #include "ripngd/ripngd.h"
42 #include "ripngd/ripng_debug.h"
44 /* If RFC2133 definition is used. */
45 #ifndef IPV6_JOIN_GROUP
46 #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
48 #ifndef IPV6_LEAVE_GROUP
49 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
52 DEFINE_MTYPE_STATIC(RIPNGD
, RIPNG_IF
, "ripng interface")
54 /* Static utility function. */
55 static void ripng_enable_apply(struct interface
*);
56 static void ripng_passive_interface_apply(struct interface
*);
57 static int ripng_enable_if_lookup(struct ripng
*ripng
, const char *ifname
);
58 static int ripng_enable_network_lookup2(struct connected
*);
59 static void ripng_enable_apply_all(struct ripng
*ripng
);
61 /* Join to the all rip routers multicast group. */
62 static int ripng_multicast_join(struct interface
*ifp
, int sock
)
65 struct ipv6_mreq mreq
;
68 if (if_is_multicast(ifp
)) {
69 memset(&mreq
, 0, sizeof(mreq
));
70 inet_pton(AF_INET6
, RIPNG_GROUP
, &mreq
.ipv6mr_multiaddr
);
71 mreq
.ipv6mr_interface
= ifp
->ifindex
;
74 * NetBSD 1.6.2 requires root to join groups on gif(4).
75 * While this is bogus, privs are available and easy to use
76 * for this call as a workaround.
78 frr_elevate_privs(&ripngd_privs
) {
80 ret
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_JOIN_GROUP
,
81 (char *)&mreq
, sizeof(mreq
));
86 if (ret
< 0 && save_errno
== EADDRINUSE
) {
88 * Group is already joined. This occurs due to sloppy
90 * management, in particular declining to leave the
92 * an interface that has just gone down.
94 zlog_warn("ripng join on %s EADDRINUSE (ignoring)",
96 return 0; /* not an error */
100 zlog_warn("can't setsockopt IPV6_JOIN_GROUP: %s",
101 safe_strerror(save_errno
));
103 if (IS_RIPNG_DEBUG_EVENT
)
105 "RIPng %s join to all-rip-routers multicast group",
114 /* Leave from the all rip routers multicast group. */
115 static int ripng_multicast_leave(struct interface
*ifp
, int sock
)
118 struct ipv6_mreq mreq
;
120 if (if_is_multicast(ifp
)) {
121 memset(&mreq
, 0, sizeof(mreq
));
122 inet_pton(AF_INET6
, RIPNG_GROUP
, &mreq
.ipv6mr_multiaddr
);
123 mreq
.ipv6mr_interface
= ifp
->ifindex
;
125 ret
= setsockopt(sock
, IPPROTO_IPV6
, IPV6_LEAVE_GROUP
,
126 (char *)&mreq
, sizeof(mreq
));
128 zlog_warn("can't setsockopt IPV6_LEAVE_GROUP: %s",
129 safe_strerror(errno
));
131 if (IS_RIPNG_DEBUG_EVENT
)
133 "RIPng %s leave from all-rip-routers multicast group",
143 /* How many link local IPv6 address could be used on the interface ? */
144 static int ripng_if_ipv6_lladdress_check(struct interface
*ifp
)
147 struct connected
*connected
;
150 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, nn
, connected
)) {
152 p
= connected
->address
;
154 if ((p
->family
== AF_INET6
)
155 && IN6_IS_ADDR_LINKLOCAL(&p
->u
.prefix6
))
162 static int ripng_if_down(struct interface
*ifp
)
165 struct ripng_info
*rinfo
;
166 struct ripng_interface
*ri
;
168 struct list
*list
= NULL
;
169 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
175 for (rp
= agg_route_top(ripng
->table
); rp
;
176 rp
= agg_route_next(rp
))
177 if ((list
= rp
->info
) != NULL
)
178 for (ALL_LIST_ELEMENTS(list
, listnode
, nextnode
,
180 if (rinfo
->ifindex
== ifp
->ifindex
)
181 ripng_ecmp_delete(ripng
, rinfo
);
185 if (IS_RIPNG_DEBUG_EVENT
)
186 zlog_debug("turn off %s", ifp
->name
);
188 /* Leave from multicast group. */
190 ripng_multicast_leave(ifp
, ripng
->sock
);
198 /* Inteface link up message processing. */
199 int ripng_interface_up(ZAPI_CALLBACK_ARGS
)
202 struct interface
*ifp
;
204 /* zebra_interface_state_read() updates interface structure in iflist.
207 ifp
= zebra_interface_state_read(s
, vrf_id
);
212 if (IS_RIPNG_DEBUG_ZEBRA
)
214 "interface up %s vrf %u index %d flags %llx metric %d mtu %d",
215 ifp
->name
, ifp
->vrf
->vrf_id
, ifp
->ifindex
,
216 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
218 ripng_interface_sync(ifp
);
220 /* Check if this interface is RIPng enabled or not. */
221 ripng_enable_apply(ifp
);
223 /* Check for a passive interface. */
224 ripng_passive_interface_apply(ifp
);
226 /* Apply distribute list to the all interface. */
227 ripng_distribute_update_interface(ifp
);
232 /* Inteface link down message processing. */
233 int ripng_interface_down(ZAPI_CALLBACK_ARGS
)
236 struct interface
*ifp
;
238 /* zebra_interface_state_read() updates interface structure in iflist.
241 ifp
= zebra_interface_state_read(s
, vrf_id
);
246 ripng_interface_sync(ifp
);
249 if (IS_RIPNG_DEBUG_ZEBRA
)
251 "interface down %s vrf %u index %d flags %#llx metric %d mtu %d",
252 ifp
->name
, ifp
->vrf
->vrf_id
, ifp
->ifindex
,
253 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
258 /* Inteface addition message from zebra. */
259 int ripng_interface_add(ZAPI_CALLBACK_ARGS
)
261 struct interface
*ifp
;
263 ifp
= zebra_interface_add_read(zclient
->ibuf
, vrf_id
);
264 ripng_interface_sync(ifp
);
266 if (IS_RIPNG_DEBUG_ZEBRA
)
268 "RIPng interface add %s vrf %u index %d flags %#llx metric %d mtu %d",
269 ifp
->name
, ifp
->vrf
->vrf_id
, ifp
->ifindex
,
270 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
272 /* Check is this interface is RIP enabled or not.*/
273 ripng_enable_apply(ifp
);
275 /* Apply distribute list to the interface. */
276 ripng_distribute_update_interface(ifp
);
278 /* Check interface routemap. */
279 ripng_if_rmap_update_interface(ifp
);
284 int ripng_interface_delete(ZAPI_CALLBACK_ARGS
)
286 struct interface
*ifp
;
290 /* zebra_interface_state_read() updates interface structure in iflist
292 ifp
= zebra_interface_state_read(s
, vrf_id
);
297 ripng_interface_sync(ifp
);
303 "interface delete %s vrf %u index %d flags %#llx metric %d mtu %d",
304 ifp
->name
, ifp
->vrf
->vrf_id
, ifp
->ifindex
,
305 (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
307 /* To support pseudo interface do not free interface structure. */
308 /* if_delete(ifp); */
309 if_set_index(ifp
, IFINDEX_INTERNAL
);
314 /* VRF update for an interface. */
315 int ripng_interface_vrf_update(ZAPI_CALLBACK_ARGS
)
317 struct interface
*ifp
;
321 ifp
= zebra_interface_vrf_update_read(zclient
->ibuf
, vrf_id
,
326 new_vrf
= vrf_lookup_by_id(new_vrf_id
);
328 if (IS_RIPNG_DEBUG_ZEBRA
)
329 zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
330 ifp
->name
, vrf_id
, new_vrf_id
);
332 if_update_to_new_vrf(ifp
, new_vrf
);
334 ripng_interface_sync(ifp
);
339 void ripng_interface_clean(struct ripng
*ripng
)
341 struct interface
*ifp
;
342 struct ripng_interface
*ri
;
344 FOR_ALL_INTERFACES (ripng
->vrf
, ifp
) {
347 ri
->enable_network
= 0;
348 ri
->enable_interface
= 0;
352 thread_cancel(ri
->t_wakeup
);
358 static void ripng_apply_address_add(struct connected
*ifc
)
360 struct ripng_interface
*ri
= ifc
->ifp
->info
;
361 struct ripng
*ripng
= ri
->ripng
;
362 struct prefix_ipv6 address
;
368 if (!if_is_up(ifc
->ifp
))
373 memset(&address
, 0, sizeof(address
));
374 address
.family
= p
->family
;
375 address
.prefix
= p
->u
.prefix6
;
376 address
.prefixlen
= p
->prefixlen
;
377 apply_mask_ipv6(&address
);
379 /* Check if this interface is RIP enabled or not
380 or Check if this address's prefix is RIP enabled */
381 if ((ripng_enable_if_lookup(ripng
, ifc
->ifp
->name
) >= 0)
382 || (ripng_enable_network_lookup2(ifc
) >= 0))
383 ripng_redistribute_add(ripng
, ZEBRA_ROUTE_CONNECT
,
384 RIPNG_ROUTE_INTERFACE
, &address
,
385 ifc
->ifp
->ifindex
, NULL
, 0);
388 int ripng_interface_address_add(ZAPI_CALLBACK_ARGS
)
393 c
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD
,
394 zclient
->ibuf
, vrf_id
);
401 if (p
->family
== AF_INET6
) {
402 struct ripng_interface
*ri
= c
->ifp
->info
;
404 if (IS_RIPNG_DEBUG_ZEBRA
)
405 zlog_debug("RIPng connected address %s/%d add",
406 inet6_ntoa(p
->u
.prefix6
), p
->prefixlen
);
408 /* Check is this prefix needs to be redistributed. */
409 ripng_apply_address_add(c
);
411 /* Let's try once again whether the interface could be activated
414 /* Check if this interface is RIP enabled or not.*/
415 ripng_enable_apply(c
->ifp
);
417 /* Apply distribute list to the interface. */
418 ripng_distribute_update_interface(c
->ifp
);
420 /* Check interface routemap. */
421 ripng_if_rmap_update_interface(c
->ifp
);
428 static void ripng_apply_address_del(struct connected
*ifc
)
430 struct ripng_interface
*ri
= ifc
->ifp
->info
;
431 struct ripng
*ripng
= ri
->ripng
;
432 struct prefix_ipv6 address
;
438 if (!if_is_up(ifc
->ifp
))
443 memset(&address
, 0, sizeof(address
));
444 address
.family
= p
->family
;
445 address
.prefix
= p
->u
.prefix6
;
446 address
.prefixlen
= p
->prefixlen
;
447 apply_mask_ipv6(&address
);
449 ripng_redistribute_delete(ripng
, ZEBRA_ROUTE_CONNECT
,
450 RIPNG_ROUTE_INTERFACE
, &address
,
454 int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS
)
456 struct connected
*ifc
;
458 char buf
[INET6_ADDRSTRLEN
];
460 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE
,
461 zclient
->ibuf
, vrf_id
);
466 if (p
->family
== AF_INET6
) {
467 if (IS_RIPNG_DEBUG_ZEBRA
)
469 "RIPng connected address %s/%d delete",
470 inet_ntop(AF_INET6
, &p
->u
.prefix6
, buf
,
474 /* Check wether this prefix needs to be removed. */
475 ripng_apply_address_del(ifc
);
483 /* Lookup RIPng enable network. */
484 /* Check wether the interface has at least a connected prefix that
485 * is within the ripng->enable_network table. */
486 static int ripng_enable_network_lookup_if(struct interface
*ifp
)
488 struct ripng_interface
*ri
= ifp
->info
;
489 struct ripng
*ripng
= ri
->ripng
;
490 struct listnode
*node
;
491 struct connected
*connected
;
492 struct prefix_ipv6 address
;
497 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, node
, connected
)) {
501 p
= connected
->address
;
503 if (p
->family
== AF_INET6
) {
504 address
.family
= AF_INET6
;
505 address
.prefix
= p
->u
.prefix6
;
506 address
.prefixlen
= IPV6_MAX_BITLEN
;
508 n
= agg_node_match(ripng
->enable_network
,
509 (struct prefix
*)&address
);
519 /* Check wether connected is within the ripng->enable_network table. */
520 static int ripng_enable_network_lookup2(struct connected
*connected
)
522 struct ripng_interface
*ri
= connected
->ifp
->info
;
523 struct ripng
*ripng
= ri
->ripng
;
524 struct prefix_ipv6 address
;
530 p
= connected
->address
;
532 if (p
->family
== AF_INET6
) {
533 struct agg_node
*node
;
535 address
.family
= p
->family
;
536 address
.prefix
= p
->u
.prefix6
;
537 address
.prefixlen
= IPV6_MAX_BITLEN
;
539 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within
540 * ripng->enable_network */
541 node
= agg_node_match(ripng
->enable_network
,
542 (struct prefix
*)&address
);
545 agg_unlock_node(node
);
553 /* Add RIPng enable network. */
554 int ripng_enable_network_add(struct ripng
*ripng
, struct prefix
*p
)
556 struct agg_node
*node
;
558 node
= agg_node_get(ripng
->enable_network
, p
);
561 agg_unlock_node(node
);
562 return NB_ERR_INCONSISTENCY
;
564 node
->info
= (void *)1;
566 /* XXX: One should find a better solution than a generic one */
567 ripng_enable_apply_all(ripng
);
572 /* Delete RIPng enable network. */
573 int ripng_enable_network_delete(struct ripng
*ripng
, struct prefix
*p
)
575 struct agg_node
*node
;
577 node
= agg_node_lookup(ripng
->enable_network
, p
);
581 /* Unlock info lock. */
582 agg_unlock_node(node
);
584 /* Unlock lookup lock. */
585 agg_unlock_node(node
);
590 return NB_ERR_INCONSISTENCY
;
593 /* Lookup function. */
594 static int ripng_enable_if_lookup(struct ripng
*ripng
, const char *ifname
)
602 for (i
= 0; i
< vector_active(ripng
->enable_if
); i
++)
603 if ((str
= vector_slot(ripng
->enable_if
, i
)) != NULL
)
604 if (strcmp(str
, ifname
) == 0)
609 int ripng_enable_if_add(struct ripng
*ripng
, const char *ifname
)
613 ret
= ripng_enable_if_lookup(ripng
, ifname
);
615 return NB_ERR_INCONSISTENCY
;
617 vector_set(ripng
->enable_if
, strdup(ifname
));
619 ripng_enable_apply_all(ripng
);
624 int ripng_enable_if_delete(struct ripng
*ripng
, const char *ifname
)
629 index
= ripng_enable_if_lookup(ripng
, ifname
);
631 return NB_ERR_INCONSISTENCY
;
633 str
= vector_slot(ripng
->enable_if
, index
);
635 vector_unset(ripng
->enable_if
, index
);
637 ripng_enable_apply_all(ripng
);
642 /* Wake up interface. */
643 static int ripng_interface_wakeup(struct thread
*t
)
645 struct interface
*ifp
;
646 struct ripng_interface
*ri
;
654 /* Join to multicast group. */
655 if (ripng_multicast_join(ifp
, ri
->ripng
->sock
) < 0) {
656 flog_err_sys(EC_LIB_SOCKET
,
657 "multicast join failed, interface %s not running",
662 /* Set running flag. */
665 /* Send RIP request to the interface. */
671 static void ripng_connect_set(struct interface
*ifp
, int set
)
673 struct ripng_interface
*ri
= ifp
->info
;
674 struct ripng
*ripng
= ri
->ripng
;
675 struct listnode
*node
, *nnode
;
676 struct connected
*connected
;
677 struct prefix_ipv6 address
;
679 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
681 p
= connected
->address
;
683 if (p
->family
!= AF_INET6
)
686 address
.family
= AF_INET6
;
687 address
.prefix
= p
->u
.prefix6
;
688 address
.prefixlen
= p
->prefixlen
;
689 apply_mask_ipv6(&address
);
692 /* Check once more wether this prefix is within a
693 * "network IF_OR_PREF" one */
694 if ((ripng_enable_if_lookup(ripng
, connected
->ifp
->name
)
696 || (ripng_enable_network_lookup2(connected
) >= 0))
697 ripng_redistribute_add(
698 ripng
, ZEBRA_ROUTE_CONNECT
,
699 RIPNG_ROUTE_INTERFACE
, &address
,
700 connected
->ifp
->ifindex
, NULL
, 0);
702 ripng_redistribute_delete(ripng
, ZEBRA_ROUTE_CONNECT
,
703 RIPNG_ROUTE_INTERFACE
,
705 connected
->ifp
->ifindex
);
706 if (ripng_redistribute_check(ripng
,
707 ZEBRA_ROUTE_CONNECT
))
708 ripng_redistribute_add(
709 ripng
, ZEBRA_ROUTE_CONNECT
,
710 RIPNG_ROUTE_REDISTRIBUTE
, &address
,
711 connected
->ifp
->ifindex
, NULL
, 0);
716 /* Check RIPng is enabed on this interface. */
717 void ripng_enable_apply(struct interface
*ifp
)
720 struct ripng_interface
*ri
= NULL
;
722 /* Check interface. */
728 /* Is this interface a candidate for RIPng ? */
729 ret
= ripng_enable_network_lookup_if(ifp
);
731 /* If the interface is matched. */
733 ri
->enable_network
= 1;
735 ri
->enable_network
= 0;
737 /* Check interface name configuration. */
738 ret
= ripng_enable_if_lookup(ri
->ripng
, ifp
->name
);
740 ri
->enable_interface
= 1;
742 ri
->enable_interface
= 0;
744 /* any candidate interface MUST have a link-local IPv6 address */
745 if ((!ripng_if_ipv6_lladdress_check(ifp
))
746 && (ri
->enable_network
|| ri
->enable_interface
)) {
747 ri
->enable_network
= 0;
748 ri
->enable_interface
= 0;
749 zlog_warn("Interface %s does not have any link-local address",
753 /* Update running status of the interface. */
754 if (ri
->enable_network
|| ri
->enable_interface
) {
755 zlog_info("RIPng INTERFACE ON %s", ifp
->name
);
757 /* Add interface wake up thread. */
758 thread_add_timer(master
, ripng_interface_wakeup
, ifp
, 1,
761 ripng_connect_set(ifp
, 1);
764 /* Might as well clean up the route table as well
765 * ripng_if_down sets to 0 ri->running, and displays
770 ripng_connect_set(ifp
, 0);
775 /* Set distribute list to all interfaces. */
776 static void ripng_enable_apply_all(struct ripng
*ripng
)
778 struct interface
*ifp
;
780 FOR_ALL_INTERFACES (ripng
->vrf
, ifp
)
781 ripng_enable_apply(ifp
);
784 /* Clear all network and neighbor configuration */
785 void ripng_clean_network(struct ripng
*ripng
)
791 /* ripng->enable_network */
792 for (rn
= agg_route_top(ripng
->enable_network
); rn
;
793 rn
= agg_route_next(rn
))
799 /* ripng->enable_if */
800 for (i
= 0; i
< vector_active(ripng
->enable_if
); i
++)
801 if ((str
= vector_slot(ripng
->enable_if
, i
)) != NULL
) {
803 vector_slot(ripng
->enable_if
, i
) = NULL
;
807 /* Utility function for looking up passive interface settings. */
808 static int ripng_passive_interface_lookup(struct ripng
*ripng
,
814 for (i
= 0; i
< vector_active(ripng
->passive_interface
); i
++)
815 if ((str
= vector_slot(ripng
->passive_interface
, i
)) != NULL
)
816 if (strcmp(str
, ifname
) == 0)
821 void ripng_passive_interface_apply(struct interface
*ifp
)
824 struct ripng_interface
*ri
;
832 ret
= ripng_passive_interface_lookup(ripng
, ifp
->name
);
839 static void ripng_passive_interface_apply_all(struct ripng
*ripng
)
841 struct interface
*ifp
;
843 FOR_ALL_INTERFACES (ripng
->vrf
, ifp
)
844 ripng_passive_interface_apply(ifp
);
847 /* Passive interface. */
848 int ripng_passive_interface_set(struct ripng
*ripng
, const char *ifname
)
850 if (ripng_passive_interface_lookup(ripng
, ifname
) >= 0)
851 return NB_ERR_INCONSISTENCY
;
853 vector_set(ripng
->passive_interface
, strdup(ifname
));
855 ripng_passive_interface_apply_all(ripng
);
860 int ripng_passive_interface_unset(struct ripng
*ripng
, const char *ifname
)
865 i
= ripng_passive_interface_lookup(ripng
, ifname
);
867 return NB_ERR_INCONSISTENCY
;
869 str
= vector_slot(ripng
->passive_interface
, i
);
871 vector_unset(ripng
->passive_interface
, i
);
873 ripng_passive_interface_apply_all(ripng
);
878 /* Free all configured RIP passive-interface settings. */
879 void ripng_passive_interface_clean(struct ripng
*ripng
)
884 for (i
= 0; i
< vector_active(ripng
->passive_interface
); i
++)
885 if ((str
= vector_slot(ripng
->passive_interface
, i
)) != NULL
) {
887 vector_slot(ripng
->passive_interface
, i
) = NULL
;
889 ripng_passive_interface_apply_all(ripng
);
892 /* Write RIPng enable network and interface to the vty. */
893 int ripng_network_write(struct vty
*vty
, struct ripng
*ripng
)
897 struct agg_node
*node
;
900 /* Write enable network. */
901 for (node
= agg_route_top(ripng
->enable_network
); node
;
902 node
= agg_route_next(node
))
904 struct prefix
*p
= &node
->p
;
905 vty_out(vty
, " %s/%d\n",
906 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
910 /* Write enable interface. */
911 for (i
= 0; i
< vector_active(ripng
->enable_if
); i
++)
912 if ((ifname
= vector_slot(ripng
->enable_if
, i
)) != NULL
)
913 vty_out(vty
, " %s\n", ifname
);
918 static struct ripng_interface
*ri_new(void)
920 struct ripng_interface
*ri
;
922 ri
= XCALLOC(MTYPE_RIPNG_IF
, sizeof(struct ripng_interface
));
924 /* Set default split-horizon behavior. If the interface is Frame
925 Relay or SMDS is enabled, the default value for split-horizon is
926 off. But currently Zebra does detect Frame Relay or SMDS
927 interface. So all interface is set to split horizon. */
929 yang_get_default_enum("%s/split-horizon", RIPNG_IFACE
);
934 void ripng_interface_sync(struct interface
*ifp
)
940 struct ripng_interface
*ri
;
944 ri
->ripng
= vrf
->info
;
948 static int ripng_if_new_hook(struct interface
*ifp
)
950 ifp
->info
= ri_new();
951 ripng_interface_sync(ifp
);
956 /* Called when interface structure deleted. */
957 static int ripng_if_delete_hook(struct interface
*ifp
)
959 XFREE(MTYPE_RIPNG_IF
, ifp
->info
);
964 /* Configuration write function for ripngd. */
965 static int interface_config_write(struct vty
*vty
)
970 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
971 struct interface
*ifp
;
973 FOR_ALL_INTERFACES (vrf
, ifp
) {
974 struct lyd_node
*dnode
;
976 dnode
= yang_dnode_get(
977 running_config
->dnode
,
978 "/frr-interface:lib/interface[name='%s'][vrf='%s']",
979 ifp
->name
, vrf
->name
);
984 nb_cli_show_dnode_cmds(vty
, dnode
, false);
991 /* ripngd's interface node. */
992 static struct cmd_node interface_node
= {
993 INTERFACE_NODE
, "%s(config-if)# ", 1 /* VTYSH */
996 /* Initialization of interface. */
997 void ripng_if_init(void)
999 /* Interface initialize. */
1000 hook_register_prio(if_add
, 0, ripng_if_new_hook
);
1001 hook_register_prio(if_del
, 0, ripng_if_delete_hook
);
1003 /* Install interface node. */
1004 install_node(&interface_node
, interface_config_write
);