aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lezcano <dlezcano@fr.ibm.com>2008-03-04 16:45:33 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-04 16:45:33 -0500
commitcdb1876192dbe680b3ac955717fdf7f863c1762d (patch)
treefb2bb2fda2aa828dc9a38c414a8fb086a3778fb6
parent83321d6b9872b94604e481a79dc2c8acbe4ece31 (diff)
[NETNS][IPV6] route6 - create route6 proc files for the namespace
Make /proc/net/ipv6_route and /proc/net/rt6_stats to be per namespace. These proc files are now created when the network namespace is initialized. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/route.c70
1 files changed, 27 insertions, 43 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3afc3f41f2d5..5d9d293156cd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2377,40 +2377,6 @@ static const struct file_operations rt6_stats_seq_fops = {
2377 .llseek = seq_lseek, 2377 .llseek = seq_lseek,
2378 .release = single_release, 2378 .release = single_release,
2379}; 2379};
2380
2381static int ipv6_route_proc_init(struct net *net)
2382{
2383 int ret = -ENOMEM;
2384 if (!proc_net_fops_create(net, "ipv6_route",
2385 0, &ipv6_route_proc_fops))
2386 goto out;
2387
2388 if (!proc_net_fops_create(net, "rt6_stats",
2389 S_IRUGO, &rt6_stats_seq_fops))
2390 goto out_ipv6_route;
2391
2392 ret = 0;
2393out:
2394 return ret;
2395out_ipv6_route:
2396 proc_net_remove(net, "ipv6_route");
2397 goto out;
2398}
2399
2400static void ipv6_route_proc_fini(struct net *net)
2401{
2402 proc_net_remove(net, "ipv6_route");
2403 proc_net_remove(net, "rt6_stats");
2404}
2405#else
2406static inline int ipv6_route_proc_init(struct net *net)
2407{
2408 return 0;
2409}
2410static inline void ipv6_route_proc_fini(struct net *net)
2411{
2412 return ;
2413}
2414#endif /* CONFIG_PROC_FS */ 2380#endif /* CONFIG_PROC_FS */
2415 2381
2416#ifdef CONFIG_SYSCTL 2382#ifdef CONFIG_SYSCTL
@@ -2544,6 +2510,28 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net)
2544} 2510}
2545#endif 2511#endif
2546 2512
2513static int ip6_route_net_init(struct net *net)
2514{
2515#ifdef CONFIG_PROC_FS
2516 proc_net_fops_create(net, "ipv6_route", 0, &ipv6_route_proc_fops);
2517 proc_net_fops_create(net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
2518#endif
2519 return 0;
2520}
2521
2522static void ip6_route_net_exit(struct net *net)
2523{
2524#ifdef CONFIG_PROC_FS
2525 proc_net_remove(net, "ipv6_route");
2526 proc_net_remove(net, "rt6_stats");
2527#endif
2528}
2529
2530static struct pernet_operations ip6_route_net_ops = {
2531 .init = ip6_route_net_init,
2532 .exit = ip6_route_net_exit,
2533};
2534
2547int __init ip6_route_init(void) 2535int __init ip6_route_init(void)
2548{ 2536{
2549 int ret; 2537 int ret;
@@ -2560,13 +2548,9 @@ int __init ip6_route_init(void)
2560 if (ret) 2548 if (ret)
2561 goto out_kmem_cache; 2549 goto out_kmem_cache;
2562 2550
2563 ret = ipv6_route_proc_init(&init_net);
2564 if (ret)
2565 goto out_fib6_init;
2566
2567 ret = xfrm6_init(); 2551 ret = xfrm6_init();
2568 if (ret) 2552 if (ret)
2569 goto out_proc_init; 2553 goto out_fib6_init;
2570 2554
2571 ret = fib6_rules_init(); 2555 ret = fib6_rules_init();
2572 if (ret) 2556 if (ret)
@@ -2578,7 +2562,9 @@ int __init ip6_route_init(void)
2578 __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL)) 2562 __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL))
2579 goto fib6_rules_init; 2563 goto fib6_rules_init;
2580 2564
2581 ret = 0; 2565 ret = register_pernet_subsys(&ip6_route_net_ops);
2566 if (ret)
2567 goto fib6_rules_init;
2582out: 2568out:
2583 return ret; 2569 return ret;
2584 2570
@@ -2586,8 +2572,6 @@ fib6_rules_init:
2586 fib6_rules_cleanup(); 2572 fib6_rules_cleanup();
2587xfrm6_init: 2573xfrm6_init:
2588 xfrm6_fini(); 2574 xfrm6_fini();
2589out_proc_init:
2590 ipv6_route_proc_fini(&init_net);
2591out_fib6_init: 2575out_fib6_init:
2592 rt6_ifdown(&init_net, NULL); 2576 rt6_ifdown(&init_net, NULL);
2593 fib6_gc_cleanup(); 2577 fib6_gc_cleanup();
@@ -2598,8 +2582,8 @@ out_kmem_cache:
2598 2582
2599void ip6_route_cleanup(void) 2583void ip6_route_cleanup(void)
2600{ 2584{
2585 unregister_pernet_subsys(&ip6_route_net_ops);
2601 fib6_rules_cleanup(); 2586 fib6_rules_cleanup();
2602 ipv6_route_proc_fini(&init_net);
2603 xfrm6_fini(); 2587 xfrm6_fini();
2604 rt6_ifdown(&init_net, NULL); 2588 rt6_ifdown(&init_net, NULL);
2605 fib6_gc_cleanup(); 2589 fib6_gc_cleanup();