summaryrefslogtreecommitdiff
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2024-03-07 16:30:20 +0000
committerJakub Kicinski <kuba@kernel.org>2024-03-08 11:39:44 -0800
commitd721812aa875a898eb38b2729abf6e96abdb357b (patch)
tree5a90e866ad5180e8d2531435f481d9d7d3506569 /net/ipv4
parent026763ece881b4c636173c25d012cde085689027 (diff)
ipv4: raw: check sk->sk_rcvbuf earlier
There is no point cloning an skb and having to free the clone if the receive queue of the raw socket is full. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://lore.kernel.org/r/20240307163020.2524409-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/raw.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 494a6284bd7e..42ac434cfcfa 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -175,6 +175,13 @@ static int raw_v4_input(struct net *net, struct sk_buff *skb,
if (!raw_v4_match(net, sk, iph->protocol,
iph->saddr, iph->daddr, dif, sdif))
continue;
+
+ if (atomic_read(&sk->sk_rmem_alloc) >=
+ READ_ONCE(sk->sk_rcvbuf)) {
+ atomic_inc(&sk->sk_drops);
+ continue;
+ }
+
delivered = 1;
if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
ip_mc_sf_allow(sk, iph->daddr, iph->saddr,