Blame SOURCES/0130-gre-gre6-allow-clearing-i-o-key-seq-csum-flags.patch

36cfb7
From 24eec64aa52b65b606d8cc0b03619f3974f12484 Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Wed, 5 Jun 2019 13:08:41 +0200
36cfb7
Subject: [PATCH] gre/gre6: allow clearing {,i,o}{key,seq,csum} flags
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714660
36cfb7
Upstream Status: iproute2.git commit 7f520601f59ee
36cfb7
Conflicts: context change on ip/link_gre?.c due to missing commit
36cfb7
           ae91205c4d2a7 ("gre/gre6: Unify gre_print_help()")
36cfb7
36cfb7
commit 7f520601f59ee35da2fc48b3f1b39ed2b80c9efa
36cfb7
Author: Sabrina Dubroca <sd@queasysnail.net>
36cfb7
Date:   Fri Apr 20 10:32:00 2018 +0200
36cfb7
36cfb7
    gre/gre6: allow clearing {,i,o}{key,seq,csum} flags
36cfb7
36cfb7
    Currently, iproute allows setting those flags, but it's impossible to
36cfb7
    clear them, since their current value is fetched from the kernel and
36cfb7
    then we OR in the additional flags passed on the command line.
36cfb7
36cfb7
    Add no* variants to allow clearing them.
36cfb7
36cfb7
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
36cfb7
    Signed-off-by: David Ahern <dsahern@gmail.com>
36cfb7
---
36cfb7
 ip/link_gre.c         | 30 +++++++++++++++++++++++++++---
36cfb7
 ip/link_gre6.c        | 30 +++++++++++++++++++++++++++---
36cfb7
 man/man8/ip-link.8.in | 27 ++++++++++++++++++---------
36cfb7
 3 files changed, 72 insertions(+), 15 deletions(-)
36cfb7
36cfb7
diff --git a/ip/link_gre.c b/ip/link_gre.c
36cfb7
index 1376d2e3af7de..41e2edbedb6eb 100644
36cfb7
--- a/ip/link_gre.c
36cfb7
+++ b/ip/link_gre.c
36cfb7
@@ -28,9 +28,9 @@ static void print_usage(FILE *f)
36cfb7
 	fprintf(f,
36cfb7
 		"Usage: ... { gre | gretap } [ remote ADDR ]\n"
36cfb7
 		"                            [ local ADDR ]\n"
36cfb7
-		"                            [ [i|o]seq ]\n"
36cfb7
-		"                            [ [i|o]key KEY ]\n"
36cfb7
-		"                            [ [i|o]csum ]\n"
36cfb7
+		"                            [ [no][i|o]seq ]\n"
36cfb7
+		"                            [ [i|o]key KEY | no[i|o]key ]\n"
36cfb7
+		"                            [ [no][i|o]csum ]\n"
36cfb7
 		"                            [ ttl TTL ]\n"
36cfb7
 		"                            [ tos TOS ]\n"
36cfb7
 		"                            [ [no]pmtudisc ]\n"
36cfb7
@@ -171,28 +171,52 @@ get_failed:
36cfb7
 			iflags |= GRE_KEY;
36cfb7
 			oflags |= GRE_KEY;
36cfb7
 			ikey = okey = tnl_parse_key("key", *argv);
36cfb7
+		} else if (!matches(*argv, "nokey")) {
36cfb7
+			iflags &= ~GRE_KEY;
36cfb7
+			oflags &= ~GRE_KEY;
36cfb7
+			ikey = okey = 0;
36cfb7
 		} else if (!matches(*argv, "ikey")) {
36cfb7
 			NEXT_ARG();
36cfb7
 			iflags |= GRE_KEY;
36cfb7
 			ikey = tnl_parse_key("ikey", *argv);
36cfb7
+		} else if (!matches(*argv, "noikey")) {
36cfb7
+			iflags &= ~GRE_KEY;
36cfb7
+			ikey = 0;
36cfb7
 		} else if (!matches(*argv, "okey")) {
36cfb7
 			NEXT_ARG();
36cfb7
 			oflags |= GRE_KEY;
36cfb7
 			okey = tnl_parse_key("okey", *argv);
36cfb7
+		} else if (!matches(*argv, "nookey")) {
36cfb7
+			oflags &= ~GRE_KEY;
36cfb7
+			okey = 0;
36cfb7
 		} else if (!matches(*argv, "seq")) {
36cfb7
 			iflags |= GRE_SEQ;
36cfb7
 			oflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "noseq")) {
36cfb7
+			iflags &= ~GRE_SEQ;
36cfb7
+			oflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "iseq")) {
36cfb7
 			iflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "noiseq")) {
36cfb7
+			iflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "oseq")) {
36cfb7
 			oflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "nooseq")) {
36cfb7
+			oflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "csum")) {
36cfb7
 			iflags |= GRE_CSUM;
36cfb7
 			oflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "nocsum")) {
36cfb7
+			iflags &= ~GRE_CSUM;
36cfb7
+			oflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "icsum")) {
36cfb7
 			iflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "noicsum")) {
36cfb7
+			iflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "ocsum")) {
36cfb7
 			oflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "noocsum")) {
36cfb7
+			oflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "nopmtudisc")) {
36cfb7
 			pmtudisc = 0;
36cfb7
 		} else if (!matches(*argv, "pmtudisc")) {
36cfb7
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
36cfb7
index 22e6e44aae29b..127e51de4ab73 100644
36cfb7
--- a/ip/link_gre6.c
36cfb7
+++ b/ip/link_gre6.c
36cfb7
@@ -35,9 +35,9 @@ static void print_usage(FILE *f)
36cfb7
 	fprintf(f,
36cfb7
 		"Usage: ... { ip6gre | ip6gretap } [ remote ADDR ]\n"
36cfb7
 		"                                  [ local ADDR ]\n"
36cfb7
-		"                                  [ [i|o]seq ]\n"
36cfb7
-		"                                  [ [i|o]key KEY ]\n"
36cfb7
-		"                                  [ [i|o]csum ]\n"
36cfb7
+		"                                  [ [no][i|o]seq ]\n"
36cfb7
+		"                                  [ [i|o]key KEY | no[i|o]key ]\n"
36cfb7
+		"                                  [ [no][i|o]csum ]\n"
36cfb7
 		"                                  [ hoplimit TTL ]\n"
36cfb7
 		"                                  [ encaplimit ELIM ]\n"
36cfb7
 		"                                  [ tclass TCLASS ]\n"
36cfb7
@@ -185,28 +185,52 @@ get_failed:
36cfb7
 			iflags |= GRE_KEY;
36cfb7
 			oflags |= GRE_KEY;
36cfb7
 			ikey = okey = tnl_parse_key("key", *argv);
36cfb7
+		} else if (!matches(*argv, "nokey")) {
36cfb7
+			iflags &= ~GRE_KEY;
36cfb7
+			oflags &= ~GRE_KEY;
36cfb7
+			ikey = okey = 0;
36cfb7
 		} else if (!matches(*argv, "ikey")) {
36cfb7
 			NEXT_ARG();
36cfb7
 			iflags |= GRE_KEY;
36cfb7
 			ikey = tnl_parse_key("ikey", *argv);
36cfb7
+		} else if (!matches(*argv, "noikey")) {
36cfb7
+			iflags &= ~GRE_KEY;
36cfb7
+			ikey = 0;
36cfb7
 		} else if (!matches(*argv, "okey")) {
36cfb7
 			NEXT_ARG();
36cfb7
 			oflags |= GRE_KEY;
36cfb7
 			okey = tnl_parse_key("okey", *argv);
36cfb7
+		} else if (!matches(*argv, "nookey")) {
36cfb7
+			oflags &= ~GRE_KEY;
36cfb7
+			okey = 0;
36cfb7
 		} else if (!matches(*argv, "seq")) {
36cfb7
 			iflags |= GRE_SEQ;
36cfb7
 			oflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "noseq")) {
36cfb7
+			iflags &= ~GRE_SEQ;
36cfb7
+			oflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "iseq")) {
36cfb7
 			iflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "noiseq")) {
36cfb7
+			iflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "oseq")) {
36cfb7
 			oflags |= GRE_SEQ;
36cfb7
+		} else if (!matches(*argv, "nooseq")) {
36cfb7
+			oflags &= ~GRE_SEQ;
36cfb7
 		} else if (!matches(*argv, "csum")) {
36cfb7
 			iflags |= GRE_CSUM;
36cfb7
 			oflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "nocsum")) {
36cfb7
+			iflags &= ~GRE_CSUM;
36cfb7
+			oflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "icsum")) {
36cfb7
 			iflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "noicsum")) {
36cfb7
+			iflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "ocsum")) {
36cfb7
 			oflags |= GRE_CSUM;
36cfb7
+		} else if (!matches(*argv, "noocsum")) {
36cfb7
+			oflags &= ~GRE_CSUM;
36cfb7
 		} else if (!matches(*argv, "remote")) {
36cfb7
 			inet_prefix addr;
36cfb7
 
36cfb7
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
36cfb7
index cfea1bdfdc030..8be5d5e1e9fd6 100644
36cfb7
--- a/man/man8/ip-link.8.in
36cfb7
+++ b/man/man8/ip-link.8.in
36cfb7
@@ -708,12 +708,14 @@ the following additional arguments are supported:
36cfb7
 .BR type " { " gre " | " gretap " }"
36cfb7
 .BI " remote " ADDR " local " ADDR
36cfb7
 [
36cfb7
-.RB [ i | o ] seq
36cfb7
+.RB [ no ] "" [ i | o ] seq
36cfb7
 ] [
36cfb7
 .RB [ i | o ] key
36cfb7
 .I KEY
36cfb7
+|
36cfb7
+.BR no [ i | o ] key
36cfb7
 ] [
36cfb7
-.RB [ i | o ] csum
36cfb7
+.RB [ no ] "" [ i | o ] csum
36cfb7
 ] [
36cfb7
 .BI ttl " TTL "
36cfb7
 ] [
36cfb7
@@ -749,7 +751,7 @@ the following additional arguments are supported:
36cfb7
 It must be an address on another interface on this host.
36cfb7
 
36cfb7
 .sp
36cfb7
-.RB [ i | o ] seq
36cfb7
+.RB  [ no ] "" [ i | o ] seq
36cfb7
 - serialize packets.
36cfb7
 The
36cfb7
 .B oseq
36cfb7
@@ -761,6 +763,8 @@ flag requires that all input packets are serialized.
36cfb7
 .sp
36cfb7
 .RB [ i | o ] key
36cfb7
 .I KEY
36cfb7
+|
36cfb7
+.BR no [ i | o ] key
36cfb7
 - use keyed GRE with key
36cfb7
 .IR KEY ". "KEY
36cfb7
 is either a number or an IPv4 address-like dotted quad.
36cfb7
@@ -772,7 +776,7 @@ The
36cfb7
 parameters specify different keys for input and output.
36cfb7
 
36cfb7
 .sp
36cfb7
-.RB  [ i | o ] csum
36cfb7
+.RB  [ no ] "" [ i | o ] csum
36cfb7
 - generate/require checksums for tunneled packets.
36cfb7
 The
36cfb7
 .B ocsum
36cfb7
@@ -853,12 +857,14 @@ the following additional arguments are supported:
36cfb7
 .BR type " { " ip6gre " | " ip6gretap " }"
36cfb7
 .BI remote " ADDR " local " ADDR"
36cfb7
 [
36cfb7
-.RB [ i | o ] seq
36cfb7
+.RB [ no ] "" [ i | o ] seq
36cfb7
 ] [
36cfb7
 .RB [ i | o ] key
36cfb7
 .I KEY
36cfb7
+|
36cfb7
+.BR no [ i | o ] key
36cfb7
 ] [
36cfb7
-.RB [ i | o ] csum
36cfb7
+.RB [ no ] "" [ i | o ] csum
36cfb7
 ] [
36cfb7
 .BI hoplimit " TTL "
36cfb7
 ] [
36cfb7
@@ -884,7 +890,7 @@ the following additional arguments are supported:
36cfb7
 It must be an address on another interface on this host.
36cfb7
 
36cfb7
 .sp
36cfb7
-.RB  [ i | o ] seq
36cfb7
+.RB  [ no ] "" [ i | o ] seq
36cfb7
 - serialize packets.
36cfb7
 The
36cfb7
 .B oseq
36cfb7
@@ -894,7 +900,10 @@ The
36cfb7
 flag requires that all input packets are serialized.
36cfb7
 
36cfb7
 .sp
36cfb7
-.RB  [ i | o ] key " \fIKEY"
36cfb7
+.RB [ i | o ] key
36cfb7
+.I KEY
36cfb7
+|
36cfb7
+.BR no [ i | o ] key
36cfb7
 - use keyed GRE with key
36cfb7
 .IR KEY ". "KEY
36cfb7
 is either a number or an IPv4 address-like dotted quad.
36cfb7
@@ -906,7 +915,7 @@ The
36cfb7
 parameters specify different keys for input and output.
36cfb7
 
36cfb7
 .sp
36cfb7
-.RB  [ i | o ] csum
36cfb7
+.RB  [ no ] "" [ i | o ] csum
36cfb7
 - generate/require checksums for tunneled packets.
36cfb7
 The
36cfb7
 .B ocsum
36cfb7
-- 
e138d9
2.21.0
36cfb7