: Define packet dropping statistics.
Subsystems (4)
PATCH 1/3 : Define packet dropping statistics.
This statistics is shown factor dropped by transformation at /proc/net/xfrm_stat for developer.
It is a counter designed from current transformation source code and defined as linux private MIB.
See Documentation/networking/xfrm_proc.txt for the detail.
Signed-off-by Masahide NAKAMURA <[email protected]>
--- Documentation/networking/xfrm_proc.txt | 71 +++++++++++++++++++++++ include/linux/snmp.h | 31 ++++++++++ include/net/snmp.h | 5 ++ include/net/xfrm.h | 18 ++++++ net/xfrm/Makefile | 1 + net/xfrm/xfrm_policy.c | 24 ++++++++ net/xfrm/xfrm_proc.c | 96 ++++++++++++++++++++++++++++++++ 7 files changed, 246 insertions(+), 0 deletions(-)
Documentation/networking/xfrm_proc.txt new file +71 -0
@@ -0,0 +1,71 @@ +XFRM proc - /proc/net/xfrm_* files +================================== +Masahide NAKAMURA <[email protected]> + + +Transformation Statistics +------------------------- +xfrm_proc is a statistics shown factor dropped by transformation +for developer. +It is a counter designed from current transformation source code +and defined like linux private MIB. + +Inbound statistics +~~~~~~~~~~~~~~~~~~ +XfrmInError: + All errors which is not matched others +XfrmInBufferError: + No buffer is left +XfrmInHdrError: + Header error +XfrmInNoStates: + No state is found + i.e. Either inbound SPI, address, or IPsec protocol at SA is wrong +XfrmInStateProtoError: + Transformation protocol specific error + e.g. SA key is wrong +XfrmInStateModeError: + Transformation mode specific error +XfrmInSeqOutOfWindow: + Sequence out of window +XfrmInStateExpired: + State is expired +XfrmInStateMismatch: + State has mismatch option + e.g. UDP encapsulation type is mismatch +XfrmInStateInvalid: + State is invalid +XfrmInTmplMismatch: + No matching template for states + e.g. Inbound SAs are correct but SP rule is wrong +XfrmInNoPols: + No policy is found for states + e.g. Inbound SAs are correct but no SP is found +XfrmInPolBlock: + Policy discards +XfrmInPolError: + Policy error + +Outbound errors +~~~~~~~~~~~~~~~ +XfrmOutError: + All errors which is not matched others +XfrmOutBundleGenError: + Bundle generation error +XfrmOutBundleCheckError: + Bundle check error +XfrmOutNoStates: + No state is found +XfrmOutStateProtoError: + Transformation protocol specific error +XfrmOutStateModeError: + Transformation mode specific error + e.g. Outer header space is not enough +XfrmOutStateExpired: + State is expired +XfrmOutPolBlock: + Policy discards +XfrmOutPolDead: + Policy is dead +XfrmOutPolError: + Policy error
include/linux/snmp.h +31 -0
@@ -217,4 +217,35 @@ enum__LINUX_MIB_MAX }; +/* linux Xfrm mib definitions */ +enum +{ +LINUX_MIB_XFRMNUM =0 , +LINUX_MIB_XFRMINERROR ,/* XfrmInError */ +LINUX_MIB_XFRMINBUFFERERROR ,/* XfrmInBufferError */ +LINUX_MIB_XFRMINHDRERROR ,/* XfrmInHdrError */ +LINUX_MIB_XFRMINNOSTATES ,/* XfrmInNoStates */ +LINUX_MIB_XFRMINSTATEPROTOERROR ,/* XfrmInStateProtoError */ +LINUX_MIB_XFRMINSTATEMODEERROR ,/* XfrmInStateModeError */ +LINUX_MIB_XFRMINSEQOUTOFWINDOW ,/* XfrmInSeqOutOfWindow */ +LINUX_MIB_XFRMINSTATEEXPIRED ,/* XfrmInStateExpired */ +LINUX_MIB_XFRMINSTATEMISMATCH ,/* XfrmInStateMismatch */ +LINUX_MIB_XFRMINSTATEINVALID ,/* XfrmInStateInvalid */ +LINUX_MIB_XFRMINTMPLMISMATCH ,/* XfrmInTmplMismatch */ +LINUX_MIB_XFRMINNOPOLS ,/* XfrmInNoPols */ +LINUX_MIB_XFRMINPOLBLOCK ,/* XfrmInPolBlock */ +LINUX_MIB_XFRMINPOLERROR ,/* XfrmInPolError */ +LINUX_MIB_XFRMOUTERROR ,/* XfrmOutError */ +LINUX_MIB_XFRMOUTBUNDLEGENERROR ,/* XfrmOutBundleGenError */ +LINUX_MIB_XFRMOUTBUNDLECHECKERROR ,/* XfrmOutBundleCheckError */ +LINUX_MIB_XFRMOUTNOSTATES ,/* XfrmOutNoStates */ +LINUX_MIB_XFRMOUTSTATEPROTOERROR ,/* XfrmOutStateProtoError */ +LINUX_MIB_XFRMOUTSTATEMODEERROR ,/* XfrmOutStateModeError */ +LINUX_MIB_XFRMOUTSTATEEXPIRED ,/* XfrmOutStateExpired */ +LINUX_MIB_XFRMOUTPOLBLOCK ,/* XfrmOutPolBlock */ +LINUX_MIB_XFRMOUTPOLDEAD ,/* XfrmOutPolDead */ +LINUX_MIB_XFRMOUTPOLERROR ,/* XfrmOutPolError */ + __LINUX_MIB_XFRMMAX +}; +#endif /* _LINUX_SNMP_H */
include/net/snmp.h +5 -0
@@ -117,6 +117,11 @@ struct linux_mib {unsigned long mibs[LINUX_MIB_MAX ]; }; +/* Linux Xfrm */ +#define LINUX_MIB_XFRMMAX __LINUX_MIB_XFRMMAX +struct linux_xfrm_mib { +unsigned long mibs[LINUX_MIB_XFRMMAX ]; +};/* * FIXME: On x86 and some other CPUs the split into user and softirq parts
include/net/xfrm.h +18 -0
@@ -19,6 +19,9 @@#include <net/route.h> #include <net/ipv6.h> #include <net/ip6_fib.h> +#ifdef CONFIG_XFRM_STATISTICS +#include <net/snmp.h> +#endif #define XFRM_PROTO_ESP 50#define XFRM_PROTO_AH 51
@@ -34,6 +37,17 @@#define MODULE_ALIAS_XFRM_TYPE (family, proto) \ MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) +#ifdef CONFIG_XFRM_STATISTICS +DECLARE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); +#define XFRM_INC_STATS (field) SNMP_INC_STATS(xfrm_statistics, field) +#define XFRM_INC_STATS_BH (field) SNMP_INC_STATS_BH(xfrm_statistics, field) +#define XFRM_INC_STATS_USER (field) SNMP_INC_STATS_USER(xfrm_statistics, field) +#else +#define XFRM_INC_STATS (field) +#define XFRM_INC_STATS_BH (field) +#define XFRM_INC_STATS_USER (field) +#endif +extern struct sock *xfrm_nl;extern u32 sysctl_xfrm_aevent_etime;extern u32 sysctl_xfrm_aevent_rseqth;
@@ -1139,6 +1153,10 @@ static inline void xfrm6_fini(void) }#endif +#ifdef CONFIG_XFRM_STATISTICS +extern int xfrm_proc_init (void ); +#endif +extern int xfrm_state_walk (u8 proto,int (*func)(struct xfrm_state *,int ,void *),void *);extern struct xfrm_state *xfrm_state_alloc (void ); extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
net/xfrm/Makefile +1 -0
@@ -4,5 +4,6 @@ obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \ xfrm_input.o xfrm_output.o xfrm_algo.o +obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o obj-$(CONFIG_XFRM_USER) += xfrm_user.o
net/xfrm/xfrm_policy.c +24 -0
@@ -27,11 +27,19 @@#include <net/dst.h> #include <net/xfrm.h> #include <net/ip.h> +#ifdef CONFIG_XFRM_STATISTICS +#include <net/snmp.h> +#endif #include "xfrm_hash.h" int sysctl_xfrm_larval_drop__read_mostly ; +#ifdef CONFIG_XFRM_STATISTICS +DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics) __read_mostly; +EXPORT_SYMBOL (xfrm_statistics); +#endif +DEFINE_MUTEX (xfrm_cfg_mutex);EXPORT_SYMBOL (xfrm_cfg_mutex);
@@ -2258,6 +2266,16 @@ static struct notifier_block xfrm_dev_notifier = { 0 }; +#ifdef CONFIG_XFRM_STATISTICS +static int __init xfrm_statistics_init (void ) +{ +if (snmp_mib_init ((void **)xfrm_statistics, +sizeof (struct linux_xfrm_mib )) <0 ) +return -ENOMEM ; +return 0 ; +} +#endif +static void __init xfrm_policy_init (void ) {unsigned int hmask, sz;
@@ -2294,9 +2312,15 @@ static void __init xfrm_policy_init(void)void __init xfrm_init (void ) { +#ifdef CONFIG_XFRM_STATISTICS +xfrm_statistics_init (); +#endif xfrm_state_init ();xfrm_policy_init ();xfrm_input_init (); +#ifdef CONFIG_XFRM_STATISTICS +xfrm_proc_init (); +#endif }#ifdef CONFIG_AUDITSYSCALL
net/xfrm/xfrm_proc.c new file +96 -0
96 lines not on this page · raw message
Signature · 1 line
1.4.4.2
David Miller
maintainerFrom: Masahide NAKAMURA <[email protected]>
Date: Fri, 21 Dec 2007 12:41:53 +0900
Quoted 8 lines
This statistics is shown factor dropped by transformation at
/proc/net/xfrm_statfor developer.
It is a counter designed from current transformation source code and defined as linux private MIB.See
Documentation/networking/xfrm_proc.txtfor the detail.Signed-off-by Masahide NAKAMURA <[email protected]>
Patch applied.
This is very useful, thanks for implementing this feature.