naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0161-iproute2-GENEVE-support.patch

049c96
From 66373cc86a92570198bc282fde92782d8a256966 Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Sat, 2 Jul 2016 12:42:24 +0200
049c96
Subject: [PATCH] iproute2: GENEVE support
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1339178
049c96
Upstream Status: iproute2.git commit 908755dc49df0
049c96
Conflicts:
049c96
 - Context changes due to missing interface type support for hsr, fou
049c96
   and ipvlan.
049c96
 - Added missing IFLA_GENEVE_* defines.
049c96
049c96
commit 908755dc49df0beffd12c8cad91e425e5be76888
049c96
Author: John W. Linville <linville@tuxdriver.com>
049c96
Date:   Fri May 8 13:27:08 2015 -0400
049c96
049c96
    iproute2: GENEVE support
049c96
049c96
    Signed-off-by: John W. Linville <linville@tuxdriver.com>
049c96
---
049c96
 include/linux/if_link.h |   5 ++
049c96
 ip/Makefile             |   3 +-
049c96
 ip/iplink.c             |   2 +-
049c96
 ip/iplink_geneve.c      | 122 ++++++++++++++++++++++++++++++++++++++++++++++++
049c96
 4 files changed, 130 insertions(+), 2 deletions(-)
049c96
 create mode 100644 ip/iplink_geneve.c
049c96
049c96
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
049c96
index ca9a681..73b5556 100644
049c96
--- a/include/linux/if_link.h
049c96
+++ b/include/linux/if_link.h
049c96
@@ -410,6 +410,11 @@ enum {
049c96
 	IFLA_GENEVE_TOS,
049c96
 	IFLA_GENEVE_PORT,	/* destination port */
049c96
 	IFLA_GENEVE_COLLECT_METADATA,
049c96
+	IFLA_GENEVE_REMOTE6,
049c96
+	IFLA_GENEVE_UDP_CSUM,
049c96
+	IFLA_GENEVE_UDP_ZERO_CSUM6_TX,
049c96
+	IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
049c96
+	IFLA_GENEVE_LABEL,
049c96
 	__IFLA_GENEVE_MAX
049c96
 };
049c96
 #define IFLA_GENEVE_MAX	(__IFLA_GENEVE_MAX - 1)
049c96
diff --git a/ip/Makefile b/ip/Makefile
049c96
index e4f0507..5aad224 100644
049c96
--- a/ip/Makefile
049c96
+++ b/ip/Makefile
049c96
@@ -6,7 +6,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
049c96
     iplink_macvlan.o ipl2tp.o link_vti.o link_vti6.o \
049c96
     iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
049c96
     link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o \
049c96
-    iplink_bridge.o iplink_bridge_slave.o
049c96
+    iplink_bridge.o iplink_bridge_slave.o \
049c96
+    iplink_geneve.o
049c96
 
049c96
 RTMONOBJ=rtmon.o
049c96
 
049c96
diff --git a/ip/iplink.c b/ip/iplink.c
049c96
index 84bdc56..0e2390d 100644
049c96
--- a/ip/iplink.c
049c96
+++ b/ip/iplink.c
049c96
@@ -93,7 +93,7 @@ void iplink_usage(void)
049c96
 		fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
049c96
 		fprintf(stderr, "          bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan |\n");
049c96
 		fprintf(stderr, "          gre | gretap | ip6gre | ip6gretap | vti | nlmon |\n");
049c96
-		fprintf(stderr, "          bond_slave }\n");
049c96
+		fprintf(stderr, "          bond_slave | geneve }\n");
049c96
 	}
049c96
 	exit(-1);
049c96
 }
049c96
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
049c96
new file mode 100644
049c96
index 0000000..74703e1
049c96
--- /dev/null
049c96
+++ b/ip/iplink_geneve.c
049c96
@@ -0,0 +1,122 @@
049c96
+/*
049c96
+ * iplink_geneve.c	GENEVE device support
049c96
+ *
049c96
+ *              This program is free software; you can redistribute it and/or
049c96
+ *              modify it under the terms of the GNU General Public License
049c96
+ *              as published by the Free Software Foundation; either version
049c96
+ *              2 of the License, or (at your option) any later version.
049c96
+ *
049c96
+ * Authors:     John W. Linville <linville@tuxdriver.com>
049c96
+ */
049c96
+
049c96
+#include <stdio.h>
049c96
+
049c96
+#include "utils.h"
049c96
+#include "ip_common.h"
049c96
+
049c96
+static void print_explain(FILE *f)
049c96
+{
049c96
+	fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
049c96
+	fprintf(f, "\n");
049c96
+	fprintf(f, "Where: VNI  := 0-16777215\n");
049c96
+	fprintf(f, "       ADDR := IP_ADDRESS\n");
049c96
+}
049c96
+
049c96
+static void explain(void)
049c96
+{
049c96
+	print_explain(stderr);
049c96
+}
049c96
+
049c96
+static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
049c96
+			  struct nlmsghdr *n)
049c96
+{
049c96
+	__u32 vni = 0;
049c96
+	int vni_set = 0;
049c96
+	__u32 daddr = 0;
049c96
+	struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
049c96
+
049c96
+
049c96
+	while (argc > 0) {
049c96
+		if (!matches(*argv, "id") ||
049c96
+		    !matches(*argv, "vni")) {
049c96
+			NEXT_ARG();
049c96
+			if (get_u32(&vni, *argv, 0) ||
049c96
+			    vni >= 1u << 24)
049c96
+				invarg("invalid id", *argv);
049c96
+			vni_set = 1;
049c96
+		} else if (!matches(*argv, "remote")) {
049c96
+			NEXT_ARG();
049c96
+			if (!inet_get_addr(*argv, &daddr, &daddr6)) {
049c96
+				fprintf(stderr, "Invalid address \"%s\"\n", *argv);
049c96
+				return -1;
049c96
+			}
049c96
+			if (IN_MULTICAST(ntohl(daddr)))
049c96
+				invarg("invalid remote address", *argv);
049c96
+		} else if (matches(*argv, "help") == 0) {
049c96
+			explain();
049c96
+			return -1;
049c96
+		} else {
049c96
+			fprintf(stderr, "geneve: unknown command \"%s\"?\n", *argv);
049c96
+			explain();
049c96
+			return -1;
049c96
+		}
049c96
+		argc--, argv++;
049c96
+	}
049c96
+
049c96
+	if (!vni_set) {
049c96
+		fprintf(stderr, "geneve: missing virtual network identifier\n");
049c96
+		return -1;
049c96
+	}
049c96
+
049c96
+	if (!daddr) {
049c96
+		fprintf(stderr, "geneve: remove link partner not specified\n");
049c96
+		return -1;
049c96
+	}
049c96
+	if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0) {
049c96
+		fprintf(stderr, "geneve: remove link over IPv6 not supported\n");
049c96
+		return -1;
049c96
+	}
049c96
+
049c96
+	addattr32(n, 1024, IFLA_GENEVE_ID, vni);
049c96
+	if (daddr)
049c96
+		addattr_l(n, 1024, IFLA_GENEVE_REMOTE, &daddr, 4);
049c96
+
049c96
+	return 0;
049c96
+}
049c96
+
049c96
+static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
049c96
+{
049c96
+	__u32 vni;
049c96
+	char s1[1024];
049c96
+
049c96
+	if (!tb)
049c96
+		return;
049c96
+
049c96
+	if (!tb[IFLA_GENEVE_ID] ||
049c96
+	    RTA_PAYLOAD(tb[IFLA_GENEVE_ID]) < sizeof(__u32))
049c96
+		return;
049c96
+
049c96
+	vni = rta_getattr_u32(tb[IFLA_GENEVE_ID]);
049c96
+	fprintf(f, "id %u ", vni);
049c96
+
049c96
+	if (tb[IFLA_GENEVE_REMOTE]) {
049c96
+		__be32 addr = rta_getattr_u32(tb[IFLA_GENEVE_REMOTE]);
049c96
+		if (addr)
049c96
+			fprintf(f, "remote %s ",
049c96
+				format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
049c96
+	}
049c96
+}
049c96
+
049c96
+static void geneve_print_help(struct link_util *lu, int argc, char **argv,
049c96
+	FILE *f)
049c96
+{
049c96
+	print_explain(f);
049c96
+}
049c96
+
049c96
+struct link_util geneve_link_util = {
049c96
+	.id		= "geneve",
049c96
+	.maxattr	= IFLA_GENEVE_MAX,
049c96
+	.parse_opt	= geneve_parse_opt,
049c96
+	.print_opt	= geneve_print_opt,
049c96
+	.print_help	= geneve_print_help,
049c96
+};
049c96
-- 
049c96
1.8.3.1
049c96