net: spread __net_init, __net_exit
[safe/jmp/linux-2.6] / net / 8021q / vlanproc.c
index 995544b..afead35 100644 (file)
  *****************************************************************************/
 
 #include <linux/module.h>
-#include <linux/stddef.h>      /* offsetof(), etc. */
-#include <linux/errno.h>       /* return codes */
+#include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>                /* kmalloc(), kfree() */
-#include <linux/mm.h>
-#include <linux/string.h>      /* inline mem*, str* functions */
-#include <linux/init.h>                /* __initfunc et al. */
-#include <asm/byteorder.h>     /* htons(), etc. */
-#include <asm/uaccess.h>       /* copy_to_user */
-#include <asm/io.h>
+#include <linux/string.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/fs.h>
@@ -80,7 +73,8 @@ static const struct seq_operations vlan_seq_ops = {
 
 static int vlan_seq_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &vlan_seq_ops);
+       return seq_open_net(inode, file, &vlan_seq_ops,
+                       sizeof(struct seq_net_private));
 }
 
 static const struct file_operations vlan_fops = {
@@ -88,7 +82,7 @@ static const struct file_operations vlan_fops = {
        .open    = vlan_seq_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
-       .release = seq_release,
+       .release = seq_release_net,
 };
 
 /*
@@ -113,7 +107,7 @@ static const struct file_operations vlandev_fops = {
  */
 
 /* Strings */
-static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
+static const char *const vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
     [VLAN_NAME_TYPE_RAW_PLUS_VID]        = "VLAN_NAME_TYPE_RAW_PLUS_VID",
     [VLAN_NAME_TYPE_PLUS_VID_NO_PAD]    = "VLAN_NAME_TYPE_PLUS_VID_NO_PAD",
     [VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD] = "VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD",
@@ -146,7 +140,7 @@ void vlan_proc_cleanup(struct net *net)
  *     Create /proc/net/vlan entries
  */
 
-int vlan_proc_init(struct net *net)
+int __net_init vlan_proc_init(struct net *net)
 {
        struct vlan_net *vn = net_generic(net, vlan_net_id);
 
@@ -175,12 +169,11 @@ int vlan_proc_add_dev(struct net_device *vlandev)
        struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
        struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
 
-       dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
-                                    vn->proc_vlan_dir, &vlandev_fops);
+       dev_info->dent =
+               proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
+                                vn->proc_vlan_dir, &vlandev_fops, vlandev);
        if (!dev_info->dent)
                return -ENOBUFS;
-
-       dev_info->dent->data = vlandev;
        return 0;
 }
 
@@ -208,17 +201,17 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
 
 /* start read of /proc/net/vlan/config */
 static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
-       __acquires(dev_base_lock)
+       __acquires(rcu)
 {
        struct net_device *dev;
+       struct net *net = seq_file_net(seq);
        loff_t i = 1;
 
-       read_lock(&dev_base_lock);
-
+       rcu_read_lock();
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for_each_netdev(&init_net, dev) {
+       for_each_netdev_rcu(net, dev) {
                if (!is_vlan_dev(dev))
                        continue;
 
@@ -232,14 +225,15 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
 static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        struct net_device *dev;
+       struct net *net = seq_file_net(seq);
 
        ++*pos;
 
        dev = (struct net_device *)v;
        if (v == SEQ_START_TOKEN)
-               dev = net_device_entry(&init_net.dev_base_head);
+               dev = net_device_entry(&net->dev_base_head);
 
-       for_each_netdev_continue(&init_net, dev) {
+       for_each_netdev_continue_rcu(net, dev) {
                if (!is_vlan_dev(dev))
                        continue;
 
@@ -250,20 +244,23 @@ static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 }
 
 static void vlan_seq_stop(struct seq_file *seq, void *v)
-       __releases(dev_base_lock)
+       __releases(rcu)
 {
-       read_unlock(&dev_base_lock);
+       rcu_read_unlock();
 }
 
 static int vlan_seq_show(struct seq_file *seq, void *v)
 {
+       struct net *net = seq_file_net(seq);
+       struct vlan_net *vn = net_generic(net, vlan_net_id);
+
        if (v == SEQ_START_TOKEN) {
                const char *nmtype = NULL;
 
                seq_puts(seq, "VLAN Dev name     | VLAN ID\n");
 
-               if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str))
-                   nmtype =  vlan_name_type_str[vlan_name_type];
+               if (vn->name_type < ARRAY_SIZE(vlan_name_type_str))
+                   nmtype =  vlan_name_type_str[vn->name_type];
 
                seq_printf(seq, "Name-Type: %s\n",
                           nmtype ? nmtype :  "UNKNOWN");
@@ -281,13 +278,14 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
 {
        struct net_device *vlandev = (struct net_device *) seq->private;
        const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
-       struct net_device_stats *stats = &vlandev->stats;
+       const struct net_device_stats *stats;
        static const char fmt[] = "%30s %12lu\n";
        int i;
 
-       if (!(vlandev->priv_flags & IFF_802_1Q_VLAN))
+       if (!is_vlan_dev(vlandev))
                return 0;
 
+       stats = dev_get_stats(vlandev);
        seq_printf(seq,
                   "%s  VID: %d  REORDER_HDR: %i  dev->priv_flags: %hx\n",
                   vlandev->name, dev_info->vlan_id,
@@ -316,7 +314,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
                   dev_info->ingress_priority_map[6],
                   dev_info->ingress_priority_map[7]);
 
-       seq_printf(seq, "EGRESSS priority Mappings: ");
+       seq_printf(seq, " EGRESS priority mappings: ");
        for (i = 0; i < 16; i++) {
                const struct vlan_priority_tci_mapping *mp
                        = dev_info->egress_priority_map[i];