]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WNM: Lower rankings of current AP if disassociation imminent bit set
authorPo-Hao Huang <phhuang@realtek.com>
Fri, 9 Jun 2023 09:26:43 +0000 (17:26 +0800)
committerJouni Malinen <j@w1.fi>
Sat, 28 Oct 2023 14:43:30 +0000 (17:43 +0300)
If the current AP advertises disassociation imminent, move it to the
back of the candidate list so we don't select it again while other
candidates are available.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
wpa_supplicant/wnm_sta.c
wpa_supplicant/wnm_sta.h

index ac0dd1aa046b5208621a85d349aed2cb410e1a81..5b3de30d5ecadc3e9949f4339d15277689522ce0 100644 (file)
@@ -1207,6 +1207,11 @@ static int cand_pref_compar(const void *a, const void *b)
        const struct neighbor_report *aa = a;
        const struct neighbor_report *bb = b;
 
+       if (aa->disassoc_imminent && !bb->disassoc_imminent)
+               return 1;
+       if (bb->disassoc_imminent && !aa->disassoc_imminent)
+               return -1;
+
        if (!aa->preference_present && !bb->preference_present)
                return 0;
        if (!aa->preference_present)
@@ -1485,8 +1490,6 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
                wpa_msg(wpa_s, MSG_INFO, "WNM: Disassociation Imminent - "
                        "Disassociation Timer %u", wpa_s->wnm_dissoc_timer);
                if (wpa_s->wnm_dissoc_timer && !wpa_s->scanning) {
-                       /* TODO: mark current BSS less preferred for
-                        * selection */
                        wpa_printf(MSG_DEBUG, "Trying to find another BSS");
                        wpa_supplicant_req_scan(wpa_s, 0, 0);
                }
@@ -1526,6 +1529,12 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
                                rep = &wpa_s->wnm_neighbor_report_elements[
                                        wpa_s->wnm_num_neighbor_report];
                                wnm_parse_neighbor_report(wpa_s, pos, len, rep);
+                               if ((wpa_s->wnm_mode &
+                                    WNM_BSS_TM_REQ_DISASSOC_IMMINENT) &&
+                                   os_memcmp(rep->bssid, wpa_s->bssid,
+                                             ETH_ALEN) == 0)
+                                       rep->disassoc_imminent = 1;
+
                                wpa_s->wnm_num_neighbor_report++;
 #ifdef CONFIG_MBO
                                if (wpa_s->wnm_mbo_trans_reason_present &&
index 29625f8ca943e62ad955087585573ab5470c3dbd..e4957e48aa202b857121b4292da1df7d1ddab52b 100644 (file)
@@ -37,6 +37,7 @@ struct neighbor_report {
        u32 distance; /* valid if bearing_present=1 */
        u64 bss_term_tsf; /* valid if bss_term_present=1 */
        u16 bss_term_dur; /* valid if bss_term_present=1 */
+       unsigned int disassoc_imminent:1;
        unsigned int preference_present:1;
        unsigned int tsf_present:1;
        unsigned int country_present:1;