Skip to content

Commit f9e10ce

Browse files
jmberg-intellinvjw
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 09b1747 commit f9e10ce

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

include/net/cfg80211.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,8 @@ struct cfg80211_pmksa {
10331033
*
10341034
* @add_virtual_intf: create a new virtual interface with the given name,
10351035
* 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.
10371038
*
10381039
* @del_virtual_intf: remove the virtual interface determined by ifindex.
10391040
*
@@ -1168,9 +1169,11 @@ struct cfg80211_ops {
11681169
int (*suspend)(struct wiphy *wiphy);
11691170
int (*resume)(struct wiphy *wiphy);
11701171

1171-
int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
1172-
enum nl80211_iftype type, u32 *flags,
1173-
struct vif_params *params);
1172+
struct net_device * (*add_virtual_intf)(struct wiphy *wiphy,
1173+
char *name,
1174+
enum nl80211_iftype type,
1175+
u32 *flags,
1176+
struct vif_params *params);
11741177
int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev);
11751178
int (*change_virtual_intf)(struct wiphy *wiphy,
11761179
struct net_device *dev,

net/mac80211/cfg.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,26 @@
1919
#include "rate.h"
2020
#include "mesh.h"
2121

22-
static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
23-
enum nl80211_iftype type, u32 *flags,
24-
struct vif_params *params)
22+
static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
23+
enum nl80211_iftype type,
24+
u32 *flags,
25+
struct vif_params *params)
2526
{
2627
struct ieee80211_local *local = wiphy_priv(wiphy);
2728
struct net_device *dev;
2829
struct ieee80211_sub_if_data *sdata;
2930
int err;
3031

3132
err = ieee80211_if_add(local, name, &dev, type, params);
32-
if (err || type != NL80211_IFTYPE_MONITOR || !flags)
33-
return err;
33+
if (err)
34+
return ERR_PTR(err);
3435

35-
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
36-
sdata->u.mntr_flags = *flags;
37-
return 0;
36+
if (type == NL80211_IFTYPE_MONITOR && flags) {
37+
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
38+
sdata->u.mntr_flags = *flags;
39+
}
40+
41+
return dev;
3842
}
3943

4044
static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)

net/wireless/nl80211.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
13681368
{
13691369
struct cfg80211_registered_device *rdev = info->user_ptr[0];
13701370
struct vif_params params;
1371+
struct net_device *dev;
13711372
int err;
13721373
enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
13731374
u32 flags;
@@ -1403,11 +1404,13 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
14031404
err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
14041405
info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
14051406
&flags);
1406-
err = rdev->ops->add_virtual_intf(&rdev->wiphy,
1407+
dev = rdev->ops->add_virtual_intf(&rdev->wiphy,
14071408
nla_data(info->attrs[NL80211_ATTR_IFNAME]),
14081409
type, err ? NULL : &flags, &params);
1410+
if (IS_ERR(dev))
1411+
return PTR_ERR(dev);
14091412

1410-
return err;
1413+
return 0;
14111414
}
14121415

14131416
static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)

0 commit comments

Comments
 (0)