diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-11-25 21:00:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-25 21:00:14 -0500 |
commit | c68cd1a01ba56995d85a4a62b195b2b3f6415c64 (patch) | |
tree | 69351005622aced7acf9085fa5c54134419286ba /net/xfrm | |
parent | 59c9940ed0ef026673cac52f2eaed77af7d486da (diff) |
netns xfrm: /proc/net/xfrm_stat in netns
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 11 | ||||
-rw-r--r-- | net/xfrm/xfrm_proc.c | 26 |
2 files changed, 19 insertions, 18 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index e239a25e571c..38822b34ba7d 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -2377,14 +2377,20 @@ static struct notifier_block xfrm_dev_notifier = { | |||
2377 | #ifdef CONFIG_XFRM_STATISTICS | 2377 | #ifdef CONFIG_XFRM_STATISTICS |
2378 | static int __net_init xfrm_statistics_init(struct net *net) | 2378 | static int __net_init xfrm_statistics_init(struct net *net) |
2379 | { | 2379 | { |
2380 | int rv; | ||
2381 | |||
2380 | if (snmp_mib_init((void **)net->mib.xfrm_statistics, | 2382 | if (snmp_mib_init((void **)net->mib.xfrm_statistics, |
2381 | sizeof(struct linux_xfrm_mib)) < 0) | 2383 | sizeof(struct linux_xfrm_mib)) < 0) |
2382 | return -ENOMEM; | 2384 | return -ENOMEM; |
2383 | return 0; | 2385 | rv = xfrm_proc_init(net); |
2386 | if (rv < 0) | ||
2387 | snmp_mib_free((void **)net->mib.xfrm_statistics); | ||
2388 | return rv; | ||
2384 | } | 2389 | } |
2385 | 2390 | ||
2386 | static void xfrm_statistics_fini(struct net *net) | 2391 | static void xfrm_statistics_fini(struct net *net) |
2387 | { | 2392 | { |
2393 | xfrm_proc_fini(net); | ||
2388 | snmp_mib_free((void **)net->mib.xfrm_statistics); | 2394 | snmp_mib_free((void **)net->mib.xfrm_statistics); |
2389 | } | 2395 | } |
2390 | #else | 2396 | #else |
@@ -2524,9 +2530,6 @@ void __init xfrm_init(void) | |||
2524 | { | 2530 | { |
2525 | register_pernet_subsys(&xfrm_net_ops); | 2531 | register_pernet_subsys(&xfrm_net_ops); |
2526 | xfrm_input_init(); | 2532 | xfrm_input_init(); |
2527 | #ifdef CONFIG_XFRM_STATISTICS | ||
2528 | xfrm_proc_init(); | ||
2529 | #endif | ||
2530 | } | 2533 | } |
2531 | 2534 | ||
2532 | #ifdef CONFIG_AUDITSYSCALL | 2535 | #ifdef CONFIG_AUDITSYSCALL |
diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c index 27a2ab92d874..284eaef1dbf2 100644 --- a/net/xfrm/xfrm_proc.c +++ b/net/xfrm/xfrm_proc.c | |||
@@ -59,17 +59,18 @@ fold_field(void *mib[], int offt) | |||
59 | 59 | ||
60 | static int xfrm_statistics_seq_show(struct seq_file *seq, void *v) | 60 | static int xfrm_statistics_seq_show(struct seq_file *seq, void *v) |
61 | { | 61 | { |
62 | struct net *net = seq->private; | ||
62 | int i; | 63 | int i; |
63 | for (i=0; xfrm_mib_list[i].name; i++) | 64 | for (i=0; xfrm_mib_list[i].name; i++) |
64 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, | 65 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, |
65 | fold_field((void **)init_net.mib.xfrm_statistics, | 66 | fold_field((void **)net->mib.xfrm_statistics, |
66 | xfrm_mib_list[i].entry)); | 67 | xfrm_mib_list[i].entry)); |
67 | return 0; | 68 | return 0; |
68 | } | 69 | } |
69 | 70 | ||
70 | static int xfrm_statistics_seq_open(struct inode *inode, struct file *file) | 71 | static int xfrm_statistics_seq_open(struct inode *inode, struct file *file) |
71 | { | 72 | { |
72 | return single_open(file, xfrm_statistics_seq_show, NULL); | 73 | return single_open_net(inode, file, xfrm_statistics_seq_show); |
73 | } | 74 | } |
74 | 75 | ||
75 | static struct file_operations xfrm_statistics_seq_fops = { | 76 | static struct file_operations xfrm_statistics_seq_fops = { |
@@ -77,21 +78,18 @@ static struct file_operations xfrm_statistics_seq_fops = { | |||
77 | .open = xfrm_statistics_seq_open, | 78 | .open = xfrm_statistics_seq_open, |
78 | .read = seq_read, | 79 | .read = seq_read, |
79 | .llseek = seq_lseek, | 80 | .llseek = seq_lseek, |
80 | .release = single_release, | 81 | .release = single_release_net, |
81 | }; | 82 | }; |
82 | 83 | ||
83 | int __init xfrm_proc_init(void) | 84 | int __net_init xfrm_proc_init(struct net *net) |
84 | { | 85 | { |
85 | int rc = 0; | 86 | if (!proc_net_fops_create(net, "xfrm_stat", S_IRUGO, |
86 | |||
87 | if (!proc_net_fops_create(&init_net, "xfrm_stat", S_IRUGO, | ||
88 | &xfrm_statistics_seq_fops)) | 87 | &xfrm_statistics_seq_fops)) |
89 | goto stat_fail; | 88 | return -ENOMEM; |
90 | 89 | return 0; | |
91 | out: | 90 | } |
92 | return rc; | ||
93 | 91 | ||
94 | stat_fail: | 92 | void xfrm_proc_fini(struct net *net) |
95 | rc = -ENOMEM; | 93 | { |
96 | goto out; | 94 | proc_net_remove(net, "xfrm_stat"); |
97 | } | 95 | } |