diff options
| author | Zhenlei Huang <zlei@FreeBSD.org> | 2025-05-22 15:00:05 +0000 |
|---|---|---|
| committer | Zhenlei Huang <zlei@FreeBSD.org> | 2025-07-07 10:03:58 +0000 |
| commit | 2466a18711548113d3ca4c61ccc7d6717adb6ade (patch) | |
| tree | 6ad041863a1302c5de405e762f5bf423b425b521 | |
| parent | 077895676d3baf62a6d2e50626faaaa3e7ef2473 (diff) | |
ifnet: Initialize the address family dependent data region earlier
if_link_ifnet() adds the interface to the global network interface list,
and it is a natural synchronization point. With this change, any threads
that obtain the reference of the interface via ifunit(), ifunit_ref() etc.,
will be guaranteed to see the address family dependent data rightly.
The issue [1] reported by Mike Belanger also hints the potential race.
MFC note: this change depends on e64fe5ad3a23, as calculating the max
IPv6 MTU through all the interfaces requires the current interface to
be added to the global network interface list firstly.
[1] https://lists.freebsd.org/archives/freebsd-net/2025-May/006817.html
Reviewed by: glebius
MFC after: 1 month
MFC with: e64fe5ad3a23 netinet6: Remove a set but not used global variable in6_maxmtu
Differential Revision: https://reviews.freebsd.org/D49358
(cherry picked from commit 098b5d4dc744283a90b2d80c11395ecc18a84084)
| -rw-r--r-- | sys/net/if.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index b4ffa9883efc..a0570aed32e9 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -948,11 +948,11 @@ if_attach_internal(struct ifnet *ifp, bool vmove) } #endif - if_link_ifnet(ifp); - if (domain_init_status >= 2) if_attachdomain1(ifp); + if_link_ifnet(ifp); + EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); if (IS_DEFAULT_VNET(curvnet)) devctl_notify("IFNET", ifp->if_xname, "ATTACH", NULL); |
