aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2023-06-01 11:44:15 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-06-01 11:44:19 +0000
commita77facd27368f618520d25391cfce11149879a41 (patch)
treefd4b495735313fa581d0ff503c76f4585686f567 /sys/netinet6
parent54b955f4df5e76b5679ba7f3eb6bb2d5fc62923d (diff)
downloadsrc-a77facd27368f618520d25391cfce11149879a41.tar.gz
src-a77facd27368f618520d25391cfce11149879a41.zip
ifnet: consistently call hooks when the interface gets up.
Some context on the current IPv6 interface setup & address management: There are two data path for IPv6 initialisation in context of assigning LL addresses: 1) Userland explicitly requests IFF_UP for the interface w/o any addresses. if_up() then calls in6_if_up(), which calls in6_ifattach(). The latter sets up some initial ND/IN6 state and disables IPv6 for the interface if it’s not loopback. If the interface is loopback, then it adds ::1/128 and LL addresses via in6_ifattach_loopback(). Then, devd notification is generated (if the VNET is the default one), which triggers rc.network ifconfig_up(), causing ifdisabled to be removed via SIOCSIFINFO_IN6 from ifconfig. The kernel SIOCSIFINFO_IN6 handler calls in6_if_up() once again and it assigns the interface link-local address. 2) Userland adds IPv4 or IPv6 address to the interface. SIOCAIFADDR[_IN6] kernel handler calls IPv4/IPv6 protocol handler to add the address. Both then call if_ioctl() with SIOCSIFADDR. Ethernet/loopback ioctl handlers silently sets IFF_UP for the interface. Finally, if.c:ifioctl() wrapper code compares old and new interface flags and, if IFF_UP is added, it explicitly calls in6_if_up(), which adds link-local address if either the original address is IPv6 or the interface is loopback. In the latter case, “formal” interface-up notifications are missing. The kernel does not trigger event handler event, does not call carp hook and does not provide any userland notification. This diff unifies the event handling in both scenarios, providing the necessary notifications to the kernel and userland. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D40332 MFC after: 2 weeks
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 3d967e9a40c7..0ef640c5c4bf 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -2049,6 +2049,20 @@ in6_if_up(struct ifnet *ifp)
in6_ifattach(ifp, NULL);
}
+static void
+in6_ifevent(void *arg __unused, struct ifnet *ifp, int event)
+{
+ if (event == IFNET_EVENT_UP)
+ in6_if_up(ifp);
+}
+
+static void
+in6_init(void *arg __unused)
+{
+ EVENTHANDLER_REGISTER(ifnet_event, in6_ifevent, NULL, EVENTHANDLER_PRI_ANY);
+}
+SYSINIT(in6_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, in6_init, NULL);
+
int
in6if_do_dad(struct ifnet *ifp)
{