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 DFE5A3344F4; Mon, 5 May 2025 22:36:23 +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=1746484584; cv=none; b=Qc9gn0sWgySNcs5wAHavPljGntbrSc+o5v8CDmNb7jxXSwCauoGTSp+5MrOGprkTjIOXbJZIHCSChxyl1gdTOAls1UnJ0T+a0KQpl/A0FX3OOo765fKYdbKRMajDrDyjiUe4ssThVimmA2DC8PBGdEhmss0OtirELRXkdy/nnd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746484584; c=relaxed/simple; bh=cZ7WccVEY3rBxlcARtOzc5KgjxT33cNmGCMLTwHk7F4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=P3EsLyVk1BiNOP2DP/InV11g2xxSck78syW51SK/2WsFQ8AluAZ2Z6wJg4B5SnROc5fp4DT6L/AeGnYsE0dBgb0OP/8GRxnb+DFBW+vQRWHH6DR9AWL44I+nsl2JlV9jKcMU+NMEUomDBXBee3F5zM67/t4dgrB79P3hlgBJV4k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qmjtv9y2; 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="qmjtv9y2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EF27C4CEED; Mon, 5 May 2025 22:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746484583; bh=cZ7WccVEY3rBxlcARtOzc5KgjxT33cNmGCMLTwHk7F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qmjtv9y2uNrfelxC40eW+tIFlHeN07PIoyXbUPJzdA4MfyK/GRmurC/lDZnvSJjT1 dmqMkUZZ3mrdfMuijRRiPjryahir6ElCjpQjgNrZBn6mFDUV2fDbX2JtP5djhH05MY 4qmyZ9+2t9CGMtGhoAU8ONUM904kvRuAz0ayvnIt4OnjH49nLXj/wFldQCSoEANrDy a+B9CEeYtfBg0UJBA+01E2b2uJHziSTdmfxKU2K00agP5ed+1Y1lzUMk434eVnR2cs jZ4m9PXXRi/DqjC/0kZ4wpKCIX7Dki2ztaQptvJNgCRlamCZRro5ufxmYtQm/UxPpH nNyEp8R97upxg== 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.14 548/642] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only Date: Mon, 5 May 2025 18:12:44 -0400 Message-Id: <20250505221419.2672473-548-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505221419.2672473-1-sashal@kernel.org> References: <20250505221419.2672473-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@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.14.5 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 ed1b6b44faf80..c9f11a046c263 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -141,7 +141,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)) @@ -182,7 +181,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: @@ -190,10 +188,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