mptcp: more cleanups
Subsystems (2)
Paolo Abeni
maintainerv3 cover mptcp: more cleanups
Follow-up the recent fixes, as per sashiko nipa feedback. A new patch and an update to an exiting one.
This is basically v1 again with hopefully better changelog to avoid AI slop review (and myself not detecting the latter as such).
Paolo Abeni (2):
mptcp: prevent race between disconnect() and rtx
Squash-to: "mptcp: do not reschedule the RTX timer for fallback
sockets"
net/mptcp/protocol.c | 18 +++++++++++++----- net/mptcp/protocol.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0
Paolo Abeni
maintainerPATCH v3 1/2 mptcp: prevent race between disconnect() and rtx
Sashiko noted that the two event can race, leading to inconsistent status. Prevent the race using the synchronous timer stop operation.
--- net/mptcp/protocol.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +8 -2
@@ -3625,6 +3625,7 @@ static void mptcp_destroy_common(struct mptcp_sock *msk)static int mptcp_disconnect (struct sock *sk,int flags) { +struct inet_connection_sock *icsk =inet_csk (sk);struct mptcp_sock *msk =mptcp_sk (sk);/* We are on the fastopen error path. We can't call straight into the
@@ -3637,8 +3638,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)mptcp_check_listen_stop (sk);mptcp_set_state (sk,TCP_CLOSE ); -mptcp_stop_rtx_timer (sk); -mptcp_stop_tout_timer (sk); +/* The later subflow close can not kick again the tout timer, +* as the msk is already in closed status. +*/ + msk->timer_ival = icsk->icsk_rto_min; +sk_stop_timer_sync (sk, &sk->mptcp_retransmit_timer); + icsk->icsk_mtup.probe_timestamp =0 ; +sk_stop_timer_sync (sk, &icsk->mptcp_tout_timer);mptcp_pm_connection_closed (msk);
Signature · 1 line
2.55.0
Paolo Abeni
maintainerPATCH v3 2/2 Squash-to: "mptcp: do not reschedule the RTX timer for fallback sockets"
In reply to Paolo AbeniSashiko noted that the 'RTX disabled' status is carried over across connect() failures, potentially to subsequent successful connect() or listen().
Explicitly control the RTX enabling status across the whole msk life-cycle. To make the code more straight forward switch the newly introduced flag semantic.
To be appended to the squash-to commit message:
"""
The RTX enable bit is clear at close time and set before the msk could start retransmitting, with a couple of caveats:
- passive sockets inherit the bit from the listener msk; set the bit on such socket to avoid flipping it in the fast-path, even if the listener will obviously never retransmit.
- while fastopening, mptcp_sendmsg_fastopen still ends-up calling mptcp_connect via tcp_sendmsg_fastopen -> __inet_stream_connect(ssk->sk_socket), and the first subflow sk_socket points to the msk one.
"""
---
v2 -> v3:
- roll back to v1, sashiko review was wrong and I should have noticed :( hopefully the update changelog should guide sashiko review to avoid repeating the sloop, in any case the issue reported here:
is a false positive (see the above changelog).
v1 -> v2:
- consolidate enable, fix missing enable for fastopen
--- net/mptcp/protocol.c | 8 +++++--- net/mptcp/protocol.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
net/mptcp/protocol.c +5 -3
@@ -96,7 +96,7 @@ bool __mptcp_try_fallback(struct mptcp_sock *msk, int fb_mib) msk->allow_subflows = false;set_bit (MPTCP_FALLBACK_DONE , &msk->flags); -set_bit (MPTCP_RTX_DISABLED , &msk->flags); +clear_bit (MPTCP_RTX_ENABLED , &msk->flags);__MPTCP_INC_STATS (net, fb_mib);spin_unlock_bh (&msk->fallback_lock);return true;
@@ -1126,7 +1126,7 @@ static void mptcp_reset_rtx_timer(struct sock *sk)unsigned long tout;/* Prevent rescheduling on close and in case of fallback. */ -if (test_bit (MPTCP_RTX_DISABLED , &msk->flags)) +if (!test_bit (MPTCP_RTX_ENABLED , &msk->flags))return ; tout = msk->timer_ival;
@@ -3363,7 +3363,7 @@ void mptcp_set_state(struct sock *sk, int state)*/ break ;case TCP_CLOSE : -set_bit (MPTCP_RTX_DISABLED , &mptcp_sk (sk)->flags); +clear_bit (MPTCP_RTX_ENABLED , &mptcp_sk (sk)->flags); fallthrough;default :if (oldstate ==TCP_ESTABLISHED || oldstate ==TCP_CLOSE_WAIT )
@@ -4189,6 +4189,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr_unsized *uaddr,if (IS_ERR (ssk))return PTR_ERR (ssk); +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_SYN_SENT ); subflow =mptcp_subflow_ctx (ssk);#ifdef CONFIG_TCP_MD5SIG
@@ -4336,6 +4337,7 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_LISTEN );sock_set_flag (sk,SOCK_RCU_FREE );
net/mptcp/protocol.h +1 -1
@@ -116,7 +116,7 @@#define MPTCP_WORK_RTX 1#define MPTCP_FALLBACK_DONE 2#define MPTCP_WORK_CLOSE_SUBFLOW 3 -#define MPTCP_RTX_DISABLED 4 +#define MPTCP_RTX_ENABLED 4/* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1
Signature · 1 line
2.55.0
Hi Paolo,
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): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/33164019952
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/bce912e922bd
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1153165
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)
Matthieu Baerts
maintainerHi Paolo,
Quoted 2 lines · Paolo Abeni
Follow-up the recent fixes, as per sashiko nipa feedback. A new patch and an update to an exiting one.
Thank you for the fixes!
New patches for t/upstream-net and t/upstream:
- f95e1533532b: "squashed" patch 2/2 in "mptcp: do not reschedule the RTX timer for fallback sockets"
- 7951c9d65b6f: mptcp: prevent race between disconnect() and rtx
- 0057523d4132: tg:msg: appended explanations for reviewers
- Results: d4a0635cd6fc..bb60157d0392 (export-net)
- Results: d92f7d553a9b..c5eb9a747a9a (export)
Tests are now in progress:
- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/1db74a6e22390b0bc05dc9c57f8af7ef3edb4c63/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/39d4f32c5d534bd880ffdfe4f32499379a7ccd01/checks
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.