From: Eric Dumazet Date: Tue, 16 Sep 2025 16:09:46 +0000 (+0000) Subject: udp: refine __udp_enqueue_schedule_skb() test X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9aaec660b5be29f23aaa7d1b0ae426b895dc0ca5;p=users%2Fhch%2Fmisc.git udp: refine __udp_enqueue_schedule_skb() test Commit 5a465a0da13e ("udp: Fix multiple wraparounds of sk->sk_rmem_alloc.") allowed to slightly overshoot sk->sk_rmem_alloc, when many cpus are trying to feed packets to a common UDP socket. This patch, combined with the following one reduces false sharing on the victim socket under DDOS. Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Reviewed-by: Kuniyuki Iwashima Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20250916160951.541279-6-edumazet@google.com Reviewed-by: Jakub Kicinski Signed-off-by: Paolo Abeni --- diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index cca41c569f37..edd846fee90f 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1739,8 +1739,8 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) if (rcvbuf > INT_MAX >> 1) goto drop; - /* Always allow at least one packet for small buffer. */ - if (rmem > rcvbuf) + /* Accept the packet if queue is empty. */ + if (rmem) goto drop; }