Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 715cf35a authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller
Browse files

[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: default avatarAlexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 025d93d1
Loading
Loading
Loading
Loading
+19 −12
Original line number Original line Diff line number Diff line
@@ -720,27 +720,33 @@ void *xt_unregister_table(struct xt_table *table)
EXPORT_SYMBOL_GPL(xt_unregister_table);
EXPORT_SYMBOL_GPL(xt_unregister_table);


#ifdef CONFIG_PROC_FS
#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)
static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
{
{
	struct proc_dir_entry *pde = (struct proc_dir_entry *)seq->private;
	struct xt_names_priv *priv = seq->private;
	u_int16_t af = (unsigned long)pde->data;
	struct net *net = priv->p.net;
	int af = priv->af;


	mutex_lock(&xt[af].mutex);
	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)
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;
	struct xt_names_priv *priv = seq->private;
	u_int16_t af = (unsigned long)pde->data;
	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)
static void xt_table_seq_stop(struct seq_file *seq, void *v)
{
{
	struct proc_dir_entry *pde = seq->private;
	struct xt_names_priv *priv = seq->private;
	u_int16_t af = (unsigned long)pde->data;
	int af = priv->af;


	mutex_unlock(&xt[af].mutex);
	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)
static int xt_table_open(struct inode *inode, struct file *file)
{
{
	int ret;
	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) {
	if (!ret) {
		struct seq_file *seq = file->private_data;
		priv = ((struct seq_file *)file->private_data)->private;

		priv->af = (unsigned long)PDE(inode)->data;
		seq->private = PDE(inode);
	}
	}
	return ret;
	return ret;
}
}