Linux Audio

Check our new training course

Loading...
v3.1
 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 const 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("XfrmInStateSeqError", LINUX_MIB_XFRMINSTATESEQERROR),
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("XfrmOutStateSeqError", LINUX_MIB_XFRMOUTSTATESEQERROR),
40	SNMP_MIB_ITEM("XfrmOutStateExpired", LINUX_MIB_XFRMOUTSTATEEXPIRED),
41	SNMP_MIB_ITEM("XfrmOutPolBlock", LINUX_MIB_XFRMOUTPOLBLOCK),
42	SNMP_MIB_ITEM("XfrmOutPolDead", LINUX_MIB_XFRMOUTPOLDEAD),
43	SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR),
44	SNMP_MIB_ITEM("XfrmFwdHdrError", LINUX_MIB_XFRMFWDHDRERROR),
45	SNMP_MIB_SENTINEL
46};
47
48static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
49{
50	struct net *net = seq->private;
51	int i;
52	for (i=0; xfrm_mib_list[i].name; i++)
53		seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name,
54			   snmp_fold_field((void __percpu **)
55					   net->mib.xfrm_statistics,
56					   xfrm_mib_list[i].entry));
57	return 0;
58}
59
60static int xfrm_statistics_seq_open(struct inode *inode, struct file *file)
61{
62	return single_open_net(inode, file, xfrm_statistics_seq_show);
63}
64
65static const struct file_operations xfrm_statistics_seq_fops = {
66	.owner	 = THIS_MODULE,
67	.open	 = xfrm_statistics_seq_open,
68	.read	 = seq_read,
69	.llseek	 = seq_lseek,
70	.release = single_release_net,
71};
72
73int __net_init xfrm_proc_init(struct net *net)
74{
75	if (!proc_net_fops_create(net, "xfrm_stat", S_IRUGO,
76				  &xfrm_statistics_seq_fops))
77		return -ENOMEM;
78	return 0;
79}
80
81void xfrm_proc_fini(struct net *net)
82{
83	proc_net_remove(net, "xfrm_stat");
84}
v3.5.6
 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 <linux/export.h>
16#include <net/snmp.h>
17#include <net/xfrm.h>
18
19static const struct snmp_mib xfrm_mib_list[] = {
20	SNMP_MIB_ITEM("XfrmInError", LINUX_MIB_XFRMINERROR),
21	SNMP_MIB_ITEM("XfrmInBufferError", LINUX_MIB_XFRMINBUFFERERROR),
22	SNMP_MIB_ITEM("XfrmInHdrError", LINUX_MIB_XFRMINHDRERROR),
23	SNMP_MIB_ITEM("XfrmInNoStates", LINUX_MIB_XFRMINNOSTATES),
24	SNMP_MIB_ITEM("XfrmInStateProtoError", LINUX_MIB_XFRMINSTATEPROTOERROR),
25	SNMP_MIB_ITEM("XfrmInStateModeError", LINUX_MIB_XFRMINSTATEMODEERROR),
26	SNMP_MIB_ITEM("XfrmInStateSeqError", LINUX_MIB_XFRMINSTATESEQERROR),
27	SNMP_MIB_ITEM("XfrmInStateExpired", LINUX_MIB_XFRMINSTATEEXPIRED),
28	SNMP_MIB_ITEM("XfrmInStateMismatch", LINUX_MIB_XFRMINSTATEMISMATCH),
29	SNMP_MIB_ITEM("XfrmInStateInvalid", LINUX_MIB_XFRMINSTATEINVALID),
30	SNMP_MIB_ITEM("XfrmInTmplMismatch", LINUX_MIB_XFRMINTMPLMISMATCH),
31	SNMP_MIB_ITEM("XfrmInNoPols", LINUX_MIB_XFRMINNOPOLS),
32	SNMP_MIB_ITEM("XfrmInPolBlock", LINUX_MIB_XFRMINPOLBLOCK),
33	SNMP_MIB_ITEM("XfrmInPolError", LINUX_MIB_XFRMINPOLERROR),
34	SNMP_MIB_ITEM("XfrmOutError", LINUX_MIB_XFRMOUTERROR),
35	SNMP_MIB_ITEM("XfrmOutBundleGenError", LINUX_MIB_XFRMOUTBUNDLEGENERROR),
36	SNMP_MIB_ITEM("XfrmOutBundleCheckError", LINUX_MIB_XFRMOUTBUNDLECHECKERROR),
37	SNMP_MIB_ITEM("XfrmOutNoStates", LINUX_MIB_XFRMOUTNOSTATES),
38	SNMP_MIB_ITEM("XfrmOutStateProtoError", LINUX_MIB_XFRMOUTSTATEPROTOERROR),
39	SNMP_MIB_ITEM("XfrmOutStateModeError", LINUX_MIB_XFRMOUTSTATEMODEERROR),
40	SNMP_MIB_ITEM("XfrmOutStateSeqError", LINUX_MIB_XFRMOUTSTATESEQERROR),
41	SNMP_MIB_ITEM("XfrmOutStateExpired", LINUX_MIB_XFRMOUTSTATEEXPIRED),
42	SNMP_MIB_ITEM("XfrmOutPolBlock", LINUX_MIB_XFRMOUTPOLBLOCK),
43	SNMP_MIB_ITEM("XfrmOutPolDead", LINUX_MIB_XFRMOUTPOLDEAD),
44	SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR),
45	SNMP_MIB_ITEM("XfrmFwdHdrError", LINUX_MIB_XFRMFWDHDRERROR),
46	SNMP_MIB_SENTINEL
47};
48
49static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
50{
51	struct net *net = seq->private;
52	int i;
53	for (i=0; xfrm_mib_list[i].name; i++)
54		seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name,
55			   snmp_fold_field((void __percpu **)
56					   net->mib.xfrm_statistics,
57					   xfrm_mib_list[i].entry));
58	return 0;
59}
60
61static int xfrm_statistics_seq_open(struct inode *inode, struct file *file)
62{
63	return single_open_net(inode, file, xfrm_statistics_seq_show);
64}
65
66static const struct file_operations xfrm_statistics_seq_fops = {
67	.owner	 = THIS_MODULE,
68	.open	 = xfrm_statistics_seq_open,
69	.read	 = seq_read,
70	.llseek	 = seq_lseek,
71	.release = single_release_net,
72};
73
74int __net_init xfrm_proc_init(struct net *net)
75{
76	if (!proc_net_fops_create(net, "xfrm_stat", S_IRUGO,
77				  &xfrm_statistics_seq_fops))
78		return -ENOMEM;
79	return 0;
80}
81
82void xfrm_proc_fini(struct net *net)
83{
84	proc_net_remove(net, "xfrm_stat");
85}