git: 8d9b4e219f5a - stable/14 - LinuxKPI: 802.11: improve lladdr change to not use ifnet internals

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 14 Nov 2024 01:53:55 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=8d9b4e219f5ac1b0f4f7fb646472c162b0c9af00

commit 8d9b4e219f5ac1b0f4f7fb646472c162b0c9af00
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-11-08 21:24:00 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-11-14 01:53:12 +0000

    LinuxKPI: 802.11: improve lladdr change to not use ifnet internals
    
    The changes from 4aff4048 were based on net80211 which is still using
    if_private.h details.  Adjust the code to no longer depend on internal
    details of ifnet.  We also switch the "check"-functionn from if_init to
    if_transmit which we can query.  Given we do have a per-vif eventhandler
    we could do without that check but would still need to check
    if_getflags() for IFF_UP.
    
    Sponsored by:   The FreeBSD Foundation
    Reported by:    jhibbits
    Fixes:          4aff4048
    Reviewed by:    jhibbits
    Differential Revision: https://reviews.freebsd.org/D47490
    
    (cherry picked from commit edab5a280e0b4a53d0f3e34957075c7efe048e8d)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index c26eb8740c77..b0ad1dee4784 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2764,6 +2764,10 @@ lkpi_ic_wme_update(struct ieee80211com *ic)
  * we do use a per-[l]vif event handler to be sure we exist as we
  * cannot assume that from every vap derives a vif and we have a hard
  * time checking based on net80211 information.
+ * Should this ever become a real problem we could add a callback function
+ * to wlan_iflladdr() to be set optionally but that would be for a
+ * single-consumer (or needs a list) -- was just too complicated for an
+ * otherwise perfect mechanism FreeBSD already provides.
  */
 static void
 lkpi_vif_iflladdr(void *arg, struct ifnet *ifp)
@@ -2772,8 +2776,9 @@ lkpi_vif_iflladdr(void *arg, struct ifnet *ifp)
 	struct ieee80211_vif *vif;
 
 	NET_EPOCH_ENTER(et);
-	/* NB: identify vap's by if_init; left as an extra check. */
-	if (ifp->if_init != ieee80211_init || (ifp->if_flags & IFF_UP) != 0) {
+	/* NB: identify vap's by if_transmit; left as an extra check. */
+	if (if_gettransmitfn(ifp) != ieee80211_vap_transmit ||
+	    (if_getflags(ifp) & IFF_UP) != 0) {
 		NET_EPOCH_EXIT(et);
 		return;
 	}