365-mac80211-IBSS-send-deauth-when-expiring-inactive-STA.patch 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. From 4b08d1b6a994dbb593557bd2095ba4f0c3c47819 Mon Sep 17 00:00:00 2001
  2. From: Johannes Berg <johannes.berg@intel.com>
  3. Date: Fri, 30 Aug 2019 14:24:51 +0300
  4. Subject: [PATCH] mac80211: IBSS: send deauth when expiring inactive STAs
  5. When we expire an inactive station, try to send it a deauth. This
  6. helps if it's actually still around, and just has issues with
  7. beacon distribution (or we do), and it will not also remove us.
  8. Then, if we have shared state, this may not be reset properly,
  9. causing problems; for example, we saw a case where aggregation
  10. sessions weren't removed properly (due to the TX start being
  11. offloaded to firmware and it relying on deauth for stop), causing
  12. a lot of traffic to get lost due to the SN reset after remove/add
  13. of the peer.
  14. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  15. Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
  16. Link: https://lore.kernel.org/r/20190830112451.21655-9-luca@coelho.fi
  17. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  18. ---
  19. net/mac80211/ibss.c | 8 ++++++++
  20. net/mac80211/ieee80211_i.h | 3 ++-
  21. net/mac80211/mlme.c | 11 ++++++-----
  22. net/mac80211/util.c | 5 +++--
  23. 4 files changed, 19 insertions(+), 8 deletions(-)
  24. --- a/net/mac80211/ibss.c
  25. +++ b/net/mac80211/ibss.c
  26. @@ -1253,6 +1253,7 @@ void ieee80211_ibss_rx_no_sta(struct iee
  27. static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
  28. {
  29. + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
  30. struct ieee80211_local *local = sdata->local;
  31. struct sta_info *sta, *tmp;
  32. unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT;
  33. @@ -1269,10 +1270,17 @@ static void ieee80211_ibss_sta_expire(st
  34. if (time_is_before_jiffies(last_active + exp_time) ||
  35. (time_is_before_jiffies(last_active + exp_rsn) &&
  36. sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
  37. + u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
  38. +
  39. sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
  40. sta->sta_state != IEEE80211_STA_AUTHORIZED ?
  41. "not authorized " : "", sta->sta.addr);
  42. + ieee80211_send_deauth_disassoc(sdata, sta->sta.addr,
  43. + ifibss->bssid,
  44. + IEEE80211_STYPE_DEAUTH,
  45. + WLAN_REASON_DEAUTH_LEAVING,
  46. + true, frame_buf);
  47. WARN_ON(__sta_info_destroy(sta));
  48. }
  49. }
  50. --- a/net/mac80211/ieee80211_i.h
  51. +++ b/net/mac80211/ieee80211_i.h
  52. @@ -2071,7 +2071,8 @@ void ieee80211_send_auth(struct ieee8021
  53. const u8 *da, const u8 *key, u8 key_len, u8 key_idx,
  54. u32 tx_flags);
  55. void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
  56. - const u8 *bssid, u16 stype, u16 reason,
  57. + const u8 *da, const u8 *bssid,
  58. + u16 stype, u16 reason,
  59. bool send_frame, u8 *frame_buf);
  60. enum {
  61. --- a/net/mac80211/mlme.c
  62. +++ b/net/mac80211/mlme.c
  63. @@ -2203,8 +2203,9 @@ static void ieee80211_set_disassoc(struc
  64. !ifmgd->have_beacon)
  65. drv_mgd_prepare_tx(sdata->local, sdata, 0);
  66. - ieee80211_send_deauth_disassoc(sdata, ifmgd->bssid, stype,
  67. - reason, tx, frame_buf);
  68. + ieee80211_send_deauth_disassoc(sdata, ifmgd->bssid,
  69. + ifmgd->bssid, stype, reason,
  70. + tx, frame_buf);
  71. }
  72. /* flush out frame - make sure the deauth was actually sent */
  73. @@ -4369,7 +4370,7 @@ void ieee80211_mgd_quiesce(struct ieee80
  74. * cfg80211 won't know and won't actually abort those attempts,
  75. * thus we need to do that ourselves.
  76. */
  77. - ieee80211_send_deauth_disassoc(sdata, bssid,
  78. + ieee80211_send_deauth_disassoc(sdata, bssid, bssid,
  79. IEEE80211_STYPE_DEAUTH,
  80. WLAN_REASON_DEAUTH_LEAVING,
  81. false, frame_buf);
  82. @@ -5349,7 +5350,7 @@ int ieee80211_mgd_deauth(struct ieee8021
  83. ieee80211_get_reason_code_string(req->reason_code));
  84. drv_mgd_prepare_tx(sdata->local, sdata, 0);
  85. - ieee80211_send_deauth_disassoc(sdata, req->bssid,
  86. + ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
  87. IEEE80211_STYPE_DEAUTH,
  88. req->reason_code, tx,
  89. frame_buf);
  90. @@ -5369,7 +5370,7 @@ int ieee80211_mgd_deauth(struct ieee8021
  91. ieee80211_get_reason_code_string(req->reason_code));
  92. drv_mgd_prepare_tx(sdata->local, sdata, 0);
  93. - ieee80211_send_deauth_disassoc(sdata, req->bssid,
  94. + ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
  95. IEEE80211_STYPE_DEAUTH,
  96. req->reason_code, tx,
  97. frame_buf);
  98. --- a/net/mac80211/util.c
  99. +++ b/net/mac80211/util.c
  100. @@ -1433,7 +1433,8 @@ void ieee80211_send_auth(struct ieee8021
  101. }
  102. void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
  103. - const u8 *bssid, u16 stype, u16 reason,
  104. + const u8 *da, const u8 *bssid,
  105. + u16 stype, u16 reason,
  106. bool send_frame, u8 *frame_buf)
  107. {
  108. struct ieee80211_local *local = sdata->local;
  109. @@ -1444,7 +1445,7 @@ void ieee80211_send_deauth_disassoc(stru
  110. mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
  111. mgmt->duration = 0; /* initialize only */
  112. mgmt->seq_ctrl = 0; /* initialize only */
  113. - memcpy(mgmt->da, bssid, ETH_ALEN);
  114. + memcpy(mgmt->da, da, ETH_ALEN);
  115. memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
  116. memcpy(mgmt->bssid, bssid, ETH_ALEN);
  117. /* u.deauth.reason_code == u.disassoc.reason_code */