Skip to content

Commit 457c4cb

Browse files
ebiedermDavid S. Miller
authored andcommitted
[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>
1 parent 07feaeb commit 457c4cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+342
-261
lines changed

drivers/isdn/divert/divert_procfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/fs.h>
1818
#endif
1919
#include <linux/isdnif.h>
20+
#include <net/net_namespace.h>
2021
#include "isdn_divert.h"
2122

2223

@@ -284,12 +285,12 @@ divert_dev_init(void)
284285
init_waitqueue_head(&rd_queue);
285286

286287
#ifdef CONFIG_PROC_FS
287-
isdn_proc_entry = proc_mkdir("net/isdn", NULL);
288+
isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net);
288289
if (!isdn_proc_entry)
289290
return (-1);
290291
isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
291292
if (!isdn_divert_entry) {
292-
remove_proc_entry("net/isdn", NULL);
293+
remove_proc_entry("isdn", init_net.proc_net);
293294
return (-1);
294295
}
295296
isdn_divert_entry->proc_fops = &isdn_fops;
@@ -309,7 +310,7 @@ divert_dev_deinit(void)
309310

310311
#ifdef CONFIG_PROC_FS
311312
remove_proc_entry("divert", isdn_proc_entry);
312-
remove_proc_entry("net/isdn", NULL);
313+
remove_proc_entry("isdn", init_net.proc_net);
313314
#endif /* CONFIG_PROC_FS */
314315

315316
return (0);

drivers/isdn/hardware/eicon/diva_didd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/init.h>
1616
#include <linux/kernel.h>
1717
#include <linux/proc_fs.h>
18+
#include <net/net_namespace.h>
1819

1920
#include "platform.h"
2021
#include "di_defs.h"
@@ -86,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof,
8687

8788
static int DIVA_INIT_FUNCTION create_proc(void)
8889
{
89-
proc_net_eicon = proc_mkdir("net/eicon", NULL);
90+
proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
9091

9192
if (proc_net_eicon) {
9293
if ((proc_didd =
@@ -102,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void)
102103
static void remove_proc(void)
103104
{
104105
remove_proc_entry(DRIVERLNAME, proc_net_eicon);
105-
remove_proc_entry("net/eicon", NULL);
106+
remove_proc_entry("eicon", init_net.proc_net);
106107
}
107108

108109
static int DIVA_INIT_FUNCTION divadidd_init(void)

drivers/isdn/hysdn/hysdn_procconf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/proc_fs.h>
1717
#include <linux/pci.h>
1818
#include <linux/smp_lock.h>
19+
#include <net/net_namespace.h>
1920

2021
#include "hysdn_defs.h"
2122

@@ -392,7 +393,7 @@ hysdn_procconf_init(void)
392393
hysdn_card *card;
393394
unsigned char conf_name[20];
394395

395-
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
396+
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, init_net.proc_net);
396397
if (!hysdn_proc_entry) {
397398
printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
398399
return (-1);
@@ -437,5 +438,5 @@ hysdn_procconf_release(void)
437438
card = card->next; /* point to next card */
438439
}
439440

440-
remove_proc_entry(PROC_SUBDIR_NAME, proc_net);
441+
remove_proc_entry(PROC_SUBDIR_NAME, init_net.proc_net);
441442
}

drivers/net/bonding/bond_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include <linux/if_vlan.h>
7676
#include <linux/if_bonding.h>
7777
#include <net/route.h>
78+
#include <net/net_namespace.h>
7879
#include "bonding.h"
7980
#include "bond_3ad.h"
8081
#include "bond_alb.h"
@@ -3144,7 +3145,7 @@ static void bond_create_proc_dir(void)
31443145
{
31453146
int len = strlen(DRV_NAME);
31463147

3147-
for (bond_proc_dir = proc_net->subdir; bond_proc_dir;
3148+
for (bond_proc_dir = init_net.proc_net->subdir; bond_proc_dir;
31483149
bond_proc_dir = bond_proc_dir->next) {
31493150
if ((bond_proc_dir->namelen == len) &&
31503151
!memcmp(bond_proc_dir->name, DRV_NAME, len)) {
@@ -3153,7 +3154,7 @@ static void bond_create_proc_dir(void)
31533154
}
31543155

31553156
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);
31573158
if (bond_proc_dir) {
31583159
bond_proc_dir->owner = THIS_MODULE;
31593160
} else {
@@ -3188,7 +3189,7 @@ static void bond_destroy_proc_dir(void)
31883189
bond_proc_dir->owner = NULL;
31893190
}
31903191
} else {
3191-
remove_proc_entry(DRV_NAME, proc_net);
3192+
remove_proc_entry(DRV_NAME, init_net.proc_net);
31923193
bond_proc_dir = NULL;
31933194
}
31943195
}

drivers/net/hamradio/bpqether.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383

8484
#include <net/ip.h>
8585
#include <net/arp.h>
86+
#include <net/net_namespace.h>
8687

8788
#include <linux/bpqether.h>
8889

@@ -594,7 +595,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
594595
static int __init bpq_init_driver(void)
595596
{
596597
#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)) {
598599
printk(KERN_ERR
599600
"bpq: cannot create /proc/net/bpqether entry.\n");
600601
return -ENOENT;
@@ -618,7 +619,7 @@ static void __exit bpq_cleanup_driver(void)
618619

619620
unregister_netdevice_notifier(&bpq_dev_notifier);
620621

621-
proc_net_remove("bpqether");
622+
proc_net_remove(&init_net, "bpqether");
622623

623624
rtnl_lock();
624625
while (!list_empty(&bpq_devices)) {

drivers/net/hamradio/scc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
#include <linux/seq_file.h>
175175
#include <linux/bitops.h>
176176

177+
#include <net/net_namespace.h>
177178
#include <net/ax25.h>
178179

179180
#include <asm/irq.h>
@@ -2114,7 +2115,7 @@ static int __init scc_init_driver (void)
21142115
}
21152116
rtnl_unlock();
21162117

2117-
proc_net_fops_create("z8530drv", 0, &scc_net_seq_fops);
2118+
proc_net_fops_create(&init_net, "z8530drv", 0, &scc_net_seq_fops);
21182119

21192120
return 0;
21202121
}
@@ -2169,7 +2170,7 @@ static void __exit scc_cleanup_driver(void)
21692170
if (Vector_Latch)
21702171
release_region(Vector_Latch, 1);
21712172

2172-
proc_net_remove("z8530drv");
2173+
proc_net_remove(&init_net, "z8530drv");
21732174
}
21742175

21752176
MODULE_AUTHOR("Joerg Reuter <jreuter@yaina.de>");

drivers/net/hamradio/yam.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include <linux/kernel.h>
6666
#include <linux/proc_fs.h>
6767
#include <linux/seq_file.h>
68+
#include <net/net_namespace.h>
6869

6970
#include <asm/uaccess.h>
7071
#include <linux/init.h>
@@ -1142,7 +1143,7 @@ static int __init yam_init_driver(void)
11421143
yam_timer.expires = jiffies + HZ / 100;
11431144
add_timer(&yam_timer);
11441145

1145-
proc_net_fops_create("yam", S_IRUGO, &yam_info_fops);
1146+
proc_net_fops_create(&init_net, "yam", S_IRUGO, &yam_info_fops);
11461147
return 0;
11471148
error:
11481149
while (--i >= 0) {
@@ -1174,7 +1175,7 @@ static void __exit yam_cleanup_driver(void)
11741175
kfree(p);
11751176
}
11761177

1177-
proc_net_remove("yam");
1178+
proc_net_remove(&init_net, "yam");
11781179
}
11791180

11801181
/* --------------------------------------------------------------------- */

drivers/net/ibmveth.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <linux/mm.h>
4848
#include <linux/ethtool.h>
4949
#include <linux/proc_fs.h>
50+
#include <net/net_namespace.h>
5051
#include <asm/semaphore.h>
5152
#include <asm/hvcall.h>
5253
#include <asm/atomic.h>
@@ -97,7 +98,7 @@ static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter);
9798
static struct kobj_type ktype_veth_pool;
9899

99100
#ifdef CONFIG_PROC_FS
100-
#define IBMVETH_PROC_DIR "net/ibmveth"
101+
#define IBMVETH_PROC_DIR "ibmveth"
101102
static struct proc_dir_entry *ibmveth_proc_dir;
102103
#endif
103104

@@ -1091,15 +1092,15 @@ static int __devexit ibmveth_remove(struct vio_dev *dev)
10911092
#ifdef CONFIG_PROC_FS
10921093
static void ibmveth_proc_register_driver(void)
10931094
{
1094-
ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL);
1095+
ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, init_net.proc_net);
10951096
if (ibmveth_proc_dir) {
10961097
SET_MODULE_OWNER(ibmveth_proc_dir);
10971098
}
10981099
}
10991100

11001101
static void ibmveth_proc_unregister_driver(void)
11011102
{
1102-
remove_proc_entry(IBMVETH_PROC_DIR, NULL);
1103+
remove_proc_entry(IBMVETH_PROC_DIR, init_net.proc_net);
11031104
}
11041105

11051106
static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)

drivers/net/pppoe.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include <linux/proc_fs.h>
7979
#include <linux/seq_file.h>
8080

81+
#include <net/net_namespace.h>
8182
#include <net/sock.h>
8283

8384
#include <asm/uaccess.h>
@@ -1042,7 +1043,7 @@ static int __init pppoe_proc_init(void)
10421043
{
10431044
struct proc_dir_entry *p;
10441045

1045-
p = create_proc_entry("net/pppoe", S_IRUGO, NULL);
1046+
p = create_proc_entry("pppoe", S_IRUGO, init_net.proc_net);
10461047
if (!p)
10471048
return -ENOMEM;
10481049

@@ -1113,7 +1114,7 @@ static void __exit pppoe_exit(void)
11131114
dev_remove_pack(&pppoes_ptype);
11141115
dev_remove_pack(&pppoed_ptype);
11151116
unregister_netdevice_notifier(&pppoe_notifier);
1116-
remove_proc_entry("net/pppoe", NULL);
1117+
remove_proc_entry("pppoe", init_net.proc_net);
11171118
proto_unregister(&pppoe_sk_proto);
11181119
}
11191120

drivers/net/pppol2tp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include <linux/hash.h>
9292
#include <linux/sort.h>
9393
#include <linux/proc_fs.h>
94+
#include <net/net_namespace.h>
9495
#include <net/dst.h>
9596
#include <net/ip.h>
9697
#include <net/udp.h>
@@ -2444,7 +2445,7 @@ static int __init pppol2tp_init(void)
24442445
goto out_unregister_pppol2tp_proto;
24452446

24462447
#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);
24482449
if (!pppol2tp_proc) {
24492450
err = -ENOMEM;
24502451
goto out_unregister_pppox_proto;
@@ -2469,7 +2470,7 @@ static void __exit pppol2tp_exit(void)
24692470
unregister_pppox_proto(PX_PROTO_OL2TP);
24702471

24712472
#ifdef CONFIG_PROC_FS
2472-
remove_proc_entry("pppol2tp", proc_net);
2473+
remove_proc_entry("pppol2tp", init_net.proc_net);
24732474
#endif
24742475
proto_unregister(&pppol2tp_sk_proto);
24752476
}

0 commit comments

Comments
 (0)