Skip to content

Commit b4ba544

Browse files
committed
mac80211: fix bufferable MMPDU RX handling
Action, disassoc and deauth frames are bufferable, and as such don't have the PM bit in the frame control field reserved which means we need to react to the bit when receiving in such a frame. Fix this by introducing a new helper ieee80211_is_bufferable_mmpdu() and using it for the RX path that currently ignores the PM bit in any non-data frames for doze->wake transitions, but listens to it in all frames for wake->doze transitions, both of which are wrong. Also use the new helper in the TX path to clean up the code. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 953467d commit b4ba544

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎include/linux/ieee80211.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,20 @@ static inline int ieee80211_is_qos_nullfunc(__le16 fc)
596596
cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC);
597597
}
598598

599+
/**
600+
* ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
601+
* @fc: frame control field in little-endian byteorder
602+
*/
603+
static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
604+
{
605+
/* IEEE 802.11-2012, definition of "bufferable management frame";
606+
* note that this ignores the IBSS special case. */
607+
return ieee80211_is_mgmt(fc) &&
608+
(ieee80211_is_action(fc) ||
609+
ieee80211_is_disassoc(fc) ||
610+
ieee80211_is_deauth(fc));
611+
}
612+
599613
/**
600614
* ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
601615
* @seq_ctrl: frame sequence control bytes in little-endian byteorder

‎net/mac80211/rx.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,18 +1311,15 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
13111311
!ieee80211_has_morefrags(hdr->frame_control) &&
13121312
!(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
13131313
(rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1314-
rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
1314+
rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1315+
/* PM bit is only checked in frames where it isn't reserved,
1316+
* in AP mode it's reserved in non-bufferable management frames
1317+
* (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
1318+
*/
1319+
(!ieee80211_is_mgmt(hdr->frame_control) ||
1320+
ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
13151321
if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1316-
/*
1317-
* Ignore doze->wake transitions that are
1318-
* indicated by non-data frames, the standard
1319-
* is unclear here, but for example going to
1320-
* PS mode and then scanning would cause a
1321-
* doze->wake transition for the probe request,
1322-
* and that is clearly undesirable.
1323-
*/
1324-
if (ieee80211_is_data(hdr->frame_control) &&
1325-
!ieee80211_has_pm(hdr->frame_control))
1322+
if (!ieee80211_has_pm(hdr->frame_control))
13261323
sta_ps_end(sta);
13271324
} else {
13281325
if (ieee80211_has_pm(hdr->frame_control))

‎net/mac80211/tx.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,8 @@ ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)
522522
if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED))
523523
return TX_CONTINUE;
524524

525-
/* only deauth, disassoc and action are bufferable MMPDUs */
526525
if (ieee80211_is_mgmt(hdr->frame_control) &&
527-
!ieee80211_is_deauth(hdr->frame_control) &&
528-
!ieee80211_is_disassoc(hdr->frame_control) &&
529-
!ieee80211_is_action(hdr->frame_control)) {
526+
!ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {
530527
if (tx->flags & IEEE80211_TX_UNICAST)
531528
info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
532529
return TX_CONTINUE;

0 commit comments

Comments
 (0)