summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorCong Wang <cong.wang@bytedance.com>2024-12-10 01:20:38 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-02 10:30:48 +0100
commit2a572e308f67ecf8d0234ead4a2728c3ad176591 (patch)
tree0a16399b197e873fcafbca850a113e810094bb7a /include/net
parentb480e57d1389a040bfa08f0a634dac1b4db989e7 (diff)
downloadlinux-2a572e308f67ecf8d0234ead4a2728c3ad176591.tar.gz
linux-2a572e308f67ecf8d0234ead4a2728c3ad176591.tar.bz2
linux-2a572e308f67ecf8d0234ead4a2728c3ad176591.zip
tcp_bpf: Charge receive socket buffer in bpf_tcp_ingress()
[ Upstream commit 54f89b3178d5448dd4457afbb98fc1ab99090a65 ] When bpf_tcp_ingress() is called, the skmsg is being redirected to the ingress of the destination socket. Therefore, we should charge its receive socket buffer, instead of sending socket buffer. Because sk_rmem_schedule() tests pfmemalloc of skb, we need to introduce a wrapper and call it for skmsg. Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface") Signed-off-by: Cong Wang <cong.wang@bytedance.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20241210012039.1669389-2-zijianzhang@bytedance.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sock.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 0a06c997b45b..e716b2ba00bb 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1660,7 +1660,7 @@ static inline bool sk_wmem_schedule(struct sock *sk, int size)
}
static inline bool
-sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
+__sk_rmem_schedule(struct sock *sk, int size, bool pfmemalloc)
{
int delta;
@@ -1668,7 +1668,13 @@ sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
return true;
delta = size - sk->sk_forward_alloc;
return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_RECV) ||
- skb_pfmemalloc(skb);
+ pfmemalloc;
+}
+
+static inline bool
+sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
+{
+ return __sk_rmem_schedule(sk, size, skb_pfmemalloc(skb));
}
static inline int sk_unused_reserved_mem(const struct sock *sk)