Skip to content

Commit

Permalink
cfg80211: stop tracking authenticated state
Browse files Browse the repository at this point in the history
To track authenticated state seems to have been
a design mistake in cfg80211. It is possible to
have out of band authentication (FT), tracking
multiple authentications caused more problems
than it ever helped, and the implementation in
mac80211 is too complex.

Remove all this complexity, and let userspace
do whatever it wants to, mac80211 can deal with
that just fine. Association is still tracked of
course, but authentication no longer is. Local
auth state changes are thus no longer of value,
so ignore them completely.

This will also help implement SAE -- asking the
driver to do an authentication is now almost
equivalent to sending an authentication frame,
with the exception of shared key authentication
which is still handled completely.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Feb 6, 2012
1 parent 7852e36 commit 95de817
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 362 deletions.
1 change: 0 additions & 1 deletion Documentation/DocBook/80211.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
!Finclude/net/cfg80211.h cfg80211_pmksa
!Finclude/net/cfg80211.h cfg80211_send_rx_auth
!Finclude/net/cfg80211.h cfg80211_send_auth_timeout
!Finclude/net/cfg80211.h __cfg80211_auth_canceled
!Finclude/net/cfg80211.h cfg80211_send_rx_assoc
!Finclude/net/cfg80211.h cfg80211_send_assoc_timeout
!Finclude/net/cfg80211.h cfg80211_send_deauth
Expand Down
39 changes: 11 additions & 28 deletions include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,6 @@ const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
* @key_len: length of WEP key for shared key authentication
* @key_idx: index of WEP key for shared key authentication
* @key: WEP key for shared key authentication
* @local_state_change: This is a request for a local state only, i.e., no
* Authentication frame is to be transmitted and authentication state is
* to be changed without having to wait for a response from the peer STA
* (AP).
*/
struct cfg80211_auth_request {
struct cfg80211_bss *bss;
Expand All @@ -1051,7 +1047,6 @@ struct cfg80211_auth_request {
enum nl80211_auth_type auth_type;
const u8 *key;
u8 key_len, key_idx;
bool local_state_change;
};

/**
Expand All @@ -1068,7 +1063,11 @@ enum cfg80211_assoc_req_flags {
*
* This structure provides information needed to complete IEEE 802.11
* (re)association.
* @bss: The BSS to associate with.
* @bss: The BSS to associate with. If the call is successful the driver
* is given a reference that it must release, normally via a call to
* cfg80211_send_rx_assoc(), or, if association timed out, with a
* call to cfg80211_put_bss() (in addition to calling
* cfg80211_send_assoc_timeout())
* @ie: Extra IEs to add to (Re)Association Request frame or %NULL
* @ie_len: Length of ie buffer in octets
* @use_mfp: Use management frame protection (IEEE 802.11w) in this association
Expand Down Expand Up @@ -1096,19 +1095,16 @@ struct cfg80211_assoc_request {
* This structure provides information needed to complete IEEE 802.11
* deauthentication.
*
* @bss: the BSS to deauthenticate from
* @bssid: the BSSID of the BSS to deauthenticate from
* @ie: Extra IEs to add to Deauthentication frame or %NULL
* @ie_len: Length of ie buffer in octets
* @reason_code: The reason code for the deauthentication
* @local_state_change: This is a request for a local state only, i.e., no
* Deauthentication frame is to be transmitted.
*/
struct cfg80211_deauth_request {
struct cfg80211_bss *bss;
const u8 *bssid;
const u8 *ie;
size_t ie_len;
u16 reason_code;
bool local_state_change;
};

/**
Expand Down Expand Up @@ -2206,8 +2202,6 @@ struct cfg80211_conn;
struct cfg80211_internal_bss;
struct cfg80211_cached_keys;

#define MAX_AUTH_BSSES 4

/**
* struct wireless_dev - wireless per-netdev state
*
Expand Down Expand Up @@ -2271,8 +2265,6 @@ struct wireless_dev {
struct list_head event_list;
spinlock_t event_lock;

struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES];
struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES];
struct cfg80211_internal_bss *current_bss; /* associated / joined */
struct ieee80211_channel *channel;

Expand Down Expand Up @@ -2763,21 +2755,11 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len);
*/
void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr);

/**
* __cfg80211_auth_canceled - notify cfg80211 that authentication was canceled
* @dev: network device
* @addr: The MAC address of the device with which the authentication timed out
*
* When a pending authentication had no action yet, the driver may decide
* to not send a deauth frame, but in that case must calls this function
* to tell cfg80211 about this decision. It is only valid to call this
* function within the deauth() callback.
*/
void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr);

/**
* cfg80211_send_rx_assoc - notification of processed association
* @dev: network device
* @bss: the BSS struct association was requested for, the struct reference
* is owned by cfg80211 after this call
* @buf: (re)association response frame (header + body)
* @len: length of the frame data
*
Expand All @@ -2786,7 +2768,8 @@ void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr);
* function or cfg80211_send_assoc_timeout() to indicate the result of
* cfg80211_ops::assoc() call. This function may sleep.
*/
void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len);
void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss,
const u8 *buf, size_t len);

/**
* cfg80211_send_assoc_timeout - notification of timed out association
Expand Down
23 changes: 8 additions & 15 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,9 +2459,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
struct ieee80211_work *wk;
u16 auth_alg;

if (req->local_state_change)
return 0; /* no need to update mac80211 state */

switch (req->auth_type) {
case NL80211_AUTHTYPE_OPEN_SYSTEM:
auth_alg = WLAN_AUTH_OPEN;
Expand Down Expand Up @@ -2593,7 +2590,7 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
sta_info_destroy_addr(wk->sdata, cbss->bssid);
}

cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len);
cfg80211_send_rx_assoc(wk->sdata->dev, cbss, skb->data, skb->len);
destroy:
if (wk->assoc.synced)
drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
Expand Down Expand Up @@ -2750,13 +2747,12 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
{
struct ieee80211_local *local = sdata->local;
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
u8 bssid[ETH_ALEN];
bool assoc_bss = false;

mutex_lock(&ifmgd->mtx);

memcpy(bssid, req->bss->bssid, ETH_ALEN);
if (ifmgd->associated == req->bss) {
if (ifmgd->associated &&
memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) {
ieee80211_set_disassoc(sdata, false, true);
mutex_unlock(&ifmgd->mtx);
assoc_bss = true;
Expand All @@ -2777,7 +2773,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
tmp->type != IEEE80211_WORK_ASSOC_BEACON_WAIT)
continue;

if (memcmp(req->bss->bssid, tmp->filter_ta, ETH_ALEN))
if (memcmp(req->bssid, tmp->filter_ta, ETH_ALEN))
continue;

not_auth_yet = tmp->type == IEEE80211_WORK_DIRECT_PROBE;
Expand Down Expand Up @@ -2811,18 +2807,15 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
* frame, and if it's IDLE we have completed the auth
* process already.
*/
if (not_auth_yet) {
__cfg80211_auth_canceled(sdata->dev, bssid);
if (not_auth_yet)
return 0;
}
}

printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n",
sdata->name, bssid, req->reason_code);
sdata->name, req->bssid, req->reason_code);

ieee80211_send_deauth_disassoc(sdata, bssid, IEEE80211_STYPE_DEAUTH,
req->reason_code, cookie,
!req->local_state_change);
ieee80211_send_deauth_disassoc(sdata, req->bssid, IEEE80211_STYPE_DEAUTH,
req->reason_code, cookie, true);
if (assoc_bss)
sta_info_flush(sdata->local, sdata);

Expand Down
9 changes: 4 additions & 5 deletions net/wireless/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,13 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
const u8 *bssid,
const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len,
const u8 *key, int key_len, int key_idx,
bool local_state_change);
const u8 *key, int key_len, int key_idx);
int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct ieee80211_channel *chan,
enum nl80211_auth_type auth_type, const u8 *bssid,
const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len,
const u8 *key, int key_len, int key_idx,
bool local_state_change);
const u8 *key, int key_len, int key_idx);
int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct ieee80211_channel *chan,
Expand Down Expand Up @@ -421,7 +419,8 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
size_t ie_len, u16 reason, bool from_ap);
void cfg80211_sme_scan_done(struct net_device *dev);
void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len);
void cfg80211_sme_disassoc(struct net_device *dev, int idx);
void cfg80211_sme_disassoc(struct net_device *dev,
struct cfg80211_internal_bss *bss);
void __cfg80211_scan_done(struct work_struct *wk);
void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak);
void __cfg80211_sched_scan_results(struct work_struct *wk);
Expand Down
Loading

0 comments on commit 95de817

Please sign in to comment.