Skip to contentSkip to conversation

ipv4: raw: check sk->sk_rcvbuf earlier

PATCH Applied Eric Dumazet 3 participants 3 messages Mar 7, 2024 – Mar 8, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 net/ipv4/raw.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/ipv4/raw.c +7 -0
index 494a6284bd7ee346a4fca7a161477e6dc5ed5021..42ac434cfcfa677ee58408297f4d3ac05d98b546 100644
@@ -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,
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 7 lines · On Thu, 7 Mar 2024 16:30:20 +0000 you wrote:

There is no point cloning an skb and having to free the clone if the receive queue of the raw socket is full.

---
 net/ipv4/raw.c | 7 +++++++
 1 file changed, 7 insertions(+)

Here is the summary with links:
- [net-next] ipv4: raw: check sk->sk_rcvbuf earlier

    https://git.kernel.org/netdev/net-next/c/d721812aa875

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html