diff mbox series

[net-next] ipv4: raw: check sk->sk_rcvbuf earlier

Message ID 20240307163020.2524409-1-edumazet@google.com (mailing list archive)
State Accepted
Commit d721812aa875a898eb38b2729abf6e96abdb357b
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ipv4: raw: check sk->sk_rcvbuf earlier | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 942 this patch: 942
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 958 this patch: 958
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-07--21-00 (tests: 890)

Commit Message

Eric Dumazet March 7, 2024, 4:30 p.m. UTC
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>
---
 net/ipv4/raw.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Willem de Bruijn March 7, 2024, 8:26 p.m. UTC | #1
Eric Dumazet wrote:
> 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>
patchwork-bot+netdevbpf@kernel.org March 8, 2024, 9:20 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  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!
diff mbox series

Patch

diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 494a6284bd7ee346a4fca7a161477e6dc5ed5021..42ac434cfcfa677ee58408297f4d3ac05d98b546 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,