From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2 2/3] gre6/tunnel: Do not submit garbage in flowinfo Date: Wed, 27 Dec 2017 13:28:15 +0200 Message-ID: <1514374096-1473-3-git-send-email-serhe.popovych@gmail.com> References: <1514374096-1473-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f67.google.com ([209.85.215.67]:42731 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbdL0L3C (ORCPT ); Wed, 27 Dec 2017 06:29:02 -0500 Received: by mail-lf0-f67.google.com with SMTP id e27so7231459lfb.9 for ; Wed, 27 Dec 2017 03:29:01 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id a7sm4313593lfh.10.2017.12.27.03.28.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Dec 2017 03:28:59 -0800 (PST) In-Reply-To: <1514374096-1473-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- ip/link_gre6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ip/link_gre6.c b/ip/link_gre6.c index a3e8e08..7ae4b49 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; } -- 1.7.10.4