HomeFreeBSD

if_vlan: Fix up if_type before attaching the interface

Description

if_vlan: Fix up if_type before attaching the interface

ether_ifattach() does not touch if_type, so it is not mandatory to fix
the if_type after ether_ifattach(). Without this change, the event
listeners, e.g. netlink, will see wrong interface type IFT_ETHER rather
than the correct one IFT_L2VLAN. There is also a potential race that
other threads see inconsistent interface type, i.e. initially IFT_ETHER
and eventually IFT_L2VLAN.

As a nice effect, this change eliminates the memory allocation for
if_hw_addr, as vlan(4) interfaces do not support setting or retrieving
the hardware MAC address yet [1].

[1] ddae57504b79 Persistently store NIC's hardware MAC address, and add a way to retrive it

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50914

(cherry picked from commit a19b353d354d4ef808965c53253103cb6e7e6708)
(cherry picked from commit ff54b680383bb0f212e813b74e7a3f76423d2238)

Details

Provenance
zleiAuthored on Jun 26 2025, 4:37 PM
Differential Revision
D50914: if_vlan: Fix up the if_type prior to attaching the interface
Parents
rGafaa32661b48: axgbe: Fix setting promisc mode
Branches
Unknown
Tags
Unknown