Commit 612b8376e811 for kernel
commit 612b8376e8112a6f9caaedc25fa48ac42e02826d
Author: Antonio Quartulli <antonio@mandelbit.com>
Date: Tue Nov 10 12:33:06 2026 +0100
udp_tunnel: don't treat IPv4 sockets bound to an address as wildcard
With IPv6 enabled, sk_saddr_any() checks sk_v6_rcv_saddr also for
AF_INET sockets, where it is always zero. An IPv4 tunnel socket bound to
a specific address (e.g. fou or geneve with "local") ends up in the GRO
lookup fast path, although another socket may bind the same port on a
different address: GRO then hands that socket's packets to the tunnel's
gro_receive.
Check the IPv6 address only for AF_INET6 sockets.
Fixes: a36283e2b683 ("udp_tunnel: create a fastpath GRO lookup.")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20261110113306.3698438-1-antonio@mandelbit.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c
index a128fe85620d..29581c94fdcf 100644
--- a/net/ipv4/udp_tunnel_core.c
+++ b/net/ipv4/udp_tunnel_core.c
@@ -62,10 +62,10 @@ EXPORT_SYMBOL(udp_sock_create4);
static bool sk_saddr_any(struct sock *sk)
{
#if IS_ENABLED(CONFIG_IPV6)
- return ipv6_addr_any(&sk->sk_v6_rcv_saddr);
-#else
- return !sk->sk_rcv_saddr;
+ if (sk->sk_family == AF_INET6)
+ return ipv6_addr_any(&sk->sk_v6_rcv_saddr);
#endif
+ return !sk->sk_rcv_saddr;
}
void setup_udp_tunnel_sock(struct net *net, struct sock *sk,