[PATCH wireless-next v3 15/21] wifi: mac80211: filter uplink and downlink frames based on SMD states

From: Pooventhiran G

Date: Thu Nov 05 2026 - 14:59:45 EST


During SMD BSS Transition, based on the state that the non-AP MLD is
currently in, there are frame filtering conditions imposed in both
uplink and downlink directions, as per IEEE P802.11bn/D2.0, Aug 2026,
subclause 11.3.1.

State 4a:
- UL/DL: All Class 3 frames except ST Execution Request and Response
frames are disallowed.

State 4b:
- UL: Class 3 data frames are disallowed.
- DL: All Class 3 data, control, management frames are disallowed.

State 4c:
- UL: All Class 3 frames except QoS Null, Control, and UHR
Reconfiguration Notify frames are disallowed.
- DL: All Class 3 frames except Data, Control, and UHR
Reconfiguration Notify frames are disallowed.

Add the filters in both tx and rx handlers to implement the conditions
to avoid exchanging those frames while the station is transitioning
'seamlessly' (state-4) to the target AP MLD. The unexpected frames will
cause out-of-state operations and leaks in the context transferred.

Signed-off-by: Pooventhiran G <pooventhiran.g@xxxxxxxxxxxxxxxx>
---
net/mac80211/drop.h | 1 +
net/mac80211/rx.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
net/mac80211/tx.c | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+)

diff --git a/net/mac80211/drop.h b/net/mac80211/drop.h
index f433ee17cce5..fe037c94b2ca 100644
--- a/net/mac80211/drop.h
+++ b/net/mac80211/drop.h
@@ -109,6 +109,7 @@ typedef unsigned int __bitwise ieee80211_rx_result;
R(RX_DROP_U_UNHANDLED_MGMT_STYPE) \
R(RX_DROP_U_NO_LINK) \
R(RX_DROP_U_DEFRAG_OVERFLOW) \
+ R(RX_DROP_U_SMD_FILTERED) \
/* this line for the trailing \ - add before this */

/* having two enums allows for checking ieee80211_rx_result use with sparse */
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index ee1f33178d26..12ba9fbcc983 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1628,6 +1628,49 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
return RX_CONTINUE;
}

+static ieee80211_rx_result debug_noinline
+ieee80211_rx_h_smd_state(struct ieee80211_rx_data *rx)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+ __le16 fc = hdr->frame_control;
+
+ if (!rx->sta ||
+ (rx->sdata->vif.type != NL80211_IFTYPE_AP &&
+ rx->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) ||
+ !test_sta_flag(rx->sta, WLAN_STA_ASSOC) ||
+ is_multicast_ether_addr(hdr->addr1))
+ return RX_CONTINUE;
+
+ switch (rx->sta->smd_state) {
+ case IEEE80211_STA_SMD_NONE:
+ break;
+ case IEEE80211_STA_SMD_PREP:
+ /* 4a: Class 3 disallowed except ST Execution Request */
+ if (ieee80211_is_st_exec_req(rx->skb))
+ break;
+ if (ieee80211_is_class3(rx->skb))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ case IEEE80211_STA_SMD_EXEC:
+ /* 4b: Class 3 Data frames disallowed */
+ if (ieee80211_is_data(fc))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ case IEEE80211_STA_SMD_DRAIN:
+ /*
+ * 4c: Class 3 frames disallowed except QoS Null, Control, and
+ * UHR Reconfiguration Notify frames.
+ */
+ if (ieee80211_is_qos_nullfunc(fc) || ieee80211_is_ctl(fc) ||
+ ieee80211_is_uhr_link_reconf_notify(rx->skb))
+ break;
+ if (ieee80211_is_class3(rx->skb))
+ return RX_DROP_U_SMD_FILTERED;
+ break;
+ }
+
+ return RX_CONTINUE;
+}

static ieee80211_rx_result debug_noinline
ieee80211_rx_h_check_more_data(struct ieee80211_rx_data *rx)
@@ -4279,6 +4322,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data *rx)

CALL_RXH(ieee80211_rx_h_check_dup);
CALL_RXH(ieee80211_rx_h_check);
+ CALL_RXH(ieee80211_rx_h_smd_state);

ieee80211_rx_reorder_ampdu(rx, &reorder_release);

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index e9b6a0415d6a..17735fd0946b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -308,6 +308,47 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
return TX_CONTINUE;
}

+static ieee80211_tx_result debug_noinline
+ieee80211_tx_h_smd_state(struct ieee80211_tx_data *tx)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+ __le16 fc = hdr->frame_control;
+
+ if (!tx->sta ||
+ (tx->sdata->vif.type != NL80211_IFTYPE_AP ||
+ tx->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) ||
+ !test_sta_flag(tx->sta, WLAN_STA_ASSOC) ||
+ !(tx->flags & IEEE80211_TX_UNICAST))
+ return TX_CONTINUE;
+
+ switch (tx->sta->smd_state) {
+ case IEEE80211_STA_SMD_NONE:
+ break;
+ case IEEE80211_STA_SMD_PREP:
+ /* 4a: Class 3 disallowed except ST Execution Response */
+ if (ieee80211_is_st_exec_resp(tx->skb))
+ break;
+ if (ieee80211_is_class3(tx->skb))
+ return TX_DROP;
+ break;
+ case IEEE80211_STA_SMD_EXEC:
+ /* 4b: no restriction */
+ break;
+ case IEEE80211_STA_SMD_DRAIN:
+ /* 4c: Class 3 disallowed except Data, Control,
+ * UHR Reconfiguration Notify
+ */
+ if (ieee80211_is_ctl(fc) || ieee80211_is_data(fc) ||
+ ieee80211_is_uhr_link_reconf_notify(tx->skb))
+ break;
+ if (ieee80211_is_class3(tx->skb))
+ return TX_DROP;
+ break;
+ }
+
+ return TX_CONTINUE;
+}
+
/* This function is called whenever the AP is about to exceed the maximum limit
* of buffered frames for power saving STAs. This situation should not really
* happen often during normal operation, so dropping the oldest buffered packet
@@ -1881,6 +1922,7 @@ static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)

CALL_TXH(ieee80211_tx_h_dynamic_ps);
CALL_TXH(ieee80211_tx_h_check_assoc);
+ CALL_TXH(ieee80211_tx_h_smd_state);
CALL_TXH(ieee80211_tx_h_ps_buf);
CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
CALL_TXH(ieee80211_tx_h_select_key);

--
2.34.1