Commit 6e04d01d authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Show routing information from correct namespace (fib_hash.c)

This is the second part (for the CONFIG_IP_FIB_HASH case) of the patch
#4, where we have created proc files in namespaces.

Now we can dump correct info in them.
Acked-by: default avatarBenjamin Thery <benjamin.thery@bull.net>
Acked-by: default avatarDaniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4d1169c1
...@@ -783,6 +783,7 @@ struct fib_table *fib_hash_init(u32 id) ...@@ -783,6 +783,7 @@ struct fib_table *fib_hash_init(u32 id)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct fib_iter_state { struct fib_iter_state {
struct seq_net_private p;
struct fn_zone *zone; struct fn_zone *zone;
int bucket; int bucket;
struct hlist_head *hash_head; struct hlist_head *hash_head;
...@@ -796,8 +797,11 @@ struct fib_iter_state { ...@@ -796,8 +797,11 @@ struct fib_iter_state {
static struct fib_alias *fib_get_first(struct seq_file *seq) static struct fib_alias *fib_get_first(struct seq_file *seq)
{ {
struct fib_iter_state *iter = seq->private; struct fib_iter_state *iter = seq->private;
struct fib_table *main_table = fib_get_table(&init_net, RT_TABLE_MAIN); struct fib_table *main_table;
struct fn_hash *table = (struct fn_hash *)main_table->tb_data; struct fn_hash *table;
main_table = fib_get_table(iter->p.net, RT_TABLE_MAIN);
table = (struct fn_hash *)main_table->tb_data;
iter->bucket = 0; iter->bucket = 0;
iter->hash_head = NULL; iter->hash_head = NULL;
...@@ -934,10 +938,11 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos) ...@@ -934,10 +938,11 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos)
static void *fib_seq_start(struct seq_file *seq, loff_t *pos) static void *fib_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(fib_hash_lock) __acquires(fib_hash_lock)
{ {
struct fib_iter_state *iter = seq->private;
void *v = NULL; void *v = NULL;
read_lock(&fib_hash_lock); read_lock(&fib_hash_lock);
if (fib_get_table(&init_net, RT_TABLE_MAIN)) if (fib_get_table(iter->p.net, RT_TABLE_MAIN))
v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
return v; return v;
} }
...@@ -1025,8 +1030,8 @@ static const struct seq_operations fib_seq_ops = { ...@@ -1025,8 +1030,8 @@ static const struct seq_operations fib_seq_ops = {
static int fib_seq_open(struct inode *inode, struct file *file) static int fib_seq_open(struct inode *inode, struct file *file)
{ {
return seq_open_private(file, &fib_seq_ops, return seq_open_net(inode, file, &fib_seq_ops,
sizeof(struct fib_iter_state)); sizeof(struct fib_iter_state));
} }
static const struct file_operations fib_seq_fops = { static const struct file_operations fib_seq_fops = {
...@@ -1034,7 +1039,7 @@ static const struct file_operations fib_seq_fops = { ...@@ -1034,7 +1039,7 @@ static const struct file_operations fib_seq_fops = {
.open = fib_seq_open, .open = fib_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release_private, .release = seq_release_net,
}; };
int __net_init fib_proc_init(struct net *net) int __net_init fib_proc_init(struct net *net)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment