Skip to contentSkip to conversation

ip/geneve: add support for IFLA_GENEVE_INNER_PROTO_INHERIT

PATCH In review Eyal Birger 2 participants 2 messages Mar 19, 2022 – Mar 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip/geneve: add support for IFLA_GENEVE_INNER_PROTO_INHERIT

Add support for creating devices with this property. Since it cannot be changed, not adding a [no] option.

---
 include/uapi/linux/if_link.h |  1 +
 ip/iplink_geneve.c           | 13 +++++++++++++
 man/man8/ip-link.8.in        |  6 ++++++
 3 files changed, 20 insertions(+)
include/uapi/linux/if_link.h +1 -0
index 5f36ff8e..8d2f23d3 100644
@@ -840,6 +840,7 @@ enum {
 	IFLA_GENEVE_LABEL,
 	IFLA_GENEVE_TTL_INHERIT,
 	IFLA_GENEVE_DF,
+	IFLA_GENEVE_INNER_PROTO_INHERIT,
 	__IFLA_GENEVE_MAX
 };
 #define IFLA_GENEVE_MAX	(__IFLA_GENEVE_MAX - 1)
ip/iplink_geneve.c +13 -0
index 78fc818e..a0d3ed61 100644
@@ -31,6 +31,7 @@ static void print_explain(FILE *f)
 		"		[ [no]udpcsum ]\n"
 		"		[ [no]udp6zerocsumtx ]\n"
 		"		[ [no]udp6zerocsumrx ]\n"
+		"		[ innerprotoinherit ]\n"
 		"\n"
 		"Where:	VNI   := 0-16777215\n"
 		"	ADDR  := IP_ADDRESS\n"
@@ -72,6 +73,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 	__u64 attrs = 0;
 	bool set_op = (n->nlmsg_type == RTM_NEWLINK &&
 		       !(n->nlmsg_flags & NLM_F_CREATE));
+	bool inner_proto_inherit = false;
 
 	inet_prefix_reset(&daddr);
 
@@ -182,6 +184,10 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 			check_duparg(&attrs, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
 				     *argv, *argv);
 			udp6zerocsumrx = 0;
+		} else if (!matches(*argv, "innerprotoinherit")) {
+			check_duparg(&attrs, IFLA_GENEVE_INNER_PROTO_INHERIT,
+				     *argv, *argv);
+			inner_proto_inherit = true;
 		} else if (matches(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -231,6 +237,8 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 		addattr16(n, 1024, IFLA_GENEVE_PORT, htons(dstport));
 	if (metadata)
 		addattr(n, 1024, IFLA_GENEVE_COLLECT_METADATA);
+	if (inner_proto_inherit)
+		addattr(n, 1024, IFLA_GENEVE_INNER_PROTO_INHERIT);
 	if (GENEVE_ATTRSET(attrs, IFLA_GENEVE_UDP_CSUM))
 		addattr8(n, 1024, IFLA_GENEVE_UDP_CSUM, udpcsum);
 	if (GENEVE_ATTRSET(attrs, IFLA_GENEVE_UDP_ZERO_CSUM6_TX))
@@ -365,6 +373,11 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			fputs("udp6zerocsumrx ", f);
 		}
 	}
+
+	if (tb[IFLA_GENEVE_INNER_PROTO_INHERIT]) {
+		print_bool(PRINT_ANY, "inner_proto_inherit",
+			   "innerprotoinherit ", true);
+	}
 }
 
 static void geneve_print_help(struct link_util *lu, int argc, char **argv,
man/man8/ip-link.8.in +6 -0
index 93106d7f..5713a872 100644
@@ -1255,6 +1255,8 @@ the following additional arguments are supported:
 .RB [ no ] udp6zerocsumtx
 ] [
 .RB [ no ] udp6zerocsumrx
+] [
+.B innerprotoinherit
 ]
 
 .in +8
@@ -1318,6 +1320,10 @@ options.
 .RB [ no ] udp6zerocsumrx
 - allow incoming UDP packets over IPv6 with zero checksum field.
 
+.sp
+.B innerprotoinherit
+- use IPv4/IPv6 as inner protocol instead of Ethernet.
+
 .in -8
 
 .TP
Signature · 1 line
2.32.0
#1 lore raw

ip/iplink_geneve.c static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, · line 187

Quoted 5 lines · Eyal Birger
ip/iplink_geneve.c +1 -0
@@ -182,6 +184,10 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 			check_duparg(&attrs, IFLA_GENEVE_UDP_ZERO_CSUM6_RX,
 				     *argv, *argv);
 			udp6zerocsumrx = 0;
+		} else if (!matches(*argv, "innerprotoinherit")) {

changed matches to strcmp (not taking any more usage of matches) and applied to iproute2-next.