Skip to content

Commit 7f8ed01

Browse files
denkenzjmberg-intel
authored andcommitted
cfg80211: always notify userspace when wireless netdev is removed
This change alters the semantics of NL80211_CMD_DEL_INTERFACE events by always sending this event whenever a net_device object associated with a wdev is destroyed. Prior to this change, this event was only emitted as a result of NL80211_CMD_DEL_INTERFACE command sent from userspace. This allows userspace to reliably detect when wireless interfaces have been removed, e.g. due to USB removal events, etc. For wireless device objects without an associated net_device (e.g. NL80211_IFTYPE_P2P_DEVICE), the NL80211_CMD_DEL_INTERFACE event is now generated inside cfg80211_unregister_wdev. Signed-off-by: Denis Kenzior <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 896ff06 commit 7f8ed01

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

net/wireless/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,8 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
906906
if (WARN_ON(wdev->netdev))
907907
return;
908908

909+
nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
910+
909911
list_del_rcu(&wdev->list);
910912
rdev->devlist_generation++;
911913

@@ -1159,6 +1161,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
11591161
* remove and clean it up.
11601162
*/
11611163
if (!list_empty(&wdev->list)) {
1164+
nl80211_notify_iface(rdev, wdev,
1165+
NL80211_CMD_DEL_INTERFACE);
11621166
sysfs_remove_link(&dev->dev.kobj, "phy80211");
11631167
list_del_rcu(&wdev->list);
11641168
rdev->devlist_generation++;

net/wireless/nl80211.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,18 +2871,10 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
28712871
{
28722872
struct cfg80211_registered_device *rdev = info->user_ptr[0];
28732873
struct wireless_dev *wdev = info->user_ptr[1];
2874-
struct sk_buff *msg;
2875-
int status;
28762874

28772875
if (!rdev->ops->del_virtual_intf)
28782876
return -EOPNOTSUPP;
28792877

2880-
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2881-
if (msg && nl80211_send_iface(msg, 0, 0, 0, rdev, wdev, true) < 0) {
2882-
nlmsg_free(msg);
2883-
msg = NULL;
2884-
}
2885-
28862878
/*
28872879
* If we remove a wireless device without a netdev then clear
28882880
* user_ptr[1] so that nl80211_post_doit won't dereference it
@@ -2893,15 +2885,7 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
28932885
if (!wdev->netdev)
28942886
info->user_ptr[1] = NULL;
28952887

2896-
status = rdev_del_virtual_intf(rdev, wdev);
2897-
if (status >= 0 && msg)
2898-
genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
2899-
msg, 0, NL80211_MCGRP_CONFIG,
2900-
GFP_KERNEL);
2901-
else
2902-
nlmsg_free(msg);
2903-
2904-
return status;
2888+
return rdev_del_virtual_intf(rdev, wdev);
29052889
}
29062890

29072891
static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)

0 commit comments

Comments
 (0)