Commit 325839da authored by Johannes Berg's avatar Johannes Berg

wifi: cfg80211: simplify cfg80211_mlme_auth() prototype

This function has far too many parameters now, move out
the BSS lookup and pass the request struct instead.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 0f48b8b8
...@@ -363,13 +363,7 @@ int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, ...@@ -363,13 +363,7 @@ int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
/* 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 cfg80211_auth_request *req);
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 *auth_data, int auth_data_len);
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 cfg80211_assoc_request *req); struct cfg80211_assoc_request *req);
......
...@@ -232,47 +232,26 @@ EXPORT_SYMBOL(cfg80211_michael_mic_failure); ...@@ -232,47 +232,26 @@ 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 cfg80211_auth_request *req)
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 *auth_data, int auth_data_len)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_auth_request req = {
.ie = ie,
.ie_len = ie_len,
.auth_data = auth_data,
.auth_data_len = auth_data_len,
.auth_type = auth_type,
.key = key,
.key_len = key_len,
.key_idx = key_idx,
};
int err;
ASSERT_WDEV_LOCK(wdev); ASSERT_WDEV_LOCK(wdev);
if (auth_type == NL80211_AUTHTYPE_SHARED_KEY) if (!req->bss)
if (!key || !key_len || key_idx < 0 || key_idx > 3) return -ENOENT;
if (req->auth_type == NL80211_AUTHTYPE_SHARED_KEY) {
if (!req->key || !req->key_len ||
req->key_idx < 0 || req->key_idx > 3)
return -EINVAL; return -EINVAL;
}
if (wdev->connected && if (wdev->connected &&
ether_addr_equal(bssid, wdev->u.client.connected_addr)) ether_addr_equal(req->bss->bssid, wdev->u.client.connected_addr))
return -EALREADY; return -EALREADY;
req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, return rdev_auth(rdev, dev, req);
IEEE80211_BSS_TYPE_ESS,
IEEE80211_PRIVACY_ANY);
if (!req.bss)
return -ENOENT;
err = rdev_auth(rdev, dev, &req);
cfg80211_put_bss(&rdev->wiphy, req.bss);
return err;
} }
/* Do a logical ht_capa &= ht_capa_mask. */ /* Do a logical ht_capa &= ht_capa_mask. */
......
...@@ -10168,11 +10168,12 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -10168,11 +10168,12 @@ static int nl80211_authenticate(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];
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
const u8 *bssid, *ssid, *ie = NULL, *auth_data = NULL; const u8 *bssid, *ssid;
int err, ssid_len, ie_len = 0, auth_data_len = 0; int err, ssid_len;
enum nl80211_auth_type auth_type; enum nl80211_auth_type auth_type;
struct key_parse key; struct key_parse key;
bool local_state_change; bool local_state_change;
struct cfg80211_auth_request req = {};
u32 freq; u32 freq;
if (!info->attrs[NL80211_ATTR_MAC]) if (!info->attrs[NL80211_ATTR_MAC])
...@@ -10243,8 +10244,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -10243,8 +10244,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
if (info->attrs[NL80211_ATTR_IE]) { if (info->attrs[NL80211_ATTR_IE]) {
ie = nla_data(info->attrs[NL80211_ATTR_IE]); req.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
} }
auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]);
...@@ -10264,8 +10265,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -10264,8 +10265,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
auth_type != NL80211_AUTHTYPE_FILS_SK_PFS && auth_type != NL80211_AUTHTYPE_FILS_SK_PFS &&
auth_type != NL80211_AUTHTYPE_FILS_PK) auth_type != NL80211_AUTHTYPE_FILS_PK)
return -EINVAL; return -EINVAL;
auth_data = nla_data(info->attrs[NL80211_ATTR_AUTH_DATA]); req.auth_data = nla_data(info->attrs[NL80211_ATTR_AUTH_DATA]);
auth_data_len = nla_len(info->attrs[NL80211_ATTR_AUTH_DATA]); req.auth_data_len = nla_len(info->attrs[NL80211_ATTR_AUTH_DATA]);
} }
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
...@@ -10277,12 +10278,23 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) ...@@ -10277,12 +10278,23 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
if (local_state_change) if (local_state_change)
return 0; return 0;
req.auth_type = auth_type;
req.key = key.p.key;
req.key_len = key.p.key_len;
req.key_idx = key.idx;
req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
IEEE80211_BSS_TYPE_ESS,
IEEE80211_PRIVACY_ANY);
if (!req.bss)
return -ENOENT;
wdev_lock(dev->ieee80211_ptr); wdev_lock(dev->ieee80211_ptr);
err = cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, err = cfg80211_mlme_auth(rdev, dev, &req);
ssid, ssid_len, ie, ie_len,
key.p.key, key.p.key_len, key.idx,
auth_data, auth_data_len);
wdev_unlock(dev->ieee80211_ptr); wdev_unlock(dev->ieee80211_ptr);
cfg80211_put_bss(&rdev->wiphy, req.bss);
return err; return err;
} }
......
...@@ -147,6 +147,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev, ...@@ -147,6 +147,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev,
{ {
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
struct cfg80211_connect_params *params; struct cfg80211_connect_params *params;
struct cfg80211_auth_request auth_req = {};
struct cfg80211_assoc_request req = {}; struct cfg80211_assoc_request req = {};
int err; int err;
...@@ -167,13 +168,18 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev, ...@@ -167,13 +168,18 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev,
if (WARN_ON(!rdev->ops->auth)) if (WARN_ON(!rdev->ops->auth))
return -EOPNOTSUPP; return -EOPNOTSUPP;
wdev->conn->state = CFG80211_CONN_AUTHENTICATING; wdev->conn->state = CFG80211_CONN_AUTHENTICATING;
return cfg80211_mlme_auth(rdev, wdev->netdev, auth_req.key = params->key;
params->channel, params->auth_type, auth_req.key_len = params->key_len;
params->bssid, auth_req.key_idx = params->key_idx;
params->ssid, params->ssid_len, auth_req.auth_type = params->auth_type;
NULL, 0, auth_req.bss = cfg80211_get_bss(&rdev->wiphy, params->channel,
params->key, params->key_len, params->bssid,
params->key_idx, NULL, 0); params->ssid, params->ssid_len,
IEEE80211_BSS_TYPE_ESS,
IEEE80211_PRIVACY_ANY);
err = cfg80211_mlme_auth(rdev, wdev->netdev, &auth_req);
cfg80211_put_bss(&rdev->wiphy, auth_req.bss);
return err;
case CFG80211_CONN_AUTH_FAILED_TIMEOUT: case CFG80211_CONN_AUTH_FAILED_TIMEOUT:
*treason = NL80211_TIMEOUT_AUTH; *treason = NL80211_TIMEOUT_AUTH;
return -ENOTCONN; return -ENOTCONN;
......
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