From a8187468b534aa49a13e51ff96d5ca4581207446 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 17 Sep 2019 09:49:53 -0700 Subject: [PATCH] station: optimize roam scanning If neighbor reports are unavailable, or the report yielded no results we can quickly scan for only known frequencies. This changes the original behavior where we would do a full scan in this case. --- src/station.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/station.c b/src/station.c index 88985b1d..a89c44d1 100644 --- a/src/station.c +++ b/src/station.c @@ -1696,6 +1696,25 @@ static void station_roam_scan(struct station *station, station_roam_failed(station); } +static bool station_roam_scan_known_freqs(struct station *station) +{ + const struct network_info *info = network_get_info( + station->connected_network); + struct scan_freq_set *freqs = network_info_get_roam_frequencies(info, + station->connected_bss->frequency, 5); + + if (!freqs) { + l_debug("no known frequencies to scan"); + return false; + } + + station_roam_scan(station, freqs); + + scan_freq_set_free(freqs); + + return true; +} + static uint32_t station_freq_from_neighbor_report(const uint8_t *country, struct ie_neighbor_report_info *info, enum scan_band *out_band) { @@ -1765,8 +1784,10 @@ static void station_neighbor_report_cb(struct netdev *netdev, int err, return; if (!reports || err) { - /* Have to do a full scan */ - station_roam_scan(station, NULL); + if (!station_roam_scan_known_freqs(station)) { + l_debug("no neighbor report results or known freqs"); + station_roam_failed(station); + } return; } @@ -1895,8 +1916,11 @@ static void station_roam_trigger_cb(struct l_timeout *timeout, void *user_data) station_neighbor_report_cb)) return; - /* Otherwise do a full scan for target BSS candidates */ - station_roam_scan(station, NULL); + if (!station_roam_scan_known_freqs(station)) { + l_debug("No neighbor report or known frequencies, roam failed"); + station_roam_failed(station); + return; + } } static void station_roam_timeout_rearm(struct station *station, int seconds)