summaryrefslogtreecommitdiff
path: root/net/core/net-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/net-sysfs.c')
-rw-r--r--net/core/net-sysfs.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 3318b5666e43..352173df7578 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -37,12 +37,6 @@ static const char fmt_uint[] = "%u\n";
static const char fmt_ulong[] = "%lu\n";
static const char fmt_u64[] = "%llu\n";
-/* Caller holds RTNL, netdev->lock or RCU */
-static inline int dev_isalive(const struct net_device *dev)
-{
- return READ_ONCE(dev->reg_state) <= NETREG_REGISTERED;
-}
-
/* There is a possible ABBA deadlock between rtnl_lock and kernfs_node->active,
* when unregistering a net device and accessing associated sysfs files. The
* potential deadlock is as follow:
@@ -1438,7 +1432,7 @@ static ssize_t traffic_class_show(struct kobject *kobj, struct attribute *attr,
/* If queue belongs to subordinate dev use its TC mapping */
dev = netdev_get_tx_queue(dev, index)->sb_dev ? : dev;
- num_tc = dev->num_tc;
+ num_tc = READ_ONCE(dev->num_tc);
tc = netdev_txq_to_tc(dev, index);
rtnl_unlock();
@@ -2340,6 +2334,9 @@ int netdev_register_kobject(struct net_device *ndev)
*groups++ = &wireless_group;
#endif /* CONFIG_SYSFS */
+ /* Hold back the KOBJ_ADD uevent until the device is listed. */
+ dev_set_uevent_suppress(dev, 1);
+
error = device_add(dev);
if (error)
return error;
@@ -2355,6 +2352,17 @@ int netdev_register_kobject(struct net_device *ndev)
return error;
}
+/* Announce a fully registered device to userspace. This pairs with the uevent
+ * suppression from netdev_register_kobject().
+ */
+void netdev_uevent_add(struct net_device *ndev)
+{
+ struct device *dev = &ndev->dev;
+
+ dev_set_uevent_suppress(dev, 0);
+ kobject_uevent(&dev->kobj, KOBJ_ADD);
+}
+
/* Change owner for sysfs entries when moving network devices across network
* namespaces owned by different user namespaces.
*/