From nobody Sun May 25 15:24:26 2025 X-Original-To: dev-commits-src-main@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 4b52kM0qk9z5xfyc; Sun, 25 May 2025 15:24:27 +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 4b52kL5Yhjz3vFF; Sun, 25 May 2025 15:24:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748186666; 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=2IwoaiDJeyt2hQ2JTJlhIsQWT6XjTLoJYJIJ32rkWeM=; b=jNUWbxkqRXcgqbPOLpCZAFOk+OgE8lrKORd2REye6/ikZIB1Imnxx+RfFoSkW4Ge4XhcsG qMgtxlPLZPobuxQLS5wWfpfsS6igw539T7C6ZdWjKNLq2tP6/uO9GWXbnowQn7wq1IHCYw MkJbVCLU6heAxF2MSdifJM+jm5svwlWqIS2i8BvbwASgkAidFpo9kJENQ4OhlyMgeSP7Qe mI1kJdiNTeU8iDhY5mM3YolkvQkT+9MBc3m0hSdDZ4S2LR0mZy6AXAjttCjkR+rk1JUyuU MlGzzQwBccQdvokRgPIo9Wt13Bd194rtBZ/1hiRsUM5+V/IRC0gBMEIOPt7gGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748186666; 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=2IwoaiDJeyt2hQ2JTJlhIsQWT6XjTLoJYJIJ32rkWeM=; b=u/ZY3va2c2P5DvEVcPwyYkW+FEzqiIW4PYbKeIAc5R/lluKamMKo6PvMqJddbn5IUPrjRe 7Ume71OTSsu/rYrIWi59gxPFHtPEfcayhVkNHJTU5GnyXZJn3PTVWFe5Owigd/lKT4GqZ3 dfKWdoYGRciHYXOsxEJZrboJKh1mxsCqHw6/olfvVTo/77d1ySmy4kD7mEcTADd8FBgaUN gO6DPdWHGlhw9320P8nu772Fnlpudcdr8HEmrGk+Lvmv2lqm80bISbYeZMWZiXZEjVE6TE eFcff82BwjfFgL5mt2x00HajMMvKAkjhjeFlH2McnW5FxlmUmzOKG14m/ivL9A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748186666; a=rsa-sha256; cv=none; b=CA37D7Vw8GqvxLRmg7bwzpTLzTsLCC9Xo0lnvCGV5sKAm4BLz3wM4jZieynqV9hPcdzx1r qwSmjsjRL9QkRab/22ytgQ6b7+dpyazOreQXxaAWpo/B9/G7Xp46VL5tpa3U9XbsxUS8uN bZtyWJ6MuE5QS98Rsmp31fggW4tt9GLl9qylseiAD1wzc8H8UU1+Q/ocANt29e7ORPmDIe gNqFGPzvz/MHxXHP0Sqp2Opeyjz+gTMKfw3Zv4ePoflb4Scb6tyQrH5s2e/VNlNOmtcikV OjqxbIftYigZKToBhDAb3LpXgbyz3s5QZll7bZTGJo5GTdV6caPZqDllVH950A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4b52kL4znLzC14; Sun, 25 May 2025 15:24:26 +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 54PFOQIQ031836; Sun, 25 May 2025 15:24:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54PFOQ2t031833; Sun, 25 May 2025 15:24:26 GMT (envelope-from git) Date: Sun, 25 May 2025 15:24:26 GMT Message-Id: <202505251524.54PFOQ2t031833@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: ed987e16887b - main - net80211: migrate if_flags, if_drvflags out of most source files List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed987e16887b968210b69de6caf50a91f7d020e9 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=ed987e16887b968210b69de6caf50a91f7d020e9 commit ed987e16887b968210b69de6caf50a91f7d020e9 Author: Adrian Chadd AuthorDate: 2025-05-18 04:32:36 +0000 Commit: Adrian Chadd CommitDate: 2025-05-25 15:23:34 +0000 net80211: migrate if_flags, if_drvflags out of most source files Migrate both if_flags and if_drvflags out of most source files. Ideally it'd only be referenced in ieee80211_freebsd.c, but for now it also ignores references in ieee80211_ioctl.c. * migrate if_flags set to if_setflags * migrate if_flags get to if_getflags * migrate if_drvflags get to if_getdrvflags * add ieee80211_vap_ifp_check_is_monitor() and ieee8021_vap_ifp_check_is_simplex() to abstract out the IFF_MONITOR and IFF_SIMPLEX flag checks. * add ieee80211_vap_ifp_check_is_running() and ieee80211_vap_ifp_set_running_state() to represent what IFF_DRV_RUNNING means (ie, mark the underlying OS network interface as active and inactive.) Notably this doesn't yet clear up OACTIVE; I need to better describe that. Differential Revision: https://reviews.freebsd.org/D50405 Reviewed by: bz --- sys/net80211/ieee80211.c | 2 +- sys/net80211/ieee80211_freebsd.c | 57 ++++++++++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_freebsd.h | 10 ++++--- sys/net80211/ieee80211_ioctl.c | 2 +- sys/net80211/ieee80211_output.c | 2 +- sys/net80211/ieee80211_proto.c | 11 ++++---- sys/net80211/ieee80211_sta.c | 4 +-- 7 files changed, 74 insertions(+), 14 deletions(-) diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index e64568abb024..e4de0b439ac0 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -564,7 +564,7 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap, ifp = if_alloc(IFT_ETHER); if_initname(ifp, name, unit); ifp->if_softc = vap; /* back pointer */ - ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; + if_setflags(ifp, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST); ifp->if_transmit = ieee80211_vap_transmit; ifp->if_qflush = ieee80211_vap_qflush; ifp->if_ioctl = ieee80211_ioctl; diff --git a/sys/net80211/ieee80211_freebsd.c b/sys/net80211/ieee80211_freebsd.c index 0a51063e1d9a..aa3ae82d089f 100644 --- a/sys/net80211/ieee80211_freebsd.c +++ b/sys/net80211/ieee80211_freebsd.c @@ -1257,6 +1257,63 @@ ieee80211_vap_deliver_data(struct ieee80211vap *vap, struct mbuf *m) NET_EPOCH_EXIT(et); } +/** + * @brief Return whether the VAP is configured with monitor mode + * + * This checks the operating system layer for whether monitor mode + * is enabled. + * + * @param vap the current VAP + * @retval true if the underlying interface is in MONITOR mode, false otherwise + */ +bool +ieee80211_vap_ifp_check_is_monitor(struct ieee80211vap *vap) +{ + return ((if_getflags(vap->iv_ifp) & IFF_MONITOR) != 0); +} + +/** + * @brief Return whether the VAP is configured in simplex mode. + * + * This checks the operating system layer for whether simplex mode + * is enabled. + * + * @param vap the current VAP + * @retval true if the underlying interface is in SIMPLEX mode, false otherwise + */ +bool +ieee80211_vap_ifp_check_is_simplex(struct ieee80211vap *vap) +{ + return ((if_getflags(vap->iv_ifp) & IFF_SIMPLEX) != 0); +} + +/** + * @brief Return if the VAP underlying network interface is running + * + * @param vap the current VAP + * @retval true if the underlying interface is running; false otherwise + */ +bool +ieee80211_vap_ifp_check_is_running(struct ieee80211vap *vap) +{ + return ((if_getdrvflags(vap->iv_ifp) & IFF_DRV_RUNNING) != 0); +} + +/** + * @brief Change the VAP underlying network interface state + * + * @param vap the current VAP + * @param state true to mark the interface as RUNNING, false to clear + */ +void +ieee80211_vap_ifp_set_running_state(struct ieee80211vap *vap, bool state) +{ + if (state) + if_setdrvflagbits(vap->iv_ifp, IFF_DRV_RUNNING, 0); + else + if_setdrvflagbits(vap->iv_ifp, 0, IFF_DRV_RUNNING); +} + /* * Module glue. * diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h index 442c5edef52d..449ff8f05202 100644 --- a/sys/net80211/ieee80211_freebsd.h +++ b/sys/net80211/ieee80211_freebsd.h @@ -262,9 +262,9 @@ void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *); void ieee80211_vap_destroy(struct ieee80211vap *); const char * ieee80211_get_vap_ifname(struct ieee80211vap *); -#define IFNET_IS_UP_RUNNING(_ifp) \ - (((_ifp)->if_flags & IFF_UP) && \ - ((_ifp)->if_drv_flags & IFF_DRV_RUNNING)) +#define IFNET_IS_UP_RUNNING(_ifp) \ + (((if_getflags(_ifp) & IFF_UP) != 0) && \ + ((if_getdrvflags(_ifp) & IFF_DRV_RUNNING) != 0)) #define msecs_to_ticks(ms) MSEC_2_TICKS(ms) #define ticks_to_msecs(t) TICKS_2_MSEC(t) @@ -543,6 +543,10 @@ struct debugnet80211_methods { void ieee80211_vap_sync_mac_address(struct ieee80211vap *); void ieee80211_vap_copy_mac_address(struct ieee80211vap *); void ieee80211_vap_deliver_data(struct ieee80211vap *, struct mbuf *); +bool ieee80211_vap_ifp_check_is_monitor(struct ieee80211vap *); +bool ieee80211_vap_ifp_check_is_simplex(struct ieee80211vap *); +bool ieee80211_vap_ifp_check_is_running(struct ieee80211vap *); +void ieee80211_vap_ifp_set_running_state(struct ieee80211vap *, bool); #endif /* _KERNEL */ diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index d70004c0fb7a..7e698ba5cdb8 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -3619,7 +3619,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) wait = 1; ieee80211_start_locked(vap); } - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + } else if (ieee80211_vap_ifp_check_is_running(vap)) { /* * Stop ourself. If we are the last vap to be * marked down the parent will also be taken down. diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 1f726f75b6c6..1b5b3373685f 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -777,7 +777,7 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m, if (error) senderr(error); #endif - if (ifp->if_flags & IFF_MONITOR) + if (ieee80211_vap_ifp_check_is_monitor(vap)) senderr(ENETDOWN); if (!IFNET_IS_UP_RUNNING(ifp)) senderr(ENETDOWN); diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 823f1ab3f486..14c0d2beaad5 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1976,7 +1976,6 @@ ieee80211_start_reset_chan(struct ieee80211vap *vap) void ieee80211_start_locked(struct ieee80211vap *vap) { - struct ifnet *ifp = vap->iv_ifp; struct ieee80211com *ic = vap->iv_ic; IEEE80211_LOCK_ASSERT(ic); @@ -1985,7 +1984,7 @@ ieee80211_start_locked(struct ieee80211vap *vap) IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG, "start running, %d vaps running\n", ic->ic_nrunning); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + if (!ieee80211_vap_ifp_check_is_running(vap)) { /* * Mark us running. Note that it's ok to do this first; * if we need to bring the parent device up we defer that @@ -1994,7 +1993,7 @@ ieee80211_start_locked(struct ieee80211vap *vap) * through ieee80211_start_all at which point we'll come * back in here and complete the work. */ - ifp->if_drv_flags |= IFF_DRV_RUNNING; + ieee80211_vap_ifp_set_running_state(vap, true); ieee80211_notify_ifnet_change(vap, IFF_DRV_RUNNING); /* @@ -2099,7 +2098,6 @@ void ieee80211_stop_locked(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; - struct ifnet *ifp = vap->iv_ifp; IEEE80211_LOCK_ASSERT(ic); @@ -2107,8 +2105,9 @@ ieee80211_stop_locked(struct ieee80211vap *vap) "stop running, %d vaps running\n", ic->ic_nrunning); ieee80211_new_state_locked(vap, IEEE80211_S_INIT, -1); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; /* mark us stopped */ + if (ieee80211_vap_ifp_check_is_running(vap)) { + /* mark us stopped */ + ieee80211_vap_ifp_set_running_state(vap, false); ieee80211_notify_ifnet_change(vap, IFF_DRV_RUNNING); if (--ic->ic_nrunning == 0) { IEEE80211_DPRINTF(vap, diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c index 0dd007fef508..062b5610d082 100644 --- a/sys/net80211/ieee80211_sta.c +++ b/sys/net80211/ieee80211_sta.c @@ -681,7 +681,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, } resubmit_ampdu: if (dir == IEEE80211_FC1_DIR_FROMDS) { - if ((ifp->if_flags & IFF_SIMPLEX) && + if (ieee80211_vap_ifp_check_is_simplex(vap) && isfromds_mcastecho(vap, wh)) { /* * In IEEE802.11 network, multicast @@ -716,7 +716,7 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, vap->iv_stats.is_rx_wrongdir++; goto out; } - if ((ifp->if_flags & IFF_SIMPLEX) && + if (ieee80211_vap_ifp_check_is_simplex(vap) && isdstods_mcastecho(vap, wh)) { /* * In IEEE802.11 network, multicast