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

[NETNS]: Process /proc/net/rt_cache inside a namespace.

Show routing cache for a particular namespace only.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 642d6318
...@@ -273,6 +273,7 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr) ...@@ -273,6 +273,7 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct rt_cache_iter_state { struct rt_cache_iter_state {
struct seq_net_private p;
int bucket; int bucket;
int genid; int genid;
}; };
...@@ -285,7 +286,8 @@ static struct rtable *rt_cache_get_first(struct rt_cache_iter_state *st) ...@@ -285,7 +286,8 @@ static struct rtable *rt_cache_get_first(struct rt_cache_iter_state *st)
rcu_read_lock_bh(); rcu_read_lock_bh();
r = rcu_dereference(rt_hash_table[st->bucket].chain); r = rcu_dereference(rt_hash_table[st->bucket].chain);
while (r) { while (r) {
if (r->rt_genid == st->genid) if (r->u.dst.dev->nd_net == st->p.net &&
r->rt_genid == st->genid)
return r; return r;
r = rcu_dereference(r->u.dst.rt_next); r = rcu_dereference(r->u.dst.rt_next);
} }
...@@ -312,6 +314,8 @@ static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st, ...@@ -312,6 +314,8 @@ static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st,
struct rtable *r) struct rtable *r)
{ {
while ((r = __rt_cache_get_next(st, r)) != NULL) { while ((r = __rt_cache_get_next(st, r)) != NULL) {
if (r->u.dst.dev->nd_net != st->p.net)
continue;
if (r->rt_genid == st->genid) if (r->rt_genid == st->genid)
break; break;
} }
...@@ -398,7 +402,7 @@ static const struct seq_operations rt_cache_seq_ops = { ...@@ -398,7 +402,7 @@ static const struct seq_operations rt_cache_seq_ops = {
static int rt_cache_seq_open(struct inode *inode, struct file *file) static int rt_cache_seq_open(struct inode *inode, struct file *file)
{ {
return seq_open_private(file, &rt_cache_seq_ops, return seq_open_net(inode, file, &rt_cache_seq_ops,
sizeof(struct rt_cache_iter_state)); sizeof(struct rt_cache_iter_state));
} }
...@@ -407,7 +411,7 @@ static const struct file_operations rt_cache_seq_fops = { ...@@ -407,7 +411,7 @@ static const struct file_operations rt_cache_seq_fops = {
.open = rt_cache_seq_open, .open = rt_cache_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release_private, .release = seq_release_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