[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240307162943.2523817-1-edumazet@google.com>
Date: Thu, 7 Mar 2024 16:29:43 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org, eric.dumazet@...il.com,
Eric Dumazet <edumazet@...gle.com>
Subject: [PATCH net-next] ipv6: 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@...gle.com>
---
net/ipv6/raw.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 779274055abf99530048ad4738c2263e97c94cce..ca49e6617afaff3fe6c5f3a174bbe6d96f94ac62 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -160,6 +160,13 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
if (!raw_v6_match(net, sk, nexthdr, daddr, saddr,
inet6_iif(skb), inet6_sdif(skb)))
continue;
+
+ if (atomic_read(&sk->sk_rmem_alloc) >=
+ READ_ONCE(sk->sk_rcvbuf)) {
+ atomic_inc(&sk->sk_drops);
+ continue;
+ }
+
delivered = true;
switch (nexthdr) {
case IPPROTO_ICMPV6:
--
2.44.0.278.ge034bb2e1d-goog
Powered by blists - more mailing lists