naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0167-geneve-Add-support-for-configuring-UDP-checksums.patch

049c96
From 95f2a6b5b5d0065cd08cf23bb0ad6dda510454cf Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Sat, 2 Jul 2016 12:46:04 +0200
049c96
Subject: [PATCH] geneve: Add support for configuring UDP checksums.
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1339178
049c96
Upstream Status: iproute2.git commit 325d02b44ce31
049c96
049c96
commit 325d02b44ce3194a6d7a57e6a46b5ed767b61025
049c96
Author: Jesse Gross <jesse@kernel.org>
049c96
Date:   Fri Mar 18 17:51:09 2016 -0700
049c96
049c96
    geneve: Add support for configuring UDP checksums.
049c96
049c96
    Enable support for configuring outer UDP checksums on Geneve tunnels:
049c96
049c96
    ip link add type geneve id 10 remote 10.0.0.2 udpcsum
049c96
049c96
    Signed-off-by: Jesse Gross <jesse@kernel.org>
049c96
---
049c96
 ip/iplink_geneve.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
049c96
 1 file changed, 48 insertions(+)
049c96
049c96
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
049c96
index 30b16b9..13a6d80 100644
049c96
--- a/ip/iplink_geneve.c
049c96
+++ b/ip/iplink_geneve.c
049c96
@@ -20,6 +20,7 @@ static void print_explain(FILE *f)
049c96
 	fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
049c96
 	fprintf(f, "                 [ ttl TTL ] [ tos TOS ]\n");
049c96
 	fprintf(f, "                 [ dstport PORT ] [ [no]external ]\n");
049c96
+	fprintf(f, "                 [ [no]udpcsum ] [ [no]udp6zerocsumtx ] [ [no]udp6zerocsumrx ]\n");
049c96
 	fprintf(f, "\n");
049c96
 	fprintf(f, "Where: VNI  := 0-16777215\n");
049c96
 	fprintf(f, "       ADDR := IP_ADDRESS\n");
049c96
@@ -43,6 +44,12 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 	__u8 tos = 0;
049c96
 	__u16 dstport = 0;
049c96
 	bool metadata = 0;
049c96
+	__u8 udpcsum = 0;
049c96
+	bool udpcsum_set = false;
049c96
+	__u8 udp6zerocsumtx = 0;
049c96
+	bool udp6zerocsumtx_set = false;
049c96
+	__u8 udp6zerocsumrx = 0;
049c96
+	bool udp6zerocsumrx_set = false;
049c96
 
049c96
 	while (argc > 0) {
049c96
 		if (!matches(*argv, "id") ||
049c96
@@ -91,6 +98,24 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 			metadata = true;
049c96
 		} else if (!matches(*argv, "noexternal")) {
049c96
 			metadata = false;
049c96
+		} else if (!matches(*argv, "udpcsum")) {
049c96
+			udpcsum = 1;
049c96
+			udpcsum_set = true;
049c96
+		} else if (!matches(*argv, "noudpcsum")) {
049c96
+			udpcsum = 0;
049c96
+			udpcsum_set = true;
049c96
+		} else if (!matches(*argv, "udp6zerocsumtx")) {
049c96
+			udp6zerocsumtx = 1;
049c96
+			udp6zerocsumtx_set = true;
049c96
+		} else if (!matches(*argv, "noudp6zerocsumtx")) {
049c96
+			udp6zerocsumtx = 0;
049c96
+			udp6zerocsumtx_set = true;
049c96
+		} else if (!matches(*argv, "udp6zerocsumrx")) {
049c96
+			udp6zerocsumrx = 1;
049c96
+			udp6zerocsumrx_set = true;
049c96
+		} else if (!matches(*argv, "noudp6zerocsumrx")) {
049c96
+			udp6zerocsumrx = 0;
049c96
+			udp6zerocsumrx_set = true;
049c96
 		} else if (matches(*argv, "help") == 0) {
049c96
 			explain();
049c96
 			return -1;
049c96
@@ -131,6 +156,12 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 		addattr16(n, 1024, IFLA_GENEVE_PORT, htons(dstport));
049c96
 	if (metadata)
049c96
 		addattr(n, 1024, IFLA_GENEVE_COLLECT_METADATA);
049c96
+	if (udpcsum_set)
049c96
+		addattr8(n, 1024, IFLA_GENEVE_UDP_CSUM, udpcsum);
049c96
+	if (udp6zerocsumtx_set)
049c96
+		addattr8(n, 1024, IFLA_GENEVE_UDP_ZERO_CSUM6_TX, udp6zerocsumtx);
049c96
+	if (udp6zerocsumrx_set)
049c96
+		addattr8(n, 1024, IFLA_GENEVE_UDP_ZERO_CSUM6_RX, udp6zerocsumrx);
049c96
 
049c96
 	return 0;
049c96
 }
049c96
@@ -187,6 +218,23 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
049c96
 	if (tb[IFLA_GENEVE_COLLECT_METADATA])
049c96
 		fputs("external ", f);
049c96
 
049c96
+	if (tb[IFLA_GENEVE_UDP_CSUM]) {
049c96
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_CSUM]))
049c96
+			fputs("no", f);
049c96
+		fputs("udpcsum ", f);
049c96
+	}
049c96
+
049c96
+	if (tb[IFLA_GENEVE_UDP_ZERO_CSUM6_TX]) {
049c96
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_ZERO_CSUM6_TX]))
049c96
+			fputs("no", f);
049c96
+		fputs("udp6zerocsumtx ", f);
049c96
+	}
049c96
+
049c96
+	if (tb[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) {
049c96
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]))
049c96
+			fputs("no", f);
049c96
+		fputs("udp6zerocsumrx ", f);
049c96
+	}
049c96
 }
049c96
 
049c96
 static void geneve_print_help(struct link_util *lu, int argc, char **argv,
049c96
-- 
049c96
1.8.3.1
049c96