Date: Sun, 25 May 2025 15:24:26 GMT From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ed987e16887b - main - net80211: migrate if_flags, if_drvflags out of most source files Message-ID: <202505251524.54PFOQ2t031833@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=ed987e16887b968210b69de6caf50a91f7d020e9 commit ed987e16887b968210b69de6caf50a91f7d020e9 Author: Adrian Chadd <adrian@FreeBSD.org> AuthorDate: 2025-05-18 04:32:36 +0000 Commit: Adrian Chadd <adrian@FreeBSD.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505251524.54PFOQ2t031833>