HomeFreeBSD

ifnet: Initialize the address family dependent data region earlier

Description

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)