mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
tcp: Split out __tcp_set_rcvlowat().
We will add a kfunc for bpf_tcp_ops.{enqueue,dequeue}_rcvq()
to adjust sk->sk_rcvlowat.
These hooks are triggered
* when the TCP stack enqueues an skb to sk->sk_receive_queue
* after data is dequeued from sk->sk_receive_queue
In the enqueue path, tcp_data_ready() is always called after
the hooks in tcp_queue_rcv() and tcp_ofo_queue().
If tcp_set_rcvlowat() were used as is, tcp_data_ready() could
be called twice for the same skb, which is redundant and also
confusing.
Let's split out __tcp_set_rcvlowat() and add a flag to control
wakeup behaviour.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Reviewed-by: Amery Hung <ameryhung@gmail.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20261008031604.256498-8-kuniyu@google.com
This commit is contained in:
parent
32d17fe8a9
commit
dcddae18f5
|
|
@ -512,6 +512,7 @@ void tcp_set_keepalive(struct sock *sk, int val);
|
|||
void tcp_syn_ack_timeout(const struct request_sock *req);
|
||||
int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
|
||||
int flags);
|
||||
int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup);
|
||||
int tcp_set_rcvlowat(struct sock *sk, int val);
|
||||
void tcp_set_rcvbuf(struct sock *sk, int val);
|
||||
int tcp_set_window_clamp(struct sock *sk, int val);
|
||||
|
|
|
|||
|
|
@ -1827,8 +1827,7 @@ int tcp_peek_len(struct socket *sock)
|
|||
return tcp_inq(sock->sk);
|
||||
}
|
||||
|
||||
/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
|
||||
int tcp_set_rcvlowat(struct sock *sk, int val)
|
||||
int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup)
|
||||
{
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
int space, cap;
|
||||
|
|
@ -1841,7 +1840,8 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
|
|||
WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
|
||||
|
||||
/* Check if we need to signal EPOLLIN right now */
|
||||
tcp_data_ready(sk);
|
||||
if (wakeup)
|
||||
tcp_data_ready(sk);
|
||||
|
||||
if (sk->sk_userlocks & SOCK_RCVBUF_LOCK)
|
||||
return 0;
|
||||
|
|
@ -1856,6 +1856,12 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
|
||||
int tcp_set_rcvlowat(struct sock *sk, int val)
|
||||
{
|
||||
return __tcp_set_rcvlowat(sk, val, true);
|
||||
}
|
||||
|
||||
void tcp_set_rcvbuf(struct sock *sk, int val)
|
||||
{
|
||||
tcp_set_window_clamp(sk, tcp_win_from_space(sk, val));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user