]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/core/net-sysfs.c
net: convert usage of packet_type to read_mostly
[net-next-2.6.git] / net / core / net-sysfs.c
index 85cb8bdcfb8f4feb154d65c34be240eef3a46ba2..484f58750eba0438cff11dcf0979ceb4ef46738b 100644 (file)
@@ -77,7 +77,9 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
        if (endp == buf)
                goto err;
 
-       rtnl_lock();
+       if (!rtnl_trylock())
+               return -ERESTARTSYS;
+
        if (dev_isalive(net)) {
                if ((ret = (*set)(net, new)) == 0)
                        ret = len;
@@ -270,7 +272,6 @@ static ssize_t netstat_show(const struct device *d,
                            unsigned long offset)
 {
        struct net_device *dev = to_net_dev(d);
-       struct net_device_stats *stats;
        ssize_t ret = -EINVAL;
 
        WARN_ON(offset > sizeof(struct net_device_stats) ||
@@ -278,7 +279,7 @@ static ssize_t netstat_show(const struct device *d,
 
        read_lock(&dev_base_lock);
        if (dev_isalive(dev)) {
-               stats = dev->get_stats(dev);
+               const struct net_device_stats *stats = dev_get_stats(dev);
                ret = sprintf(buf, fmt_ulong,
                              *(unsigned long *)(((u8 *) stats) + offset));
        }
@@ -428,6 +429,9 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
        struct net_device *dev = to_net_dev(d);
        int retval;
 
+       if (!net_eq(dev_net(dev), &init_net))
+               return 0;
+
        /* pass interface to uevent. */
        retval = add_uevent_var(env, "INTERFACE=%s", dev->name);
        if (retval)
@@ -494,7 +498,7 @@ int netdev_register_kobject(struct net_device *net)
        dev->groups = groups;
 
        BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
-       strlcpy(dev->bus_id, net->name, BUS_ID_SIZE);
+       dev_set_name(dev, net->name);
 
 #ifdef CONFIG_SYSFS
        *groups++ = &netstat_group;