mac80211: backport upstream fixes
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 392-mac80211-don-t-Tx-a-deauth-frame-if-the-AP-forbade-T.patch
1 From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2 Date: Fri, 31 Aug 2018 11:31:12 +0300
3 Subject: [PATCH] mac80211: don't Tx a deauth frame if the AP forbade Tx
4
5 If the driver fails to properly prepare for the channel
6 switch, mac80211 will disconnect. If the CSA IE had mode
7 set to 1, it means that the clients are not allowed to send
8 any Tx on the current channel, and that includes the
9 deauthentication frame.
10
11 Make sure that we don't send the deauthentication frame in
12 this case.
13
14 In iwlwifi, this caused a failure to flush queues since the
15 firmware already closed the queues after having parsed the
16 CSA IE. Then mac80211 would wait until the deauthentication
17 frame would go out (drv_flush(drop=false)) and that would
18 never happen.
19
20 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
21 Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
22 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
23 ---
24
25 --- a/net/mac80211/mlme.c
26 +++ b/net/mac80211/mlme.c
27 @@ -1267,6 +1267,16 @@ ieee80211_sta_process_chanswitch(struct
28 cbss->beacon_interval));
29 return;
30 drop_connection:
31 + /*
32 + * This is just so that the disconnect flow will know that
33 + * we were trying to switch channel and failed. In case the
34 + * mode is 1 (we are not allowed to Tx), we will know not to
35 + * send a deauthentication frame. Those two fields will be
36 + * reset when the disconnection worker runs.
37 + */
38 + sdata->vif.csa_active = true;
39 + sdata->csa_block_tx = csa_ie.mode;
40 +
41 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work);
42 mutex_unlock(&local->chanctx_mtx);
43 mutex_unlock(&local->mtx);
44 @@ -2437,6 +2447,7 @@ static void __ieee80211_disconnect(struc
45 struct ieee80211_local *local = sdata->local;
46 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
47 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
48 + bool tx;
49
50 sdata_lock(sdata);
51 if (!ifmgd->associated) {
52 @@ -2444,6 +2455,8 @@ static void __ieee80211_disconnect(struc
53 return;
54 }
55
56 + tx = !sdata->csa_block_tx;
57 +
58 /* AP is probably out of range (or not reachable for another reason) so
59 * remove the bss struct for that AP.
60 */
61 @@ -2451,7 +2464,7 @@ static void __ieee80211_disconnect(struc
62
63 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
64 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
65 - true, frame_buf);
66 + tx, frame_buf);
67 mutex_lock(&local->mtx);
68 sdata->vif.csa_active = false;
69 ifmgd->csa_waiting_bcn = false;
70 @@ -2462,7 +2475,7 @@ static void __ieee80211_disconnect(struc
71 }
72 mutex_unlock(&local->mtx);
73
74 - ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), true,
75 + ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), tx,
76 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
77
78 sdata_unlock(sdata);