naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0168-geneve-add-support-to-set-flow-label.patch

049c96
From 20d649d4bb017d5c8280205db545a274b15ae21c 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 to set flow label
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1339178
049c96
Upstream Status: iproute2.git commit 29bb2373a8777
049c96
Conflicts:
049c96
 - Missing formatting cleanup changes.
049c96
 - Added missing LABEL_MAX_MASK define.
049c96
049c96
commit 29bb2373a8777d0c8b8c68450a872c19bc7f245c
049c96
Author: Daniel Borkmann <daniel@iogearbox.net>
049c96
Date:   Thu Mar 24 16:49:56 2016 +0100
049c96
049c96
    geneve: add support to set flow label
049c96
049c96
    Follow-up for kernel commit 8eb3b99554b8 ("geneve: support setting
049c96
    IPv6 flow label") to allow setting the label for the device config.
049c96
049c96
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
049c96
---
049c96
 ip/ip_common.h        |  4 ++++
049c96
 ip/iplink_geneve.c    | 29 ++++++++++++++++++++++++-----
049c96
 man/man8/ip-link.8.in |  6 ++++++
049c96
 3 files changed, 34 insertions(+), 5 deletions(-)
049c96
049c96
diff --git a/ip/ip_common.h b/ip/ip_common.h
049c96
index 917fcf8..880890e 100644
049c96
--- a/ip/ip_common.h
049c96
+++ b/ip/ip_common.h
049c96
@@ -90,3 +90,7 @@ struct link_util *get_link_slave_kind(const char *slave_kind);
049c96
 #ifndef	INFINITY_LIFE_TIME
049c96
 #define     INFINITY_LIFE_TIME      0xFFFFFFFFU
049c96
 #endif
049c96
+
049c96
+#ifndef LABEL_MAX_MASK
049c96
+#define     LABEL_MAX_MASK          0xFFFFFU
049c96
+#endif
049c96
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
049c96
index 13a6d80..fb0c6b1 100644
049c96
--- a/ip/iplink_geneve.c
049c96
+++ b/ip/iplink_geneve.c
049c96
@@ -18,14 +18,15 @@
049c96
 static void print_explain(FILE *f)
049c96
 {
049c96
 	fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
049c96
-	fprintf(f, "                 [ ttl TTL ] [ tos TOS ]\n");
049c96
+	fprintf(f, "                 [ ttl TTL ] [ tos TOS ] [ flowlabel LABEL ]\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
-	fprintf(f, "       TOS  := { NUMBER | inherit }\n");
049c96
-	fprintf(f, "       TTL  := { 1..255 | inherit }\n");
049c96
+	fprintf(f, "Where: VNI   := 0-16777215\n");
049c96
+	fprintf(f, "       ADDR  := IP_ADDRESS\n");
049c96
+	fprintf(f, "       TOS   := { NUMBER | inherit }\n");
049c96
+	fprintf(f, "       TTL   := { 1..255 | inherit }\n");
049c96
+	fprintf(f, "       LABEL := 0-1048575\n");
049c96
 }
049c96
 
049c96
 static void explain(void)
049c96
@@ -40,6 +41,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 	int vni_set = 0;
049c96
 	__u32 daddr = 0;
049c96
 	struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
049c96
+	__u32 label = 0;
049c96
 	__u8 ttl = 0;
049c96
 	__u8 tos = 0;
049c96
 	__u16 dstport = 0;
049c96
@@ -90,6 +92,15 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 				tos = uval;
049c96
 			} else
049c96
 				tos = 1;
049c96
+		} else if (!matches(*argv, "label") ||
049c96
+			   !matches(*argv, "flowlabel")) {
049c96
+			__u32 uval;
049c96
+
049c96
+			NEXT_ARG();
049c96
+			if (get_u32(&uval, *argv, 0) ||
049c96
+			    (uval & ~LABEL_MAX_MASK))
049c96
+				invarg("invalid flowlabel", *argv);
049c96
+			label = htonl(uval);
049c96
 		} else if (!matches(*argv, "dstport")) {
049c96
 			NEXT_ARG();
049c96
 			if (get_u16(&dstport, *argv, 0))
049c96
@@ -150,6 +161,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
 		addattr_l(n, 1024, IFLA_GENEVE_REMOTE, &daddr, 4);
049c96
 	if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0)
049c96
 		addattr_l(n, 1024, IFLA_GENEVE_REMOTE6, &daddr6, sizeof(struct in6_addr));
049c96
+	addattr32(n, 1024, IFLA_GENEVE_LABEL, label);
049c96
 	addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
049c96
 	addattr8(n, 1024, IFLA_GENEVE_TOS, tos);
049c96
 	if (dstport)
049c96
@@ -211,6 +223,13 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
049c96
 			fprintf(f, "tos %#x ", tos);
049c96
 	}
049c96
 
049c96
+	if (tb[IFLA_GENEVE_LABEL]) {
049c96
+		__u32 label = rta_getattr_u32(tb[IFLA_GENEVE_LABEL]);
049c96
+
049c96
+		if (label)
049c96
+			fprintf(f, "flowlabel %#x ", ntohl(label));
049c96
+	}
049c96
+
049c96
 	if (tb[IFLA_GENEVE_PORT])
049c96
 		fprintf(f, "dstport %u ",
049c96
 			ntohs(rta_getattr_u16(tb[IFLA_GENEVE_PORT])));
049c96
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
049c96
index 31a6190..3002e47 100644
049c96
--- a/man/man8/ip-link.8.in
049c96
+++ b/man/man8/ip-link.8.in
049c96
@@ -674,6 +674,8 @@ the following additional arguments are supported:
049c96
 .BI ttl " TTL "
049c96
 .R " ] [ "
049c96
 .BI tos " TOS "
049c96
+.R " ] [ "
049c96
+.BI flowlabel " FLOWLABEL "
049c96
 .R " ]"
049c96
 
049c96
 .in +8
049c96
@@ -693,6 +695,10 @@ the following additional arguments are supported:
049c96
 .BI tos " TOS"
049c96
 - specifies the TOS value to use in outgoing packets.
049c96
 
049c96
+.sp
049c96
+.BI flowlabel " FLOWLABEL"
049c96
+- specifies the flow label to use in outgoing packets.
049c96
+
049c96
 .in -8
049c96
 
049c96
 .TP
049c96
-- 
049c96
1.8.3.1
049c96