aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
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 /drivers/net
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 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c7
-rw-r--r--drivers/net/hamradio/bpqether.c5
-rw-r--r--drivers/net/hamradio/scc.c5
-rw-r--r--drivers/net/hamradio/yam.c5
-rw-r--r--drivers/net/ibmveth.c7
-rw-r--r--drivers/net/pppoe.c5
-rw-r--r--drivers/net/pppol2tp.c5
-rw-r--r--drivers/net/tokenring/lanstreamer.c5
-rw-r--r--drivers/net/tokenring/olympic.c9
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c7
-rw-r--r--drivers/net/wireless/strip.c5
11 files changed, 38 insertions, 27 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1afda3230de..5de648f90a4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -75,6 +75,7 @@
75#include <linux/if_vlan.h> 75#include <linux/if_vlan.h>
76#include <linux/if_bonding.h> 76#include <linux/if_bonding.h>
77#include <net/route.h> 77#include <net/route.h>
78#include <net/net_namespace.h>
78#include "bonding.h" 79#include "bonding.h"
79#include "bond_3ad.h" 80#include "bond_3ad.h"
80#include "bond_alb.h" 81#include "bond_alb.h"
@@ -3144,7 +3145,7 @@ static void bond_create_proc_dir(void)
3144{ 3145{
3145 int len = strlen(DRV_NAME); 3146 int len = strlen(DRV_NAME);
3146 3147
3147 for (bond_proc_dir = proc_net->subdir; bond_proc_dir; 3148 for (bond_proc_dir = init_net.proc_net->subdir; bond_proc_dir;
3148 bond_proc_dir = bond_proc_dir->next) { 3149 bond_proc_dir = bond_proc_dir->next) {
3149 if ((bond_proc_dir->namelen == len) && 3150 if ((bond_proc_dir->namelen == len) &&
3150 !memcmp(bond_proc_dir->name, DRV_NAME, len)) { 3151 !memcmp(bond_proc_dir->name, DRV_NAME, len)) {
@@ -3153,7 +3154,7 @@ static void bond_create_proc_dir(void)
3153 } 3154 }
3154 3155
3155 if (!bond_proc_dir) { 3156 if (!bond_proc_dir) {
3156 bond_proc_dir = proc_mkdir(DRV_NAME, proc_net); 3157 bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net);
3157 if (bond_proc_dir) { 3158 if (bond_proc_dir) {
3158 bond_proc_dir->owner = THIS_MODULE; 3159 bond_proc_dir->owner = THIS_MODULE;
3159 } else { 3160 } else {
@@ -3188,7 +3189,7 @@ static void bond_destroy_proc_dir(void)
3188 bond_proc_dir->owner = NULL; 3189 bond_proc_dir->owner = NULL;
3189 } 3190 }
3190 } else { 3191 } else {
3191 remove_proc_entry(DRV_NAME, proc_net); 3192 remove_proc_entry(DRV_NAME, init_net.proc_net);
3192 bond_proc_dir = NULL; 3193 bond_proc_dir = NULL;
3193 } 3194 }
3194} 3195}
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index cc0ee93669e..1699d42d13c 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -83,6 +83,7 @@
83 83
84#include <net/ip.h> 84#include <net/ip.h>
85#include <net/arp.h> 85#include <net/arp.h>
86#include <net/net_namespace.h>
86 87
87#include <linux/bpqether.h> 88#include <linux/bpqether.h>
88 89
@@ -594,7 +595,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
594static int __init bpq_init_driver(void) 595static int __init bpq_init_driver(void)
595{ 596{
596#ifdef CONFIG_PROC_FS 597#ifdef CONFIG_PROC_FS
597 if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) { 598 if (!proc_net_fops_create(&init_net, "bpqether", S_IRUGO, &bpq_info_fops)) {
598 printk(KERN_ERR 599 printk(KERN_ERR
599 "bpq: cannot create /proc/net/bpqether entry.\n"); 600 "bpq: cannot create /proc/net/bpqether entry.\n");
600 return -ENOENT; 601 return -ENOENT;
@@ -618,7 +619,7 @@ static void __exit bpq_cleanup_driver(void)
618 619
619 unregister_netdevice_notifier(&bpq_dev_notifier); 620 unregister_netdevice_notifier(&bpq_dev_notifier);
620 621
621 proc_net_remove("bpqether"); 622 proc_net_remove(&init_net, "bpqether");
622 623
623 rtnl_lock(); 624 rtnl_lock();
624 while (!list_empty(&bpq_devices)) { 625 while (!list_empty(&bpq_devices)) {
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 6fdaad5a457..39b3b82aa4a 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -174,6 +174,7 @@
174#include <linux/seq_file.h> 174#include <linux/seq_file.h>
175#include <linux/bitops.h> 175#include <linux/bitops.h>
176 176
177#include <net/net_namespace.h>
177#include <net/ax25.h> 178#include <net/ax25.h>
178 179
179#include <asm/irq.h> 180#include <asm/irq.h>
@@ -2114,7 +2115,7 @@ static int __init scc_init_driver (void)
2114 } 2115 }
2115 rtnl_unlock(); 2116 rtnl_unlock();
2116 2117
2117 proc_net_fops_create("z8530drv", 0, &scc_net_seq_fops); 2118 proc_net_fops_create(&init_net, "z8530drv", 0, &scc_net_seq_fops);
2118 2119
2119 return 0; 2120 return 0;
2120} 2121}
@@ -2169,7 +2170,7 @@ static void __exit scc_cleanup_driver(void)
2169 if (Vector_Latch) 2170 if (Vector_Latch)
2170 release_region(Vector_Latch, 1); 2171 release_region(Vector_Latch, 1);
2171 2172
2172 proc_net_remove("z8530drv"); 2173 proc_net_remove(&init_net, "z8530drv");
2173} 2174}
2174 2175
2175MODULE_AUTHOR("Joerg Reuter <jreuter@yaina.de>"); 2176MODULE_AUTHOR("Joerg Reuter <jreuter@yaina.de>");
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 467559debfd..401724ddafc 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -65,6 +65,7 @@
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/proc_fs.h> 66#include <linux/proc_fs.h>
67#include <linux/seq_file.h> 67#include <linux/seq_file.h>
68#include <net/net_namespace.h>
68 69
69#include <asm/uaccess.h> 70#include <asm/uaccess.h>
70#include <linux/init.h> 71#include <linux/init.h>
@@ -1142,7 +1143,7 @@ static int __init yam_init_driver(void)
1142 yam_timer.expires = jiffies + HZ / 100; 1143 yam_timer.expires = jiffies + HZ / 100;
1143 add_timer(&yam_timer); 1144 add_timer(&yam_timer);
1144 1145
1145 proc_net_fops_create("yam", S_IRUGO, &yam_info_fops); 1146 proc_net_fops_create(&init_net, "yam", S_IRUGO, &yam_info_fops);
1146 return 0; 1147 return 0;
1147 error: 1148 error:
1148 while (--i >= 0) { 1149 while (--i >= 0) {
@@ -1174,7 +1175,7 @@ static void __exit yam_cleanup_driver(void)
1174 kfree(p); 1175 kfree(p);
1175 } 1176 }
1176 1177
1177 proc_net_remove("yam"); 1178 proc_net_remove(&init_net, "yam");
1178} 1179}
1179 1180
1180/* --------------------------------------------------------------------- */ 1181/* --------------------------------------------------------------------- */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 78e28ada1e2..0c35d72f5f8 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -47,6 +47,7 @@
47#include <linux/mm.h> 47#include <linux/mm.h>
48#include <linux/ethtool.h> 48#include <linux/ethtool.h>
49#include <linux/proc_fs.h> 49#include <linux/proc_fs.h>
50#include <net/net_namespace.h>
50#include <asm/semaphore.h> 51#include <asm/semaphore.h>
51#include <asm/hvcall.h> 52#include <asm/hvcall.h>
52#include <asm/atomic.h> 53#include <asm/atomic.h>
@@ -97,7 +98,7 @@ static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter);
97static struct kobj_type ktype_veth_pool; 98static struct kobj_type ktype_veth_pool;
98 99
99#ifdef CONFIG_PROC_FS 100#ifdef CONFIG_PROC_FS
100#define IBMVETH_PROC_DIR "net/ibmveth" 101#define IBMVETH_PROC_DIR "ibmveth"
101static struct proc_dir_entry *ibmveth_proc_dir; 102static struct proc_dir_entry *ibmveth_proc_dir;
102#endif 103#endif
103 104
@@ -1091,7 +1092,7 @@ static int __devexit ibmveth_remove(struct vio_dev *dev)
1091#ifdef CONFIG_PROC_FS 1092#ifdef CONFIG_PROC_FS
1092static void ibmveth_proc_register_driver(void) 1093static void ibmveth_proc_register_driver(void)
1093{ 1094{
1094 ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL); 1095 ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, init_net.proc_net);
1095 if (ibmveth_proc_dir) { 1096 if (ibmveth_proc_dir) {
1096 SET_MODULE_OWNER(ibmveth_proc_dir); 1097 SET_MODULE_OWNER(ibmveth_proc_dir);
1097 } 1098 }
@@ -1099,7 +1100,7 @@ static void ibmveth_proc_register_driver(void)
1099 1100
1100static void ibmveth_proc_unregister_driver(void) 1101static void ibmveth_proc_unregister_driver(void)
1101{ 1102{
1102 remove_proc_entry(IBMVETH_PROC_DIR, NULL); 1103 remove_proc_entry(IBMVETH_PROC_DIR, init_net.proc_net);
1103} 1104}
1104 1105
1105static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) 1106static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 9b30cd600a6..ee8ce195c53 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -78,6 +78,7 @@
78#include <linux/proc_fs.h> 78#include <linux/proc_fs.h>
79#include <linux/seq_file.h> 79#include <linux/seq_file.h>
80 80
81#include <net/net_namespace.h>
81#include <net/sock.h> 82#include <net/sock.h>
82 83
83#include <asm/uaccess.h> 84#include <asm/uaccess.h>
@@ -1042,7 +1043,7 @@ static int __init pppoe_proc_init(void)
1042{ 1043{
1043 struct proc_dir_entry *p; 1044 struct proc_dir_entry *p;
1044 1045
1045 p = create_proc_entry("net/pppoe", S_IRUGO, NULL); 1046 p = create_proc_entry("pppoe", S_IRUGO, init_net.proc_net);
1046 if (!p) 1047 if (!p)
1047 return -ENOMEM; 1048 return -ENOMEM;
1048 1049
@@ -1113,7 +1114,7 @@ static void __exit pppoe_exit(void)
1113 dev_remove_pack(&pppoes_ptype); 1114 dev_remove_pack(&pppoes_ptype);
1114 dev_remove_pack(&pppoed_ptype); 1115 dev_remove_pack(&pppoed_ptype);
1115 unregister_netdevice_notifier(&pppoe_notifier); 1116 unregister_netdevice_notifier(&pppoe_notifier);
1116 remove_proc_entry("net/pppoe", NULL); 1117 remove_proc_entry("pppoe", init_net.proc_net);
1117 proto_unregister(&pppoe_sk_proto); 1118 proto_unregister(&pppoe_sk_proto);
1118} 1119}
1119 1120
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index abe91cb595f..2eb424ba58e 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -91,6 +91,7 @@
91#include <linux/hash.h> 91#include <linux/hash.h>
92#include <linux/sort.h> 92#include <linux/sort.h>
93#include <linux/proc_fs.h> 93#include <linux/proc_fs.h>
94#include <net/net_namespace.h>
94#include <net/dst.h> 95#include <net/dst.h>
95#include <net/ip.h> 96#include <net/ip.h>
96#include <net/udp.h> 97#include <net/udp.h>
@@ -2444,7 +2445,7 @@ static int __init pppol2tp_init(void)
2444 goto out_unregister_pppol2tp_proto; 2445 goto out_unregister_pppol2tp_proto;
2445 2446
2446#ifdef CONFIG_PROC_FS 2447#ifdef CONFIG_PROC_FS
2447 pppol2tp_proc = create_proc_entry("pppol2tp", 0, proc_net); 2448 pppol2tp_proc = create_proc_entry("pppol2tp", 0, init_net.proc_net);
2448 if (!pppol2tp_proc) { 2449 if (!pppol2tp_proc) {
2449 err = -ENOMEM; 2450 err = -ENOMEM;
2450 goto out_unregister_pppox_proto; 2451 goto out_unregister_pppox_proto;
@@ -2469,7 +2470,7 @@ static void __exit pppol2tp_exit(void)
2469 unregister_pppox_proto(PX_PROTO_OL2TP); 2470 unregister_pppox_proto(PX_PROTO_OL2TP);
2470 2471
2471#ifdef CONFIG_PROC_FS 2472#ifdef CONFIG_PROC_FS
2472 remove_proc_entry("pppol2tp", proc_net); 2473 remove_proc_entry("pppol2tp", init_net.proc_net);
2473#endif 2474#endif
2474 proto_unregister(&pppol2tp_sk_proto); 2475 proto_unregister(&pppol2tp_sk_proto);
2475} 2476}
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 5d849c089a3..fc4495581f9 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -123,6 +123,7 @@
123#include <linux/bitops.h> 123#include <linux/bitops.h>
124#include <linux/jiffies.h> 124#include <linux/jiffies.h>
125 125
126#include <net/net_namespace.h>
126#include <net/checksum.h> 127#include <net/checksum.h>
127 128
128#include <asm/io.h> 129#include <asm/io.h>
@@ -250,7 +251,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
250#if STREAMER_NETWORK_MONITOR 251#if STREAMER_NETWORK_MONITOR
251#ifdef CONFIG_PROC_FS 252#ifdef CONFIG_PROC_FS
252 if (!dev_streamer) 253 if (!dev_streamer)
253 create_proc_read_entry("net/streamer_tr", 0, 0, 254 create_proc_read_entry("streamer_tr", 0, init_net.proc_net,
254 streamer_proc_info, NULL); 255 streamer_proc_info, NULL);
255 streamer_priv->next = dev_streamer; 256 streamer_priv->next = dev_streamer;
256 dev_streamer = streamer_priv; 257 dev_streamer = streamer_priv;
@@ -423,7 +424,7 @@ static void __devexit streamer_remove_one(struct pci_dev *pdev)
423 } 424 }
424 } 425 }
425 if (!dev_streamer) 426 if (!dev_streamer)
426 remove_proc_entry("net/streamer_tr", NULL); 427 remove_proc_entry("streamer_tr", init_net.proc_net);
427 } 428 }
428#endif 429#endif
429#endif 430#endif
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 09b3cfb8e80..c323101a895 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -102,6 +102,7 @@
102#include <linux/jiffies.h> 102#include <linux/jiffies.h>
103 103
104#include <net/checksum.h> 104#include <net/checksum.h>
105#include <net/net_namespace.h>
105 106
106#include <asm/io.h> 107#include <asm/io.h>
107#include <asm/system.h> 108#include <asm/system.h>
@@ -268,9 +269,9 @@ static int __devinit olympic_probe(struct pci_dev *pdev, const struct pci_device
268 printk("Olympic: %s registered as: %s\n",olympic_priv->olympic_card_name,dev->name); 269 printk("Olympic: %s registered as: %s\n",olympic_priv->olympic_card_name,dev->name);
269 if (olympic_priv->olympic_network_monitor) { /* Must go after register_netdev as we need the device name */ 270 if (olympic_priv->olympic_network_monitor) { /* Must go after register_netdev as we need the device name */
270 char proc_name[20] ; 271 char proc_name[20] ;
271 strcpy(proc_name,"net/olympic_") ; 272 strcpy(proc_name,"olympic_") ;
272 strcat(proc_name,dev->name) ; 273 strcat(proc_name,dev->name) ;
273 create_proc_read_entry(proc_name,0,NULL,olympic_proc_info,(void *)dev) ; 274 create_proc_read_entry(proc_name,0,init_net.proc_net,olympic_proc_info,(void *)dev) ;
274 printk("Olympic: Network Monitor information: /proc/%s\n",proc_name); 275 printk("Olympic: Network Monitor information: /proc/%s\n",proc_name);
275 } 276 }
276 return 0 ; 277 return 0 ;
@@ -1752,9 +1753,9 @@ static void __devexit olympic_remove_one(struct pci_dev *pdev)
1752 1753
1753 if (olympic_priv->olympic_network_monitor) { 1754 if (olympic_priv->olympic_network_monitor) {
1754 char proc_name[20] ; 1755 char proc_name[20] ;
1755 strcpy(proc_name,"net/olympic_") ; 1756 strcpy(proc_name,"olympic_") ;
1756 strcat(proc_name,dev->name) ; 1757 strcat(proc_name,dev->name) ;
1757 remove_proc_entry(proc_name,NULL); 1758 remove_proc_entry(proc_name,init_net.proc_net);
1758 } 1759 }
1759 unregister_netdev(dev) ; 1760 unregister_netdev(dev) ;
1760 iounmap(olympic_priv->olympic_mmio) ; 1761 iounmap(olympic_priv->olympic_mmio) ;
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 446de51bab7..9a470e80ca2 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -24,6 +24,7 @@
24#include <linux/rtnetlink.h> 24#include <linux/rtnetlink.h>
25#include <linux/wireless.h> 25#include <linux/wireless.h>
26#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
27#include <net/net_namespace.h>
27#include <net/iw_handler.h> 28#include <net/iw_handler.h>
28#include <net/ieee80211.h> 29#include <net/ieee80211.h>
29#include <net/ieee80211_crypt.h> 30#include <net/ieee80211_crypt.h>
@@ -1093,8 +1094,8 @@ struct proc_dir_entry *hostap_proc;
1093 1094
1094static int __init hostap_init(void) 1095static int __init hostap_init(void)
1095{ 1096{
1096 if (proc_net != NULL) { 1097 if (init_net.proc_net != NULL) {
1097 hostap_proc = proc_mkdir("hostap", proc_net); 1098 hostap_proc = proc_mkdir("hostap", init_net.proc_net);
1098 if (!hostap_proc) 1099 if (!hostap_proc)
1099 printk(KERN_WARNING "Failed to mkdir " 1100 printk(KERN_WARNING "Failed to mkdir "
1100 "/proc/net/hostap\n"); 1101 "/proc/net/hostap\n");
@@ -1109,7 +1110,7 @@ static void __exit hostap_exit(void)
1109{ 1110{
1110 if (hostap_proc != NULL) { 1111 if (hostap_proc != NULL) {
1111 hostap_proc = NULL; 1112 hostap_proc = NULL;
1112 remove_proc_entry("hostap", proc_net); 1113 remove_proc_entry("hostap", init_net.proc_net);
1113 } 1114 }
1114} 1115}
1115 1116
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index ef32a5c1e81..edb214e8c74 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -107,6 +107,7 @@ static const char StripVersion[] = "1.3A-STUART.CHESHIRE";
107#include <linux/serialP.h> 107#include <linux/serialP.h>
108#include <linux/rcupdate.h> 108#include <linux/rcupdate.h>
109#include <net/arp.h> 109#include <net/arp.h>
110#include <net/net_namespace.h>
110 111
111#include <linux/ip.h> 112#include <linux/ip.h>
112#include <linux/tcp.h> 113#include <linux/tcp.h>
@@ -2787,7 +2788,7 @@ static int __init strip_init_driver(void)
2787 /* 2788 /*
2788 * Register the status file with /proc 2789 * Register the status file with /proc
2789 */ 2790 */
2790 proc_net_fops_create("strip", S_IFREG | S_IRUGO, &strip_seq_fops); 2791 proc_net_fops_create(&init_net, "strip", S_IFREG | S_IRUGO, &strip_seq_fops);
2791 2792
2792 return status; 2793 return status;
2793} 2794}
@@ -2809,7 +2810,7 @@ static void __exit strip_exit_driver(void)
2809 } 2810 }
2810 2811
2811 /* Unregister with the /proc/net file here. */ 2812 /* Unregister with the /proc/net file here. */
2812 proc_net_remove("strip"); 2813 proc_net_remove(&init_net, "strip");
2813 2814
2814 if ((i = tty_unregister_ldisc(N_STRIP))) 2815 if ((i = tty_unregister_ldisc(N_STRIP)))
2815 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i); 2816 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i);