[PATCH 1/2] Refactor nl80211 mode switch logic

Jouni Malinen j at w1.fi
Sat Jun 28 03:49:06 EDT 2014


On Thu, Jun 26, 2014 at 01:13:06PM -0700, Christopher Wiley wrote:
> In preparation for another wrinkle around switching into IBSS mode,
> refactor existing mode switch logic for simplicity at the expense
> of some brevity.

> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> @@ -9071,24 +9072,24 @@ static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
>  	wpa_printf(MSG_DEBUG, "nl80211: Try mode change after setting "
>  		   "interface down");
>  	for (i = 0; i < 10; i++) {
> +		os_sleep(0, 100000);
>  		res = i802_set_iface_flags(bss, 0);

This part of moving the delay to happen unconditionally before the first
attempt at setting the interface down does not look desired. This would
block all wpa_supplicant operations for 100 ms in a case that is common
with number of drivers. I'm considering this patch with the delay moved
back to after the failure cases:

> -		} else
> +		if (res != 0) {
>  			wpa_printf(MSG_DEBUG, "nl80211: Failed to set "
>  				   "interface down");
> -		os_sleep(0, 100000);
> +			continue;
> +		}

i.e., just before the continue here

> +		/* Try to set the mode again while the interface is down */
> +		mode_switch_res = nl80211_set_mode(drv, drv->ifindex, nlmode);
> +		if (mode_switch_res == -EBUSY) {
> +			wpa_printf(MSG_DEBUG, "nl80211: Delaying mode set "
> +				   "while interface going down.");
> +			continue;
> +		}

and here

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list