[PATCH] Fix scan retry after a failure

Jouni Malinen j
Sat Oct 9 07:47:11 PDT 2010


On Wed, Oct 06, 2010 at 03:46:46PM +0300, Kalle Valo wrote:
> With broadcom's "wl" driver the first scan always fails. (Apparently it also
> doesn't send scan results ready signals, but let's forget it for now.) With
> connman's five minute scan interval it meant that it would take five minutes
> from boot until a wireless connection was established.
> 
> The reason is that currently wpasupplicant doesn't handle scan retries
> and it goes directly to INACTIVE state:
> 
> 14:23:09 wpa_supplicant[1046]: Scan timeout - try to get results
> 14:23:09 wpa_supplicant[1046]: Failed to get scan results
> 14:23:09 wpa_supplicant[1046]: Failed to get scan results - try scanning again
> 14:23:09 wpa_supplicant[1046]: State: SCANNING -> INACTIVE
> 
> Instead of going to INACTIVE set wpa_s->scan_req to make it explicit
> that this is a requested scan and fix check in wpa_supplicant_req_new_scan().

I would be fine with this for the case where the initial scan is
failing. However, I'm not sure I would really like to see this hitting
for other possible error cases, i.e., I don't want this to have a
possibility of hitting a look where a new scan is requested one second
after failure to get scan results regardless of the current state..

> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> index 85dcfb2..16373da 100644
> --- a/wpa_supplicant/events.c
> +++ b/wpa_supplicant/events.c
> @@ -700,11 +700,12 @@ wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
>  static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
>  					int timeout_sec, int timeout_usec)
>  {
> -	if (!wpa_supplicant_enabled_networks(wpa_s->conf)) {
> +	if (!wpa_supplicant_enabled_networks(wpa_s->conf) &&
> +	    !wpa_s->scan_req) {

This is fine.

> @@ -893,6 +894,7 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
>  			return;
>  		wpa_printf(MSG_DEBUG, "Failed to get scan results - try "
>  			   "scanning again");
> +		wpa_s->scan_req = 2;
>  		wpa_supplicant_req_new_scan(wpa_s, 1, 0);
>  		return;
>  	}

This, I would hope to be done only if the failure happened on the
initial scan attempt and in that case, wpa_s->scan_req = 1 may be better
option here since that matches with the value used in the initial scan.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list