[openwrt/openwrt] hostapd: fix adding back stations after a missed deauth/disassoc

LEDE Commits lede-commits at lists.infradead.org
Wed May 26 03:05:38 PDT 2021


nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/d87b58bb09100beaa4825d6c8e50c894783ca2d5

commit d87b58bb09100beaa4825d6c8e50c894783ca2d5
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Tue May 25 10:50:16 2021 +0200

    hostapd: fix adding back stations after a missed deauth/disassoc
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 ...021-fix-sta-add-after-previous-connection.patch | 26 ++++++++++++++++++++++
 .../hostapd/patches/600-ubus_support.patch         | 10 ++++-----
 .../services/hostapd/patches/700-wifi-reload.patch | 12 +++++-----
 3 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/package/network/services/hostapd/patches/021-fix-sta-add-after-previous-connection.patch b/package/network/services/hostapd/patches/021-fix-sta-add-after-previous-connection.patch
new file mode 100644
index 0000000000..124fd8bdf1
--- /dev/null
+++ b/package/network/services/hostapd/patches/021-fix-sta-add-after-previous-connection.patch
@@ -0,0 +1,26 @@
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -4942,6 +4942,13 @@ static int add_associated_sta(struct hos
+ 	 * drivers to accept the STA parameter configuration. Since this is
+ 	 * after a new FT-over-DS exchange, a new TK has been derived, so key
+ 	 * reinstallation is not a concern for this case.
++	 *
++	 * If the STA was associated and authorized earlier, but came for a new
++	 * connection (!added_unassoc + !reassoc), remove the existing STA entry
++	 * so that it can be re-added. This case is rarely seen when the AP could
++	 * not receive the deauth/disassoc frame from the STA. And the STA comes
++	 * back with new connection within a short period or before the inactive
++	 * STA entry is removed from the list.
+ 	 */
+ 	wpa_printf(MSG_DEBUG, "Add associated STA " MACSTR
+ 		   " (added_unassoc=%d auth_alg=%u ft_over_ds=%u reassoc=%d authorized=%d ft_tk=%d fils_tk=%d)",
+@@ -4955,7 +4962,8 @@ static int add_associated_sta(struct hos
+ 	    (!(sta->flags & WLAN_STA_AUTHORIZED) ||
+ 	     (reassoc && sta->ft_over_ds && sta->auth_alg == WLAN_AUTH_FT) ||
+ 	     (!wpa_auth_sta_ft_tk_already_set(sta->wpa_sm) &&
+-	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)))) {
++	      !wpa_auth_sta_fils_tk_already_set(sta->wpa_sm)) ||
++	     (!reassoc && (sta->flags & WLAN_STA_AUTHORIZED)))) {
+ 		hostapd_drv_sta_remove(hapd, sta->addr);
+ 		wpa_auth_sm_event(sta->wpa_sm, WPA_DRV_STA_REMOVED);
+ 		set = 0;
diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch
index 013b81d25b..71537c9ec6 100644
--- a/package/network/services/hostapd/patches/600-ubus_support.patch
+++ b/package/network/services/hostapd/patches/600-ubus_support.patch
@@ -126,7 +126,7 @@
  	if (res == HOSTAPD_ACL_PENDING)
  		return;
  
-@@ -5446,7 +5458,7 @@ static void handle_assoc(struct hostapd_
+@@ -5454,7 +5466,7 @@ static void handle_assoc(struct hostapd_
  	int resp = WLAN_STATUS_SUCCESS;
  	u16 reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE;
  	const u8 *pos;
@@ -135,7 +135,7 @@
  	struct sta_info *sta;
  	u8 *tmp = NULL;
  #ifdef CONFIG_FILS
-@@ -5659,6 +5671,11 @@ static void handle_assoc(struct hostapd_
+@@ -5667,6 +5679,11 @@ static void handle_assoc(struct hostapd_
  		left = res;
  	}
  #endif /* CONFIG_FILS */
@@ -147,7 +147,7 @@
  
  	/* followed by SSID and Supported rates; and HT capabilities if 802.11n
  	 * is used */
-@@ -5823,6 +5840,14 @@ static void handle_assoc(struct hostapd_
+@@ -5831,6 +5848,14 @@ static void handle_assoc(struct hostapd_
  					    pos, left, rssi, omit_rsnxe);
  	os_free(tmp);
  
@@ -162,7 +162,7 @@
  	/*
  	 * Remove the station in case transmission of a success response fails
  	 * (the STA was added associated to the driver) or if the station was
-@@ -5850,6 +5875,7 @@ static void handle_disassoc(struct hosta
+@@ -5858,6 +5883,7 @@ static void handle_disassoc(struct hosta
  	wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
  		   MAC2STR(mgmt->sa),
  		   le_to_host16(mgmt->u.disassoc.reason_code));
@@ -170,7 +170,7 @@
  
  	sta = ap_get_sta(hapd, mgmt->sa);
  	if (sta == NULL) {
-@@ -5919,6 +5945,8 @@ static void handle_deauth(struct hostapd
+@@ -5927,6 +5953,8 @@ static void handle_deauth(struct hostapd
  	/* Clear the PTKSA cache entries for PASN */
  	ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
  
diff --git a/package/network/services/hostapd/patches/700-wifi-reload.patch b/package/network/services/hostapd/patches/700-wifi-reload.patch
index ba3255b35b..5993b0d445 100644
--- a/package/network/services/hostapd/patches/700-wifi-reload.patch
+++ b/package/network/services/hostapd/patches/700-wifi-reload.patch
@@ -47,14 +47,14 @@
  	enum hostapd_logger_level logger_syslog_level, logger_stdout_level;
  
  	unsigned int logger_syslog; /* module bitfield */
-@@ -782,6 +784,7 @@ struct hostapd_bss_config {
- 	int airtime_limit;
- 	struct airtime_sta_weight *airtime_weight_list;
- #endif /* CONFIG_AIRTIME_POLICY */
+@@ -938,6 +940,7 @@ struct spatial_reuse {
+ struct hostapd_config {
+ 	struct hostapd_bss_config **bss, *last_bss;
+ 	size_t num_bss;
 +	char *config_id;
  
- #ifdef CONFIG_MACSEC
- 	/**
+ 	u16 beacon_int;
+ 	int rts_threshold;
 --- a/src/ap/hostapd.c
 +++ b/src/ap/hostapd.c
 @@ -219,6 +219,10 @@ static int hostapd_iface_conf_changed(st



More information about the lede-commits mailing list