cfg80211: remove some locked wrappers from sme 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: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2013-05-15 17:44:01 +02:00
parent 91bf9b26fc
commit 83739b03de
6 changed files with 32 additions and 59 deletions

View File

@ -755,7 +755,7 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev,
wdev->wext.ie_len = 0; wdev->wext.ie_len = 0;
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
#endif #endif
__cfg80211_disconnect(rdev, dev, cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, true); WLAN_REASON_DEAUTH_LEAVING, true);
wdev_unlock(wdev); wdev_unlock(wdev);
break; break;

View File

@ -328,18 +328,11 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
const struct ieee80211_vht_cap *vht_capa_mask); const struct ieee80211_vht_cap *vht_capa_mask);
/* SME */ /* SME */
int __cfg80211_connect(struct cfg80211_registered_device *rdev, int cfg80211_connect(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct cfg80211_connect_params *connect, struct cfg80211_connect_params *connect,
struct cfg80211_cached_keys *connkeys, struct cfg80211_cached_keys *connkeys,
const u8 *prev_bssid); const u8 *prev_bssid);
int cfg80211_connect(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_connect_params *connect,
struct cfg80211_cached_keys *connkeys);
int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
struct net_device *dev, u16 reason,
bool wextev);
int cfg80211_disconnect(struct cfg80211_registered_device *rdev, int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
struct net_device *dev, u16 reason, struct net_device *dev, u16 reason,
bool wextev); bool wextev);

View File

@ -6683,7 +6683,9 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
sizeof(connect.vht_capa)); sizeof(connect.vht_capa));
} }
err = cfg80211_connect(rdev, dev, &connect, connkeys); wdev_lock(dev->ieee80211_ptr);
err = cfg80211_connect(rdev, dev, &connect, connkeys, NULL);
wdev_unlock(dev->ieee80211_ptr);
if (err) if (err)
kfree(connkeys); kfree(connkeys);
return err; return err;
@ -6694,6 +6696,7 @@ static int nl80211_disconnect(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];
u16 reason; u16 reason;
int ret;
if (!info->attrs[NL80211_ATTR_REASON_CODE]) if (!info->attrs[NL80211_ATTR_REASON_CODE])
reason = WLAN_REASON_DEAUTH_LEAVING; reason = WLAN_REASON_DEAUTH_LEAVING;
@ -6707,7 +6710,10 @@ static int nl80211_disconnect(struct sk_buff *skb, struct genl_info *info)
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return cfg80211_disconnect(rdev, dev, reason, true); wdev_lock(dev->ieee80211_ptr);
ret = cfg80211_disconnect(rdev, dev, reason, true);
wdev_unlock(dev->ieee80211_ptr);
return ret;
} }
static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info) static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info)

View File

@ -760,7 +760,7 @@ void cfg80211_disconnected(struct net_device *dev, u16 reason,
} }
EXPORT_SYMBOL(cfg80211_disconnected); EXPORT_SYMBOL(cfg80211_disconnected);
int __cfg80211_connect(struct cfg80211_registered_device *rdev, int cfg80211_connect(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct cfg80211_connect_params *connect, struct cfg80211_connect_params *connect,
struct cfg80211_cached_keys *connkeys, struct cfg80211_cached_keys *connkeys,
@ -911,21 +911,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
} }
} }
int cfg80211_connect(struct cfg80211_registered_device *rdev, int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_connect_params *connect,
struct cfg80211_cached_keys *connkeys)
{
int err;
wdev_lock(dev->ieee80211_ptr);
err = __cfg80211_connect(rdev, dev, connect, connkeys, NULL);
wdev_unlock(dev->ieee80211_ptr);
return err;
}
int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
struct net_device *dev, u16 reason, bool wextev) struct net_device *dev, u16 reason, bool wextev)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
@ -983,19 +969,6 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
return 0; return 0;
} }
int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
struct net_device *dev,
u16 reason, bool wextev)
{
int err;
wdev_lock(dev->ieee80211_ptr);
err = __cfg80211_disconnect(rdev, dev, reason, wextev);
wdev_unlock(dev->ieee80211_ptr);
return err;
}
void cfg80211_sme_disassoc(struct net_device *dev, void cfg80211_sme_disassoc(struct net_device *dev,
struct cfg80211_internal_bss *bss) struct cfg80211_internal_bss *bss)
{ {

View File

@ -858,8 +858,10 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
break; break;
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_P2P_CLIENT:
wdev_lock(dev->ieee80211_ptr);
cfg80211_disconnect(rdev, dev, cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, true); WLAN_REASON_DEAUTH_LEAVING, true);
wdev_unlock(dev->ieee80211_ptr);
break; break;
case NL80211_IFTYPE_MESH_POINT: case NL80211_IFTYPE_MESH_POINT:
/* mesh should be handled? */ /* mesh should be handled? */

View File

@ -54,7 +54,7 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
if (wdev->wext.prev_bssid_valid) if (wdev->wext.prev_bssid_valid)
prev_bssid = wdev->wext.prev_bssid; prev_bssid = wdev->wext.prev_bssid;
err = __cfg80211_connect(rdev, wdev->netdev, err = cfg80211_connect(rdev, wdev->netdev,
&wdev->wext.connect, ck, prev_bssid); &wdev->wext.connect, ck, prev_bssid);
if (err) if (err)
kfree(ck); kfree(ck);
@ -100,7 +100,7 @@ int cfg80211_mgd_wext_siwfreq(struct net_device *dev,
/* if SSID set, we'll try right again, avoid event */ /* if SSID set, we'll try right again, avoid event */
if (wdev->wext.connect.ssid_len) if (wdev->wext.connect.ssid_len)
event = false; event = false;
err = __cfg80211_disconnect(rdev, dev, err = cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, event); WLAN_REASON_DEAUTH_LEAVING, event);
if (err) if (err)
goto out; goto out;
@ -199,7 +199,7 @@ int cfg80211_mgd_wext_siwessid(struct net_device *dev,
/* if SSID set now, we'll try to connect, avoid event */ /* if SSID set now, we'll try to connect, avoid event */
if (len) if (len)
event = false; event = false;
err = __cfg80211_disconnect(rdev, dev, err = cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, event); WLAN_REASON_DEAUTH_LEAVING, event);
if (err) if (err)
goto out; goto out;
@ -288,7 +288,7 @@ int cfg80211_mgd_wext_siwap(struct net_device *dev,
ether_addr_equal(bssid, wdev->wext.connect.bssid)) ether_addr_equal(bssid, wdev->wext.connect.bssid))
goto out; goto out;
err = __cfg80211_disconnect(rdev, dev, err = cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, false); WLAN_REASON_DEAUTH_LEAVING, false);
if (err) if (err)
goto out; goto out;
@ -365,7 +365,7 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
wdev->wext.ie_len = ie_len; wdev->wext.ie_len = ie_len;
if (wdev->sme_state != CFG80211_SME_IDLE) { if (wdev->sme_state != CFG80211_SME_IDLE) {
err = __cfg80211_disconnect(rdev, dev, err = cfg80211_disconnect(rdev, dev,
WLAN_REASON_DEAUTH_LEAVING, false); WLAN_REASON_DEAUTH_LEAVING, false);
if (err) if (err)
goto out; goto out;
@ -402,8 +402,7 @@ int cfg80211_wext_siwmlme(struct net_device *dev,
switch (mlme->cmd) { switch (mlme->cmd) {
case IW_MLME_DEAUTH: case IW_MLME_DEAUTH:
case IW_MLME_DISASSOC: case IW_MLME_DISASSOC:
err = __cfg80211_disconnect(rdev, dev, mlme->reason_code, err = cfg80211_disconnect(rdev, dev, mlme->reason_code, true);
true);
break; break;
default: default:
err = -EOPNOTSUPP; err = -EOPNOTSUPP;