station: reorder AP roam logic

There are a few checks that can be done prior to parsing the
request, in addition the explicit check for preparing_roam was
removed since this is taken care of by station_cannot_roam().
This commit is contained in:
James Prestwood 2022-09-28 09:36:32 -07:00 committed by Denis Kenzior
parent 8d224624fc
commit f3b31e48e0
1 changed files with 25 additions and 30 deletions

View File

@ -2763,6 +2763,31 @@ static void station_ap_directed_roam(struct station *station,
if (station_cannot_roam(station))
return;
if (station->state != STATION_STATE_CONNECTED) {
l_debug("roam: unexpected AP directed roam -- ignore");
return;
}
/*
* Sanitize the frame to check that it is from our current AP.
*
* 802.11-2020 Section 9.3.3.1 about Address2:
* "If the STA is an AP with dot11MultiBSSDImplemented set to false,
* then this address is the BSSID."
*
* Address3:
* "If the STA is an AP or PCP, the Address 3 field is the same as the
* Address 2 field."
*
* For now check that Address2 & Address3 is the same as the connected
* BSS address.
*/
if (memcmp(hdr->address_2, station->connected_bss, ETH_ALEN) ||
memcmp(hdr->address_2, hdr->address_3, ETH_ALEN)) {
l_debug("roam: AP directed roam not from our AP -- ignore");
return;
}
if (body_len < 7)
goto format_error;
@ -2816,36 +2841,6 @@ static void station_ap_directed_roam(struct station *station,
pos += url_len;
}
if (station->state != STATION_STATE_CONNECTED) {
l_debug("roam: unexpected AP directed roam -- ignore");
return;
}
/*
* Sanitize the frame to check that it is from our current AP.
*
* 802.11-2020 Section 9.3.3.1 about Address2:
* "If the STA is an AP with dot11MultiBSSDImplemented set to false,
* then this address is the BSSID."
*
* Address3:
* "If the STA is an AP or PCP, the Address 3 field is the same as the
* Address 2 field."
*
* For now check that Address2 & Address3 is the same as the connected
* BSS address.
*/
if (memcmp(hdr->address_2, station->connected_bss, ETH_ALEN) ||
memcmp(hdr->address_2, hdr->address_3, ETH_ALEN)) {
l_debug("roam: AP directed roam not from our AP -- ignore");
return;
}
if (station->preparing_roam) {
l_debug("roam: roam attempt already in progress -- ignore");
return;
}
station->ap_directed_roaming = true;
station->preparing_roam = true;