From nobody Sun Dec 14 13:44:16 2025 Received: from michel.telenet-ops.be (michel.telenet-ops.be [195.130.137.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E158421C9ED for ; Tue, 4 Feb 2025 21:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738705030; cv=none; b=r1aO2+dPbuxSOqyxUyOT6SiKG7SgfikmlnCCkFJJJsRttQMHo0fguJPBusOoeN0qY+85gut21KgJJsmpxAWy8FRzEFyYZLLRGAS/6rika5U0ylhwe6HxUA4mIe8kMl1H8CfcmcNCYsPBPPCw4+Flx7ftxByg2Y4W3IdUc0MmNko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738705030; c=relaxed/simple; bh=KmN9Yhyxa1Lnd1aVDGktRiri3LzeMPAmBIXiAg1LHaY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ehlX9RQmKzgjM1/Ea2glYwT2dtUsI9ZJJDd9P5LiADpHfnrMELTrQbMpCZqQ5esTaUYKfUNevIscgQyxyick2N5s6IPw1ddVi9BqXO2Z8ra6wSsHgCnjNwWzbNeLjy1m4V/5DhD/QGFdol7bsc0rlbbJIUWkPl3/XRE1g76TFkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:c448:5c9f:5d50:ad45]) by michel.telenet-ops.be with cmsmtp id 9Zcy2E0055P95W306ZcyUA; Tue, 04 Feb 2025 22:37:00 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.97) (envelope-from ) id 1tfQb8-0000000FpgF-0Zjm; Tue, 04 Feb 2025 22:36:58 +0100 Received: from geert by rox.of.borg with local (Exim 4.97) (envelope-from ) id 1tfQbK-00000006Dt9-02Sa; Tue, 04 Feb 2025 22:36:58 +0100 From: Geert Uytterhoeven To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kuniyuki Iwashima Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , kernel test robot Subject: [PATCH net-next v3] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only Date: Tue, 4 Feb 2025 22:36:54 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 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" Content-Transfer-Encoding: quoted-printable if CONFIG_NET_IPGRE is enabled, but CONFIG_IPV6 is disabled: net/ipv4/ip_gre.c: In function =E2=80=98ipgre_err=E2=80=99: net/ipv4/ip_gre.c:144:22: error: variable =E2=80=98data_len=E2=80=99 se= t but not used [-Werror=3Dunused-but-set-variable] 144 | unsigned int data_len =3D 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@int= el.com/ Signed-off-by: Geert Uytterhoeven Reviewed-by: Simon Horman --- v3: - Add Reviewed-by, v2: - Do not use the ternary operator, - Target net-next. --- 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 ed1b6b44faf8049e..c9f11a046c263005 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 =3D icmp_hdr(skb)->type; const int code =3D icmp_hdr(skb)->code; - unsigned int data_len =3D 0; struct ip_tunnel *t; =20 if (tpi->proto =3D=3D htons(ETH_P_TEB)) @@ -182,7 +181,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info, case ICMP_TIME_EXCEEDED: if (code !=3D ICMP_EXC_TTL) return 0; - data_len =3D icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */ break; =20 case ICMP_REDIRECT: @@ -190,10 +188,16 @@ static int ipgre_err(struct sk_buff *skb, u32 info, } =20 #if IS_ENABLED(CONFIG_IPV6) - if (tpi->proto =3D=3D htons(ETH_P_IPV6) && - !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, - type, data_len)) - return 0; + if (tpi->proto =3D=3D htons(ETH_P_IPV6)) { + unsigned int data_len =3D 0; + + if (type =3D=3D ICMP_TIME_EXCEEDED) + data_len =3D 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 =20 if (t->parms.iph.daddr =3D=3D 0 || --=20 2.43.0