aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-01-10 06:27:17 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:01:30 -0500
commit1c340b2fd73880136c438e6e7978288fbec8273f (patch)
treee7d0c1e22be9acc4542e61125838a3b1e8bbb5fd /net/ipv4/fib_trie.c
parent6e04d01dfa6fe81d6bcae1e85de695285086cee2 (diff)
[NETNS]: Show routing information from correct namespace (fib_trie.c)
This is the second part (for the CONFIG_IP_FIB_TRIE case) of the patch #4, where we have created proc files in namespaces. Now we can dump correct info in them. Acked-by: Benjamin Thery <benjamin.thery@bull.net> Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index fc0624e6a649..aa9deb708dcf 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1995,6 +1995,7 @@ struct fib_table *fib_hash_init(u32 id)
1995#ifdef CONFIG_PROC_FS 1995#ifdef CONFIG_PROC_FS
1996/* Depth first Trie walk iterator */ 1996/* Depth first Trie walk iterator */
1997struct fib_trie_iter { 1997struct fib_trie_iter {
1998 struct seq_net_private p;
1998 struct trie *trie_local, *trie_main; 1999 struct trie *trie_local, *trie_main;
1999 struct tnode *tnode; 2000 struct tnode *tnode;
2000 struct trie *trie; 2001 struct trie *trie;
@@ -2162,17 +2163,18 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
2162 2163
2163static int fib_triestat_seq_show(struct seq_file *seq, void *v) 2164static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2164{ 2165{
2166 struct net *net = (struct net *)seq->private;
2165 struct trie *trie_local, *trie_main; 2167 struct trie *trie_local, *trie_main;
2166 struct trie_stat *stat; 2168 struct trie_stat *stat;
2167 struct fib_table *tb; 2169 struct fib_table *tb;
2168 2170
2169 trie_local = NULL; 2171 trie_local = NULL;
2170 tb = fib_get_table(&init_net, RT_TABLE_LOCAL); 2172 tb = fib_get_table(net, RT_TABLE_LOCAL);
2171 if (tb) 2173 if (tb)
2172 trie_local = (struct trie *) tb->tb_data; 2174 trie_local = (struct trie *) tb->tb_data;
2173 2175
2174 trie_main = NULL; 2176 trie_main = NULL;
2175 tb = fib_get_table(&init_net, RT_TABLE_MAIN); 2177 tb = fib_get_table(net, RT_TABLE_MAIN);
2176 if (tb) 2178 if (tb)
2177 trie_main = (struct trie *) tb->tb_data; 2179 trie_main = (struct trie *) tb->tb_data;
2178 2180
@@ -2202,7 +2204,25 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2202 2204
2203static int fib_triestat_seq_open(struct inode *inode, struct file *file) 2205static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2204{ 2206{
2205 return single_open(file, fib_triestat_seq_show, NULL); 2207 int err;
2208 struct net *net;
2209
2210 net = get_proc_net(inode);
2211 if (net == NULL)
2212 return -ENXIO;
2213 err = single_open(file, fib_triestat_seq_show, net);
2214 if (err < 0) {
2215 put_net(net);
2216 return err;
2217 }
2218 return 0;
2219}
2220
2221static int fib_triestat_seq_release(struct inode *ino, struct file *f)
2222{
2223 struct seq_file *seq = f->private_data;
2224 put_net(seq->private);
2225 return single_release(ino, f);
2206} 2226}
2207 2227
2208static const struct file_operations fib_triestat_fops = { 2228static const struct file_operations fib_triestat_fops = {
@@ -2210,7 +2230,7 @@ static const struct file_operations fib_triestat_fops = {
2210 .open = fib_triestat_seq_open, 2230 .open = fib_triestat_seq_open,
2211 .read = seq_read, 2231 .read = seq_read,
2212 .llseek = seq_lseek, 2232 .llseek = seq_lseek,
2213 .release = single_release, 2233 .release = fib_triestat_seq_release,
2214}; 2234};
2215 2235
2216static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, 2236static struct node *fib_trie_get_idx(struct fib_trie_iter *iter,
@@ -2239,12 +2259,12 @@ static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
2239 struct fib_table *tb; 2259 struct fib_table *tb;
2240 2260
2241 if (!iter->trie_local) { 2261 if (!iter->trie_local) {
2242 tb = fib_get_table(&init_net, RT_TABLE_LOCAL); 2262 tb = fib_get_table(iter->p.net, RT_TABLE_LOCAL);
2243 if (tb) 2263 if (tb)
2244 iter->trie_local = (struct trie *) tb->tb_data; 2264 iter->trie_local = (struct trie *) tb->tb_data;
2245 } 2265 }
2246 if (!iter->trie_main) { 2266 if (!iter->trie_main) {
2247 tb = fib_get_table(&init_net, RT_TABLE_MAIN); 2267 tb = fib_get_table(iter->p.net, RT_TABLE_MAIN);
2248 if (tb) 2268 if (tb)
2249 iter->trie_main = (struct trie *) tb->tb_data; 2269 iter->trie_main = (struct trie *) tb->tb_data;
2250 } 2270 }
@@ -2388,8 +2408,8 @@ static const struct seq_operations fib_trie_seq_ops = {
2388 2408
2389static int fib_trie_seq_open(struct inode *inode, struct file *file) 2409static int fib_trie_seq_open(struct inode *inode, struct file *file)
2390{ 2410{
2391 return seq_open_private(file, &fib_trie_seq_ops, 2411 return seq_open_net(inode, file, &fib_trie_seq_ops,
2392 sizeof(struct fib_trie_iter)); 2412 sizeof(struct fib_trie_iter));
2393} 2413}
2394 2414
2395static const struct file_operations fib_trie_fops = { 2415static const struct file_operations fib_trie_fops = {
@@ -2397,7 +2417,7 @@ static const struct file_operations fib_trie_fops = {
2397 .open = fib_trie_seq_open, 2417 .open = fib_trie_seq_open,
2398 .read = seq_read, 2418 .read = seq_read,
2399 .llseek = seq_lseek, 2419 .llseek = seq_lseek,
2400 .release = seq_release_private, 2420 .release = seq_release_net,
2401}; 2421};
2402 2422
2403static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi) 2423static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi)
@@ -2492,8 +2512,8 @@ static const struct seq_operations fib_route_seq_ops = {
2492 2512
2493static int fib_route_seq_open(struct inode *inode, struct file *file) 2513static int fib_route_seq_open(struct inode *inode, struct file *file)
2494{ 2514{
2495 return seq_open_private(file, &fib_route_seq_ops, 2515 return seq_open_net(inode, file, &fib_route_seq_ops,
2496 sizeof(struct fib_trie_iter)); 2516 sizeof(struct fib_trie_iter));
2497} 2517}
2498 2518
2499static const struct file_operations fib_route_fops = { 2519static const struct file_operations fib_route_fops = {
@@ -2501,7 +2521,7 @@ static const struct file_operations fib_route_fops = {
2501 .open = fib_route_seq_open, 2521 .open = fib_route_seq_open,
2502 .read = seq_read, 2522 .read = seq_read,
2503 .llseek = seq_lseek, 2523 .llseek = seq_lseek,
2504 .release = seq_release_private, 2524 .release = seq_release_net,
2505}; 2525};
2506 2526
2507int __net_init fib_proc_init(struct net *net) 2527int __net_init fib_proc_init(struct net *net)