Commit f62fab73 authored by Johannes Berg's avatar Johannes Berg

cfg80211: refactor association parameters

cfg80211_mlme_assoc() has grown far too many arguments,
make the caller build almost all of the driver struct
and pass that to the function instead.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent dd5ecfea
...@@ -330,24 +330,15 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, ...@@ -330,24 +330,15 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
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 *prev_bssid, const u8 *bssid,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len, bool use_mfp, struct cfg80211_assoc_request *req);
struct cfg80211_crypto_settings *crypt,
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
struct ieee80211_ht_cap *ht_capa_mask,
struct ieee80211_vht_cap *vht_capa,
struct ieee80211_vht_cap *vht_capa_mask);
int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct ieee80211_channel *chan, struct net_device *dev,
const u8 *bssid, const u8 *prev_bssid, struct ieee80211_channel *chan,
const u8 *bssid,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len, bool use_mfp, struct cfg80211_assoc_request *req);
struct cfg80211_crypto_settings *crypt,
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
struct ieee80211_ht_cap *ht_capa_mask,
struct ieee80211_vht_cap *vht_capa,
struct ieee80211_vht_cap *vht_capa_mask);
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,
......
...@@ -363,26 +363,18 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, ...@@ -363,26 +363,18 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
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 *prev_bssid, const u8 *bssid,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len, bool use_mfp, struct cfg80211_assoc_request *req)
struct cfg80211_crypto_settings *crypt,
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
struct ieee80211_ht_cap *ht_capa_mask,
struct ieee80211_vht_cap *vht_capa,
struct ieee80211_vht_cap *vht_capa_mask)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_assoc_request req;
int err; int err;
bool was_connected = false; bool was_connected = false;
ASSERT_WDEV_LOCK(wdev); ASSERT_WDEV_LOCK(wdev);
memset(&req, 0, sizeof(req)); if (wdev->current_bss && req->prev_bssid &&
ether_addr_equal(wdev->current_bss->pub.bssid, req->prev_bssid)) {
if (wdev->current_bss && prev_bssid &&
ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) {
/* /*
* Trying to reassociate: Allow this to proceed and let the old * Trying to reassociate: Allow this to proceed and let the old
* association to be dropped when the new one is completed. * association to be dropped when the new one is completed.
...@@ -394,47 +386,30 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, ...@@ -394,47 +386,30 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
} else if (wdev->current_bss) } else if (wdev->current_bss)
return -EALREADY; return -EALREADY;
req.ie = ie; cfg80211_oper_and_ht_capa(&req->ht_capa_mask,
req.ie_len = ie_len;
memcpy(&req.crypto, crypt, sizeof(req.crypto));
req.use_mfp = use_mfp;
req.prev_bssid = prev_bssid;
req.flags = assoc_flags;
if (ht_capa)
memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa));
if (ht_capa_mask)
memcpy(&req.ht_capa_mask, ht_capa_mask,
sizeof(req.ht_capa_mask));
cfg80211_oper_and_ht_capa(&req.ht_capa_mask,
rdev->wiphy.ht_capa_mod_mask); rdev->wiphy.ht_capa_mod_mask);
if (vht_capa) cfg80211_oper_and_vht_capa(&req->vht_capa_mask,
memcpy(&req.vht_capa, vht_capa, sizeof(req.vht_capa));
if (vht_capa_mask)
memcpy(&req.vht_capa_mask, vht_capa_mask,
sizeof(req.vht_capa_mask));
cfg80211_oper_and_vht_capa(&req.vht_capa_mask,
rdev->wiphy.vht_capa_mod_mask); rdev->wiphy.vht_capa_mod_mask);
req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
if (!req.bss) { if (!req->bss) {
if (was_connected) if (was_connected)
wdev->sme_state = CFG80211_SME_CONNECTED; wdev->sme_state = CFG80211_SME_CONNECTED;
return -ENOENT; return -ENOENT;
} }
err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel, err = cfg80211_can_use_chan(rdev, wdev, chan, CHAN_MODE_SHARED);
CHAN_MODE_SHARED);
if (err) if (err)
goto out; goto out;
err = rdev_assoc(rdev, dev, &req); err = rdev_assoc(rdev, dev, req);
out: out:
if (err) { if (err) {
if (was_connected) if (was_connected)
wdev->sme_state = CFG80211_SME_CONNECTED; wdev->sme_state = CFG80211_SME_CONNECTED;
cfg80211_put_bss(&rdev->wiphy, req.bss); cfg80211_put_bss(&rdev->wiphy, req->bss);
} }
return err; return err;
...@@ -443,24 +418,17 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, ...@@ -443,24 +418,17 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
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 *prev_bssid, const u8 *bssid,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
const u8 *ie, int ie_len, bool use_mfp, struct cfg80211_assoc_request *req)
struct cfg80211_crypto_settings *crypt,
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
struct ieee80211_ht_cap *ht_capa_mask,
struct ieee80211_vht_cap *vht_capa,
struct ieee80211_vht_cap *vht_capa_mask)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
int err; int err;
mutex_lock(&rdev->devlist_mtx); mutex_lock(&rdev->devlist_mtx);
wdev_lock(wdev); wdev_lock(wdev);
err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid,
ssid, ssid_len, ie, ie_len, use_mfp, crypt, ssid, ssid_len, req);
assoc_flags, ht_capa, ht_capa_mask,
vht_capa, vht_capa_mask);
wdev_unlock(wdev); wdev_unlock(wdev);
mutex_unlock(&rdev->devlist_mtx); mutex_unlock(&rdev->devlist_mtx);
......
...@@ -5984,16 +5984,10 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) ...@@ -5984,16 +5984,10 @@ static int nl80211_associate(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 cfg80211_crypto_settings crypto;
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL; struct cfg80211_assoc_request req = {};
int err, ssid_len, ie_len = 0; const u8 *bssid, *ssid;
bool use_mfp = false; int err, ssid_len = 0;
u32 flags = 0;
struct ieee80211_ht_cap *ht_capa = NULL;
struct ieee80211_ht_cap *ht_capa_mask = NULL;
struct ieee80211_vht_cap *vht_capa = NULL;
struct ieee80211_vht_cap *vht_capa_mask = NULL;
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
return -EINVAL; return -EINVAL;
...@@ -6021,54 +6015,58 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) ...@@ -6021,54 +6015,58 @@ static int nl80211_associate(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]);
} }
if (info->attrs[NL80211_ATTR_USE_MFP]) { if (info->attrs[NL80211_ATTR_USE_MFP]) {
enum nl80211_mfp mfp = enum nl80211_mfp mfp =
nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]); nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]);
if (mfp == NL80211_MFP_REQUIRED) if (mfp == NL80211_MFP_REQUIRED)
use_mfp = true; req.use_mfp = true;
else if (mfp != NL80211_MFP_NO) else if (mfp != NL80211_MFP_NO)
return -EINVAL; return -EINVAL;
} }
if (info->attrs[NL80211_ATTR_PREV_BSSID]) if (info->attrs[NL80211_ATTR_PREV_BSSID])
prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); req.prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
flags |= ASSOC_REQ_DISABLE_HT; req.flags |= ASSOC_REQ_DISABLE_HT;
if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
ht_capa_mask = memcpy(&req.ht_capa_mask,
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]); nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]),
sizeof(req.ht_capa_mask));
if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
if (!ht_capa_mask) if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
return -EINVAL; return -EINVAL;
ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); memcpy(&req.ht_capa,
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
sizeof(req.ht_capa));
} }
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT]))
flags |= ASSOC_REQ_DISABLE_VHT; req.flags |= ASSOC_REQ_DISABLE_VHT;
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
vht_capa_mask = memcpy(&req.vht_capa_mask,
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]); nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]),
sizeof(req.vht_capa_mask));
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) {
if (!vht_capa_mask) if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
return -EINVAL; return -EINVAL;
vht_capa = nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); memcpy(&req.vht_capa,
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]),
sizeof(req.vht_capa));
} }
err = nl80211_crypto_settings(rdev, info, &crypto, 1); err = nl80211_crypto_settings(rdev, info, &req.crypto, 1);
if (!err) if (!err)
err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, err = cfg80211_mlme_assoc(rdev, dev, chan, bssid,
ssid, ssid_len, ie, ie_len, use_mfp, ssid, ssid_len, &req);
&crypto, flags, ht_capa, ht_capa_mask,
vht_capa, vht_capa_mask);
return err; return err;
} }
......
...@@ -159,7 +159,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) ...@@ -159,7 +159,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
{ {
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
struct cfg80211_connect_params *params; struct cfg80211_connect_params *params;
const u8 *prev_bssid = NULL; struct cfg80211_assoc_request req = {};
int err; int err;
ASSERT_WDEV_LOCK(wdev); ASSERT_WDEV_LOCK(wdev);
...@@ -186,18 +186,20 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) ...@@ -186,18 +186,20 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
BUG_ON(!rdev->ops->assoc); BUG_ON(!rdev->ops->assoc);
wdev->conn->state = CFG80211_CONN_ASSOCIATING; wdev->conn->state = CFG80211_CONN_ASSOCIATING;
if (wdev->conn->prev_bssid_valid) if (wdev->conn->prev_bssid_valid)
prev_bssid = wdev->conn->prev_bssid; req.prev_bssid = wdev->conn->prev_bssid;
err = __cfg80211_mlme_assoc(rdev, wdev->netdev, req.ie = params->ie;
params->channel, params->bssid, req.ie_len = params->ie_len;
prev_bssid, req.use_mfp = params->mfp != NL80211_MFP_NO;
params->ssid, params->ssid_len, req.crypto = params->crypto;
params->ie, params->ie_len, req.flags = params->flags;
params->mfp != NL80211_MFP_NO, req.ht_capa = params->ht_capa;
&params->crypto, req.ht_capa_mask = params->ht_capa_mask;
params->flags, &params->ht_capa, req.vht_capa = params->vht_capa;
&params->ht_capa_mask, req.vht_capa_mask = params->vht_capa_mask;
&params->vht_capa,
&params->vht_capa_mask); err = __cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel,
params->bssid, params->ssid,
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,
......
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