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

Mykyta Iziumtsev mykyta.iziumtsev
Fri Sep 28 00:52:51 PDT 2012


On Fri, Sep 28, 2012 at 9:32 AM, Johannes Berg
<johannes at sipsolutions.net> wrote:
> 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.

This code is actually workaround for older versions of mac80211 returning
-EALREADY when we're already connected to some BSS. Please refer to
commit 6d6f4bb87f33278aed133875d0d561eb55d7ae59 in hostap.git .

So, we should expect -EALREADY not only in "already authenticated with this BSS"
case, but in "already authenticated with *any* BSS" case.

Of course, mac80211 doesn't have this problem any more when userspace
SME is in use, but it still returns -EALREADY when "connect" API is used
(in compat-wireless-3.2.5-1).

>> @@ -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?

Right, I'll split the patch into two.

> johannes
>



More information about the Hostap mailing list