aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/linux/proc_fs.h44
-rw-r--r--include/net/net_namespace.h5
2 files changed, 24 insertions, 25 deletions
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index cd13a78c5db..59646705f15 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -7,6 +7,7 @@
7#include <linux/magic.h> 7#include <linux/magic.h>
8#include <asm/atomic.h> 8#include <asm/atomic.h>
9 9
10struct net;
10struct completion; 11struct completion;
11 12
12/* 13/*
@@ -97,8 +98,6 @@ struct vmcore {
97 98
98extern struct proc_dir_entry proc_root; 99extern struct proc_dir_entry proc_root;
99extern struct proc_dir_entry *proc_root_fs; 100extern struct proc_dir_entry *proc_root_fs;
100extern struct proc_dir_entry *proc_net;
101extern struct proc_dir_entry *proc_net_stat;
102extern struct proc_dir_entry *proc_bus; 101extern struct proc_dir_entry *proc_bus;
103extern struct proc_dir_entry *proc_root_driver; 102extern struct proc_dir_entry *proc_root_driver;
104extern struct proc_dir_entry *proc_root_kcore; 103extern struct proc_dir_entry *proc_root_kcore;
@@ -192,36 +191,21 @@ static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
192 if (res) res->get_info=get_info; 191 if (res) res->get_info=get_info;
193 return res; 192 return res;
194} 193}
195
196static inline struct proc_dir_entry *proc_net_create(const char *name,
197 mode_t mode, get_info_t *get_info)
198{
199 return create_proc_info_entry(name,mode,proc_net,get_info);
200}
201 194
202static inline struct proc_dir_entry *proc_net_fops_create(const char *name, 195extern struct proc_dir_entry *proc_net_create(struct net *net,
203 mode_t mode, const struct file_operations *fops) 196 const char *name, mode_t mode, get_info_t *get_info);
204{ 197extern struct proc_dir_entry *proc_net_fops_create(struct net *net,
205 struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net); 198 const char *name, mode_t mode, const struct file_operations *fops);
206 if (res) 199extern void proc_net_remove(struct net *net, const char *name);
207 res->proc_fops = fops;
208 return res;
209}
210
211static inline void proc_net_remove(const char *name)
212{
213 remove_proc_entry(name,proc_net);
214}
215 200
216#else 201#else
217 202
218#define proc_root_driver NULL 203#define proc_root_driver NULL
219#define proc_net NULL
220#define proc_bus NULL 204#define proc_bus NULL
221 205
222#define proc_net_fops_create(name, mode, fops) ({ (void)(mode), NULL; }) 206#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; })
223#define proc_net_create(name, mode, info) ({ (void)(mode), NULL; }) 207#define proc_net_create(net, name, mode, info) ({ (void)(mode), NULL; })
224static inline void proc_net_remove(const char *name) {} 208static inline void proc_net_remove(struct net *net, const char *name) {}
225 209
226static inline void proc_flush_task(struct task_struct *task) { } 210static inline void proc_flush_task(struct task_struct *task) { }
227 211
@@ -281,6 +265,16 @@ static inline struct proc_dir_entry *PDE(const struct inode *inode)
281 return PROC_I(inode)->pde; 265 return PROC_I(inode)->pde;
282} 266}
283 267
268static inline struct net *PDE_NET(struct proc_dir_entry *pde)
269{
270 return pde->parent->data;
271}
272
273static inline struct net *PROC_NET(const struct inode *inode)
274{
275 return PDE_NET(PDE(inode));
276}
277
284struct proc_maps_private { 278struct proc_maps_private {
285 struct pid *pid; 279 struct pid *pid;
286 struct task_struct *task; 280 struct task_struct *task;
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 6344b77f81a..54724768134 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -8,6 +8,7 @@
8#include <linux/workqueue.h> 8#include <linux/workqueue.h>
9#include <linux/list.h> 9#include <linux/list.h>
10 10
11struct proc_dir_entry;
11struct net { 12struct net {
12 atomic_t count; /* To decided when the network 13 atomic_t count; /* To decided when the network
13 * namespace should be freed. 14 * namespace should be freed.
@@ -17,6 +18,10 @@ struct net {
17 */ 18 */
18 struct list_head list; /* list of network namespaces */ 19 struct list_head list; /* list of network namespaces */
19 struct work_struct work; /* work struct for freeing */ 20 struct work_struct work; /* work struct for freeing */
21
22 struct proc_dir_entry *proc_net;
23 struct proc_dir_entry *proc_net_stat;
24 struct proc_dir_entry *proc_net_root;
20}; 25};
21 26
22extern struct net init_net; 27extern struct net init_net;