From nobody Sat Sep 28 10:38:18 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XG3hW0scdz5X8bD; Sat, 28 Sep 2024 10:38:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XG3hV5TjSz46wr; Sat, 28 Sep 2024 10:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+IzAdofVJ06Vlhiw2TsaI5scSCgDoTsiI2gPp7qTtsw=; b=trXxIVCegGlKWkamZhVJDGdo4yidWhayhgBsMv8T52yyBzzwmh3L6pTHGiY/z8IJ3lwfox E/hXsWMkUW/sn5HDLpZW//y6Tv0JKSzWEAn0XE3fCsbkLxZneaYRWJN4qnAGq3DgsAupan B57Kv0LGtWbGu/NXDMZAVOK+OoBS7Hm4BxiUHc9RXFCTRPLoxFkKiNStubkkT7ZTUxaMjd XwL3OZ6JEG+tOaDW0/YiCLl/6hHVMnUMnnMxKaICr7N+8ZMt1gt+N9ahEK+gkZAQMBm+Uf kUgyBu07wgO0Xy6drTEAOs9tETX/3UBcTdOx4Wvysj30s6hAEyZrae/4yxayig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+IzAdofVJ06Vlhiw2TsaI5scSCgDoTsiI2gPp7qTtsw=; b=n2DMwcpRswBtbJDk5LjPC+WpbIkBpcyPB5UtHCO4zdibKvZgyaYkMsE6oVKM3Wzw+snSdw fxg5g+Q1IR3wT1RnOH/mMalQ+GEP371X77PTIJQBN89ONLxk5bxUIWD6rDkeTObALI8Dzb zDkqYOEAao3b3zUHv5BpqFG8Fryl0u1ejvpcL2FRZkOACLi17dcJ1XeNe0dQu/RxaLvQ6w Sa367mA0NedTmo2WXKChBh6n2pVyiTcmX5OsIqX/WMJoOmjXDvJY0P7mbR7IGdRYsCMTnA lFd8J/cMqb72XZZelo7uhc8YcTVHrRJ1NwTZRJTnatO6b+V3Z2OoK1+0hTWPFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727519898; a=rsa-sha256; cv=none; b=gOr0C86VlyCRVDHaKew96eJa7s8Tt2NX02yYHjgpPsY7E+Pa8fO3cDIzM2TonEVl3aRk2y 0WK+0zJQJ0edvO76yM7C84LKAfzMfZtv4WxkZcHaNM/lUfNDnwqxIcbjq1/3SxT960fqGs 0bNQ5LGynmmvteTi2tronPDe+yVPN3pk19pcnHgR4v9Xj1UcYShJJ8R24GnKnVxnoHMGEc 37yXFHiF8R7A7o+Bk9Q/BxAwAzBdj7fePgYEMvNUnQLIEzu35xD1UCMZvt6FkMlKwoMxd/ x21TI2m/K2SdpS5CLe4N5soZiyV1fGXOthrjm3grHYWpOlU5ZLuyWCEZAtN6AQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XG3hV3RZyzLwc; Sat, 28 Sep 2024 10:38:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48SAcI3T097977; Sat, 28 Sep 2024 10:38:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SAcICF097974; Sat, 28 Sep 2024 10:38:18 GMT (envelope-from git) Date: Sat, 28 Sep 2024 10:38:18 GMT Message-Id: <202409281038.48SAcICF097974@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 314069ff8c35 - stable/14 - LinuxKPI: 802.11: support manual lladdr changes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 314069ff8c35ff4f2824746b6301da7fe5b48f4e Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=314069ff8c35ff4f2824746b6301da7fe5b48f4e commit 314069ff8c35ff4f2824746b6301da7fe5b48f4e Author: Bjoern A. Zeeb AuthorDate: 2024-07-25 07:53:32 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-09-28 10:35:13 +0000 LinuxKPI: 802.11: support manual lladdr changes Allow a user to change the "ether" address by ifconfig while a VAP is not UP. Compared to net80211 (given we have no callback) we register an eventhandler per-vif (a global one would force us to use hacks to derive if a vap is indeed also a lkpi_80211 vif). Sponsored by: The FreeBSD Foundation PR: 277356 Tested by: lwhsu Differential Revision: https://reviews.freebsd.org/D46121 (cherry picked from commit 4aff4048f5b1b6ab0b905726853ba6083e37cc37) --- sys/compat/linuxkpi/common/src/linux_80211.c | 30 ++++++++++++++++++++++++++++ sys/compat/linuxkpi/common/src/linux_80211.h | 1 + 2 files changed, 31 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 948d96bd64ac..a4b5545e0c3c 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2751,6 +2751,32 @@ lkpi_ic_wme_update(struct ieee80211com *ic) return (0); /* unused */ } +/* + * Change link-layer address on the vif (if the vap is not started/"UP"). + * This can happen if a user changes 'ether' using ifconfig. + * The code is based on net80211/ieee80211_freebsd.c::wlan_iflladdr() but + * 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. + */ +static void +lkpi_vif_iflladdr(void *arg, struct ifnet *ifp) +{ + struct epoch_tracker et; + 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) { + NET_EPOCH_EXIT(et); + return; + } + + vif = arg; + IEEE80211_ADDR_COPY(vif->bss_conf.addr, IF_LLADDR(ifp)); + NET_EPOCH_EXIT(et); +} + static struct ieee80211vap * lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode, int flags, @@ -2799,6 +2825,8 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], vif->bss_conf.vif = vif; /* vap->iv_myaddr is not set until net80211::vap_setup or vap_attach. */ IEEE80211_ADDR_COPY(vif->bss_conf.addr, mac); + lvif->lvif_ifllevent = EVENTHANDLER_REGISTER(iflladdr_event, + lkpi_vif_iflladdr, vif, EVENTHANDLER_PRI_ANY); vif->bss_conf.link_id = 0; /* Non-MLO operation. */ vif->bss_conf.chandef.width = NL80211_CHAN_WIDTH_20_NOHT; vif->bss_conf.use_short_preamble = false; /* vap->iv_flags IEEE80211_F_SHPREAMBLE */ @@ -2972,6 +3000,8 @@ lkpi_ic_vap_delete(struct ieee80211vap *vap) lhw = ic->ic_softc; hw = LHW_TO_HW(lhw); + EVENTHANDLER_DEREGISTER(iflladdr_event, lvif->lvif_ifllevent); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_REMOVE(&lhw->lvif_head, lvif, lvif_entry); LKPI_80211_LHW_LVIF_UNLOCK(lhw); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index 80be87ebe231..7675a8b6cebf 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -165,6 +165,7 @@ struct lkpi_sta { struct lkpi_vif { TAILQ_ENTRY(lkpi_vif) lvif_entry; struct ieee80211vap iv_vap; + eventhandler_tag lvif_ifllevent; struct mtx mtx; struct wireless_dev wdev;