[PATCH] Use correct BSSID for deauth/disconnect in mac80211 EALREADY workaround

Johannes Berg johannes
Fri Sep 28 00:32:14 PDT 2012


On Wed, 2012-09-26 at 16:52 +0200, Mykyta Iziumtsev wrote:

> @@ -4648,7 +4650,7 @@ retry:
>  			"nl80211: MLME command failed (auth): ret=%d (%s)",
>  			ret, strerror(-ret));
>  		count++;
> -		if (ret == -EALREADY && count == 1 && params->bssid &&
> +		if (ret == -EALREADY && count == 1 &&
>  		    !params->local_state_change) {
>  			/*
>  			 * mac80211 does not currently accept new
> @@ -4658,7 +4660,7 @@ retry:
>  			wpa_printf(MSG_DEBUG, "nl80211: Retry authentication "
>  				   "after forced deauthentication");
>  			wpa_driver_nl80211_deauthenticate(
> -				bss, params->bssid,
> +				bss, prev_auth_bssid,
>  				WLAN_REASON_PREV_AUTH_NOT_VALID);
>  			nlmsg_free(msg);
>  			goto retry;

I'm not convinced this is correct. If cfg80211 returns -EALREADY, it
means "already authenticated with this BSS". So it seems using
params->bssid here would be correct in order to re-authenticate.

The case where we can't authenticate because it's already authenticated
with more APs than it would like to track will return -ENOSPC. Note like
I said, starting from kernel 3.4 all this went away.

> @@ -6617,51 +6619,11 @@ nla_put_failure:
>  }
> 
> 
> -static unsigned int nl80211_get_assoc_bssid(struct
> wpa_driver_nl80211_data *drv,
> -					    u8 *bssid)
> +static int nl80211_disconnect(struct wpa_driver_nl80211_data *drv)
>  {
> -	struct nl_msg *msg;
> -	int ret;
> -	struct nl80211_bss_info_arg arg;
> -
> -	os_memset(&arg, 0, sizeof(arg));
> -	msg = nlmsg_alloc();
> -	if (!msg)
> -		goto nla_put_failure;
> -
> -	nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SCAN);
> -	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
> -
> -	arg.drv = drv;
> -	ret = send_and_recv_msgs(drv, msg, bss_info_handler, &arg);
> -	msg = NULL;
> -	if (ret == 0) {
> -		if (is_zero_ether_addr(arg.assoc_bssid))
> -			return -ENOTCONN;
> -		os_memcpy(bssid, arg.assoc_bssid, ETH_ALEN);
> -		return 0;
> -	}
> -	wpa_printf(MSG_DEBUG, "nl80211: Scan result fetch failed: ret=%d "
> -		   "(%s)", ret, strerror(-ret));
> -nla_put_failure:
> -	nlmsg_free(msg);
> -	return drv->assoc_freq;
> -}
> -
> -
> -static int nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
> -			      const u8 *bssid)
> -{
> -	u8 addr[ETH_ALEN];
> -
> -	if (bssid == NULL) {
> -		int res = nl80211_get_assoc_bssid(drv, addr);
> -		if (res)
> -			return res;
> -		bssid = addr;
> -	}
> -
> -	return wpa_driver_nl80211_disconnect(drv, bssid,
> +	u8 zero_addr[ETH_ALEN];
> +	os_memset(zero_addr, 0, ETH_ALEN);
> +	return wpa_driver_nl80211_disconnect(drv, zero_addr,
>  					     WLAN_REASON_PREV_AUTH_NOT_VALID);
>  }

Maybe this part should be a separate patch since it's a simplification
due to the fact that DISCONNECT doesn't care about the BSSID?

johannes




More information about the Hostap mailing list