From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 797FC22D9F6; Mon, 5 May 2025 23:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746486320; cv=none; b=aoMc6IzOCVVRs6kW2KJt+PQEJ5wtwcojJE5gaqERI8so2nZUVWzysEsnda4f4F3LfF/EwqkTQEy/xw3aJkgGl+UKFXaskPuMVK14X73l8A8z4EtoBCrcxnnfWEd+wv/mIJC5erxeiPEEeadHcAqdK/H6LUbPK09hZJaFNAORKI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746486320; c=relaxed/simple; bh=PNW4NJRyX1DA1CvPLs9JmMFNEY3teA+yGpOr5xxteFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=pn9OIh3NKxFj0kZOZWeXvU5UBILviby15a+zktePK7+1Llvg7QuoOxoeadUgbj/hG9TETOSvp0NKeEa9WXalJdP0gEYkhRlL/sCmoB27aF9qp2EqQXsfWe6M9giI+OUjDM48I4mzKJTzIO6XiuobHFbH2IFk4DnPdKmiIuSkjd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X4ZwZUA5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X4ZwZUA5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC54C4CEEF; Mon, 5 May 2025 23:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746486318; bh=PNW4NJRyX1DA1CvPLs9JmMFNEY3teA+yGpOr5xxteFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4ZwZUA5JQIgYWhEx1uTmITaUHWWBukJo+Umu5C4ycpVPSPayNvZnnSsgSMSHK27R yEYsOrQLpB1rrLP8iwtfV4nDP4xkkdBAogfoMW4t/dVQOGEzZky8FEo75P3l0DcGXT YHwXAF+NMOe7H29fqJIv/rsU2u7rcZRkaSZOiymsiV1buWqnLAxljyfX5lSH+AM4+9 rUn2qW2c4jVNB0NNkRvtfBXAAMafk+mQ2Lpuat/hdxuFi+FGg6NiPABw2VmR73zySL jLyb2DwIaQQYjVFpz8qZPj6i/aFzDH6HQ9YOsSjfPHPifPgF7OdkkoKxYK9RU82x17 t2kDTQUdrAjPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geert Uytterhoeven , kernel test robot , Simon Horman , Jakub Kicinski , Sasha Levin , davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 257/294] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only Date: Mon, 5 May 2025 18:55:57 -0400 Message-Id: <20250505225634.2688578-257-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505225634.2688578-1-sashal@kernel.org> References: <20250505225634.2688578-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.89 Content-Transfer-Encoding: 8bit From: Geert Uytterhoeven [ Upstream commit 50f37fc2a39c4a8cc4813629b4cf239b71c6097d ] if CONFIG_NET_IPGRE is enabled, but CONFIG_IPV6 is disabled: net/ipv4/ip_gre.c: In function ‘ipgre_err’: net/ipv4/ip_gre.c:144:22: error: variable ‘data_len’ set but not used [-Werror=unused-but-set-variable] 144 | unsigned int data_len = 0; | ^~~~~~~~ Fix this by moving all data_len processing inside the IPV6-only section that uses its result. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202501121007.2GofXmh5-lkp@intel.com/ Signed-off-by: Geert Uytterhoeven Reviewed-by: Simon Horman Link: https://patch.msgid.link/d09113cfe2bfaca02f3dddf832fb5f48dd20958b.1738704881.git.geert@linux-m68k.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/ip_gre.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 890c15510b421..f261e29adc7c2 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -140,7 +140,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info, const struct iphdr *iph; const int type = icmp_hdr(skb)->type; const int code = icmp_hdr(skb)->code; - unsigned int data_len = 0; struct ip_tunnel *t; if (tpi->proto == htons(ETH_P_TEB)) @@ -181,7 +180,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info, case ICMP_TIME_EXCEEDED: if (code != ICMP_EXC_TTL) return 0; - data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */ break; case ICMP_REDIRECT: @@ -189,10 +187,16 @@ static int ipgre_err(struct sk_buff *skb, u32 info, } #if IS_ENABLED(CONFIG_IPV6) - if (tpi->proto == htons(ETH_P_IPV6) && - !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, - type, data_len)) - return 0; + if (tpi->proto == htons(ETH_P_IPV6)) { + unsigned int data_len = 0; + + if (type == ICMP_TIME_EXCEEDED) + data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */ + + if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, + type, data_len)) + return 0; + } #endif if (t->parms.iph.daddr == 0 || -- 2.39.5