Optimize internal BSS table updates based on a specific BSSID

When wpa_supplicant needed to update the internal BSS table with the
latest scan results from the driver, it fetched all BSSs and processed
them all. This is unnecessary for cases where an update is needed only
for a specific BSS. Optimize this by filtering out the unnecessary
entries from the results.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2024-03-20 11:20:43 +02:00 committed by Jouni Malinen
parent 8d0bd7f9c8
commit 5b4a78b1f9
16 changed files with 69 additions and 33 deletions

View file

@ -3166,6 +3166,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
* @wpa_s: Pointer to wpa_supplicant data
* @info: Information about what was scanned or %NULL if not available
* @new_scan: Whether a new scan was performed
* @bssid: Return BSS entries only for a single BSSID, %NULL for all
* Returns: Scan results, %NULL on failure
*
* This function request the current scan results from the driver and updates
@ -3174,13 +3175,14 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
*/
struct wpa_scan_results *
wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
struct scan_info *info, int new_scan)
struct scan_info *info, int new_scan,
const u8 *bssid)
{
struct wpa_scan_results *scan_res;
size_t i;
int (*compar)(const void *, const void *) = wpa_scan_result_compar;
scan_res = wpa_drv_get_scan_results2(wpa_s);
scan_res = wpa_drv_get_scan_results(wpa_s, bssid);
if (scan_res == NULL) {
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results");
return NULL;
@ -3238,6 +3240,7 @@ wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
/**
* wpa_supplicant_update_scan_results - Update scan results from the driver
* @wpa_s: Pointer to wpa_supplicant data
* @bssid: Update BSS entries only for a single BSSID, %NULL for all
* Returns: 0 on success, -1 on failure
*
* This function updates the BSS table within wpa_supplicant based on the
@ -3247,10 +3250,11 @@ wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
* needed information to complete the connection (e.g., to perform validation
* steps in 4-way handshake).
*/
int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s)
int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s,
const u8 *bssid)
{
struct wpa_scan_results *scan_res;
scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0);
scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0, bssid);
if (scan_res == NULL)
return -1;
wpa_scan_results_free(scan_res);