Date: Thu, 26 Jun 2025 16:38:04 GMT From: Zhenlei Huang <zlei@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a19b353d354d - main - if_vlan: Fix up if_type before attaching the interface Message-ID: <202506261638.55QGc4kg004753@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=a19b353d354d4ef808965c53253103cb6e7e6708 commit a19b353d354d4ef808965c53253103cb6e7e6708 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2025-06-26 16:37:13 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2025-06-26 16:37:13 +0000 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 --- sys/net/if_vlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 9561ae5c316c..e9e1c82cb688 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1177,10 +1177,10 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, ifp->if_ratelimit_query = vlan_ratelimit_query; #endif ifp->if_flags = VLAN_IFFLAGS; + ifp->if_type = IFT_L2VLAN; ether_ifattach(ifp, eaddr); /* Now undo some of the damage... */ ifp->if_baudrate = 0; - ifp->if_type = IFT_L2VLAN; ifp->if_hdrlen = ETHER_VLAN_ENCAP_LEN; ifa = ifp->if_addr; sdl = (struct sockaddr_dl *)ifa->ifa_addr;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506261638.55QGc4kg004753>