HomeFreeBSD

bus: Set the current VNET in device_attach()

Description

bus: Set the current VNET in device_attach()

Some drivers, in particular anything which creates an ifnet during
attach, need to have the current VNET set, as if_attach_internal() and
its callees access VNET-global variables.

device_probe_and_attach() handles this, but this is not the only way to
arrive in DEVICE_ATTACH. In particular, bus drivers may invoke
device_attach() directly, as does devctl2's DEV_ENABLE ioctl handler.
So, set the current VNET in device_attach() instead.

I believe it is always safe to use vnet0, as devctl2 ioctls are not
permitted within a jail.

PR: 282168
Reviewed by: zlei, kevans, bz, imp, glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47174

(cherry picked from commit f4e35c044c8988b7452cefbdcc417f5fd723e021)
(cherry picked from commit 2e80ea70b98ef75f8bea9155944e6f093c0fa828)

Details

Provenance
markjAuthored on Oct 19 2024, 1:03 PM
Reviewer
zlei
Differential Revision
D47174: bus: Set the current VNET in device_attach()
Parents
rG1bdf189b9048: vt.4: align tables + 80 character line limit
Branches
Unknown
Tags
Unknown