aboutsummaryrefslogtreecommitdiffstats
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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 92d6b9467314..6ac29a46e23e 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -270,7 +270,6 @@ static ssize_t netstat_show(const struct device *d,
270 unsigned long offset) 270 unsigned long offset)
271{ 271{
272 struct net_device *dev = to_net_dev(d); 272 struct net_device *dev = to_net_dev(d);
273 struct net_device_stats *stats;
274 ssize_t ret = -EINVAL; 273 ssize_t ret = -EINVAL;
275 274
276 WARN_ON(offset > sizeof(struct net_device_stats) || 275 WARN_ON(offset > sizeof(struct net_device_stats) ||
@@ -278,7 +277,7 @@ static ssize_t netstat_show(const struct device *d,
278 277
279 read_lock(&dev_base_lock); 278 read_lock(&dev_base_lock);
280 if (dev_isalive(dev)) { 279 if (dev_isalive(dev)) {
281 stats = dev->get_stats(dev); 280 const struct net_device_stats *stats = dev_get_stats(dev);
282 ret = sprintf(buf, fmt_ulong, 281 ret = sprintf(buf, fmt_ulong,
283 *(unsigned long *)(((u8 *) stats) + offset)); 282 *(unsigned long *)(((u8 *) stats) + offset));
284 } 283 }
@@ -428,6 +427,9 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
428 struct net_device *dev = to_net_dev(d); 427 struct net_device *dev = to_net_dev(d);
429 int retval; 428 int retval;
430 429
430 if (!net_eq(dev_net(dev), &init_net))
431 return 0;
432
431 /* pass interface to uevent. */ 433 /* pass interface to uevent. */
432 retval = add_uevent_var(env, "INTERFACE=%s", dev->name); 434 retval = add_uevent_var(env, "INTERFACE=%s", dev->name);
433 if (retval) 435 if (retval)
@@ -476,6 +478,10 @@ void netdev_unregister_kobject(struct net_device * net)
476 struct device *dev = &(net->dev); 478 struct device *dev = &(net->dev);
477 479
478 kobject_get(&dev->kobj); 480 kobject_get(&dev->kobj);
481
482 if (dev_net(net) != &init_net)
483 return;
484
479 device_del(dev); 485 device_del(dev);
480} 486}
481 487
@@ -490,7 +496,7 @@ int netdev_register_kobject(struct net_device *net)
490 dev->groups = groups; 496 dev->groups = groups;
491 497
492 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ); 498 BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
493 strlcpy(dev->bus_id, net->name, BUS_ID_SIZE); 499 dev_set_name(dev, net->name);
494 500
495#ifdef CONFIG_SYSFS 501#ifdef CONFIG_SYSFS
496 *groups++ = &netstat_group; 502 *groups++ = &netstat_group;
@@ -501,6 +507,9 @@ int netdev_register_kobject(struct net_device *net)
501#endif 507#endif
502#endif /* CONFIG_SYSFS */ 508#endif /* CONFIG_SYSFS */
503 509
510 if (dev_net(net) != &init_net)
511 return 0;
512
504 return device_add(dev); 513 return device_add(dev);
505} 514}
506 515