hostapd: fix adding back stations after a missed deauth/disassoc
authorFelix Fietkau <nbd@nbd.name>
Tue, 25 May 2021 08:50:16 +0000 (10:50 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 26 May 2021 09:48:14 +0000 (11:48 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/patches/021-fix-sta-add-after-previous-connection.patch [new file with mode: 0644]
package/network/services/hostapd/patches/600-ubus_support.patch
package/network/services/hostapd/patches/700-wifi-reload.patch

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 (file)
index 0000000..124fd8b
--- /dev/null
@@ -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;
index 013b81d25be10ed61cdee3700efbe8a998b27442..71537c9ec6f53c8fc77c3765007400b92eb58de5 100644 (file)
        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;
        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 */
  
        /* 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);
  
        /*
         * 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));
  
        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);
  
index ba3255b35b58b92ad117b63d4cbcbb6c4dbe4d9d..5993b0d44503ed5f4f8c0c32445e8c7a8706682c 100644 (file)
        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