mptcp: fix missing close transition
Subsystems (2)
Paolo Abeni
maintainerv2 cover mptcp: fix missing close transition
This is an attempt to address the 2nd issue reported in:
https://github.com/multipath-tcp/mptcp_net-next/issues/427
See the individual patch changelog for the details. The cover letter is here mainly to trigger the CI.
v1 -> v2:
- fix compile warning reported by the CI
Paolo Abeni (2):
mptcp: move __mptcp_error_report in protocol.c
mptcp: process pending subflow error on close
net/mptcp/protocol.c | 41 +++++++++++++++++++++++++++++++++++++++++ net/mptcp/subflow.c | 36 ------------------------------------ 2 files changed, 41 insertions(+), 36 deletions(-)
Signature · 1 line
2.41.0
Paolo Abeni
maintainerPATCH v2 1/2 mptcp: move __mptcp_error_report in protocol.c
This will simplify the next patch. No functional change intended.
--- net/mptcp/protocol.c | 36 ++++++++++++++++++++++++++++++++++++ net/mptcp/subflow.c | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-)
net/mptcp/protocol.c +36 -0
@@ -764,6 +764,42 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk)return moved; } +void __mptcp_error_report (struct sock *sk) +{ +struct mptcp_subflow_context *subflow; +struct mptcp_sock *msk =mptcp_sk (sk); + +mptcp_for_each_subflow (msk, subflow) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +int err =sock_error (ssk); +int ssk_state; + +if (!err) +continue ; + +/* only propagate errors on fallen-back sockets or +* on MPC connect +*/ +if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) +continue ; + +/* We need to propagate only transition to CLOSE state. +* Orphaned socket will see such state change via +* subflow_sched_work_if_closed() and that path will properly +* destroy the msk as needed. +*/ + ssk_state =inet_sk_state_load (ssk); +if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) +inet_sk_state_store (sk, ssk_state); +WRITE_ONCE (sk->sk_err, -err); + +/* This barrier is coupled with smp_rmb() in mptcp_poll() */ +smp_wmb (); +sk_error_report (sk); +break ; + } +} +/* In most cases we will be able to lock the mptcp socket. If its already * owned, we need to defer to the work queue to avoid ABBA deadlock. */
net/mptcp/subflow.c +0 -36
@@ -1362,42 +1362,6 @@ void mptcp_space(const struct sock *ssk, int *space, int *full_space) *full_space =mptcp_win_from_space (sk,READ_ONCE (sk->sk_rcvbuf)); } -void __mptcp_error_report (struct sock *sk) -{ -struct mptcp_subflow_context *subflow; -struct mptcp_sock *msk =mptcp_sk (sk); - -mptcp_for_each_subflow (msk, subflow) { -struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -int err =sock_error (ssk); -int ssk_state; - -if (!err) -continue ; - -/* only propagate errors on fallen-back sockets or -* on MPC connect -*/ -if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) -continue ; - -/* We need to propagate only transition to CLOSE state. -* Orphaned socket will see such state change via -* subflow_sched_work_if_closed() and that path will properly -* destroy the msk as needed. -*/ - ssk_state =inet_sk_state_load (ssk); -if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) -inet_sk_state_store (sk, ssk_state); -WRITE_ONCE (sk->sk_err, -err); - -/* This barrier is coupled with smp_rmb() in mptcp_poll() */ -smp_wmb (); -sk_error_report (sk); -break ; - } -} -static void subflow_error_report (struct sock *ssk) {struct sock *sk =mptcp_subflow_ctx (ssk)->conn;
Signature · 1 line
2.41.0
Paolo Abeni
maintainerPATCH v2 2/2 mptcp: process pending subflow error on close
In reply to Paolo AbeniOn incoming TCP reset, subflow closing could happen before error propagation. That in turn could cause the socket error being ignored, and a missing socket state transition, as reported by Daire-Byrne.
Address the issues explicitly checking for subflow socket error at close time. To avoid code duplication, factor-out of __mptcp_error_report() a new helper implementing the relevant bits.
---
v1 -> v2:
- fix compile warning
--- net/mptcp/protocol.c | 63 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 29 deletions(-)
net/mptcp/protocol.c +34 -29
@@ -764,40 +764,44 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk)return moved; } -void __mptcp_error_report (struct sock *sk) +static bool __mptcp_subflow_error_report (struct sock *sk,struct sock *ssk) { -struct mptcp_subflow_context *subflow; -struct mptcp_sock *msk =mptcp_sk (sk); +int err =sock_error (ssk); +int ssk_state; -mptcp_for_each_subflow (msk, subflow) { -struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -int err =sock_error (ssk); -int ssk_state; +if (!err) +return false; -if (!err) -continue ; +/* only propagate errors on fallen-back sockets or +* on MPC connect +*/ +if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (mptcp_sk (sk))) +return false; -/* only propagate errors on fallen-back sockets or -* on MPC connect -*/ -if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) -continue ; +/* We need to propagate only transition to CLOSE state. +* Orphaned socket will see such state change via +* subflow_sched_work_if_closed() and that path will properly +* destroy the msk as needed. +*/ + ssk_state =inet_sk_state_load (ssk); +if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) +inet_sk_state_store (sk, ssk_state); +WRITE_ONCE (sk->sk_err, -err); -/* We need to propagate only transition to CLOSE state. -* Orphaned socket will see such state change via -* subflow_sched_work_if_closed() and that path will properly -* destroy the msk as needed. -*/ - ssk_state =inet_sk_state_load (ssk); -if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) -inet_sk_state_store (sk, ssk_state); -WRITE_ONCE (sk->sk_err, -err); - -/* This barrier is coupled with smp_rmb() in mptcp_poll() */ -smp_wmb (); -sk_error_report (sk); -break ; - } +/* This barrier is coupled with smp_rmb() in mptcp_poll() */ +smp_wmb (); +sk_error_report (sk); +return true; +} + +void __mptcp_error_report (struct sock *sk) +{ +struct mptcp_subflow_context *subflow; +struct mptcp_sock *msk =mptcp_sk (sk); + +mptcp_for_each_subflow (msk, subflow) +if (__mptcp_subflow_error_report (sk,mptcp_subflow_tcp_sock (subflow))) +break ; }/* In most cases we will be able to lock the mptcp socket. If its already
@@ -2422,6 +2426,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, } out_release: +__mptcp_subflow_error_report (sk, ssk);release_sock (ssk);sock_put (ssk);
Signature · 1 line
2.41.0
Re: mptcp: process pending subflow error on close: Tests Results
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! ✅:
- Task: https://cirrus-ci.com/task/5564860235251712
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5564860235251712/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/4544513444675584
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4544513444675584/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5670413351518208
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5670413351518208/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/6690760142094336
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6690760142094336/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e64f9b400ebc
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-debugFor 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 (Tessares)
Quoted 10 lines · Paolo Abeni
This is an attempt to address the 2nd issue reported in:
https://github.com/multipath-tcp/mptcp_net-next/issues/427
See the individual patch changelog for the details. The cover letter is here mainly to trigger the CI.
v1 -> v2:
- fix compile warning reported by the CI
Quoted 7 lines
Paolo Abeni (2):
mptcp: move__mptcp_error_reportinprotocol.c
mptcp: process pending subflow error on close
net/mptcp/protocol.c| 41 +++++++++++++++++++++++++++++++++++++++++net/mptcp/subflow.c| 36 ------------------------------------2 files changed, 41 insertions(+), 36 deletions(-)
Thanks for the v2, series looks good:
Re: mptcp: process pending subflow error on close: Tests Results
In reply to Paolo AbeniHi 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! ✅:
- Task: https://cirrus-ci.com/task/6687372218204160
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6687372218204160/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5104075474206720
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5104075474206720/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5667025427628032
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5667025427628032/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/4541125520785408
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4541125520785408/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/fe4acd2e87af
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-debugFor 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 (Tessares)