git: 098b5d4dc744 - main - ifnet: Initialize the address family dependent data region earlier
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 22 May 2025 15:01:13 UTC
The branch main has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=098b5d4dc744283a90b2d80c11395ecc18a84084
commit 098b5d4dc744283a90b2d80c11395ecc18a84084
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-05-22 15:00:05 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-05-22 15:00:05 +0000
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
---
sys/net/if.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/net/if.c b/sys/net/if.c
index 853fc3c78fce..0255c27a3136 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -946,11 +946,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);