]> err.no Git - linux-2.6/blobdiff - net/netfilter/x_tables.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
[linux-2.6] / net / netfilter / x_tables.c
index 89e322d3b3617480d0413d3db70c031b4a84a81e..a6792089fcf9d4d8430af560addfb8f8a758b7b5 100644 (file)
@@ -720,27 +720,33 @@ void *xt_unregister_table(struct xt_table *table)
 EXPORT_SYMBOL_GPL(xt_unregister_table);
 
 #ifdef CONFIG_PROC_FS
+struct xt_names_priv {
+       struct seq_net_private p;
+       int af;
+};
 static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
 {
-       struct proc_dir_entry *pde = (struct proc_dir_entry *)seq->private;
-       u_int16_t af = (unsigned long)pde->data;
+       struct xt_names_priv *priv = seq->private;
+       struct net *net = priv->p.net;
+       int af = priv->af;
 
        mutex_lock(&xt[af].mutex);
-       return seq_list_start(&init_net.xt.tables[af], *pos);
+       return seq_list_start(&net->xt.tables[af], *pos);
 }
 
 static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-       struct proc_dir_entry *pde = (struct proc_dir_entry *)seq->private;
-       u_int16_t af = (unsigned long)pde->data;
+       struct xt_names_priv *priv = seq->private;
+       struct net *net = priv->p.net;
+       int af = priv->af;
 
-       return seq_list_next(v, &init_net.xt.tables[af], pos);
+       return seq_list_next(v, &net->xt.tables[af], pos);
 }
 
 static void xt_table_seq_stop(struct seq_file *seq, void *v)
 {
-       struct proc_dir_entry *pde = seq->private;
-       u_int16_t af = (unsigned long)pde->data;
+       struct xt_names_priv *priv = seq->private;
+       int af = priv->af;
 
        mutex_unlock(&xt[af].mutex);
 }
@@ -765,12 +771,13 @@ static const struct seq_operations xt_table_seq_ops = {
 static int xt_table_open(struct inode *inode, struct file *file)
 {
        int ret;
+       struct xt_names_priv *priv;
 
-       ret = seq_open(file, &xt_table_seq_ops);
+       ret = seq_open_net(inode, file, &xt_table_seq_ops,
+                          sizeof(struct xt_names_priv));
        if (!ret) {
-               struct seq_file *seq = file->private_data;
-
-               seq->private = PDE(inode);
+               priv = ((struct seq_file *)file->private_data)->private;
+               priv->af = (unsigned long)PDE(inode)->data;
        }
        return ret;
 }
@@ -915,7 +922,7 @@ static const struct file_operations xt_target_ops = {
 
 #endif /* CONFIG_PROC_FS */
 
-int xt_proto_init(int af)
+int xt_proto_init(struct net *net, int af)
 {
 #ifdef CONFIG_PROC_FS
        char buf[XT_FUNCTION_MAXNAMELEN];
@@ -929,7 +936,7 @@ int xt_proto_init(int af)
 #ifdef CONFIG_PROC_FS
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_TABLES, sizeof(buf));
-       proc = proc_net_fops_create(&init_net, buf, 0440, &xt_table_ops);
+       proc = proc_net_fops_create(net, buf, 0440, &xt_table_ops);
        if (!proc)
                goto out;
        proc->data = (void *)(unsigned long)af;
@@ -937,14 +944,14 @@ int xt_proto_init(int af)
 
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_MATCHES, sizeof(buf));
-       proc = proc_net_fops_create(&init_net, buf, 0440, &xt_match_ops);
+       proc = proc_net_fops_create(net, buf, 0440, &xt_match_ops);
        if (!proc)
                goto out_remove_tables;
        proc->data = (void *)(unsigned long)af;
 
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_TARGETS, sizeof(buf));
-       proc = proc_net_fops_create(&init_net, buf, 0440, &xt_target_ops);
+       proc = proc_net_fops_create(net, buf, 0440, &xt_target_ops);
        if (!proc)
                goto out_remove_matches;
        proc->data = (void *)(unsigned long)af;
@@ -956,34 +963,34 @@ int xt_proto_init(int af)
 out_remove_matches:
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_MATCHES, sizeof(buf));
-       proc_net_remove(&init_net, buf);
+       proc_net_remove(net, buf);
 
 out_remove_tables:
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_TABLES, sizeof(buf));
-       proc_net_remove(&init_net, buf);
+       proc_net_remove(net, buf);
 out:
        return -1;
 #endif
 }
 EXPORT_SYMBOL_GPL(xt_proto_init);
 
-void xt_proto_fini(int af)
+void xt_proto_fini(struct net *net, int af)
 {
 #ifdef CONFIG_PROC_FS
        char buf[XT_FUNCTION_MAXNAMELEN];
 
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_TABLES, sizeof(buf));
-       proc_net_remove(&init_net, buf);
+       proc_net_remove(net, buf);
 
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_TARGETS, sizeof(buf));
-       proc_net_remove(&init_net, buf);
+       proc_net_remove(net, buf);
 
        strlcpy(buf, xt_prefix[af], sizeof(buf));
        strlcat(buf, FORMAT_MATCHES, sizeof(buf));
-       proc_net_remove(&init_net, buf);
+       proc_net_remove(net, buf);
 #endif /*CONFIG_PROC_FS*/
 }
 EXPORT_SYMBOL_GPL(xt_proto_fini);