Received: by 10.213.65.68 with SMTP id h4csp70237imn; Wed, 21 Mar 2018 12:36:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELvW7f2g6UmabmEdJFWLsQ5Tu9A1voWgoWyRwyj8/wayfReYdBG01raM5k5Ixnv0IPM4nbE6 X-Received: by 2002:a17:902:7e09:: with SMTP id b9-v6mr21777579plm.223.1521661004268; Wed, 21 Mar 2018 12:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521661004; cv=none; d=google.com; s=arc-20160816; b=OvwFDfDIwuJ7IzOMMbvnKhM8rzVsXDV9um1aoFDCr5oZarZmTRAWlbWbiZ6O3Xy6Rl fXhSmSZw29moBTWtJjlodPWqfjYfqp0h5SpjZ34BsFktYI2pWH/gRQ9/Wvb4+4hkXSv8 dYGaUDDCL1FVbhMz54aqPzdRlM1KPaH+YLZfQExK6tGh78DDMaVgONwiM896zo4QCzJp 83uvs3V0DU53SjVActm6zZj7MNnkG15TVqIGIS2cZoZS4qC2ppdnyw6/MssY/1IaJwgL sSUwz4agUDrN9tP0AFJxg4ucF2NFs5ehaCnyKGYyfxKIO4hqwowCmN7UwY+/hKfC0rhp gIsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=+wzm/HdCcSUddY1fHDw7PZ0SeOdQfe1U2MQ4B+nuKnM=; b=zWIOt1TTd3G7EmcSKSh2jZ3C3XsEW7uXUapIPg6ZAN7Nqs3QzB4LCwNoIhR80kTw1P zLMc9G2mP/z75LKaXPzoa+ah8/W+5B92N7oiWoUy9Han1CdGHA+ph1/OCI4OfWXkgqEQ vmow7D8PhH3GnFUf9ddBOqytxz0uxW3FQHxmMZ2lxAEWbmfhVwoC4UbT+ZXosYea/bMu gELr7yW0Z7AP2tyclVqvSUV66Ca8+WT4iXAuGzfN6JDa8zHhNhtOBMCaChJv5/01I4Q7 Hq1kuy8iNb7xdTIOUsSOB1lCNr7mnIstLNp5/zhDpwcZNfYetE2L6nXlqztdnbiVmLs4 fZ6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 102-v6si4550168pla.230.2018.03.21.12.36.29; Wed, 21 Mar 2018 12:36:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbeCUTfL (ORCPT + 99 others); Wed, 21 Mar 2018 15:35:11 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:55004 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753172AbeCUTfJ (ORCPT ); Wed, 21 Mar 2018 15:35:09 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1eyjVj-0002wu-90; Wed, 21 Mar 2018 19:34:59 +0000 From: Colin King To: "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] gre: fix TUNNEL_SEQ bit check on sequence numbering Date: Wed, 21 Mar 2018 19:34:58 +0000 Message-Id: <20180321193458.4451-1-colin.king@canonical.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The current logic of flags | TUNNEL_SEQ is always non-zero and hence sequence numbers are always incremented no matter the setting of the TUNNEL_SEQ bit. Fix this by using & instead of |. Detected by CoverityScan, CID#1466039 ("Operands don't affect result") Fixes: 77a5196a804e ("gre: add sequence number for collect md mode.") Signed-off-by: Colin Ian King --- net/ipv4/ip_gre.c | 2 +- net/ipv6/ip6_gre.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 2fa2ef2e2af9..9ab1aa2f7660 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -550,7 +550,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev, (TUNNEL_CSUM | TUNNEL_KEY | TUNNEL_SEQ); gre_build_header(skb, tunnel_hlen, flags, proto, tunnel_id_to_key32(tun_info->key.tun_id), - (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0); + (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0); df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 0bcefc480aeb..3a98c694da5f 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -725,7 +725,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb, gre_build_header(skb, tunnel->tun_hlen, flags, protocol, tunnel_id_to_key32(tun_info->key.tun_id), - (flags | TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) + (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0); } else { -- 2.15.1