Skip to contentSkip to conversation

Fix and enhance link_gre6

PATCH Applied Phil Sutter 2 participants 6 messages Sep 1, 2017

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

cover Fix and enhance link_gre6

Changing a tunnel's flowlabel value was broken if it was set to a non-zero value before. Since the same problem existed for tclass, patch 1 fixes both instances at once.

Patch 2 enhances 'ip link show' to also print the tclass value. This change was necessary to properly test the first patch's result.

Phil Sutter (2):
link_gre6: Fix for changing tclass/flowlabel
link_gre6: Print the tunnel's tclass setting

 ip/link_gre6.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.13.1
#1 lore raw

PATCH 1/2 link_gre6: Fix for changing tclass/flowlabel

When trying to change tclass or flowlabel of a GREv6 tunnel which has the respective value set already, the code accidentally bitwise OR'ed the old and the new value, leading to unexpected results. Fix this by clearing the relevant bits of flowinfo variable prior to assigning the new value.

Fixes af89576d7a8c4 ("iproute2: GRE over IPv6 tunnel support.")
---
 ip/link_gre6.c | 2 ++
 1 file changed, 2 insertions(+)
ip/link_gre6.c +2 -0
index 4d3d4b54210b9..447ac5d78ab7b 100644
@@ -288,6 +288,7 @@ get_failed:
 			else {
 				if (get_u8(&uval, *argv, 16))
 					invarg("invalid TClass", *argv);
+				flowinfo &= ~IP6_FLOWINFO_TCLASS;
 				flowinfo |= htonl((__u32)uval << 20) & IP6_FLOWINFO_TCLASS;
 				flags &= ~IP6_TNL_F_USE_ORIG_TCLASS;
 			}
@@ -303,6 +304,7 @@ get_failed:
 					invarg("invalid Flowlabel", *argv);
 				if (uval > 0xFFFFF)
 					invarg("invalid Flowlabel", *argv);
+				flowinfo &= ~IP6_FLOWINFO_FLOWLABEL;
 				flowinfo |= htonl(uval) & IP6_FLOWINFO_FLOWLABEL;
 				flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL;
 			}
Signature · 1 line
2.13.1
#2 lore raw

PATCH 2/2 link_gre6: Print the tunnel's tclass setting

In reply to Phil Sutter

Print the value analogous to flowlabel. While being at it, also break the overlong lines to not exceed 80 characters boundary.

---
 ip/link_gre6.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
ip/link_gre6.c +8 -1
index 447ac5d78ab7b..78b5215c65037 100644
@@ -462,7 +462,14 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	if (flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
 		fprintf(f, "flowlabel inherit ");
 	else
-		fprintf(f, "flowlabel 0x%05x ", ntohl(flowinfo & IP6_FLOWINFO_FLOWLABEL));
+		fprintf(f, "flowlabel 0x%05x ",
+			ntohl(flowinfo & IP6_FLOWINFO_FLOWLABEL));
+
+	if (flags & IP6_TNL_F_USE_ORIG_TCLASS)
+		fprintf(f, "tclass inherit ");
+	else
+		fprintf(f, "tclass 0x%02x ",
+			ntohl(flowinfo & IP6_FLOWINFO_TCLASS) >> 20);
 
 	if (flags & IP6_TNL_F_RCV_DSCP_COPY)
 		fprintf(f, "dscp inherit ");
Signature · 1 line
2.13.1
#3 lore raw
In reply to Phil Sutter
Quoted 7 lines · On Fri, 1 Sep 2017 16:08:07 +0200 Phil Sutter <[email protected]> wrote:

Changing a tunnel's flowlabel value was broken if it was set to a non-zero value before. Since the same problem existed for tclass, patch 1 fixes both instances at once.

Patch 2 enhances 'ip link show' to also print the tclass value. This change was necessary to properly test the first patch's result.

Quoted 7 lines

Phil Sutter (2):
link_gre6: Fix for changing tclass/flowlabel
link_gre6: Print the tunnel's tclass setting

 ip/link_gre6.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Applied, thanks.

#4 lore raw
In reply to Phil Sutter
Quoted 7 lines · On Fri, 1 Sep 2017 16:08:07 +0200 Phil Sutter <[email protected]> wrote:

Changing a tunnel's flowlabel value was broken if it was set to a non-zero value before. Since the same problem existed for tclass, patch 1 fixes both instances at once.

Patch 2 enhances 'ip link show' to also print the tclass value. This change was necessary to properly test the first patch's result.

Quoted 7 lines

Phil Sutter (2):
link_gre6: Fix for changing tclass/flowlabel
link_gre6: Print the tunnel's tclass setting

 ip/link_gre6.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

This doesn't work with net-next where json has been added. I fixing it now

#5 lore raw

Hi Stephen,

Quoted 14 lines · Stephen Hemminger
Quoted 11 lines · On Fri, 1 Sep 2017 16:08:07 +0200 Phil Sutter <[email protected]> wrote:

Changing a tunnel's flowlabel value was broken if it was set to a non-zero value before. Since the same problem existed for tclass, patch 1 fixes both instances at once.

Patch 2 enhances 'ip link show' to also print the tclass value. This change was necessary to properly test the first patch's result.

Phil Sutter (2):
link_gre6: Fix for changing tclass/flowlabel
link_gre6: Print the tunnel's tclass setting

Quoted 6 lines
Quoted 3 lines
 ip/link_gre6.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

This doesn't work with net-next where json has been added. I fixing it now

Oh, thanks for that. I'm not used to having different states in master and net-next. :)

Cheers, Phil