naccyde / rpms / iproute

Forked from rpms/iproute 8 months ago
Clone

Blame SOURCES/0032-ss-allow-dumping-kTLS-info.patch

0ac2f3
From 06bd12bd8e48182f7f3293bbec187b4e90da796f Mon Sep 17 00:00:00 2001
0ac2f3
From: Andrea Claudi <aclaudi@redhat.com>
0ac2f3
Date: Mon, 29 Jun 2020 14:36:51 +0200
0ac2f3
Subject: [PATCH] ss: allow dumping kTLS info
0ac2f3
0ac2f3
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1812207
0ac2f3
Upstream Status: iproute2.git commit 14cadc707b919
0ac2f3
Conflicts: due to out-of-order cherry-pick of commit
0ac2f3
           712fdd98c0839 ("ss: allow dumping MPTCP subflow information")
0ac2f3
0ac2f3
commit 14cadc707b919914e9a2d5dffad9232c3ae97c5f
0ac2f3
Author: Davide Caratti <dcaratti@redhat.com>
0ac2f3
Date:   Mon Oct 7 12:16:44 2019 +0200
0ac2f3
0ac2f3
    ss: allow dumping kTLS info
0ac2f3
0ac2f3
    now that INET_DIAG_INFO requests can dump TCP ULP information, extend 'ss'
0ac2f3
    to allow diagnosing kTLS when it is attached to a TCP socket. While at it,
0ac2f3
    import kTLS uAPI definitions from the latest net-next tree.
0ac2f3
0ac2f3
    CC: Andrea Claudi <aclaudi@redhat.com>
0ac2f3
    Co-developed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
0ac2f3
    Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
0ac2f3
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
0ac2f3
    Signed-off-by: David Ahern <dsahern@gmail.com>
0ac2f3
---
0ac2f3
 misc/ss.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
0ac2f3
 1 file changed, 82 insertions(+)
0ac2f3
0ac2f3
diff --git a/misc/ss.c b/misc/ss.c
0ac2f3
index 3d565af86087c..8285382bd6c4a 100644
0ac2f3
--- a/misc/ss.c
0ac2f3
+++ b/misc/ss.c
0ac2f3
@@ -51,6 +51,7 @@
0ac2f3
 #include <linux/tipc.h>
0ac2f3
 #include <linux/tipc_netlink.h>
0ac2f3
 #include <linux/tipc_sockets_diag.h>
0ac2f3
+#include <linux/tls.h>
0ac2f3
 #include <linux/mptcp.h>
0ac2f3
 
0ac2f3
 /* AF_VSOCK/PF_VSOCK is only provided since glibc 2.18 */
0ac2f3
@@ -2752,6 +2753,72 @@ static void print_md5sig(struct tcp_diag_md5sig *sig)
0ac2f3
 	print_escape_buf(sig->tcpm_key, sig->tcpm_keylen, " ,");
0ac2f3
 }
0ac2f3
 
0ac2f3
+static void tcp_tls_version(struct rtattr *attr)
0ac2f3
+{
0ac2f3
+	u_int16_t val;
0ac2f3
+
0ac2f3
+	if (!attr)
0ac2f3
+		return;
0ac2f3
+	val = rta_getattr_u16(attr);
0ac2f3
+
0ac2f3
+	switch (val) {
0ac2f3
+	case TLS_1_2_VERSION:
0ac2f3
+		out(" version: 1.2");
0ac2f3
+		break;
0ac2f3
+	case TLS_1_3_VERSION:
0ac2f3
+		out(" version: 1.3");
0ac2f3
+		break;
0ac2f3
+	default:
0ac2f3
+		out(" version: unknown(%hu)", val);
0ac2f3
+		break;
0ac2f3
+	}
0ac2f3
+}
0ac2f3
+
0ac2f3
+static void tcp_tls_cipher(struct rtattr *attr)
0ac2f3
+{
0ac2f3
+	u_int16_t val;
0ac2f3
+
0ac2f3
+	if (!attr)
0ac2f3
+		return;
0ac2f3
+	val = rta_getattr_u16(attr);
0ac2f3
+
0ac2f3
+	switch (val) {
0ac2f3
+	case TLS_CIPHER_AES_GCM_128:
0ac2f3
+		out(" cipher: aes-gcm-128");
0ac2f3
+		break;
0ac2f3
+	case TLS_CIPHER_AES_GCM_256:
0ac2f3
+		out(" cipher: aes-gcm-256");
0ac2f3
+		break;
0ac2f3
+	}
0ac2f3
+}
0ac2f3
+
0ac2f3
+static void tcp_tls_conf(const char *name, struct rtattr *attr)
0ac2f3
+{
0ac2f3
+	u_int16_t val;
0ac2f3
+
0ac2f3
+	if (!attr)
0ac2f3
+		return;
0ac2f3
+	val = rta_getattr_u16(attr);
0ac2f3
+
0ac2f3
+	switch (val) {
0ac2f3
+	case TLS_CONF_BASE:
0ac2f3
+		out(" %s: none", name);
0ac2f3
+		break;
0ac2f3
+	case TLS_CONF_SW:
0ac2f3
+		out(" %s: sw", name);
0ac2f3
+		break;
0ac2f3
+	case TLS_CONF_HW:
0ac2f3
+		out(" %s: hw", name);
0ac2f3
+		break;
0ac2f3
+	case TLS_CONF_HW_RECORD:
0ac2f3
+		out(" %s: hw-record", name);
0ac2f3
+		break;
0ac2f3
+	default:
0ac2f3
+		out(" %s: unknown(%hu)", name, val);
0ac2f3
+		break;
0ac2f3
+	}
0ac2f3
+}
0ac2f3
+
0ac2f3
 static void mptcp_subflow_info(struct rtattr *tb[])
0ac2f3
 {
0ac2f3
 	u_int32_t flags = 0;
0ac2f3
@@ -2966,6 +3033,21 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
0ac2f3
 		parse_rtattr_nested(ulpinfo, INET_ULP_INFO_MAX,
0ac2f3
 				    tb[INET_DIAG_ULP_INFO]);
0ac2f3
 
0ac2f3
+		if (ulpinfo[INET_ULP_INFO_NAME])
0ac2f3
+			out(" tcp-ulp-%s",
0ac2f3
+			    rta_getattr_str(ulpinfo[INET_ULP_INFO_NAME]));
0ac2f3
+
0ac2f3
+		if (ulpinfo[INET_ULP_INFO_TLS]) {
0ac2f3
+			struct rtattr *tlsinfo[TLS_INFO_MAX + 1] = { 0 };
0ac2f3
+
0ac2f3
+			parse_rtattr_nested(tlsinfo, TLS_INFO_MAX,
0ac2f3
+					    ulpinfo[INET_ULP_INFO_TLS]);
0ac2f3
+
0ac2f3
+			tcp_tls_version(tlsinfo[TLS_INFO_VERSION]);
0ac2f3
+			tcp_tls_cipher(tlsinfo[TLS_INFO_CIPHER]);
0ac2f3
+			tcp_tls_conf("rxconf", tlsinfo[TLS_INFO_RXCONF]);
0ac2f3
+			tcp_tls_conf("txconf", tlsinfo[TLS_INFO_TXCONF]);
0ac2f3
+		}
0ac2f3
 		if (ulpinfo[INET_ULP_INFO_MPTCP]) {
0ac2f3
 			struct rtattr *sfinfo[MPTCP_SUBFLOW_ATTR_MAX + 1] =
0ac2f3
 				{ 0 };
0ac2f3
-- 
0ac2f3
2.26.2
0ac2f3