Commit b32fd3cc authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net/tls: add statistics for installed sessions

Add SNMP stats for number of sockets with successfully
installed sessions.  Break them down to software and
hardware ones.  Note that if hardware offload fails
stack uses software implementation, and counts the
session appropriately.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d26b698d
...@@ -219,3 +219,17 @@ Statistics ...@@ -219,3 +219,17 @@ Statistics
TLS implementation exposes the following per-namespace statistics TLS implementation exposes the following per-namespace statistics
(``/proc/net/tls_stat``): (``/proc/net/tls_stat``):
- ``TlsCurrTxSw``, ``TlsCurrRxSw`` -
number of TX and RX sessions currently installed where host handles
cryptography
- ``TlsCurrTxDevice``, ``TlsCurrRxDevice`` -
number of TX and RX sessions currently installed where NIC handles
cryptography
- ``TlsTxSw``, ``TlsRxSw`` -
number of TX and RX sessions opened with host cryptography
- ``TlsTxDevice``, ``TlsRxDevice`` -
number of TX and RX sessions opened with NIC cryptography
...@@ -327,6 +327,14 @@ enum ...@@ -327,6 +327,14 @@ enum
enum enum
{ {
LINUX_MIB_TLSNUM = 0, LINUX_MIB_TLSNUM = 0,
LINUX_MIB_TLSCURRTXSW, /* TlsCurrTxSw */
LINUX_MIB_TLSCURRRXSW, /* TlsCurrRxSw */
LINUX_MIB_TLSCURRTXDEVICE, /* TlsCurrTxDevice */
LINUX_MIB_TLSCURRRXDEVICE, /* TlsCurrRxDevice */
LINUX_MIB_TLSTXSW, /* TlsTxSw */
LINUX_MIB_TLSRXSW, /* TlsRxSw */
LINUX_MIB_TLSTXDEVICE, /* TlsTxDevice */
LINUX_MIB_TLSRXDEVICE, /* TlsRxDevice */
__LINUX_MIB_TLSMAX __LINUX_MIB_TLSMAX
}; };
......
...@@ -286,14 +286,19 @@ static void tls_sk_proto_cleanup(struct sock *sk, ...@@ -286,14 +286,19 @@ static void tls_sk_proto_cleanup(struct sock *sk,
kfree(ctx->tx.rec_seq); kfree(ctx->tx.rec_seq);
kfree(ctx->tx.iv); kfree(ctx->tx.iv);
tls_sw_release_resources_tx(sk); tls_sw_release_resources_tx(sk);
TLS_DEC_STATS(sock_net(sk), LINUX_MIB_TLSCURRTXSW);
} else if (ctx->tx_conf == TLS_HW) { } else if (ctx->tx_conf == TLS_HW) {
tls_device_free_resources_tx(sk); tls_device_free_resources_tx(sk);
TLS_DEC_STATS(sock_net(sk), LINUX_MIB_TLSCURRTXDEVICE);
} }
if (ctx->rx_conf == TLS_SW) if (ctx->rx_conf == TLS_SW) {
tls_sw_release_resources_rx(sk); tls_sw_release_resources_rx(sk);
else if (ctx->rx_conf == TLS_HW) TLS_DEC_STATS(sock_net(sk), LINUX_MIB_TLSCURRRXSW);
} else if (ctx->rx_conf == TLS_HW) {
tls_device_offload_cleanup_rx(sk); tls_device_offload_cleanup_rx(sk);
TLS_DEC_STATS(sock_net(sk), LINUX_MIB_TLSCURRRXDEVICE);
}
} }
static void tls_sk_proto_close(struct sock *sk, long timeout) static void tls_sk_proto_close(struct sock *sk, long timeout)
...@@ -534,19 +539,29 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, ...@@ -534,19 +539,29 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
if (tx) { if (tx) {
rc = tls_set_device_offload(sk, ctx); rc = tls_set_device_offload(sk, ctx);
conf = TLS_HW; conf = TLS_HW;
if (rc) { if (!rc) {
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSTXDEVICE);
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSCURRTXDEVICE);
} else {
rc = tls_set_sw_offload(sk, ctx, 1); rc = tls_set_sw_offload(sk, ctx, 1);
if (rc) if (rc)
goto err_crypto_info; goto err_crypto_info;
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSTXSW);
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSCURRTXSW);
conf = TLS_SW; conf = TLS_SW;
} }
} else { } else {
rc = tls_set_device_offload_rx(sk, ctx); rc = tls_set_device_offload_rx(sk, ctx);
conf = TLS_HW; conf = TLS_HW;
if (rc) { if (!rc) {
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXDEVICE);
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSCURRRXDEVICE);
} else {
rc = tls_set_sw_offload(sk, ctx, 0); rc = tls_set_sw_offload(sk, ctx, 0);
if (rc) if (rc)
goto err_crypto_info; goto err_crypto_info;
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSRXSW);
TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSCURRRXSW);
conf = TLS_SW; conf = TLS_SW;
} }
tls_sw_strparser_arm(sk, ctx); tls_sw_strparser_arm(sk, ctx);
......
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
#include <net/tls.h> #include <net/tls.h>
static const struct snmp_mib tls_mib_list[] = { static const struct snmp_mib tls_mib_list[] = {
SNMP_MIB_ITEM("TlsCurrTxSw", LINUX_MIB_TLSCURRTXSW),
SNMP_MIB_ITEM("TlsCurrRxSw", LINUX_MIB_TLSCURRRXSW),
SNMP_MIB_ITEM("TlsCurrTxDevice", LINUX_MIB_TLSCURRTXDEVICE),
SNMP_MIB_ITEM("TlsCurrRxDevice", LINUX_MIB_TLSCURRRXDEVICE),
SNMP_MIB_ITEM("TlsTxSw", LINUX_MIB_TLSTXSW),
SNMP_MIB_ITEM("TlsRxSw", LINUX_MIB_TLSRXSW),
SNMP_MIB_ITEM("TlsTxDevice", LINUX_MIB_TLSTXDEVICE),
SNMP_MIB_ITEM("TlsRxDevice", LINUX_MIB_TLSRXDEVICE),
SNMP_MIB_SENTINEL SNMP_MIB_SENTINEL
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment