WNM: Ignore WNM-Sleep Mode Response if WNM-Sleep Mode has not been used
authorJouni Malinen <j@w1.fi>
Sun, 25 Oct 2015 21:02:14 +0000 (23:02 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 10 Nov 2015 16:40:54 +0000 (18:40 +0200)
The AP is not expected to send out a WNM-Sleep Mode Response frame
without the STA trying to use WNM-Sleep Mode. Drop such unexpected
responses to reduce unnecessary processing of the frame.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/events.c
wpa_supplicant/wnm_sta.c
wpa_supplicant/wpa_supplicant_i.h

index 9538c51..6113db6 100644 (file)
@@ -6905,6 +6905,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        }
 
        eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
+       wpa_s->wnmsleep_used = 0;
 }
 
 
index aab752c..06d08e7 100644 (file)
@@ -303,6 +303,7 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        wpa_s->key_mgmt = 0;
 
        wpas_rrm_reset(wpa_s);
+       wpa_s->wnmsleep_used = 0;
 }
 
 
index 9ab40c7..e1596cb 100644 (file)
@@ -139,6 +139,8 @@ int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s,
        if (res < 0)
                wpa_printf(MSG_DEBUG, "Failed to send WNM-Sleep Request "
                           "(action=%d, intval=%d)", action, intval);
+       else
+               wpa_s->wnmsleep_used = 1;
 
        os_free(wnmsleep_ie);
        os_free(wnmtfs_ie);
@@ -255,6 +257,12 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
        const u8 *tfsresp_ie_end = NULL;
        size_t left;
 
+       if (!wpa_s->wnmsleep_used) {
+               wpa_printf(MSG_DEBUG,
+                          "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode has not been used in this association");
+               return;
+       }
+
        if (len < 3)
                return;
        key_len_total = WPA_GET_LE16(frm + 1);
index fc5fc17..5caa63e 100644 (file)
@@ -669,6 +669,7 @@ struct wpa_supplicant {
        unsigned int reattach:1; /* reassociation to the same BSS requested */
        unsigned int mac_addr_changed:1;
        unsigned int added_vif:1;
+       unsigned int wnmsleep_used:1;
 
        struct os_reltime last_mac_addr_change;
        int last_mac_addr_style;