aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-12 06:01:34 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:06 -0400
commit457c4cbc5a3dde259d2a1f15d5f9785290397267 (patch)
treea2ceee88780cbce27433b9a4434b3e9251efd81a /net/ipv6
parent07feaebfcc10cd35e745c7073667935246494bee (diff)
[NET]: Make /proc/net per network namespace
This patch makes /proc/net per network namespace. It modifies the global variables proc_net and proc_net_stat to be per network namespace. The proc_net file helpers are modified to take a network namespace argument, and all of their callers are fixed to pass &init_net for that argument. This ensures that all of the /proc/net files are only visible and usable in the initial network namespace until the code behind them has been updated to be handle multiple network namespaces. Making /proc/net per namespace is necessary as at least some files in /proc/net depend upon the set of network devices which is per network namespace, and even more files in /proc/net have contents that are relevant to a single network namespace. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c7
-rw-r--r--net/ipv6/anycast.c5
-rw-r--r--net/ipv6/ip6_flowlabel.c5
-rw-r--r--net/ipv6/mcast.c9
-rw-r--r--net/ipv6/netfilter/ip6_queue.c7
-rw-r--r--net/ipv6/proc.c17
-rw-r--r--net/ipv6/raw.c5
-rw-r--r--net/ipv6/route.c9
8 files changed, 36 insertions, 28 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 45b4c82148a0..cd2db728d183 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -62,6 +62,7 @@
62#include <linux/notifier.h> 62#include <linux/notifier.h>
63#include <linux/string.h> 63#include <linux/string.h>
64 64
65#include <net/net_namespace.h>
65#include <net/sock.h> 66#include <net/sock.h>
66#include <net/snmp.h> 67#include <net/snmp.h>
67 68
@@ -2827,14 +2828,14 @@ static const struct file_operations if6_fops = {
2827 2828
2828int __init if6_proc_init(void) 2829int __init if6_proc_init(void)
2829{ 2830{
2830 if (!proc_net_fops_create("if_inet6", S_IRUGO, &if6_fops)) 2831 if (!proc_net_fops_create(&init_net, "if_inet6", S_IRUGO, &if6_fops))
2831 return -ENOMEM; 2832 return -ENOMEM;
2832 return 0; 2833 return 0;
2833} 2834}
2834 2835
2835void if6_proc_exit(void) 2836void if6_proc_exit(void)
2836{ 2837{
2837 proc_net_remove("if_inet6"); 2838 proc_net_remove(&init_net, "if_inet6");
2838} 2839}
2839#endif /* CONFIG_PROC_FS */ 2840#endif /* CONFIG_PROC_FS */
2840 2841
@@ -4293,6 +4294,6 @@ void __exit addrconf_cleanup(void)
4293 rtnl_unlock(); 4294 rtnl_unlock();
4294 4295
4295#ifdef CONFIG_PROC_FS 4296#ifdef CONFIG_PROC_FS
4296 proc_net_remove("if_inet6"); 4297 proc_net_remove(&init_net, "if_inet6");
4297#endif 4298#endif
4298} 4299}
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index b8c533fbdb63..0bd665498d06 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -30,6 +30,7 @@
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32 32
33#include <net/net_namespace.h>
33#include <net/sock.h> 34#include <net/sock.h>
34#include <net/snmp.h> 35#include <net/snmp.h>
35 36
@@ -578,7 +579,7 @@ static const struct file_operations ac6_seq_fops = {
578 579
579int __init ac6_proc_init(void) 580int __init ac6_proc_init(void)
580{ 581{
581 if (!proc_net_fops_create("anycast6", S_IRUGO, &ac6_seq_fops)) 582 if (!proc_net_fops_create(&init_net, "anycast6", S_IRUGO, &ac6_seq_fops))
582 return -ENOMEM; 583 return -ENOMEM;
583 584
584 return 0; 585 return 0;
@@ -586,7 +587,7 @@ int __init ac6_proc_init(void)
586 587
587void ac6_proc_exit(void) 588void ac6_proc_exit(void)
588{ 589{
589 proc_net_remove("anycast6"); 590 proc_net_remove(&init_net, "anycast6");
590} 591}
591#endif 592#endif
592 593
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 413a4ebb195c..1791399c7f10 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -21,6 +21,7 @@
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23 23
24#include <net/net_namespace.h>
24#include <net/sock.h> 25#include <net/sock.h>
25 26
26#include <net/ipv6.h> 27#include <net/ipv6.h>
@@ -690,7 +691,7 @@ static const struct file_operations ip6fl_seq_fops = {
690void ip6_flowlabel_init(void) 691void ip6_flowlabel_init(void)
691{ 692{
692#ifdef CONFIG_PROC_FS 693#ifdef CONFIG_PROC_FS
693 proc_net_fops_create("ip6_flowlabel", S_IRUGO, &ip6fl_seq_fops); 694 proc_net_fops_create(&init_net, "ip6_flowlabel", S_IRUGO, &ip6fl_seq_fops);
694#endif 695#endif
695} 696}
696 697
@@ -698,6 +699,6 @@ void ip6_flowlabel_cleanup(void)
698{ 699{
699 del_timer(&ip6_fl_gc_timer); 700 del_timer(&ip6_fl_gc_timer);
700#ifdef CONFIG_PROC_FS 701#ifdef CONFIG_PROC_FS
701 proc_net_remove("ip6_flowlabel"); 702 proc_net_remove(&init_net, "ip6_flowlabel");
702#endif 703#endif
703} 704}
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index ae9881832a7e..a41d5a0b50cc 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -49,6 +49,7 @@
49#include <linux/netfilter.h> 49#include <linux/netfilter.h>
50#include <linux/netfilter_ipv6.h> 50#include <linux/netfilter_ipv6.h>
51 51
52#include <net/net_namespace.h>
52#include <net/sock.h> 53#include <net/sock.h>
53#include <net/snmp.h> 54#include <net/snmp.h>
54 55
@@ -2658,8 +2659,8 @@ int __init igmp6_init(struct net_proto_family *ops)
2658 np->hop_limit = 1; 2659 np->hop_limit = 1;
2659 2660
2660#ifdef CONFIG_PROC_FS 2661#ifdef CONFIG_PROC_FS
2661 proc_net_fops_create("igmp6", S_IRUGO, &igmp6_mc_seq_fops); 2662 proc_net_fops_create(&init_net, "igmp6", S_IRUGO, &igmp6_mc_seq_fops);
2662 proc_net_fops_create("mcfilter6", S_IRUGO, &igmp6_mcf_seq_fops); 2663 proc_net_fops_create(&init_net, "mcfilter6", S_IRUGO, &igmp6_mcf_seq_fops);
2663#endif 2664#endif
2664 2665
2665 return 0; 2666 return 0;
@@ -2671,7 +2672,7 @@ void igmp6_cleanup(void)
2671 igmp6_socket = NULL; /* for safety */ 2672 igmp6_socket = NULL; /* for safety */
2672 2673
2673#ifdef CONFIG_PROC_FS 2674#ifdef CONFIG_PROC_FS
2674 proc_net_remove("mcfilter6"); 2675 proc_net_remove(&init_net, "mcfilter6");
2675 proc_net_remove("igmp6"); 2676 proc_net_remove(&init_net, "igmp6");
2676#endif 2677#endif
2677} 2678}
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 0004db38af6d..dfc58fbdb68b 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -24,6 +24,7 @@
24#include <linux/sysctl.h> 24#include <linux/sysctl.h>
25#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <net/net_namespace.h>
27#include <net/sock.h> 28#include <net/sock.h>
28#include <net/ipv6.h> 29#include <net/ipv6.h>
29#include <net/ip6_route.h> 30#include <net/ip6_route.h>
@@ -664,7 +665,7 @@ static int __init ip6_queue_init(void)
664 goto cleanup_netlink_notifier; 665 goto cleanup_netlink_notifier;
665 } 666 }
666 667
667 proc = proc_net_create(IPQ_PROC_FS_NAME, 0, ipq_get_info); 668 proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info);
668 if (proc) 669 if (proc)
669 proc->owner = THIS_MODULE; 670 proc->owner = THIS_MODULE;
670 else { 671 else {
@@ -685,7 +686,7 @@ static int __init ip6_queue_init(void)
685cleanup_sysctl: 686cleanup_sysctl:
686 unregister_sysctl_table(ipq_sysctl_header); 687 unregister_sysctl_table(ipq_sysctl_header);
687 unregister_netdevice_notifier(&ipq_dev_notifier); 688 unregister_netdevice_notifier(&ipq_dev_notifier);
688 proc_net_remove(IPQ_PROC_FS_NAME); 689 proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
689 690
690cleanup_ipqnl: 691cleanup_ipqnl:
691 sock_release(ipqnl->sk_socket); 692 sock_release(ipqnl->sk_socket);
@@ -705,7 +706,7 @@ static void __exit ip6_queue_fini(void)
705 706
706 unregister_sysctl_table(ipq_sysctl_header); 707 unregister_sysctl_table(ipq_sysctl_header);
707 unregister_netdevice_notifier(&ipq_dev_notifier); 708 unregister_netdevice_notifier(&ipq_dev_notifier);
708 proc_net_remove(IPQ_PROC_FS_NAME); 709 proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
709 710
710 sock_release(ipqnl->sk_socket); 711 sock_release(ipqnl->sk_socket);
711 mutex_lock(&ipqnl_mutex); 712 mutex_lock(&ipqnl_mutex);
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 920dc9cf6a84..a712a2289484 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -23,6 +23,7 @@
23#include <linux/proc_fs.h> 23#include <linux/proc_fs.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/stddef.h> 25#include <linux/stddef.h>
26#include <net/net_namespace.h>
26#include <net/ip.h> 27#include <net/ip.h>
27#include <net/sock.h> 28#include <net/sock.h>
28#include <net/tcp.h> 29#include <net/tcp.h>
@@ -231,22 +232,22 @@ int __init ipv6_misc_proc_init(void)
231{ 232{
232 int rc = 0; 233 int rc = 0;
233 234
234 if (!proc_net_fops_create("snmp6", S_IRUGO, &snmp6_seq_fops)) 235 if (!proc_net_fops_create(&init_net, "snmp6", S_IRUGO, &snmp6_seq_fops))
235 goto proc_snmp6_fail; 236 goto proc_snmp6_fail;
236 237
237 proc_net_devsnmp6 = proc_mkdir("dev_snmp6", proc_net); 238 proc_net_devsnmp6 = proc_mkdir("dev_snmp6", init_net.proc_net);
238 if (!proc_net_devsnmp6) 239 if (!proc_net_devsnmp6)
239 goto proc_dev_snmp6_fail; 240 goto proc_dev_snmp6_fail;
240 241
241 if (!proc_net_fops_create("sockstat6", S_IRUGO, &sockstat6_seq_fops)) 242 if (!proc_net_fops_create(&init_net, "sockstat6", S_IRUGO, &sockstat6_seq_fops))
242 goto proc_sockstat6_fail; 243 goto proc_sockstat6_fail;
243out: 244out:
244 return rc; 245 return rc;
245 246
246proc_sockstat6_fail: 247proc_sockstat6_fail:
247 proc_net_remove("dev_snmp6"); 248 proc_net_remove(&init_net, "dev_snmp6");
248proc_dev_snmp6_fail: 249proc_dev_snmp6_fail:
249 proc_net_remove("snmp6"); 250 proc_net_remove(&init_net, "snmp6");
250proc_snmp6_fail: 251proc_snmp6_fail:
251 rc = -ENOMEM; 252 rc = -ENOMEM;
252 goto out; 253 goto out;
@@ -254,8 +255,8 @@ proc_snmp6_fail:
254 255
255void ipv6_misc_proc_exit(void) 256void ipv6_misc_proc_exit(void)
256{ 257{
257 proc_net_remove("sockstat6"); 258 proc_net_remove(&init_net, "sockstat6");
258 proc_net_remove("dev_snmp6"); 259 proc_net_remove(&init_net, "dev_snmp6");
259 proc_net_remove("snmp6"); 260 proc_net_remove(&init_net, "snmp6");
260} 261}
261 262
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 77167afa3455..38a3d21c2585 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -35,6 +35,7 @@
35#include <asm/uaccess.h> 35#include <asm/uaccess.h>
36#include <asm/ioctls.h> 36#include <asm/ioctls.h>
37 37
38#include <net/net_namespace.h>
38#include <net/ip.h> 39#include <net/ip.h>
39#include <net/sock.h> 40#include <net/sock.h>
40#include <net/snmp.h> 41#include <net/snmp.h>
@@ -1315,13 +1316,13 @@ static const struct file_operations raw6_seq_fops = {
1315 1316
1316int __init raw6_proc_init(void) 1317int __init raw6_proc_init(void)
1317{ 1318{
1318 if (!proc_net_fops_create("raw6", S_IRUGO, &raw6_seq_fops)) 1319 if (!proc_net_fops_create(&init_net, "raw6", S_IRUGO, &raw6_seq_fops))
1319 return -ENOMEM; 1320 return -ENOMEM;
1320 return 0; 1321 return 0;
1321} 1322}
1322 1323
1323void raw6_proc_exit(void) 1324void raw6_proc_exit(void)
1324{ 1325{
1325 proc_net_remove("raw6"); 1326 proc_net_remove(&init_net, "raw6");
1326} 1327}
1327#endif /* CONFIG_PROC_FS */ 1328#endif /* CONFIG_PROC_FS */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 55ea80fac601..f4f0c341e5c8 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -44,6 +44,7 @@
44#include <linux/seq_file.h> 44#include <linux/seq_file.h>
45#endif 45#endif
46 46
47#include <net/net_namespace.h>
47#include <net/snmp.h> 48#include <net/snmp.h>
48#include <net/ipv6.h> 49#include <net/ipv6.h>
49#include <net/ip6_fib.h> 50#include <net/ip6_fib.h>
@@ -2561,11 +2562,11 @@ void __init ip6_route_init(void)
2561 2562
2562 fib6_init(); 2563 fib6_init();
2563#ifdef CONFIG_PROC_FS 2564#ifdef CONFIG_PROC_FS
2564 p = proc_net_create("ipv6_route", 0, rt6_proc_info); 2565 p = proc_net_create(&init_net, "ipv6_route", 0, rt6_proc_info);
2565 if (p) 2566 if (p)
2566 p->owner = THIS_MODULE; 2567 p->owner = THIS_MODULE;
2567 2568
2568 proc_net_fops_create("rt6_stats", S_IRUGO, &rt6_stats_seq_fops); 2569 proc_net_fops_create(&init_net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
2569#endif 2570#endif
2570#ifdef CONFIG_XFRM 2571#ifdef CONFIG_XFRM
2571 xfrm6_init(); 2572 xfrm6_init();
@@ -2585,8 +2586,8 @@ void ip6_route_cleanup(void)
2585 fib6_rules_cleanup(); 2586 fib6_rules_cleanup();
2586#endif 2587#endif
2587#ifdef CONFIG_PROC_FS 2588#ifdef CONFIG_PROC_FS
2588 proc_net_remove("ipv6_route"); 2589 proc_net_remove(&init_net, "ipv6_route");
2589 proc_net_remove("rt6_stats"); 2590 proc_net_remove(&init_net, "rt6_stats");
2590#endif 2591#endif
2591#ifdef CONFIG_XFRM 2592#ifdef CONFIG_XFRM
2592 xfrm6_fini(); 2593 xfrm6_fini();