Skip to content

Commit 1249db4

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: be careful on subflow status propagation on errors
Currently the subflow error report callback unconditionally propagates the fallback subflow status to the owning msk. If the msk is already orphaned, the above prevents the code from correctly tracking the msk moving to the TCP_CLOSE state and doing the appropriate cleanup. All the above causes increasing memory usage over time and sporadic self-tests failures. There is a great deal of infrastructure trying to propagate correctly the fallback subflow status to the owning mptcp socket, e.g. via mptcp_subflow_eof() and subflow_sched_work_if_closed(): in the error propagation path we need only to cope with unorphaned sockets. Closes: multipath-tcp/mptcp_net-next#339 Fixes: 15cc104 ("mptcp: deliver ssk errors to msk") Cc: [email protected] Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad21710 commit 1249db4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/mptcp/subflow.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,7 @@ void __mptcp_error_report(struct sock *sk)
13991399
mptcp_for_each_subflow(msk, subflow) {
14001400
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
14011401
int err = sock_error(ssk);
1402+
int ssk_state;
14021403

14031404
if (!err)
14041405
continue;
@@ -1409,7 +1410,14 @@ void __mptcp_error_report(struct sock *sk)
14091410
if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(msk))
14101411
continue;
14111412

1412-
inet_sk_state_store(sk, inet_sk_state_load(ssk));
1413+
/* We need to propagate only transition to CLOSE state.
1414+
* Orphaned socket will see such state change via
1415+
* subflow_sched_work_if_closed() and that path will properly
1416+
* destroy the msk as needed.
1417+
*/
1418+
ssk_state = inet_sk_state_load(ssk);
1419+
if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD))
1420+
inet_sk_state_store(sk, ssk_state);
14131421
sk->sk_err = -err;
14141422

14151423
/* This barrier is coupled with smp_rmb() in mptcp_poll() */

0 commit comments

Comments
 (0)