Skip to contentSkip to conversation

cfg80211: allow grace period for DFS available after beacon shutdown

PATCH In review Felix Fietkau 2 participants 2 messages Sep 14, 2023 – Oct 19, 2023 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfg80211: allow grace period for DFS available after beacon shutdown

Fixes reconfiguring an AP on a DFS channel in non-ETSI regdomain

Fixes b35a51c7dd25 ("cfg80211: Make pre-CAC results valid only for ETSI domain")
---
 include/net/cfg80211.h |  3 +++
 net/wireless/ap.c      |  6 +++---
 net/wireless/chan.c    | 45 ++++++++++++++++++++++++++++++++++++++++++
 net/wireless/core.h    |  2 ++
 net/wireless/mlme.c    |  7 ++++---
 5 files changed, 57 insertions(+), 6 deletions(-)
include/net/cfg80211.h +3 -0
index 8fcfe1869424..dbb1c85ccc58 100644
@@ -170,6 +170,8 @@ enum ieee80211_channel_flags {
  * @dfs_state: current state of this channel. Only relevant if radar is required
  *	on this channel.
  * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
+ * @dfs_state_last_available: timestamp (jiffies) of the last time when the
+ *	channel was available.
  * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
  */
 struct ieee80211_channel {
@@ -186,6 +188,7 @@ struct ieee80211_channel {
 	int orig_mag, orig_mpwr;
 	enum nl80211_dfs_state dfs_state;
 	unsigned long dfs_state_entered;
+	unsigned long dfs_state_last_available;
 	unsigned int dfs_cac_ms;
 };
 
net/wireless/ap.c +3 -3
index 9a9a870806f5..9cd0ab4dbf69 100644
@@ -30,6 +30,9 @@ static int ___cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
 	if (!wdev->links[link_id].ap.beacon_interval)
 		return -ENOENT;
 
+	cfg80211_update_last_available(wdev->wiphy,
+				       &wdev->links[link_id].ap.chandef);
+
 	err = rdev_stop_ap(rdev, dev, link_id);
 	if (!err) {
 		wdev->conn_owner_nlportid = 0;
@@ -41,9 +44,6 @@ static int ___cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
 		if (notify)
 			nl80211_send_ap_stopped(wdev, link_id);
 
-		/* Should we apply the grace period during beaconing interface
-		 * shutdown also?
-		 */
 		cfg80211_sched_dfs_chan_update(rdev);
 	}
 
net/wireless/chan.c +45 -0

57 lines not on this page · raw message

net/wireless/core.h +2 -0
index 866f0a6934e6..bc68c204b1c4 100644
@@ -457,6 +457,8 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy,
 			    enum nl80211_dfs_state dfs_state);
 
 void cfg80211_dfs_channels_update_work(struct work_struct *work);
+void cfg80211_update_last_available(struct wiphy *wiphy,
+				    const struct cfg80211_chan_def *chandef);
 
 void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev);
 
net/wireless/mlme.c +4 -3
index cc7ae9ea84ea..43a93791dcfd 100644
@@ -927,6 +927,8 @@ void cfg80211_dfs_channels_update_work(struct work_struct *work)
 			if (c->dfs_state == NL80211_DFS_UNAVAILABLE) {
 				time_dfs_update = IEEE80211_DFS_MIN_NOP_TIME_MS;
 				radar_event = NL80211_RADAR_NOP_FINISHED;
+				timeout = c->dfs_state_entered +
+					  msecs_to_jiffies(time_dfs_update);
 			} else {
 				if (regulatory_pre_cac_allowed(wiphy) ||
 				    cfg80211_any_wiphy_oper_chan(wiphy, c))
@@ -934,11 +936,10 @@ void cfg80211_dfs_channels_update_work(struct work_struct *work)
 
 				time_dfs_update = REG_PRE_CAC_EXPIRY_GRACE_MS;
 				radar_event = NL80211_RADAR_PRE_CAC_EXPIRED;
+				timeout = c->dfs_state_last_available +
+					  msecs_to_jiffies(time_dfs_update);
 			}
 
-			timeout = c->dfs_state_entered +
-				  msecs_to_jiffies(time_dfs_update);
-
 			if (time_after_eq(jiffies, timeout)) {
 				c->dfs_state = NL80211_DFS_USABLE;
 				c->dfs_state_entered = jiffies;
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 1 line · Felix Fietkau

Fixes reconfiguring an AP on a DFS channel in non-ETSI regdomain

Sorry, I think I mentioned this on IRC but maybe you never saw: can you please elaborate on the commit message?

It looks pretty OK but describing just that it fixes something seems a bit sparse.

johannes