aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/Makefile1
-rw-r--r--net/xfrm/xfrm_policy.c24
-rw-r--r--net/xfrm/xfrm_proc.c96
3 files changed, 121 insertions, 0 deletions
diff --git a/net/xfrm/Makefile b/net/xfrm/Makefile
index 45744a3d3a51..332cfb0ff566 100644
--- a/net/xfrm/Makefile
+++ b/net/xfrm/Makefile
@@ -4,5 +4,6 @@
4 4
5obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \ 5obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \
6 xfrm_input.o xfrm_output.o xfrm_algo.o 6 xfrm_input.o xfrm_output.o xfrm_algo.o
7obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o
7obj-$(CONFIG_XFRM_USER) += xfrm_user.o 8obj-$(CONFIG_XFRM_USER) += xfrm_user.o
8 9
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 521cb6e12561..32ddb7b12e7f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -27,11 +27,19 @@
27#include <net/dst.h> 27#include <net/dst.h>
28#include <net/xfrm.h> 28#include <net/xfrm.h>
29#include <net/ip.h> 29#include <net/ip.h>
30#ifdef CONFIG_XFRM_STATISTICS
31#include <net/snmp.h>
32#endif
30 33
31#include "xfrm_hash.h" 34#include "xfrm_hash.h"
32 35
33int sysctl_xfrm_larval_drop __read_mostly; 36int sysctl_xfrm_larval_drop __read_mostly;
34 37
38#ifdef CONFIG_XFRM_STATISTICS
39DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics) __read_mostly;
40EXPORT_SYMBOL(xfrm_statistics);
41#endif
42
35DEFINE_MUTEX(xfrm_cfg_mutex); 43DEFINE_MUTEX(xfrm_cfg_mutex);
36EXPORT_SYMBOL(xfrm_cfg_mutex); 44EXPORT_SYMBOL(xfrm_cfg_mutex);
37 45
@@ -2258,6 +2266,16 @@ static struct notifier_block xfrm_dev_notifier = {
2258 0 2266 0
2259}; 2267};
2260 2268
2269#ifdef CONFIG_XFRM_STATISTICS
2270static int __init xfrm_statistics_init(void)
2271{
2272 if (snmp_mib_init((void **)xfrm_statistics,
2273 sizeof(struct linux_xfrm_mib)) < 0)
2274 return -ENOMEM;
2275 return 0;
2276}
2277#endif
2278
2261static void __init xfrm_policy_init(void) 2279static void __init xfrm_policy_init(void)
2262{ 2280{
2263 unsigned int hmask, sz; 2281 unsigned int hmask, sz;
@@ -2294,9 +2312,15 @@ static void __init xfrm_policy_init(void)
2294 2312
2295void __init xfrm_init(void) 2313void __init xfrm_init(void)
2296{ 2314{
2315#ifdef CONFIG_XFRM_STATISTICS
2316 xfrm_statistics_init();
2317#endif
2297 xfrm_state_init(); 2318 xfrm_state_init();
2298 xfrm_policy_init(); 2319 xfrm_policy_init();
2299 xfrm_input_init(); 2320 xfrm_input_init();
2321#ifdef CONFIG_XFRM_STATISTICS
2322 xfrm_proc_init();
2323#endif
2300} 2324}
2301 2325
2302#ifdef CONFIG_AUDITSYSCALL 2326#ifdef CONFIG_AUDITSYSCALL
diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c
new file mode 100644
index 000000000000..31d035415ecd
--- /dev/null
+++ b/net/xfrm/xfrm_proc.c
@@ -0,0 +1,96 @@
1/*
2 * xfrm_proc.c
3 *
4 * Copyright (C)2006-2007 USAGI/WIDE Project
5 *
6 * Authors: Masahide NAKAMURA <nakam@linux-ipv6.org>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#include <linux/proc_fs.h>
14#include <linux/seq_file.h>
15#include <net/snmp.h>
16#include <net/xfrm.h>
17
18static struct snmp_mib xfrm_mib_list[] = {
19 SNMP_MIB_ITEM("XfrmInError", LINUX_MIB_XFRMINERROR),
20 SNMP_MIB_ITEM("XfrmInBufferError", LINUX_MIB_XFRMINBUFFERERROR),
21 SNMP_MIB_ITEM("XfrmInHdrError", LINUX_MIB_XFRMINHDRERROR),
22 SNMP_MIB_ITEM("XfrmInNoStates", LINUX_MIB_XFRMINNOSTATES),
23 SNMP_MIB_ITEM("XfrmInStateProtoError", LINUX_MIB_XFRMINSTATEPROTOERROR),
24 SNMP_MIB_ITEM("XfrmInStateModeError", LINUX_MIB_XFRMINSTATEMODEERROR),
25 SNMP_MIB_ITEM("XfrmInSeqOutOfWindow", LINUX_MIB_XFRMINSEQOUTOFWINDOW),
26 SNMP_MIB_ITEM("XfrmInStateExpired", LINUX_MIB_XFRMINSTATEEXPIRED),
27 SNMP_MIB_ITEM("XfrmInStateMismatch", LINUX_MIB_XFRMINSTATEMISMATCH),
28 SNMP_MIB_ITEM("XfrmInStateInvalid", LINUX_MIB_XFRMINSTATEINVALID),
29 SNMP_MIB_ITEM("XfrmInTmplMismatch", LINUX_MIB_XFRMINTMPLMISMATCH),
30 SNMP_MIB_ITEM("XfrmInNoPols", LINUX_MIB_XFRMINNOPOLS),
31 SNMP_MIB_ITEM("XfrmInPolBlock", LINUX_MIB_XFRMINPOLBLOCK),
32 SNMP_MIB_ITEM("XfrmInPolError", LINUX_MIB_XFRMINPOLERROR),
33 SNMP_MIB_ITEM("XfrmOutError", LINUX_MIB_XFRMOUTERROR),
34 SNMP_MIB_ITEM("XfrmOutBundleGenError", LINUX_MIB_XFRMOUTBUNDLEGENERROR),
35 SNMP_MIB_ITEM("XfrmOutBundleCheckError", LINUX_MIB_XFRMOUTBUNDLECHECKERROR),
36 SNMP_MIB_ITEM("XfrmOutNoStates", LINUX_MIB_XFRMOUTNOSTATES),
37 SNMP_MIB_ITEM("XfrmOutStateProtoError", LINUX_MIB_XFRMOUTSTATEPROTOERROR),
38 SNMP_MIB_ITEM("XfrmOutStateModeError", LINUX_MIB_XFRMOUTSTATEMODEERROR),
39 SNMP_MIB_ITEM("XfrmOutStateExpired", LINUX_MIB_XFRMOUTSTATEEXPIRED),
40 SNMP_MIB_ITEM("XfrmOutPolBlock", LINUX_MIB_XFRMOUTPOLBLOCK),
41 SNMP_MIB_ITEM("XfrmOutPolDead", LINUX_MIB_XFRMOUTPOLDEAD),
42 SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR),
43 SNMP_MIB_SENTINEL
44};
45
46static unsigned long
47fold_field(void *mib[], int offt)
48{
49 unsigned long res = 0;
50 int i;
51
52 for_each_possible_cpu(i) {
53 res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
54 res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
55 }
56 return res;
57}
58
59static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
60{
61 int i;
62 for (i=0; xfrm_mib_list[i].name; i++)
63 seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name,
64 fold_field((void **)xfrm_statistics,
65 xfrm_mib_list[i].entry));
66 return 0;
67}
68
69static int xfrm_statistics_seq_open(struct inode *inode, struct file *file)
70{
71 return single_open(file, xfrm_statistics_seq_show, NULL);
72}
73
74static struct file_operations xfrm_statistics_seq_fops = {
75 .owner = THIS_MODULE,
76 .open = xfrm_statistics_seq_open,
77 .read = seq_read,
78 .llseek = seq_lseek,
79 .release = single_release,
80};
81
82int __init xfrm_proc_init(void)
83{
84 int rc = 0;
85
86 if (!proc_net_fops_create(&init_net, "xfrm_stat", S_IRUGO,
87 &xfrm_statistics_seq_fops))
88 goto stat_fail;
89
90 out:
91 return rc;
92
93 stat_fail:
94 rc = -ENOMEM;
95 goto out;
96}