cfg80211: remove some locked wrappers from mlme API
authorJohannes Berg <johannes.berg@intel.com>
Wed, 15 May 2013 15:44:01 +0000 (17:44 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 May 2013 22:02:20 +0000 (00:02 +0200)
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>
net/wireless/core.h
net/wireless/mlme.c
net/wireless/nl80211.c
net/wireless/sme.c

index d21a0fc0140189804097fcf6d4059675c4040111..c8f87dfd50d3d735d224ef8df5bc8e5bb275f602 100644 (file)
@@ -282,38 +282,21 @@ int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
                     struct net_device *dev);
 
 /* MLME */
-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_auth(struct cfg80211_registered_device *rdev,
-                      struct net_device *dev, struct ieee80211_channel *chan,
-                      enum nl80211_auth_type auth_type, const u8 *bssid,
+                      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,
                        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_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,
                         struct net_device *dev, const u8 *bssid,
                         const u8 *ie, int ie_len, u16 reason,
index 80ffb0138919b4555ded0f465039b4341544f737..7bde5d9c0003166d46e06b3d947e7e2455333eaa 100644 (file)
@@ -221,15 +221,15 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
 EXPORT_SYMBOL(cfg80211_michael_mic_failure);
 
 /* some MLME handling for userspace SME */
-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_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)
 {
        struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct cfg80211_auth_request req = {
@@ -271,28 +271,6 @@ out:
        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.  */
 void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
                               const struct ieee80211_ht_cap *ht_capa_mask)
@@ -327,12 +305,12 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
                p1[i] &= p2[i];
 }
 
-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,
+                       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;
@@ -382,30 +360,10 @@ out:
        return err;
 }
 
-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)
-{
-       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,
-                          const u8 *ie, int ie_len, u16 reason,
-                          bool local_state_change)
+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)
 {
        struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct cfg80211_deauth_request req = {
@@ -425,26 +383,10 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
        return rdev_deauth(rdev, dev, &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)
-{
-       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,
-                                   const u8 *ie, int ie_len, u16 reason,
-                                   bool local_state_change)
+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;
        struct cfg80211_disassoc_request req = {
@@ -470,22 +412,6 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
        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,
                        struct net_device *dev)
 {
index 74cdb1a0cf312dafae133bd1a485dec7f72fd641..49c2f2f511dc9c53210353d8af6b5817f4d68c8b 100644 (file)
@@ -5904,10 +5904,13 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
        if (local_state_change)
                return 0;
 
-       return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
-                                 ssid, ssid_len, ie, ie_len,
-                                 key.p.key, key.p.key_len, key.idx,
-                                 sae_data, sae_data_len);
+       wdev_lock(dev->ieee80211_ptr);
+       err = cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
+                                ssid, ssid_len, ie, ie_len,
+                                key.p.key, key.p.key_len, key.idx,
+                                sae_data, sae_data_len);
+       wdev_unlock(dev->ieee80211_ptr);
+       return err;
 }
 
 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)
        }
 
        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,
                                          ssid, ssid_len, &req);
+               wdev_unlock(dev->ieee80211_ptr);
+       }
 
        return err;
 }
@@ -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 net_device *dev = info->user_ptr[1];
        const u8 *ie = NULL, *bssid;
-       int ie_len = 0;
+       int ie_len = 0, err;
        u16 reason_code;
        bool local_state_change;
 
@@ -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];
 
-       return cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code,
-                                   local_state_change);
+       wdev_lock(dev->ieee80211_ptr);
+       err = cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code,
+                                  local_state_change);
+       wdev_unlock(dev->ieee80211_ptr);
+       return err;
 }
 
 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 net_device *dev = info->user_ptr[1];
        const u8 *ie = NULL, *bssid;
-       int ie_len = 0;
+       int ie_len = 0, err;
        u16 reason_code;
        bool local_state_change;
 
@@ -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];
 
-       return cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code,
-                                     local_state_change);
+       wdev_lock(dev->ieee80211_ptr);
+       err = cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code,
+                                    local_state_change);
+       wdev_unlock(dev->ieee80211_ptr);
+       return err;
 }
 
 static bool
index 4dbf31407a5685ba022c527d23b34d165fff6bda..31d67add7424eba19c5541a3ee2eb07a0c256b0c 100644 (file)
@@ -169,13 +169,13 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
        case CFG80211_CONN_AUTHENTICATE_NEXT:
                BUG_ON(!rdev->ops->auth);
                wdev->conn->state = CFG80211_CONN_AUTHENTICATING;
-               return __cfg80211_mlme_auth(rdev, wdev->netdev,
-                                           params->channel, params->auth_type,
-                                           params->bssid,
-                                           params->ssid, params->ssid_len,
-                                           NULL, 0,
-                                           params->key, params->key_len,
-                                           params->key_idx, NULL, 0);
+               return cfg80211_mlme_auth(rdev, wdev->netdev,
+                                         params->channel, params->auth_type,
+                                         params->bssid,
+                                         params->ssid, params->ssid_len,
+                                         NULL, 0,
+                                         params->key, params->key_len,
+                                         params->key_idx, NULL, 0);
        case CFG80211_CONN_ASSOCIATE_NEXT:
                BUG_ON(!rdev->ops->assoc);
                wdev->conn->state = CFG80211_CONN_ASSOCIATING;
@@ -191,19 +191,19 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
                req.vht_capa = params->vht_capa;
                req.vht_capa_mask = params->vht_capa_mask;
 
-               err = __cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel,
-                                           params->bssid, params->ssid,
-                                           params->ssid_len, &req);
+               err = cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel,
+                                         params->bssid, params->ssid,
+                                         params->ssid_len, &req);
                if (err)
-                       __cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
-                                              NULL, 0,
-                                              WLAN_REASON_DEAUTH_LEAVING,
-                                              false);
+                       cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
+                                            NULL, 0,
+                                            WLAN_REASON_DEAUTH_LEAVING,
+                                            false);
                return err;
        case CFG80211_CONN_DEAUTH_ASSOC_FAIL:
-               __cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
-                                      NULL, 0,
-                                      WLAN_REASON_DEAUTH_LEAVING, false);
+               cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
+                                    NULL, 0,
+                                    WLAN_REASON_DEAUTH_LEAVING, false);
                /* return an error so that we call __cfg80211_connect_result() */
                return -EINVAL;
        default:
@@ -961,7 +961,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
                }
 
                /* 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,
                                             NULL, 0, reason, false);
                if (err)
@@ -1018,6 +1018,6 @@ void cfg80211_sme_disassoc(struct net_device *dev,
 
        memcpy(bssid, bss->pub.bssid, ETH_ALEN);
 
-       __cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0,
-                              WLAN_REASON_DEAUTH_LEAVING, false);
+       cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0,
+                            WLAN_REASON_DEAUTH_LEAVING, false);
 }