[PATCH] supplicant: Allow simple bgscan to do btm queries.

Jouni Malinen j at w1.fi
Sun Nov 5 09:55:56 PST 2023


On Thu, Jun 08, 2023 at 04:54:01PM -0700, greearb at candelatech.com wrote:
> Allow doing X bss_transition_mgmt_query calls before falling back to
> scan.
> 
> Example format to do 4 btm before attempting a scan: bgscan="simple:30:-65:300:4"

> diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c
> @@ -36,6 +40,22 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx)
> +	if (data->use_wnm_query && !wpa_s->conf->disable_btm) {

wnm_query is a misleading name since WNM includes much more than just
BTM.. btm_query would be clearer.

This should check whether the current AP supports BTM before deciding to
use BTM queries instead of scans.

> +		int mod;
> +
> +		/* try wnm x times, scan on x + 1 */
> +		data->scan_action_count++;
> +		mod = data->scan_action_count % (data->use_wnm_query + 1);
> +		if (mod < data->use_wnm_query) {
> +			wpa_printf(MSG_DEBUG, "bgscan simple: Send bss transition mgt query %d/%d",
> +				   mod, data->use_wnm_query);
> +			if (wnm_send_bss_transition_mgmt_query(wpa_s, 6 /* better AP found */, NULL, 0))
> +				wpa_printf(MSG_DEBUG, "bgscan simple: Failed send bss transition mgt query");
> +			else
> +				goto scan_ok;
> +		}
> +	}

This success case would skip starting of the scan and this timeout on
failure:

>  	os_memset(&params, 0, sizeof(params));
>  	params.num_ssids = 1;
>  	params.ssids[0].ssid = data->ssid->ssid;
> @@ -58,6 +78,7 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx)
>  		eloop_register_timeout(data->scan_interval, 0,
>  				       bgscan_simple_timeout, data, NULL);
>  	} else {
> +	scan_ok:
>  		if (data->scan_interval == data->short_interval) {
>  			data->short_scan_count++;
>  			if (data->short_scan_count >= data->max_short_scans) {

And instead, would not leave any new trigger to get
bgscan_simple_timeout called again. In other words, this would leave
bgscan stuck not doing anything. The BTM query case should schedule a
new timeout to cover cases where BTM request is not received and also to
cover cases where BTM request is received but no transition is
performed.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list