Blame SOURCES/0139-tc-m_tunnel_key-add-csum-nocsum-option.patch

99be8f
From 0152070641c58eccf6c6d9981a33f17ada23996f Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Wed, 5 Jun 2019 13:12:49 +0200
99be8f
Subject: [PATCH] tc: m_tunnel_key: add csum/nocsum option
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714660
99be8f
Upstream Status: iproute2.git commit 59eb271d1d259
99be8f
Conflicts: context change due to out-of-order cherry-pick of
99be8f
           commit 9f89b0cc0eda2 ("tc/act_tunnel_key: Enable
99be8f
           setup of tos and ttl")
99be8f
99be8f
commit 59eb271d1d259da21372d222a2d995e57ef648a9
99be8f
Author: Jiri Benc <jbenc@redhat.com>
99be8f
Date:   Wed Jun 14 21:30:18 2017 +0200
99be8f
99be8f
    tc: m_tunnel_key: add csum/nocsum option
99be8f
99be8f
    Allows control of UDP zero checksum.
99be8f
99be8f
    Signed-off-by: Jiri Benc <jbenc@redhat.com>
99be8f
---
99be8f
 man/man8/tc-tunnel_key.8 | 18 ++++++++++++++++++
99be8f
 tc/m_tunnel_key.c        | 21 ++++++++++++++++++++-
99be8f
 2 files changed, 38 insertions(+), 1 deletion(-)
99be8f
99be8f
diff --git a/man/man8/tc-tunnel_key.8 b/man/man8/tc-tunnel_key.8
99be8f
index 5e93c59d49465..0cd792a66d185 100644
99be8f
--- a/man/man8/tc-tunnel_key.8
99be8f
+++ b/man/man8/tc-tunnel_key.8
99be8f
@@ -18,6 +18,7 @@ tunnel_key - Tunnel metadata manipulation
99be8f
 .BI dst_port " UDP_PORT"
99be8f
 .BI tos " TOS"
99be8f
 .BI ttl " TTL"
99be8f
+.RB "[ " csum " | " nocsum " ]"
99be8f
 
99be8f
 .SH DESCRIPTION
99be8f
 The
99be8f
@@ -85,6 +86,23 @@ Outer header TOS
99be8f
 .TP
99be8f
 .B ttl
99be8f
 Outer header TTL
99be8f
+.TP
99be8f
+.RB [ no ] csum
99be8f
+Controlls outer UDP checksum. When set to
99be8f
+.B csum
99be8f
+(which is default), the outer UDP checksum is calculated and included in the
99be8f
+packets. When set to
99be8f
+.BR nocsum ,
99be8f
+outer UDP checksum is zero. Note that when using zero UDP checksums with
99be8f
+IPv6, the other tunnel endpoint must be configured to accept such packets.
99be8f
+In Linux, this would be the
99be8f
+.B udp6zerocsumrx
99be8f
+option for the VXLAN tunnel interface.
99be8f
+.IP
99be8f
+If using
99be8f
+.B nocsum
99be8f
+with IPv6, be sure you know what you are doing. Zero UDP checksums provide
99be8f
+weaker protection against corrupted packets. See RFC6935 for details.
99be8f
 .RE
99be8f
 .SH EXAMPLES
99be8f
 The following example encapsulates incoming ICMP packets on eth0 into a vxlan
99be8f
diff --git a/tc/m_tunnel_key.c b/tc/m_tunnel_key.c
99be8f
index cdde64a15b929..992adc51c28ab 100644
99be8f
--- a/tc/m_tunnel_key.c
99be8f
+++ b/tc/m_tunnel_key.c
99be8f
@@ -28,7 +28,8 @@ static void explain(void)
99be8f
 		"id <TUNNELID>\n"
99be8f
 		"src_ip <IP> (mandatory)\n"
99be8f
 		"dst_ip <IP> (mandatory)\n"
99be8f
-		"dst_port <UDP_PORT>\n");
99be8f
+		"dst_port <UDP_PORT>\n"
99be8f
+		"csum | nocsum (default is \"csum\")\n");
99be8f
 }
99be8f
 
99be8f
 static void usage(void)
99be8f
@@ -107,6 +108,7 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 	int ret;
99be8f
 	int has_src_ip = 0;
99be8f
 	int has_dst_ip = 0;
99be8f
+	int csum = 1;
99be8f
 
99be8f
 	if (matches(*argv, "tunnel_key") != 0)
99be8f
 		return -1;
99be8f
@@ -186,6 +188,10 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 				fprintf(stderr, "Illegal \"ttl\"\n");
99be8f
 				return -1;
99be8f
 			}
99be8f
+		} else if (matches(*argv, "csum") == 0) {
99be8f
+			csum = 1;
99be8f
+		} else if (matches(*argv, "nocsum") == 0) {
99be8f
+			csum = 0;
99be8f
 		} else if (matches(*argv, "help") == 0) {
99be8f
 			usage();
99be8f
 		} else {
99be8f
@@ -194,6 +200,8 @@ static int parse_tunnel_key(struct action_util *a, int *argc_p, char ***argv_p,
99be8f
 		NEXT_ARG_FWD();
99be8f
 	}
99be8f
 
99be8f
+	addattr8(n, MAX_MSG, TCA_TUNNEL_KEY_NO_CSUM, !csum);
99be8f
+
99be8f
 	parse_action_control_dflt(&argc, &argv, &parm.action,
99be8f
 				  false, TC_ACT_PIPE);
99be8f
 
99be8f
@@ -276,6 +284,15 @@ static void tunnel_key_print_tos_ttl(FILE *f, char *name,
99be8f
 	}
99be8f
 }
99be8f
 
99be8f
+static void tunnel_key_print_flag(FILE *f, const char *name_on,
99be8f
+				  const char *name_off,
99be8f
+				  struct rtattr *attr)
99be8f
+{
99be8f
+	if (!attr)
99be8f
+		return;
99be8f
+	fprintf(f, "\n\t%s", rta_getattr_u8(attr) ? name_on : name_off);
99be8f
+}
99be8f
+
99be8f
 static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
99be8f
 {
99be8f
 	struct rtattr *tb[TCA_TUNNEL_KEY_MAX + 1];
99be8f
@@ -312,6 +329,8 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
99be8f
 					tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
99be8f
 		tunnel_key_print_dst_port(f, "dst_port",
99be8f
 					  tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
99be8f
+		tunnel_key_print_flag(f, "nocsum", "csum",
99be8f
+				      tb[TCA_TUNNEL_KEY_NO_CSUM]);
99be8f
 		tunnel_key_print_tos_ttl(f, "tos",
99be8f
 					  tb[TCA_TUNNEL_KEY_ENC_TOS]);
99be8f
 		tunnel_key_print_tos_ttl(f, "ttl",
99be8f
-- 
99be8f
2.20.1
99be8f