ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only

[ 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 <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501121007.2GofXmh5-lkp@intel.com/
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/d09113cfe2bfaca02f3dddf832fb5f48dd20958b.1738704881.git.geert@linux-m68k.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Geert Uytterhoeven
2025-02-04 22:36:54 +01:00
committed by Greg Kroah-Hartman
parent 13cba3f837
commit 2cb57a887a

View File

@@ -140,7 +140,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
const struct iphdr *iph; const struct iphdr *iph;
const int type = icmp_hdr(skb)->type; const int type = icmp_hdr(skb)->type;
const int code = icmp_hdr(skb)->code; const int code = icmp_hdr(skb)->code;
unsigned int data_len = 0;
struct ip_tunnel *t; struct ip_tunnel *t;
if (tpi->proto == htons(ETH_P_TEB)) 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: case ICMP_TIME_EXCEEDED:
if (code != ICMP_EXC_TTL) if (code != ICMP_EXC_TTL)
return 0; return 0;
data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
break; break;
case ICMP_REDIRECT: case ICMP_REDIRECT:
@@ -189,10 +187,16 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
} }
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
if (tpi->proto == htons(ETH_P_IPV6) && if (tpi->proto == htons(ETH_P_IPV6)) {
!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, unsigned int data_len = 0;
type, data_len))
return 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 #endif
if (t->parms.iph.daddr == 0 || if (t->parms.iph.daddr == 0 ||