aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2008-01-31 07:49:16 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:28:05 -0500
commit715cf35ac9291f31a4fea7d022695a64cac0af80 (patch)
tree2bdc67caa0b6cca6d580c0c2fc9642fbccf0a1f6 /net
parent025d93d148d46bedb26905975f5d9c83d280b46e (diff)
[NETFILTER]: x_tables: netns propagation for /proc/net/*_tables_names
Propagate netns together with AF down to ->start/->next/->stop iterators. Choose table based on netns and AF for showing. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/x_tables.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 89e322d3b361..12ed64c0bc9a 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -720,27 +720,33 @@ void *xt_unregister_table(struct xt_table *table)
720EXPORT_SYMBOL_GPL(xt_unregister_table); 720EXPORT_SYMBOL_GPL(xt_unregister_table);
721 721
722#ifdef CONFIG_PROC_FS 722#ifdef CONFIG_PROC_FS
723struct xt_names_priv {
724 struct seq_net_private p;
725 int af;
726};
723static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos) 727static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
724{ 728{
725 struct proc_dir_entry *pde = (struct proc_dir_entry *)seq->private; 729 struct xt_names_priv *priv = seq->private;
726 u_int16_t af = (unsigned long)pde->data; 730 struct net *net = priv->p.net;
731 int af = priv->af;
727 732
728 mutex_lock(&xt[af].mutex); 733 mutex_lock(&xt[af].mutex);
729 return seq_list_start(&init_net.xt.tables[af], *pos); 734 return seq_list_start(&net->xt.tables[af], *pos);
730} 735}
731 736
732static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos) 737static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos)
733{ 738{
734 struct proc_dir_entry *pde = (struct proc_dir_entry *)seq->private; 739 struct xt_names_priv *priv = seq->private;
735 u_int16_t af = (unsigned long)pde->data; 740 struct net *net = priv->p.net;
741 int af = priv->af;
736 742
737 return seq_list_next(v, &init_net.xt.tables[af], pos); 743 return seq_list_next(v, &net->xt.tables[af], pos);
738} 744}
739 745
740static void xt_table_seq_stop(struct seq_file *seq, void *v) 746static void xt_table_seq_stop(struct seq_file *seq, void *v)
741{ 747{
742 struct proc_dir_entry *pde = seq->private; 748 struct xt_names_priv *priv = seq->private;
743 u_int16_t af = (unsigned long)pde->data; 749 int af = priv->af;
744 750
745 mutex_unlock(&xt[af].mutex); 751 mutex_unlock(&xt[af].mutex);
746} 752}
@@ -765,12 +771,13 @@ static const struct seq_operations xt_table_seq_ops = {
765static int xt_table_open(struct inode *inode, struct file *file) 771static int xt_table_open(struct inode *inode, struct file *file)
766{ 772{
767 int ret; 773 int ret;
774 struct xt_names_priv *priv;
768 775
769 ret = seq_open(file, &xt_table_seq_ops); 776 ret = seq_open_net(inode, file, &xt_table_seq_ops,
777 sizeof(struct xt_names_priv));
770 if (!ret) { 778 if (!ret) {
771 struct seq_file *seq = file->private_data; 779 priv = ((struct seq_file *)file->private_data)->private;
772 780 priv->af = (unsigned long)PDE(inode)->data;
773 seq->private = PDE(inode);
774 } 781 }
775 return ret; 782 return ret;
776} 783}