d576661bd200244c523a606888f00cba619961e1
[openwrt/openwrt.git] /
1 From b478e06a16a8baa00c5ecc87c1d636981f2206d5 Mon Sep 17 00:00:00 2001
2 From: Johannes Berg <johannes.berg@intel.com>
3 Date: Tue, 29 Oct 2019 10:25:25 +0100
4 Subject: [PATCH] mac80211: sta: randomize BA session dialog token allocator
5
6 We currently always start the dialog token generator at zero,
7 so the first dialog token we use is always 1. This would be
8 OK if we had a perfect guarantee that we always do a proper
9 deauth/re-auth handshake, but in IBSS mode this doesn't always
10 happen properly.
11
12 To make problems with block ack (aggregation) sessions getting
13 stuck less likely, randomize the dialog token so if we start a
14 new session but the peer still has old state for us, it can
15 better detect this.
16
17 This is really just a workaround to make things a bit more
18 robust than they are now - a better fix would be to do a full
19 authentication handshake in IBSS mode upon having discovered a
20 new station, and on the receiver resetting the state (removing
21 and re-adding the station) on receiving the authentication
22 packet.
23
24 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
25 ---
26 net/mac80211/sta_info.c | 1 +
27 1 file changed, 1 insertion(+)
28
29 --- a/net/mac80211/sta_info.c
30 +++ b/net/mac80211/sta_info.c
31 @@ -565,6 +565,11 @@ __sta_info_alloc(struct ieee80211_sub_if
32 spin_lock_init(&sta->ps_lock);
33 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames);
34 wiphy_work_init(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
35 +#if LINUX_VERSION_IS_LESS(6,2,0)
36 + sta->ampdu_mlme.dialog_token_allocator = prandom_u32_max(U8_MAX);
37 +#else
38 + sta->ampdu_mlme.dialog_token_allocator = get_random_u32_below(U8_MAX);
39 +#endif
40 #ifdef CPTCFG_MAC80211_MESH
41 if (ieee80211_vif_is_mesh(&sdata->vif)) {
42 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);