netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum.
@ 2016-03-19  0:51 Jesse Gross
  2016-03-19  0:51 ` [PATCH iproute2 2/2] geneve: Add support for configuring UDP checksums Jesse Gross
  2016-03-27 18:01 ` [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Jesse Gross @ 2016-03-19  0:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On recent kernels, UDP checksum computation has become more efficient and
the default behavior was changed, however, the ip command overrides this
by always specifying a particular behavior.

If the user does not specify that UDP checksums should either be computed
or not then we don't need to send an explicit netlink message - the kernel
can just use its default behavior.

Signed-off-by: Jesse Gross <jesse@kernel.org>
---
 ip/iplink_vxlan.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index ede8482..be5636f 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -68,8 +68,11 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	__u32 maxaddr = 0;
 	__u16 dstport = 0;
 	__u8 udpcsum = 0;
+	bool udpcsum_set = false;
 	__u8 udp6zerocsumtx = 0;
+	bool udp6zerocsumtx_set = false;
 	__u8 udp6zerocsumrx = 0;
+	bool udp6zerocsumrx_set = false;
 	__u8 remcsumtx = 0;
 	__u8 remcsumrx = 0;
 	__u8 metadata = 0;
@@ -193,16 +196,22 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			l3miss = 1;
 		} else if (!matches(*argv, "udpcsum")) {
 			udpcsum = 1;
+			udpcsum_set = true;
 		} else if (!matches(*argv, "noudpcsum")) {
 			udpcsum = 0;
+			udpcsum_set = true;
 		} else if (!matches(*argv, "udp6zerocsumtx")) {
 			udp6zerocsumtx = 1;
+			udp6zerocsumtx_set = true;
 		} else if (!matches(*argv, "noudp6zerocsumtx")) {
 			udp6zerocsumtx = 0;
+			udp6zerocsumtx_set = true;
 		} else if (!matches(*argv, "udp6zerocsumrx")) {
 			udp6zerocsumrx = 1;
+			udp6zerocsumrx_set = true;
 		} else if (!matches(*argv, "noudp6zerocsumrx")) {
 			udp6zerocsumrx = 0;
+			udp6zerocsumrx_set = true;
 		} else if (!matches(*argv, "remcsumtx")) {
 			remcsumtx = 1;
 		} else if (!matches(*argv, "noremcsumtx")) {
@@ -277,13 +286,16 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	addattr8(n, 1024, IFLA_VXLAN_RSC, rsc);
 	addattr8(n, 1024, IFLA_VXLAN_L2MISS, l2miss);
 	addattr8(n, 1024, IFLA_VXLAN_L3MISS, l3miss);
-	addattr8(n, 1024, IFLA_VXLAN_UDP_CSUM, udpcsum);
-	addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, udp6zerocsumtx);
-	addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, udp6zerocsumrx);
 	addattr8(n, 1024, IFLA_VXLAN_REMCSUM_TX, remcsumtx);
 	addattr8(n, 1024, IFLA_VXLAN_REMCSUM_RX, remcsumrx);
 	addattr8(n, 1024, IFLA_VXLAN_COLLECT_METADATA, metadata);
 
+	if (udpcsum_set)
+		addattr8(n, 1024, IFLA_VXLAN_UDP_CSUM, udpcsum);
+	if (udp6zerocsumtx_set)
+		addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, udp6zerocsumtx);
+	if (udp6zerocsumrx_set)
+		addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, udp6zerocsumrx);
 	if (noage)
 		addattr32(n, 1024, IFLA_VXLAN_AGEING, 0);
 	else if (age)
@@ -420,16 +432,23 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	    ((maxaddr = rta_getattr_u32(tb[IFLA_VXLAN_LIMIT])) != 0))
 		    fprintf(f, "maxaddr %u ", maxaddr);
 
-	if (tb[IFLA_VXLAN_UDP_CSUM] && rta_getattr_u8(tb[IFLA_VXLAN_UDP_CSUM]))
+	if (tb[IFLA_VXLAN_UDP_CSUM]) {
+		if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_CSUM]))
+			fputs("no", f);
 		fputs("udpcsum ", f);
+	}
 
-	if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX] &&
-	    rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]))
+	if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) {
+		if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]))
+			fputs("no", f);
 		fputs("udp6zerocsumtx ", f);
+	}
 
-	if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX] &&
-	    rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]))
+	if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) {
+		if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]))
+			fputs("no", f);
 		fputs("udp6zerocsumrx ", f);
+	}
 
 	if (tb[IFLA_VXLAN_REMCSUM_TX] &&
 	    rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_TX]))
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH iproute2 2/2] geneve: Add support for configuring UDP checksums.
  2016-03-19  0:51 [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Jesse Gross
@ 2016-03-19  0:51 ` Jesse Gross
  2016-03-27 18:01 ` [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Jesse Gross @ 2016-03-19  0:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

Enable support for configuring outer UDP checksums on Geneve tunnels:

ip link add type geneve id 10 remote 10.0.0.2 udpcsum

Signed-off-by: Jesse Gross <jesse@kernel.org>
---
 ip/iplink_geneve.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
index 30b16b9..13a6d80 100644
--- a/ip/iplink_geneve.c
+++ b/ip/iplink_geneve.c
@@ -20,6 +20,7 @@ static void print_explain(FILE *f)
 	fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
 	fprintf(f, "                 [ ttl TTL ] [ tos TOS ]\n");
 	fprintf(f, "                 [ dstport PORT ] [ [no]external ]\n");
+	fprintf(f, "                 [ [no]udpcsum ] [ [no]udp6zerocsumtx ] [ [no]udp6zerocsumrx ]\n");
 	fprintf(f, "\n");
 	fprintf(f, "Where: VNI  := 0-16777215\n");
 	fprintf(f, "       ADDR := IP_ADDRESS\n");
@@ -43,6 +44,12 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 	__u8 tos = 0;
 	__u16 dstport = 0;
 	bool metadata = 0;
+	__u8 udpcsum = 0;
+	bool udpcsum_set = false;
+	__u8 udp6zerocsumtx = 0;
+	bool udp6zerocsumtx_set = false;
+	__u8 udp6zerocsumrx = 0;
+	bool udp6zerocsumrx_set = false;
 
 	while (argc > 0) {
 		if (!matches(*argv, "id") ||
@@ -91,6 +98,24 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 			metadata = true;
 		} else if (!matches(*argv, "noexternal")) {
 			metadata = false;
+		} else if (!matches(*argv, "udpcsum")) {
+			udpcsum = 1;
+			udpcsum_set = true;
+		} else if (!matches(*argv, "noudpcsum")) {
+			udpcsum = 0;
+			udpcsum_set = true;
+		} else if (!matches(*argv, "udp6zerocsumtx")) {
+			udp6zerocsumtx = 1;
+			udp6zerocsumtx_set = true;
+		} else if (!matches(*argv, "noudp6zerocsumtx")) {
+			udp6zerocsumtx = 0;
+			udp6zerocsumtx_set = true;
+		} else if (!matches(*argv, "udp6zerocsumrx")) {
+			udp6zerocsumrx = 1;
+			udp6zerocsumrx_set = true;
+		} else if (!matches(*argv, "noudp6zerocsumrx")) {
+			udp6zerocsumrx = 0;
+			udp6zerocsumrx_set = true;
 		} else if (matches(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -131,6 +156,12 @@ 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 (udpcsum_set)
+		addattr8(n, 1024, IFLA_GENEVE_UDP_CSUM, udpcsum);
+	if (udp6zerocsumtx_set)
+		addattr8(n, 1024, IFLA_GENEVE_UDP_ZERO_CSUM6_TX, udp6zerocsumtx);
+	if (udp6zerocsumrx_set)
+		addattr8(n, 1024, IFLA_GENEVE_UDP_ZERO_CSUM6_RX, udp6zerocsumrx);
 
 	return 0;
 }
@@ -187,6 +218,23 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	if (tb[IFLA_GENEVE_COLLECT_METADATA])
 		fputs("external ", f);
 
+	if (tb[IFLA_GENEVE_UDP_CSUM]) {
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_CSUM]))
+			fputs("no", f);
+		fputs("udpcsum ", f);
+	}
+
+	if (tb[IFLA_GENEVE_UDP_ZERO_CSUM6_TX]) {
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_ZERO_CSUM6_TX]))
+			fputs("no", f);
+		fputs("udp6zerocsumtx ", f);
+	}
+
+	if (tb[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) {
+		if (!rta_getattr_u8(tb[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]))
+			fputs("no", f);
+		fputs("udp6zerocsumrx ", f);
+	}
 }
 
 static void geneve_print_help(struct link_util *lu, int argc, char **argv,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum.
  2016-03-19  0:51 [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Jesse Gross
  2016-03-19  0:51 ` [PATCH iproute2 2/2] geneve: Add support for configuring UDP checksums Jesse Gross
@ 2016-03-27 18:01 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2016-03-27 18:01 UTC (permalink / raw)
  To: Jesse Gross; +Cc: netdev

On Fri, 18 Mar 2016 17:51:08 -0700
Jesse Gross <jesse@kernel.org> wrote:

> On recent kernels, UDP checksum computation has become more efficient and
> the default behavior was changed, however, the ip command overrides this
> by always specifying a particular behavior.
> 
> If the user does not specify that UDP checksums should either be computed
> or not then we don't need to send an explicit netlink message - the kernel
> can just use its default behavior.
> 
> Signed-off-by: Jesse Gross <jesse@kernel.org>
> ---

Applied both, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-27 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-19  0:51 [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Jesse Gross
2016-03-19  0:51 ` [PATCH iproute2 2/2] geneve: Add support for configuring UDP checksums Jesse Gross
2016-03-27 18:01 ` [PATCH iproute2 1/2] vxlan: Follow kernel defaults for outer UDP checksum Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).