diff options
author | Denis V. Lunev <den@openvz.org> | 2007-11-20 01:31:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:28 -0500 |
commit | e372c41401993b45c721c4d92730e7e0a79f7c1b (patch) | |
tree | 8f062f506c0578fc83b7d05c8751a7ccac96e50e /net/core | |
parent | 097e66c578459f79e3a2128c54e9df5194e1419a (diff) |
[NET]: Consolidate net namespace related proc files creation.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 28 | ||||
-rw-r--r-- | net/core/dev_mcast.c | 26 |
2 files changed, 9 insertions, 45 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 0879f52115eb..d0e23d8310ff 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2364,7 +2364,7 @@ static int dev_ifconf(struct net *net, char __user *arg) | |||
2364 | */ | 2364 | */ |
2365 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) | 2365 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) |
2366 | { | 2366 | { |
2367 | struct net *net = seq->private; | 2367 | struct net *net = seq_file_net(seq); |
2368 | loff_t off; | 2368 | loff_t off; |
2369 | struct net_device *dev; | 2369 | struct net_device *dev; |
2370 | 2370 | ||
@@ -2382,7 +2382,7 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos) | |||
2382 | 2382 | ||
2383 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2383 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
2384 | { | 2384 | { |
2385 | struct net *net = seq->private; | 2385 | struct net *net = seq_file_net(seq); |
2386 | ++*pos; | 2386 | ++*pos; |
2387 | return v == SEQ_START_TOKEN ? | 2387 | return v == SEQ_START_TOKEN ? |
2388 | first_net_device(net) : next_net_device((struct net_device *)v); | 2388 | first_net_device(net) : next_net_device((struct net_device *)v); |
@@ -2481,26 +2481,8 @@ static const struct seq_operations dev_seq_ops = { | |||
2481 | 2481 | ||
2482 | static int dev_seq_open(struct inode *inode, struct file *file) | 2482 | static int dev_seq_open(struct inode *inode, struct file *file) |
2483 | { | 2483 | { |
2484 | struct seq_file *seq; | 2484 | return seq_open_net(inode, file, &dev_seq_ops, |
2485 | int res; | 2485 | sizeof(struct seq_net_private)); |
2486 | res = seq_open(file, &dev_seq_ops); | ||
2487 | if (!res) { | ||
2488 | seq = file->private_data; | ||
2489 | seq->private = get_proc_net(inode); | ||
2490 | if (!seq->private) { | ||
2491 | seq_release(inode, file); | ||
2492 | res = -ENXIO; | ||
2493 | } | ||
2494 | } | ||
2495 | return res; | ||
2496 | } | ||
2497 | |||
2498 | static int dev_seq_release(struct inode *inode, struct file *file) | ||
2499 | { | ||
2500 | struct seq_file *seq = file->private_data; | ||
2501 | struct net *net = seq->private; | ||
2502 | put_net(net); | ||
2503 | return seq_release(inode, file); | ||
2504 | } | 2486 | } |
2505 | 2487 | ||
2506 | static const struct file_operations dev_seq_fops = { | 2488 | static const struct file_operations dev_seq_fops = { |
@@ -2508,7 +2490,7 @@ static const struct file_operations dev_seq_fops = { | |||
2508 | .open = dev_seq_open, | 2490 | .open = dev_seq_open, |
2509 | .read = seq_read, | 2491 | .read = seq_read, |
2510 | .llseek = seq_lseek, | 2492 | .llseek = seq_lseek, |
2511 | .release = dev_seq_release, | 2493 | .release = seq_release_net, |
2512 | }; | 2494 | }; |
2513 | 2495 | ||
2514 | static const struct seq_operations softnet_seq_ops = { | 2496 | static const struct seq_operations softnet_seq_ops = { |
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c index 69fff16ece10..63f0b33d7ced 100644 --- a/net/core/dev_mcast.c +++ b/net/core/dev_mcast.c | |||
@@ -187,7 +187,7 @@ EXPORT_SYMBOL(dev_mc_unsync); | |||
187 | #ifdef CONFIG_PROC_FS | 187 | #ifdef CONFIG_PROC_FS |
188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) | 188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) |
189 | { | 189 | { |
190 | struct net *net = seq->private; | 190 | struct net *net = seq_file_net(seq); |
191 | struct net_device *dev; | 191 | struct net_device *dev; |
192 | loff_t off = 0; | 192 | loff_t off = 0; |
193 | 193 | ||
@@ -241,26 +241,8 @@ static const struct seq_operations dev_mc_seq_ops = { | |||
241 | 241 | ||
242 | static int dev_mc_seq_open(struct inode *inode, struct file *file) | 242 | static int dev_mc_seq_open(struct inode *inode, struct file *file) |
243 | { | 243 | { |
244 | struct seq_file *seq; | 244 | return seq_open_net(inode, file, &dev_mc_seq_ops, |
245 | int res; | 245 | sizeof(struct seq_net_private)); |
246 | res = seq_open(file, &dev_mc_seq_ops); | ||
247 | if (!res) { | ||
248 | seq = file->private_data; | ||
249 | seq->private = get_proc_net(inode); | ||
250 | if (!seq->private) { | ||
251 | seq_release(inode, file); | ||
252 | res = -ENXIO; | ||
253 | } | ||
254 | } | ||
255 | return res; | ||
256 | } | ||
257 | |||
258 | static int dev_mc_seq_release(struct inode *inode, struct file *file) | ||
259 | { | ||
260 | struct seq_file *seq = file->private_data; | ||
261 | struct net *net = seq->private; | ||
262 | put_net(net); | ||
263 | return seq_release(inode, file); | ||
264 | } | 246 | } |
265 | 247 | ||
266 | static const struct file_operations dev_mc_seq_fops = { | 248 | static const struct file_operations dev_mc_seq_fops = { |
@@ -268,7 +250,7 @@ static const struct file_operations dev_mc_seq_fops = { | |||
268 | .open = dev_mc_seq_open, | 250 | .open = dev_mc_seq_open, |
269 | .read = seq_read, | 251 | .read = seq_read, |
270 | .llseek = seq_lseek, | 252 | .llseek = seq_lseek, |
271 | .release = dev_mc_seq_release, | 253 | .release = seq_release_net, |
272 | }; | 254 | }; |
273 | 255 | ||
274 | #endif | 256 | #endif |