File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,3 +213,9 @@ A patchset to OpenSSL to use ktls as the record layer is
213213of calling send directly after a handshake using gnutls.
214214Since it doesn't implement a full record layer, control
215215messages are not supported.
216+
217+ Statistics
218+ ==========
219+
220+ TLS implementation exposes the following per-namespace statistics
221+ (``/proc/net/tls_stat ``):
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ struct netns_mib {
2424#ifdef CONFIG_XFRM_STATISTICS
2525 DEFINE_SNMP_STAT (struct linux_xfrm_mib , xfrm_statistics );
2626#endif
27+ #if IS_ENABLED (CONFIG_TLS )
28+ DEFINE_SNMP_STAT (struct linux_tls_mib , tls_statistics );
29+ #endif
2730};
2831
2932#endif
Original file line number Diff line number Diff line change @@ -111,6 +111,12 @@ struct linux_xfrm_mib {
111111 unsigned long mibs [LINUX_MIB_XFRMMAX ];
112112};
113113
114+ /* Linux TLS */
115+ #define LINUX_MIB_TLSMAX __LINUX_MIB_TLSMAX
116+ struct linux_tls_mib {
117+ unsigned long mibs [LINUX_MIB_TLSMAX ];
118+ };
119+
114120#define DEFINE_SNMP_STAT (type , name ) \
115121 __typeof__(type) __percpu *name
116122#define DEFINE_SNMP_STAT_ATOMIC (type , name ) \
Original file line number Diff line number Diff line change 4343#include <linux/netdevice.h>
4444#include <linux/rcupdate.h>
4545
46+ #include <net/net_namespace.h>
4647#include <net/tcp.h>
4748#include <net/strparser.h>
4849#include <crypto/aead.h>
7374 */
7475#define TLS_AES_CCM_IV_B0_BYTE 2
7576
77+ #define __TLS_INC_STATS (net , field ) \
78+ __SNMP_INC_STATS((net)->mib.tls_statistics, field)
79+ #define TLS_INC_STATS (net , field ) \
80+ SNMP_INC_STATS((net)->mib.tls_statistics, field)
81+ #define __TLS_DEC_STATS (net , field ) \
82+ __SNMP_DEC_STATS((net)->mib.tls_statistics, field)
83+ #define TLS_DEC_STATS (net , field ) \
84+ SNMP_DEC_STATS((net)->mib.tls_statistics, field)
85+
7686enum {
7787 TLS_BASE ,
7888 TLS_SW ,
@@ -605,6 +615,9 @@ static inline bool tls_offload_tx_resync_pending(struct sock *sk)
605615 return ret ;
606616}
607617
618+ int __net_init tls_proc_init (struct net * net );
619+ void __net_exit tls_proc_fini (struct net * net );
620+
608621int tls_proccess_cmsg (struct sock * sk , struct msghdr * msg ,
609622 unsigned char * record_type );
610623int decrypt_skb (struct sock * sk , struct sk_buff * skb ,
Original file line number Diff line number Diff line change @@ -323,4 +323,11 @@ enum
323323 __LINUX_MIB_XFRMMAX
324324};
325325
326+ /* linux TLS mib definitions */
327+ enum
328+ {
329+ LINUX_MIB_TLSNUM = 0 ,
330+ __LINUX_MIB_TLSMAX
331+ };
332+
326333#endif /* _LINUX_SNMP_H */
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ CFLAGS_trace.o := -I$(src)
77
88obj-$(CONFIG_TLS) += tls.o
99
10- tls-y := tls_main.o tls_sw.o trace.o
10+ tls-y := tls_main.o tls_sw.o tls_proc.o trace.o
1111
1212tls-$(CONFIG_TLS_TOE) += tls_toe.o
1313tls-$(CONFIG_TLS_DEVICE) += tls_device.o tls_device_fallback.o
Original file line number Diff line number Diff line change 4141#include <linux/inetdevice.h>
4242#include <linux/inet_diag.h>
4343
44+ #include <net/snmp.h>
4445#include <net/tls.h>
4546#include <net/tls_toe.h>
4647
@@ -795,6 +796,35 @@ static size_t tls_get_info_size(const struct sock *sk)
795796 return size ;
796797}
797798
799+ static int __net_init tls_init_net (struct net * net )
800+ {
801+ int err ;
802+
803+ net -> mib .tls_statistics = alloc_percpu (struct linux_tls_mib );
804+ if (!net -> mib .tls_statistics )
805+ return - ENOMEM ;
806+
807+ err = tls_proc_init (net );
808+ if (err )
809+ goto err_free_stats ;
810+
811+ return 0 ;
812+ err_free_stats :
813+ free_percpu (net -> mib .tls_statistics );
814+ return err ;
815+ }
816+
817+ static void __net_exit tls_exit_net (struct net * net )
818+ {
819+ tls_proc_fini (net );
820+ free_percpu (net -> mib .tls_statistics );
821+ }
822+
823+ static struct pernet_operations tls_proc_ops = {
824+ .init = tls_init_net ,
825+ .exit = tls_exit_net ,
826+ };
827+
798828static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = {
799829 .name = "tls" ,
800830 .owner = THIS_MODULE ,
@@ -806,6 +836,12 @@ static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = {
806836
807837static int __init tls_register (void )
808838{
839+ int err ;
840+
841+ err = register_pernet_subsys (& tls_proc_ops );
842+ if (err )
843+ return err ;
844+
809845 tls_sw_proto_ops = inet_stream_ops ;
810846 tls_sw_proto_ops .splice_read = tls_sw_splice_read ;
811847
@@ -819,6 +855,7 @@ static void __exit tls_unregister(void)
819855{
820856 tcp_unregister_ulp (& tcp_tls_ulp_ops );
821857 tls_device_cleanup ();
858+ unregister_pernet_subsys (& tls_proc_ops );
822859}
823860
824861module_init (tls_register );
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+ /* Copyright (C) 2019 Netronome Systems, Inc. */
3+
4+ #include <linux/proc_fs.h>
5+ #include <linux/seq_file.h>
6+ #include <net/snmp.h>
7+ #include <net/tls.h>
8+
9+ static const struct snmp_mib tls_mib_list [] = {
10+ SNMP_MIB_SENTINEL
11+ };
12+
13+ static int tls_statistics_seq_show (struct seq_file * seq , void * v )
14+ {
15+ unsigned long buf [LINUX_MIB_TLSMAX ] = {};
16+ struct net * net = seq -> private ;
17+ int i ;
18+
19+ snmp_get_cpu_field_batch (buf , tls_mib_list , net -> mib .tls_statistics );
20+ for (i = 0 ; tls_mib_list [i ].name ; i ++ )
21+ seq_printf (seq , "%-32s\t%lu\n" , tls_mib_list [i ].name , buf [i ]);
22+
23+ return 0 ;
24+ }
25+
26+ int __net_init tls_proc_init (struct net * net )
27+ {
28+ if (!proc_create_net_single ("tls_stat" , 0444 , net -> proc_net ,
29+ tls_statistics_seq_show , NULL ))
30+ return - ENOMEM ;
31+ return 0 ;
32+ }
33+
34+ void __net_exit tls_proc_fini (struct net * net )
35+ {
36+ remove_proc_entry ("tls_stat" , net -> proc_net );
37+ }
You can’t perform that action at this time.
0 commit comments