From: Serhey Popovych Date: Wed, 27 Dec 2017 11:28:15 +0000 (+0200) Subject: gre6/tunnel: Do not submit garbage in flowinfo X-Git-Tag: v4.15.0~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afdf9277eb216c923e2ed729d045c07b99be2a3c;p=thirdparty%2Fiproute2.git gre6/tunnel: Do not submit garbage in flowinfo We always send flowinfo to the kernel. If flowlabel/tclass was set first to non-inherit value and then reset to inherit we do not clear flowlabel/tclass part in flowinfo, send it to kernel and can get from the kernel back. Even if we check for IP6_TNL_F_USE_ORIG_TCLASS and IP6_TNL_F_USE_ORIG_FLOWLABEL when printing options sending invalid flowlabel/tclass to the kernel seems bad idea. Note that ip6tnl always clean corresponding flowinfo parts on inherit. Signed-off-by: Serhey Popovych --- diff --git a/ip/link_gre6.c b/ip/link_gre6.c index a3e8e0883..7ae4b4924 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -251,12 +251,12 @@ get_failed: __u8 uval; NEXT_ARG(); + flowinfo &= ~IP6_FLOWINFO_TCLASS; if (strcmp(*argv, "inherit") == 0) flags |= IP6_TNL_F_USE_ORIG_TCLASS; 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; } @@ -265,6 +265,7 @@ get_failed: __u32 uval; NEXT_ARG(); + flowinfo &= ~IP6_FLOWINFO_FLOWLABEL; if (strcmp(*argv, "inherit") == 0) flags |= IP6_TNL_F_USE_ORIG_FLOWLABEL; else { @@ -272,7 +273,6 @@ 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; }