[PATCH v2] wext: handle mode switches correctly for mac80211

Jouni Malinen j
Mon Sep 29 06:53:40 PDT 2008


On Tue, Sep 02, 2008 at 09:37:43AM -0400, Dan Williams wrote:
> On Fri, 2008-08-29 at 12:57 -0400, Dan Williams wrote: 
> > The basic problem is that since taking the device down clears the keys
> > from the driver on many mac80211-based cards, and since the mode gets
> > set _after_ the keys have been set in the driver, the keys get cleared
> > on a mode switch and the resulting association is wrong.  The report is
> > about ad-hoc mode specifically, but this could happen when switching
> > from adhoc back to managed mode.
> > 
> > Fabrice suggested using WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC for the
> > driver, but it seems to me that setting the mode as _early_ as possible
> > is the best thing to do.  Perhaps create another driver hook for
> > set_mode and call that (if needed) very early in
> > wpa_supplicant_associate() around line 924:

Agreed, this is indeed better way of solving the problem.
WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC was a workaround for similar
problem with NDIS drivers where oper mode changes cleared keys. However,
it looks like it is not used in any of the driver wrappers included in
the wpa_supplicant package. driver_ndis.c has some ugly workaround code
for setting the keys again inside the associate() handler. I would
assume that this can be removed once the new wpa_driver_ops handler
becomes available.

> Two patches attached, the "big" patch moves every driver over to
> set_mode(), while the "small" patch just adds the hook and moves the
> nl80211 and wext drivers over.

Thanks! I don't want to break backwards compatibility of the
wpa_driver_ops API and as such, I'm applying the "small" patch. Please
note that I moved the set_mode() function pointer into the end of
wpa_driver_ops and added bit more detailed comments on this handler
function.

Once I get a chance to test this bit more, I would assume the
driver_ndis.c part from "big" patch should also be included and
likewise, a change to make driver_privsep.c support this new handler
function (though, that is going to be a bit different from the one in
your "big" patch).

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list