From nobody Thu Jul 25 18:43:56 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 4WVKXr4y0wz5R4C9; Thu, 25 Jul 2024 18:43:56 +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 4WVKXr30qgz56LC; Thu, 25 Jul 2024 18:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721933036; 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=hmHuJZUNaLns3N8mmQSR57YFVcqi3OOYU3amikqwTvg=; b=POh4bUX1Gl5vtlrvXXi2DNCbnt4OBGLKfC7hYJkuTHxpqXJRTTOzn3EeXhZsyOKlul14H3 WZtxj9+DtXY39jYkHEP5SHxyLvH0kotukR4+hiNQFtoUBAxY00Ja7c+gc49bVy7j41zmks DYyE1IKAXtCFmlcDTh3OtJ1KOyV02Qc9L6Xy5Lst/8Q3RUNm/UO2pHQ6UtUsElvE4UIbzw EvG8eIzg6tj2ehtpbF+cFf+NV8ACJnPZw14Rk3mASRICHbVtVMB5pqREYffr6/Wo8RJzQY 4aUT7N8t/L8Il1I8YDZTQ4iMq9bowQlM91vWUxiM904tf4IGGlkU7bkCNipdAw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721933036; a=rsa-sha256; cv=none; b=slN3l1oXrUKSfp/fULc1G9X2Cbw5vcODB6R+4lOPItRDv/fdil5Gd4nmJem/kQtkjEqjpR D8EdMPU5WEqkEZ6EM9lkCnB2ecTYsr8JYh4Mj9YcbgcSx4xMJmrwsR6i1fnR12neKtJ7Yj 3RqKQJBlclUJucXD3sBYu0tznF7rUl5852Sk5sb96Sv8LbEvIsxOKkS8IxTxRbhXoDmkUM oN0M7mWrZ+okpEw3GICHG7bTft19elfRrmPr/yV8hgj9+BaeWsmP3Khff5E/kZLuEFmC4S +BsggnOsSJPdar12t9j6cReqmceYj7M7pic6oK9CAPI9wQ/oRUZ/kJss29xITg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721933036; 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=hmHuJZUNaLns3N8mmQSR57YFVcqi3OOYU3amikqwTvg=; b=F3/OA46zDvarbz5PYEllcJ+h0KSIOP2CFY1v1qZTmNT6RcS4UuvYduTrdOAcniwB8QU2/5 2W4/F3CTOoRAnhK9oTL8bWbLEjyeONsNJI3CS8Rc/U2Y8BpSymN+CoQ6FdTpVKHHrG0xLC vXlPP+Cs+5+nzQhDxbveMxDfs4pnGJ+qCuP6Lr9m6SnYhFwq0tKP20IY+fQFNwPymT/d7Y PDAShQn7E1Mz4DwAb0PnSc2WW91X9OKChXkFBjOG77beSTskXIRxo8oW/EjWZ0aDB5QgNb gobQJBaTeYlebV0Ywy8bsSpJkdUGyoZJbfZLg3CRCoAV2FxFkUsJM5ADlv8ywA== 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 4WVKXr2cjkz16Jl; Thu, 25 Jul 2024 18:43:56 +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 46PIhuVR057420; Thu, 25 Jul 2024 18:43:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46PIhuBr057417; Thu, 25 Jul 2024 18:43:56 GMT (envelope-from git) Date: Thu, 25 Jul 2024 18:43:56 GMT Message-Id: <202407251843.46PIhuBr057417@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 4aff4048f5b1 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 4aff4048f5b1b6ab0b905726853ba6083e37cc37 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4aff4048f5b1b6ab0b905726853ba6083e37cc37 commit 4aff4048f5b1b6ab0b905726853ba6083e37cc37 Author: Bjoern A. Zeeb AuthorDate: 2024-07-25 07:53:32 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-07-25 18:42:26 +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 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D46121 --- 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 adef35ec2d5c..b46e56133725 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2750,6 +2750,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, @@ -2798,6 +2824,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 */ @@ -2971,6 +2999,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;