aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-06-15 18:00:26 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-07-12 06:08:10 -0400
commit84efbb84cf76238faf26facf481c8675859bfaeb (patch)
tree3cc01b479a4c2db70b1b9ed59e1451d93acb5769 /net
parent71bbc9943883cffaf5d7a7728a4e4c50b3ac44d3 (diff)
cfg80211: use wireless_dev for interface management
In order to be able to create P2P Device wdevs, move the virtual interface management over to wireless_dev structures. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/cfg.c20
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/iface.c6
-rw-r--r--net/wireless/nl80211.c26
4 files changed, 31 insertions, 23 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 7d9abea37b17..a752c7341d62 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -20,31 +20,31 @@
20#include "rate.h" 20#include "rate.h"
21#include "mesh.h" 21#include "mesh.h"
22 22
23static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name, 23static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, char *name,
24 enum nl80211_iftype type, 24 enum nl80211_iftype type,
25 u32 *flags, 25 u32 *flags,
26 struct vif_params *params) 26 struct vif_params *params)
27{ 27{
28 struct ieee80211_local *local = wiphy_priv(wiphy); 28 struct ieee80211_local *local = wiphy_priv(wiphy);
29 struct net_device *dev; 29 struct wireless_dev *wdev;
30 struct ieee80211_sub_if_data *sdata; 30 struct ieee80211_sub_if_data *sdata;
31 int err; 31 int err;
32 32
33 err = ieee80211_if_add(local, name, &dev, type, params); 33 err = ieee80211_if_add(local, name, &wdev, type, params);
34 if (err) 34 if (err)
35 return ERR_PTR(err); 35 return ERR_PTR(err);
36 36
37 if (type == NL80211_IFTYPE_MONITOR && flags) { 37 if (type == NL80211_IFTYPE_MONITOR && flags) {
38 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 38 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
39 sdata->u.mntr_flags = *flags; 39 sdata->u.mntr_flags = *flags;
40 } 40 }
41 41
42 return dev; 42 return wdev;
43} 43}
44 44
45static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) 45static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
46{ 46{
47 ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev)); 47 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
48 48
49 return 0; 49 return 0;
50} 50}
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8f8535ee5995..c3241c3ec6d1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1284,7 +1284,7 @@ void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1284int ieee80211_iface_init(void); 1284int ieee80211_iface_init(void);
1285void ieee80211_iface_exit(void); 1285void ieee80211_iface_exit(void);
1286int ieee80211_if_add(struct ieee80211_local *local, const char *name, 1286int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1287 struct net_device **new_dev, enum nl80211_iftype type, 1287 struct wireless_dev **new_wdev, enum nl80211_iftype type,
1288 struct vif_params *params); 1288 struct vif_params *params);
1289int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, 1289int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1290 enum nl80211_iftype type); 1290 enum nl80211_iftype type);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index fbef7a1ada7a..b1edf60fbba7 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1373,7 +1373,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
1373} 1373}
1374 1374
1375int ieee80211_if_add(struct ieee80211_local *local, const char *name, 1375int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1376 struct net_device **new_dev, enum nl80211_iftype type, 1376 struct wireless_dev **new_wdev, enum nl80211_iftype type,
1377 struct vif_params *params) 1377 struct vif_params *params)
1378{ 1378{
1379 struct net_device *ndev; 1379 struct net_device *ndev;
@@ -1463,8 +1463,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1463 list_add_tail_rcu(&sdata->list, &local->interfaces); 1463 list_add_tail_rcu(&sdata->list, &local->interfaces);
1464 mutex_unlock(&local->iflist_mtx); 1464 mutex_unlock(&local->iflist_mtx);
1465 1465
1466 if (new_dev) 1466 if (new_wdev)
1467 *new_dev = ndev; 1467 *new_wdev = &sdata->wdev;
1468 1468
1469 return 0; 1469 return 0;
1470 1470
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0dc3356eea40..789d0c7b287e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1971,7 +1971,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
1971{ 1971{
1972 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 1972 struct cfg80211_registered_device *rdev = info->user_ptr[0];
1973 struct vif_params params; 1973 struct vif_params params;
1974 struct net_device *dev; 1974 struct wireless_dev *wdev;
1975 int err; 1975 int err;
1976 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; 1976 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
1977 u32 flags; 1977 u32 flags;
@@ -2001,16 +2001,14 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
2001 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? 2001 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
2002 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, 2002 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
2003 &flags); 2003 &flags);
2004 dev = rdev->ops->add_virtual_intf(&rdev->wiphy, 2004 wdev = rdev->ops->add_virtual_intf(&rdev->wiphy,
2005 nla_data(info->attrs[NL80211_ATTR_IFNAME]), 2005 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
2006 type, err ? NULL : &flags, &params); 2006 type, err ? NULL : &flags, &params);
2007 if (IS_ERR(dev)) 2007 if (IS_ERR(wdev))
2008 return PTR_ERR(dev); 2008 return PTR_ERR(wdev);
2009 2009
2010 if (type == NL80211_IFTYPE_MESH_POINT && 2010 if (type == NL80211_IFTYPE_MESH_POINT &&
2011 info->attrs[NL80211_ATTR_MESH_ID]) { 2011 info->attrs[NL80211_ATTR_MESH_ID]) {
2012 struct wireless_dev *wdev = dev->ieee80211_ptr;
2013
2014 wdev_lock(wdev); 2012 wdev_lock(wdev);
2015 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != 2013 BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN !=
2016 IEEE80211_MAX_MESH_ID_LEN); 2014 IEEE80211_MAX_MESH_ID_LEN);
@@ -2027,12 +2025,22 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
2027static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) 2025static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
2028{ 2026{
2029 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 2027 struct cfg80211_registered_device *rdev = info->user_ptr[0];
2030 struct net_device *dev = info->user_ptr[1]; 2028 struct wireless_dev *wdev = info->user_ptr[1];
2031 2029
2032 if (!rdev->ops->del_virtual_intf) 2030 if (!rdev->ops->del_virtual_intf)
2033 return -EOPNOTSUPP; 2031 return -EOPNOTSUPP;
2034 2032
2035 return rdev->ops->del_virtual_intf(&rdev->wiphy, dev); 2033 /*
2034 * If we remove a wireless device without a netdev then clear
2035 * user_ptr[1] so that nl80211_post_doit won't dereference it
2036 * to check if it needs to do dev_put(). Otherwise it crashes
2037 * since the wdev has been freed, unlike with a netdev where
2038 * we need the dev_put() for the netdev to really be freed.
2039 */
2040 if (!wdev->netdev)
2041 info->user_ptr[1] = NULL;
2042
2043 return rdev->ops->del_virtual_intf(&rdev->wiphy, wdev);
2036} 2044}
2037 2045
2038static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) 2046static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)
@@ -6874,7 +6882,7 @@ static struct genl_ops nl80211_ops[] = {
6874 .doit = nl80211_del_interface, 6882 .doit = nl80211_del_interface,
6875 .policy = nl80211_policy, 6883 .policy = nl80211_policy,
6876 .flags = GENL_ADMIN_PERM, 6884 .flags = GENL_ADMIN_PERM,
6877 .internal_flags = NL80211_FLAG_NEED_NETDEV | 6885 .internal_flags = NL80211_FLAG_NEED_WDEV |
6878 NL80211_FLAG_NEED_RTNL, 6886 NL80211_FLAG_NEED_RTNL,
6879 }, 6887 },
6880 { 6888 {