Skip to content

Commit

Permalink
mptcp: do not keep around the first subflow after disconnect
Browse files Browse the repository at this point in the history
After the previous patch the first subflow is allocated as
needed at bind, connect, listen time. We don't need anymore
to keep alive the first subflow after a disconnect just to
be able to perform such syscall.

Overall, this change makes the passive and active sockets consistent:
even passive sockets will be allowed to complete life cycle after
disconnect.

Closes: #290
Signed-off-by: Paolo Abeni <[email protected]>
Reviewed-by: Matthieu Baerts <[email protected]>
  • Loading branch information
Paolo Abeni authored and matttbe committed Feb 8, 2023
1 parent 42229c2 commit 8b83394
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2344,11 +2344,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
unsigned int flags)
{
struct mptcp_sock *msk = mptcp_sk(sk);
bool need_push, dispose_it;
bool need_push;

dispose_it = !msk->subflow || ssk != msk->subflow->sk;
if (dispose_it)
list_del(&subflow->node);
list_del(&subflow->node);

lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);

Expand All @@ -2362,15 +2360,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
}

need_push = (flags & MPTCP_CF_PUSH) && __mptcp_retransmit_pending_data(sk);
if (!dispose_it) {
tcp_disconnect(ssk, 0);
msk->subflow->state = SS_UNCONNECTED;
mptcp_subflow_ctx_reset(subflow);
release_sock(ssk);

goto out;
}

sock_orphan(ssk);
subflow->disposable = 1;

Expand All @@ -2397,10 +2386,11 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,

sock_put(ssk);

if (ssk == msk->first)
if (ssk == msk->first) {
msk->first = NULL;
mptcp_dispose_initial_subflow(msk);
}

out:
if (ssk == msk->last_snd)
msk->last_snd = NULL;

Expand Down Expand Up @@ -3224,10 +3214,6 @@ static void mptcp_destroy(struct sock *sk)
{
struct mptcp_sock *msk = mptcp_sk(sk);

/* clears msk->subflow, allowing the following to close
* even the initial subflow
*/
mptcp_dispose_initial_subflow(msk);
mptcp_destroy_common(msk, 0);
sk_sockets_allocated_dec(sk);
}
Expand Down

0 comments on commit 8b83394

Please sign in to comment.