[PATCH] wext: don't force-disconnect in ad-hoc mode

Dan Williams dcbw
Tue May 12 10:22:11 PDT 2009


On Tue, 2009-05-12 at 13:10 -0400, Dan Williams wrote:
> Otherwise the driver might interpret the request as a request to
> create/join a new adhoc network with the bogus SSID.
> 
> Signed-off-by: Dan Williams <dcbw at redhat.com>

For reference, I believe this issue is the cause of:

https://bugzilla.redhat.com/show_bug.cgi?id=497771

at least, the logic seems plausible in my mind :)  NM does call the
control interface's 'disconnect' method when it tears down a wifi
network, and that in turn should cause the mlme_disassociate() method to
get called, which I believe is what triggers the bug.

Dan

> diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
> index e6242da..698e4f3 100644
> --- a/src/drivers/driver_wext.c
> +++ b/src/drivers/driver_wext.c
> @@ -1923,21 +1923,35 @@ static int wpa_driver_wext_mlme(struct wpa_driver_wext_data *drv,
>  
>  static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
>  {
> +	struct iwreq iwr;
>  	const u8 null_bssid[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
>  	u8 ssid[32];
>  	int i;
>  
> -	/*
> -	 * Clear the BSSID selection and set a random SSID to make sure the
> -	 * driver will not be trying to associate with something even if it
> -	 * does not understand SIOCSIWMLME commands (or tries to associate
> -	 * automatically after deauth/disassoc).
> +	/* Only force-disconnect when the card is in infrastructure mode,
> +	 * otherwise the driver might interpret the cleared BSSID and random
> +	 * SSID as an attempt to create a new ad-hoc network.
>  	 */
> -	wpa_driver_wext_set_bssid(drv, null_bssid);
> +	os_memset(&iwr, 0, sizeof(iwr));
> +	os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
> +	if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) {
> +		perror("ioctl[SIOCGIWMODE]");
> +		iwr.u.mode = IW_MODE_INFRA;
> +	}
>  
> -	for (i = 0; i < 32; i++)
> -		ssid[i] = rand() & 0xFF;
> -	wpa_driver_wext_set_ssid(drv, ssid, 32);
> +	if (iwr.u.mode == IW_MODE_INFRA) {
> +		/*
> +		 * Clear the BSSID selection and set a random SSID to make sure
> +		 * the driver will not be trying to associate with something
> +		 * even if it does not understand SIOCSIWMLME commands (or tries
> +		 * to associate automatically after deauth/disassoc).
> +		 */
> +		wpa_driver_wext_set_bssid(drv, null_bssid);
> +
> +		for (i = 0; i < 32; i++)
> +			ssid[i] = rand() & 0xFF;
> +		wpa_driver_wext_set_ssid(drv, ssid, 32);
> +	}
>  }
>  
> 
> @@ -1947,8 +1961,8 @@ static int wpa_driver_wext_deauthenticate(void *priv, const u8 *addr,
>  	struct wpa_driver_wext_data *drv = priv;
>  	int ret;
>  	wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
> -	wpa_driver_wext_disconnect(drv);
>  	ret = wpa_driver_wext_mlme(drv, addr, IW_MLME_DEAUTH, reason_code);
> +	wpa_driver_wext_disconnect(drv);
>  	return ret;
>  }
>  
> 
> _______________________________________________
> HostAP mailing list
> HostAP at lists.shmoo.com
> http://lists.shmoo.com/mailman/listinfo/hostap




More information about the Hostap mailing list