aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-12-03 03:20:42 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-12-06 16:01:28 -0500
commitf9e10ce4cf86945eb5efcab31284c971877ed012 (patch)
treea56ec8ed84019901bf92aa969e366afb8b8ce36b
parent09b174702601079c3a04806754be30ffbd70db4d (diff)
cfg80211: require add_virtual_intf to return new dev
cfg80211 used to do all its bookkeeping in the notifier, but some new stuff will have to use local variables so make the callback return the netdev pointer. Tested-by: Javier Cardona <javier@cozybit.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/net/cfg80211.h11
-rw-r--r--net/mac80211/cfg.c20
-rw-r--r--net/wireless/nl80211.c7
3 files changed, 24 insertions, 14 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 93a4b2068334..902895dfbd49 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1033,7 +1033,8 @@ struct cfg80211_pmksa {
1033 * 1033 *
1034 * @add_virtual_intf: create a new virtual interface with the given name, 1034 * @add_virtual_intf: create a new virtual interface with the given name,
1035 * must set the struct wireless_dev's iftype. Beware: You must create 1035 * must set the struct wireless_dev's iftype. Beware: You must create
1036 * the new netdev in the wiphy's network namespace! 1036 * the new netdev in the wiphy's network namespace! Returns the netdev,
1037 * or an ERR_PTR.
1037 * 1038 *
1038 * @del_virtual_intf: remove the virtual interface determined by ifindex. 1039 * @del_virtual_intf: remove the virtual interface determined by ifindex.
1039 * 1040 *
@@ -1168,9 +1169,11 @@ struct cfg80211_ops {
1168 int (*suspend)(struct wiphy *wiphy); 1169 int (*suspend)(struct wiphy *wiphy);
1169 int (*resume)(struct wiphy *wiphy); 1170 int (*resume)(struct wiphy *wiphy);
1170 1171
1171 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 1172 struct net_device * (*add_virtual_intf)(struct wiphy *wiphy,
1172 enum nl80211_iftype type, u32 *flags, 1173 char *name,
1173 struct vif_params *params); 1174 enum nl80211_iftype type,
1175 u32 *flags,
1176 struct vif_params *params);
1174 int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); 1177 int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev);
1175 int (*change_virtual_intf)(struct wiphy *wiphy, 1178 int (*change_virtual_intf)(struct wiphy *wiphy,
1176 struct net_device *dev, 1179 struct net_device *dev,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ce6936890c26..d34c7c3dd762 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -19,9 +19,10 @@
19#include "rate.h" 19#include "rate.h"
20#include "mesh.h" 20#include "mesh.h"
21 21
22static int ieee80211_add_iface(struct wiphy *wiphy, char *name, 22static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
23 enum nl80211_iftype type, u32 *flags, 23 enum nl80211_iftype type,
24 struct vif_params *params) 24 u32 *flags,
25 struct vif_params *params)
25{ 26{
26 struct ieee80211_local *local = wiphy_priv(wiphy); 27 struct ieee80211_local *local = wiphy_priv(wiphy);
27 struct net_device *dev; 28 struct net_device *dev;
@@ -29,12 +30,15 @@ static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
29 int err; 30 int err;
30 31
31 err = ieee80211_if_add(local, name, &dev, type, params); 32 err = ieee80211_if_add(local, name, &dev, type, params);
32 if (err || type != NL80211_IFTYPE_MONITOR || !flags) 33 if (err)
33 return err; 34 return ERR_PTR(err);
34 35
35 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 36 if (type == NL80211_IFTYPE_MONITOR && flags) {
36 sdata->u.mntr_flags = *flags; 37 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
37 return 0; 38 sdata->u.mntr_flags = *flags;
39 }
40
41 return dev;
38} 42}
39 43
40static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) 44static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0b90cab5da2f..cc2e5d6163de 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1368,6 +1368,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
1368{ 1368{
1369 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 1369 struct cfg80211_registered_device *rdev = info->user_ptr[0];
1370 struct vif_params params; 1370 struct vif_params params;
1371 struct net_device *dev;
1371 int err; 1372 int err;
1372 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; 1373 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
1373 u32 flags; 1374 u32 flags;
@@ -1403,11 +1404,13 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
1403 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? 1404 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
1404 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, 1405 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
1405 &flags); 1406 &flags);
1406 err = rdev->ops->add_virtual_intf(&rdev->wiphy, 1407 dev = rdev->ops->add_virtual_intf(&rdev->wiphy,
1407 nla_data(info->attrs[NL80211_ATTR_IFNAME]), 1408 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
1408 type, err ? NULL : &flags, &params); 1409 type, err ? NULL : &flags, &params);
1410 if (IS_ERR(dev))
1411 return PTR_ERR(dev);
1409 1412
1410 return err; 1413 return 0;
1411} 1414}
1412 1415
1413static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) 1416static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)