Skip to content

Commit 50f37fc

Browse files
geertukuba-moo
authored andcommitted
ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only
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 <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/d09113cfe2bfaca02f3dddf832fb5f48dd20958b.1738704881.git.geert@linux-m68k.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent faac69a commit 50f37fc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

net/ipv4/ip_gre.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
141141
const struct iphdr *iph;
142142
const int type = icmp_hdr(skb)->type;
143143
const int code = icmp_hdr(skb)->code;
144-
unsigned int data_len = 0;
145144
struct ip_tunnel *t;
146145

147146
if (tpi->proto == htons(ETH_P_TEB))
@@ -182,18 +181,23 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
182181
case ICMP_TIME_EXCEEDED:
183182
if (code != ICMP_EXC_TTL)
184183
return 0;
185-
data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
186184
break;
187185

188186
case ICMP_REDIRECT:
189187
break;
190188
}
191189

192190
#if IS_ENABLED(CONFIG_IPV6)
193-
if (tpi->proto == htons(ETH_P_IPV6) &&
194-
!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len,
195-
type, data_len))
196-
return 0;
191+
if (tpi->proto == htons(ETH_P_IPV6)) {
192+
unsigned int data_len = 0;
193+
194+
if (type == ICMP_TIME_EXCEEDED)
195+
data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
196+
197+
if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len,
198+
type, data_len))
199+
return 0;
200+
}
197201
#endif
198202

199203
if (t->parms.iph.daddr == 0 ||

0 commit comments

Comments
 (0)