add tcp_recv_should_stop helper
Subsystems (3)
Geliang Tang
reviewerv2 cover add tcp_recv_should_stop helper
From: Geliang Tang <[email protected]>
Two cleanups for "implement read_sock" series.
v2:
- v1 changed the original behavior when replacing tcp_recv_should_stop. This version preserves the behavior unchanged.
- add a cleanup patch for read_sock into this set.
v1:
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
Gang Yan (1):
mptcp: check desc->count in read_sock
Geliang Tang (1):
tcp: add recv_should_stop helper
include/net/tcp.h | 9 +++++++++ net/ipv4/tcp.c | 10 ++-------- net/mptcp/protocol.c | 12 ++++-------- 3 files changed, 15 insertions(+), 16 deletions(-)
Signature · 1 line
2.52.0
Geliang Tang
reviewerPATCH v2 1/2 mptcp: check desc->count in read_sock
From: Gang Yan <[email protected]>
In __tcp_read_sock(), it checks whether desc->count equals 0 within the loop and breaks the loop if true. This check should also be synchronized to __mptcp_read_sock().
--- net/mptcp/protocol.c | 2 ++ 1 file changed, 2 insertions(+)
net/mptcp/protocol.c +2 -0
@@ -4382,6 +4382,8 @@ static int __mptcp_read_sock(struct sock *sk, read_descriptor_t *desc, }mptcp_eat_recv_skb (sk, skb); +if (!desc->count) +break ; }if (noack)
Signature · 1 line
2.52.0
Geliang Tang
reviewerPATCH v2 2/2 tcp: add recv_should_stop helper
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Factor out a new helper tcp_recv_should_stop() from tcp_recvmsg_locked() and tcp_splice_read() to check whether to stop receiving. And use this helper in mptcp_recvmsg() and mptcp_splice_read() to reduce redundant code.
--- include/net/tcp.h | 9 +++++++++ net/ipv4/tcp.c | 10 ++-------- net/mptcp/protocol.c | 10 ++-------- 3 files changed, 13 insertions(+), 16 deletions(-)
include/net/tcp.h +9 -0
@@ -2951,4 +2951,13 @@ enum skb_drop_reason tcp_inbound_hash(struct sock *sk, const void *saddr, const void *daddr, int family, int dif, int sdif); +static inline int tcp_recv_should_stop (struct sock *sk,long timeo) +{ +return sk->sk_err || + sk->sk_state ==TCP_CLOSE || + (sk->sk_shutdown &RCV_SHUTDOWN ) || +signal_pending (current) || + !timeo; +} +#endif /* _TCP_H */
net/ipv4/tcp.c +2 -8
@@ -894,9 +894,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,release_sock (sk);lock_sock (sk); -if (sk->sk_err || sk->sk_state ==TCP_CLOSE || - (sk->sk_shutdown &RCV_SHUTDOWN ) || -signal_pending (current)) +if (tcp_recv_should_stop (sk, timeo))break ; }
@@ -2783,11 +2781,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,break ;if (copied) { -if (!timeo || - sk->sk_err || - sk->sk_state ==TCP_CLOSE || - (sk->sk_shutdown &RCV_SHUTDOWN ) || -signal_pending (current)) +if (tcp_recv_should_stop (sk, timeo))break ; }else {if (sock_flag (sk,SOCK_DONE ))
net/mptcp/protocol.c +2 -8
@@ -2316,11 +2316,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,break ;if (copied) { -if (sk->sk_err || - sk->sk_state ==TCP_CLOSE || - (sk->sk_shutdown &RCV_SHUTDOWN ) || - !timeo || -signal_pending (current)) +if (tcp_recv_should_stop (sk, timeo))break ; }else {if (sk->sk_err) {
@@ -4506,9 +4502,7 @@ static ssize_t mptcp_splice_read(struct socket *sock, loff_t *ppos,release_sock (sk);lock_sock (sk); -if (sk->sk_err || sk->sk_state ==TCP_CLOSE || - (sk->sk_shutdown &RCV_SHUTDOWN ) || -signal_pending (current)) +if (tcp_recv_should_stop (sk, timeo))break ; }
Signature · 1 line
2.52.0
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Critical: Boot failures ❌
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/21616628959
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/47f73d0cc08e
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1050056
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)