aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-07-18 07:07:21 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-18 07:07:21 -0400
commitde05c557b24c7dffc6d392e3db120cf11c9f6ae7 (patch)
treed1d6fe1323657afd7d416c6af8a62d6a9e1e1e66 /net/ipv4
parent60bdde95807e982a824be9cfdd35055cc721a88a (diff)
proc: consolidate per-net single_open callers
There are already 7 of them - time to kill some duplicate code. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/fib_trie.c13
-rw-r--r--net/ipv4/proc.c57
2 files changed, 4 insertions, 66 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f155a66d6ebf..6009df238ed9 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2251,18 +2251,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2251 2251
2252static int fib_triestat_seq_open(struct inode *inode, struct file *file) 2252static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2253{ 2253{
2254 int err; 2254 return single_open_net(inode, file, fib_triestat_seq_show);
2255 struct net *net;
2256
2257 net = get_proc_net(inode);
2258 if (net == NULL)
2259 return -ENXIO;
2260 err = single_open(file, fib_triestat_seq_show, net);
2261 if (err < 0) {
2262 put_net(net);
2263 return err;
2264 }
2265 return 0;
2266} 2255}
2267 2256
2268static int fib_triestat_seq_release(struct inode *ino, struct file *f) 2257static int fib_triestat_seq_release(struct inode *ino, struct file *f)
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 554390431a4e..daf5d3c80cef 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -71,24 +71,7 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
71 71
72static int sockstat_seq_open(struct inode *inode, struct file *file) 72static int sockstat_seq_open(struct inode *inode, struct file *file)
73{ 73{
74 int err; 74 return single_open_net(inode, file, sockstat_seq_show);
75 struct net *net;
76
77 err = -ENXIO;
78 net = get_proc_net(inode);
79 if (net == NULL)
80 goto err_net;
81
82 err = single_open(file, sockstat_seq_show, net);
83 if (err < 0)
84 goto err_open;
85
86 return 0;
87
88err_open:
89 put_net(net);
90err_net:
91 return err;
92} 75}
93 76
94static int sockstat_seq_release(struct inode *inode, struct file *file) 77static int sockstat_seq_release(struct inode *inode, struct file *file)
@@ -397,24 +380,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
397 380
398static int snmp_seq_open(struct inode *inode, struct file *file) 381static int snmp_seq_open(struct inode *inode, struct file *file)
399{ 382{
400 int err; 383 return single_open_net(inode, file, snmp_seq_show);
401 struct net *net;
402
403 err = -ENXIO;
404 net = get_proc_net(inode);
405 if (net == NULL)
406 goto err_net;
407
408 err = single_open(file, snmp_seq_show, net);
409 if (err < 0)
410 goto err_open;
411
412 return 0;
413
414err_open:
415 put_net(net);
416err_net:
417 return err;
418} 384}
419 385
420static int snmp_seq_release(struct inode *inode, struct file *file) 386static int snmp_seq_release(struct inode *inode, struct file *file)
@@ -469,24 +435,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
469 435
470static int netstat_seq_open(struct inode *inode, struct file *file) 436static int netstat_seq_open(struct inode *inode, struct file *file)
471{ 437{
472 int err; 438 return single_open_net(inode, file, netstat_seq_show);
473 struct net *net;
474
475 err = -ENXIO;
476 net = get_proc_net(inode);
477 if (net == NULL)
478 goto err_net;
479
480 err = single_open(file, netstat_seq_show, net);
481 if (err < 0)
482 goto err_open;
483
484 return 0;
485
486err_open:
487 put_net(net);
488err_net:
489 return err;
490} 439}
491 440
492static int netstat_seq_release(struct inode *inode, struct file *file) 441static int netstat_seq_release(struct inode *inode, struct file *file)