Page MenuHomeFreeBSD

ifnet: Initialize address family dependent data region earlier
ClosedPublic

Authored by zlei on Mar 14 2025, 11:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 5, 10:00 PM
Unknown Object (File)
Thu, Nov 27, 4:48 PM
Unknown Object (File)
Fri, Nov 14, 5:41 PM
Unknown Object (File)
Mon, Nov 10, 9:37 AM
Unknown Object (File)
Mon, Nov 10, 9:37 AM
Unknown Object (File)
Nov 7 2025, 5:12 AM
Unknown Object (File)
Nov 2 2025, 12:22 AM
Unknown Object (File)
Oct 26 2025, 12:42 PM
Subscribers

Details

Summary

if_link_ifnet() add the interface to global network interface list, and
is a natural synchronization point, i.e., any threads that obtain the
reference of the interface via ifunit(), ifunit_ref() e.g., can see the
address family dependent data.

Currently there's no reports about the potential synchronization issue,
but we can make guarantee that it will never happen.

MFC after: 2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

zlei requested review of this revision.Mar 14 2025, 11:56 AM

This depends on D49357 , as if_attachdomain1() tries to update in6_maxmtu .

This looks correct to me. Does it fix any uninitialized af_data races? If it does, that is a strong MFC candidate.

P.S. You may want to move it even down lower beyond EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp). But not in this commit. The if_attachdomain() is a 1980s relic, long before EVENTHANDLER(9) was introduced to kernel. My vague hand-waving plan on attacking the uninitialized af_data problem is to switch to EVENTHANDLER(9) and code a proper sequence. This reminds me work of moving domains/protocols to SYSINIT(9): 89128ff3e42196c8b41a3c59f7a2d95c0a4ac0ee, 24e1c6ae7d3f7731a0884a62e9d5273e5ca1335a, 81a34d374ed6e5a7b14f24583bc8e3abfdc66306.

This revision is now accepted and ready to land.Mar 14 2025, 5:03 PM

This looks correct to me.
Does it fix any uninitialized af_data races? If it does, that is a strong MFC candidate.

At the time I was working on this change, No. But weeks ago Mike Belanger reported an issue from net mailing list [1], after diagnosing I think that is possible.

[1] https://lists.freebsd.org/archives/freebsd-net/2025-May/006817.html

P.S. You may want to move it even down lower beyond EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp). But not in this commit. The if_attachdomain() is a 1980s relic, long before EVENTHANDLER(9) was introduced to kernel. My vague hand-waving plan on attacking the uninitialized af_data problem is to switch to EVENTHANDLER(9) and code a proper sequence. This reminds me work of moving domains/protocols to SYSINIT(9): 89128ff3e42196c8b41a3c59f7a2d95c0a4ac0ee, 24e1c6ae7d3f7731a0884a62e9d5273e5ca1335a, 81a34d374ed6e5a7b14f24583bc8e3abfdc66306.

Technically it can be, but I'm a little nervous about that. I thought ifnet_arrival_event should be invoked after the interface is really READY ( at least in attached status ). EVENTHANDLER(9) is mostly useful to notify other sub-system, such as routing / pfil, so they are loosely connected.