]> git.karo-electronics.de Git - linux-beck.git/commitdiff
cfg80211: always notify userspace when wireless netdev is removed
authorDenis Kenzior <denkenz@gmail.com>
Wed, 3 Aug 2016 21:58:35 +0000 (16:58 -0500)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 11 Aug 2016 14:51:42 +0000 (16:51 +0200)
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 <denkenz@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/core.c
net/wireless/nl80211.c

index 7758c0fe781a6f81dd52fe7fd9fca5c31416d870..2029b49a1df339ca7f9b0a240343dde86e707ef6 100644 (file)
@@ -906,6 +906,8 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
        if (WARN_ON(wdev->netdev))
                return;
 
+       nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
+
        list_del_rcu(&wdev->list);
        rdev->devlist_generation++;
 
@@ -1159,6 +1161,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
                 * remove and clean it up.
                 */
                if (!list_empty(&wdev->list)) {
+                       nl80211_notify_iface(rdev, wdev,
+                                            NL80211_CMD_DEL_INTERFACE);
                        sysfs_remove_link(&dev->dev.kobj, "phy80211");
                        list_del_rcu(&wdev->list);
                        rdev->devlist_generation++;
index a8c062dbd51d31f6ef7279bc0e6fb134dc8c3a4e..0560870fc69d94814441f9b8a0825f5d29afc4a3 100644 (file)
@@ -2871,18 +2871,10 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
        struct wireless_dev *wdev = info->user_ptr[1];
-       struct sk_buff *msg;
-       int status;
 
        if (!rdev->ops->del_virtual_intf)
                return -EOPNOTSUPP;
 
-       msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (msg && nl80211_send_iface(msg, 0, 0, 0, rdev, wdev, true) < 0) {
-               nlmsg_free(msg);
-               msg = NULL;
-       }
-
        /*
         * If we remove a wireless device without a netdev then clear
         * 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)
        if (!wdev->netdev)
                info->user_ptr[1] = NULL;
 
-       status = rdev_del_virtual_intf(rdev, wdev);
-       if (status >= 0 && msg)
-               genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
-                                       msg, 0, NL80211_MCGRP_CONFIG,
-                                       GFP_KERNEL);
-       else
-               nlmsg_free(msg);
-
-       return status;
+       return rdev_del_virtual_intf(rdev, wdev);
 }
 
 static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)