2019-05-27 09:55:01 +03:00
// SPDX-License-Identifier: GPL-2.0-or-later
2007-12-21 07:42:57 +03:00
/*
* xfrm_proc . c
*
* Copyright ( C ) 2006 - 2007 USAGI / WIDE Project
*
* Authors : Masahide NAKAMURA < nakam @ linux - ipv6 . org >
*/
# include <linux/proc_fs.h>
# include <linux/seq_file.h>
2011-07-15 19:47:34 +04:00
# include <linux/export.h>
2007-12-21 07:42:57 +03:00
# include <net/snmp.h>
# include <net/xfrm.h>
2010-01-22 13:17:26 +03:00
static const struct snmp_mib xfrm_mib_list [ ] = {
2007-12-21 07:42:57 +03:00
SNMP_MIB_ITEM ( " XfrmInError " , LINUX_MIB_XFRMINERROR ) ,
SNMP_MIB_ITEM ( " XfrmInBufferError " , LINUX_MIB_XFRMINBUFFERERROR ) ,
SNMP_MIB_ITEM ( " XfrmInHdrError " , LINUX_MIB_XFRMINHDRERROR ) ,
SNMP_MIB_ITEM ( " XfrmInNoStates " , LINUX_MIB_XFRMINNOSTATES ) ,
SNMP_MIB_ITEM ( " XfrmInStateProtoError " , LINUX_MIB_XFRMINSTATEPROTOERROR ) ,
SNMP_MIB_ITEM ( " XfrmInStateModeError " , LINUX_MIB_XFRMINSTATEMODEERROR ) ,
2008-02-01 04:14:58 +03:00
SNMP_MIB_ITEM ( " XfrmInStateSeqError " , LINUX_MIB_XFRMINSTATESEQERROR ) ,
2007-12-21 07:42:57 +03:00
SNMP_MIB_ITEM ( " XfrmInStateExpired " , LINUX_MIB_XFRMINSTATEEXPIRED ) ,
SNMP_MIB_ITEM ( " XfrmInStateMismatch " , LINUX_MIB_XFRMINSTATEMISMATCH ) ,
SNMP_MIB_ITEM ( " XfrmInStateInvalid " , LINUX_MIB_XFRMINSTATEINVALID ) ,
SNMP_MIB_ITEM ( " XfrmInTmplMismatch " , LINUX_MIB_XFRMINTMPLMISMATCH ) ,
SNMP_MIB_ITEM ( " XfrmInNoPols " , LINUX_MIB_XFRMINNOPOLS ) ,
SNMP_MIB_ITEM ( " XfrmInPolBlock " , LINUX_MIB_XFRMINPOLBLOCK ) ,
SNMP_MIB_ITEM ( " XfrmInPolError " , LINUX_MIB_XFRMINPOLERROR ) ,
SNMP_MIB_ITEM ( " XfrmOutError " , LINUX_MIB_XFRMOUTERROR ) ,
SNMP_MIB_ITEM ( " XfrmOutBundleGenError " , LINUX_MIB_XFRMOUTBUNDLEGENERROR ) ,
SNMP_MIB_ITEM ( " XfrmOutBundleCheckError " , LINUX_MIB_XFRMOUTBUNDLECHECKERROR ) ,
SNMP_MIB_ITEM ( " XfrmOutNoStates " , LINUX_MIB_XFRMOUTNOSTATES ) ,
SNMP_MIB_ITEM ( " XfrmOutStateProtoError " , LINUX_MIB_XFRMOUTSTATEPROTOERROR ) ,
SNMP_MIB_ITEM ( " XfrmOutStateModeError " , LINUX_MIB_XFRMOUTSTATEMODEERROR ) ,
2008-02-01 04:14:58 +03:00
SNMP_MIB_ITEM ( " XfrmOutStateSeqError " , LINUX_MIB_XFRMOUTSTATESEQERROR ) ,
2007-12-21 07:42:57 +03:00
SNMP_MIB_ITEM ( " XfrmOutStateExpired " , LINUX_MIB_XFRMOUTSTATEEXPIRED ) ,
SNMP_MIB_ITEM ( " XfrmOutPolBlock " , LINUX_MIB_XFRMOUTPOLBLOCK ) ,
SNMP_MIB_ITEM ( " XfrmOutPolDead " , LINUX_MIB_XFRMOUTPOLDEAD ) ,
SNMP_MIB_ITEM ( " XfrmOutPolError " , LINUX_MIB_XFRMOUTPOLERROR ) ,
2010-02-18 06:35:07 +03:00
SNMP_MIB_ITEM ( " XfrmFwdHdrError " , LINUX_MIB_XFRMFWDHDRERROR ) ,
2012-12-28 12:06:28 +04:00
SNMP_MIB_ITEM ( " XfrmOutStateInvalid " , LINUX_MIB_XFRMOUTSTATEINVALID ) ,
2013-06-06 06:15:54 +04:00
SNMP_MIB_ITEM ( " XfrmAcquireError " , LINUX_MIB_XFRMACQUIREERROR ) ,
2007-12-21 07:42:57 +03:00
SNMP_MIB_SENTINEL
} ;
static int xfrm_statistics_seq_show ( struct seq_file * seq , void * v )
{
2016-09-30 06:29:02 +03:00
unsigned long buff [ LINUX_MIB_XFRMMAX ] ;
2008-11-26 05:00:14 +03:00
struct net * net = seq - > private ;
2007-12-21 07:42:57 +03:00
int i ;
2016-09-30 06:29:02 +03:00
memset ( buff , 0 , sizeof ( unsigned long ) * LINUX_MIB_XFRMMAX ) ;
snmp_get_cpu_field_batch ( buff , xfrm_mib_list ,
net - > mib . xfrm_statistics ) ;
2013-12-24 05:43:46 +04:00
for ( i = 0 ; xfrm_mib_list [ i ] . name ; i + + )
2007-12-21 07:42:57 +03:00
seq_printf ( seq , " %-24s \t %lu \n " , xfrm_mib_list [ i ] . name ,
2016-09-30 06:29:02 +03:00
buff [ i ] ) ;
2007-12-21 07:42:57 +03:00
return 0 ;
}
2008-11-26 05:00:14 +03:00
int __net_init xfrm_proc_init ( struct net * net )
2007-12-21 07:42:57 +03:00
{
2018-04-13 21:38:35 +03:00
if ( ! proc_create_net_single ( " xfrm_stat " , 0444 , net - > proc_net ,
xfrm_statistics_seq_show , NULL ) )
2008-11-26 05:00:14 +03:00
return - ENOMEM ;
return 0 ;
}
2007-12-21 07:42:57 +03:00
2008-11-26 05:00:14 +03:00
void xfrm_proc_fini ( struct net * net )
{
2013-02-18 05:34:56 +04:00
remove_proc_entry ( " xfrm_stat " , net - > proc_net ) ;
2007-12-21 07:42:57 +03:00
}