Commit 91bf9b26 authored by Johannes Berg's avatar Johannes Berg

cfg80211: remove some locked wrappers from mlme API

By making all the API functions require wdev locking we
can clean up the API a bit, getting rid of the locking
version of each function. This also decreases the size
of cfg80211 by a small amount.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 38fd2143
...@@ -282,7 +282,7 @@ int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, ...@@ -282,7 +282,7 @@ int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
struct net_device *dev); struct net_device *dev);
/* MLME */ /* MLME */
int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
enum nl80211_auth_type auth_type, enum nl80211_auth_type auth_type,
...@@ -291,29 +291,12 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, ...@@ -291,29 +291,12 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
const u8 *ie, int ie_len, const u8 *ie, int ie_len,
const u8 *key, int key_len, int key_idx, const u8 *key, int key_len, int key_idx,
const u8 *sae_data, int sae_data_len); const u8 *sae_data, int sae_data_len);
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,
const u8 *sae_data, int sae_data_len);
int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct ieee80211_channel *chan,
const u8 *bssid,
const u8 *ssid, int ssid_len,
struct cfg80211_assoc_request *req);
int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
const u8 *bssid, const u8 *bssid,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
struct cfg80211_assoc_request *req); struct cfg80211_assoc_request *req);
int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason,
bool local_state_change);
int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid, struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason, const u8 *ie, int ie_len, u16 reason,
......
...@@ -221,7 +221,7 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, ...@@ -221,7 +221,7 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
EXPORT_SYMBOL(cfg80211_michael_mic_failure); EXPORT_SYMBOL(cfg80211_michael_mic_failure);
/* some MLME handling for userspace SME */ /* some MLME handling for userspace SME */
int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
enum nl80211_auth_type auth_type, enum nl80211_auth_type auth_type,
...@@ -271,28 +271,6 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, ...@@ -271,28 +271,6 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
return err; return err;
} }
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,
const u8 *sae_data, int sae_data_len)
{
int err;
ASSERT_RTNL();
wdev_lock(dev->ieee80211_ptr);
err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
ssid, ssid_len, ie, ie_len,
key, key_len, key_idx,
sae_data, sae_data_len);
wdev_unlock(dev->ieee80211_ptr);
return err;
}
/* Do a logical ht_capa &= ht_capa_mask. */ /* Do a logical ht_capa &= ht_capa_mask. */
void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa, void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
const struct ieee80211_ht_cap *ht_capa_mask) const struct ieee80211_ht_cap *ht_capa_mask)
...@@ -327,7 +305,7 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, ...@@ -327,7 +305,7 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
p1[i] &= p2[i]; p1[i] &= p2[i];
} }
int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
const u8 *bssid, const u8 *bssid,
...@@ -382,27 +360,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, ...@@ -382,27 +360,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
return err; return err;
} }
int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct ieee80211_channel *chan,
const u8 *bssid,
const u8 *ssid, int ssid_len,
struct cfg80211_assoc_request *req)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
int err;
ASSERT_RTNL();
wdev_lock(wdev);
err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid,
ssid, ssid_len, req);
wdev_unlock(wdev);
return err;
}
int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid, struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason, const u8 *ie, int ie_len, u16 reason,
bool local_state_change) bool local_state_change)
...@@ -425,23 +383,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, ...@@ -425,23 +383,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
return rdev_deauth(rdev, dev, &req); return rdev_deauth(rdev, dev, &req);
} }
int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason,
bool local_state_change)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
int err;
wdev_lock(wdev);
err = __cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason,
local_state_change);
wdev_unlock(wdev);
return err;
}
static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid, struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason, const u8 *ie, int ie_len, u16 reason,
bool local_state_change) bool local_state_change)
...@@ -470,22 +412,6 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, ...@@ -470,22 +412,6 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
return rdev_disassoc(rdev, dev, &req); return rdev_disassoc(rdev, dev, &req);
} }
int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, const u8 *bssid,
const u8 *ie, int ie_len, u16 reason,
bool local_state_change)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
int err;
wdev_lock(wdev);
err = __cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason,
local_state_change);
wdev_unlock(wdev);
return err;
}
void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
struct net_device *dev) struct net_device *dev)
{ {
......
...@@ -5904,10 +5904,13 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -5904,10 +5904,13 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
if (local_state_change) if (local_state_change)
return 0; return 0;
return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, wdev_lock(dev->ieee80211_ptr);
err = cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
ssid, ssid_len, ie, ie_len, ssid, ssid_len, ie, ie_len,
key.p.key, key.p.key_len, key.idx, key.p.key, key.p.key_len, key.idx,
sae_data, sae_data_len); sae_data, sae_data_len);
wdev_unlock(dev->ieee80211_ptr);
return err;
} }
static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
...@@ -6074,9 +6077,12 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) ...@@ -6074,9 +6077,12 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
} }
err = nl80211_crypto_settings(rdev, info, &req.crypto, 1); err = nl80211_crypto_settings(rdev, info, &req.crypto, 1);
if (!err) if (!err) {
wdev_lock(dev->ieee80211_ptr);
err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, err = cfg80211_mlme_assoc(rdev, dev, chan, bssid,
ssid, ssid_len, &req); ssid, ssid_len, &req);
wdev_unlock(dev->ieee80211_ptr);
}
return err; return err;
} }
...@@ -6086,7 +6092,7 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -6086,7 +6092,7 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct cfg80211_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1]; struct net_device *dev = info->user_ptr[1];
const u8 *ie = NULL, *bssid; const u8 *ie = NULL, *bssid;
int ie_len = 0; int ie_len = 0, err;
u16 reason_code; u16 reason_code;
bool local_state_change; bool local_state_change;
...@@ -6121,8 +6127,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -6121,8 +6127,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
return cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code, wdev_lock(dev->ieee80211_ptr);
err = cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code,
local_state_change); local_state_change);
wdev_unlock(dev->ieee80211_ptr);
return err;
} }
static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
...@@ -6130,7 +6139,7 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) ...@@ -6130,7 +6139,7 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct cfg80211_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1]; struct net_device *dev = info->user_ptr[1];
const u8 *ie = NULL, *bssid; const u8 *ie = NULL, *bssid;
int ie_len = 0; int ie_len = 0, err;
u16 reason_code; u16 reason_code;
bool local_state_change; bool local_state_change;
...@@ -6165,8 +6174,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) ...@@ -6165,8 +6174,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
return cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code, wdev_lock(dev->ieee80211_ptr);
err = cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code,
local_state_change); local_state_change);
wdev_unlock(dev->ieee80211_ptr);
return err;
} }
static bool static bool
......
...@@ -169,7 +169,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) ...@@ -169,7 +169,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
case CFG80211_CONN_AUTHENTICATE_NEXT: case CFG80211_CONN_AUTHENTICATE_NEXT:
BUG_ON(!rdev->ops->auth); BUG_ON(!rdev->ops->auth);
wdev->conn->state = CFG80211_CONN_AUTHENTICATING; wdev->conn->state = CFG80211_CONN_AUTHENTICATING;
return __cfg80211_mlme_auth(rdev, wdev->netdev, return cfg80211_mlme_auth(rdev, wdev->netdev,
params->channel, params->auth_type, params->channel, params->auth_type,
params->bssid, params->bssid,
params->ssid, params->ssid_len, params->ssid, params->ssid_len,
...@@ -191,17 +191,17 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) ...@@ -191,17 +191,17 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
req.vht_capa = params->vht_capa; req.vht_capa = params->vht_capa;
req.vht_capa_mask = params->vht_capa_mask; req.vht_capa_mask = params->vht_capa_mask;
err = __cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel, err = cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel,
params->bssid, params->ssid, params->bssid, params->ssid,
params->ssid_len, &req); params->ssid_len, &req);
if (err) if (err)
__cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
NULL, 0, NULL, 0,
WLAN_REASON_DEAUTH_LEAVING, WLAN_REASON_DEAUTH_LEAVING,
false); false);
return err; return err;
case CFG80211_CONN_DEAUTH_ASSOC_FAIL: case CFG80211_CONN_DEAUTH_ASSOC_FAIL:
__cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
NULL, 0, NULL, 0,
WLAN_REASON_DEAUTH_LEAVING, false); WLAN_REASON_DEAUTH_LEAVING, false);
/* return an error so that we call __cfg80211_connect_result() */ /* return an error so that we call __cfg80211_connect_result() */
...@@ -961,7 +961,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev, ...@@ -961,7 +961,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
} }
/* wdev->conn->params.bssid must be set if > SCANNING */ /* wdev->conn->params.bssid must be set if > SCANNING */
err = __cfg80211_mlme_deauth(rdev, dev, err = cfg80211_mlme_deauth(rdev, dev,
wdev->conn->params.bssid, wdev->conn->params.bssid,
NULL, 0, reason, false); NULL, 0, reason, false);
if (err) if (err)
...@@ -1018,6 +1018,6 @@ void cfg80211_sme_disassoc(struct net_device *dev, ...@@ -1018,6 +1018,6 @@ void cfg80211_sme_disassoc(struct net_device *dev,
memcpy(bssid, bss->pub.bssid, ETH_ALEN); memcpy(bssid, bss->pub.bssid, ETH_ALEN);
__cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0,
WLAN_REASON_DEAUTH_LEAVING, false); WLAN_REASON_DEAUTH_LEAVING, false);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment