Skip to content

Commit 55b47ca

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix active subflow finalization
Active subflow are inserted into the connection list at creation time. When the MPJ handshake completes successfully, a new subflow creation netlink event is generated correctly, but the current code wrongly avoid initializing a couple of subflow data. The above will cause misbehavior on a few exceptional events: unneeded mptcp-level retransmission on msk-level sequence wrap-around and infinite mapping fallback even when a MPJ socket is present. Address the issue factoring out the needed initialization in a new helper and invoking the latter from __mptcp_finish_join() time for passive subflow and from mptcp_finish_join() for active ones. Fixes: 0530020 ("mptcp: track and update contiguous data status") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6b9831b commit 55b47ca

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

net/mptcp/protocol.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,13 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk)
825825
mptcp_data_unlock(sk);
826826
}
827827

828+
static void mptcp_subflow_joined(struct mptcp_sock *msk, struct sock *ssk)
829+
{
830+
mptcp_subflow_ctx(ssk)->map_seq = READ_ONCE(msk->ack_seq);
831+
WRITE_ONCE(msk->allow_infinite_fallback, false);
832+
mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC);
833+
}
834+
828835
static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk)
829836
{
830837
struct sock *sk = (struct sock *)msk;
@@ -839,6 +846,7 @@ static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk)
839846
mptcp_sock_graft(ssk, sk->sk_socket);
840847

841848
mptcp_sockopt_sync_locked(msk, ssk);
849+
mptcp_subflow_joined(msk, ssk);
842850
return true;
843851
}
844852

@@ -3485,14 +3493,16 @@ bool mptcp_finish_join(struct sock *ssk)
34853493
return false;
34863494
}
34873495

3488-
if (!list_empty(&subflow->node))
3489-
goto out;
3496+
/* active subflow, already present inside the conn_list */
3497+
if (!list_empty(&subflow->node)) {
3498+
mptcp_subflow_joined(msk, ssk);
3499+
return true;
3500+
}
34903501

34913502
if (!mptcp_pm_allow_new_subflow(msk))
34923503
goto err_prohibited;
34933504

3494-
/* active connections are already on conn_list.
3495-
* If we can't acquire msk socket lock here, let the release callback
3505+
/* If we can't acquire msk socket lock here, let the release callback
34963506
* handle it
34973507
*/
34983508
mptcp_data_lock(parent);
@@ -3515,11 +3525,6 @@ bool mptcp_finish_join(struct sock *ssk)
35153525
return false;
35163526
}
35173527

3518-
subflow->map_seq = READ_ONCE(msk->ack_seq);
3519-
WRITE_ONCE(msk->allow_infinite_fallback, false);
3520-
3521-
out:
3522-
mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC);
35233528
return true;
35243529
}
35253530

0 commit comments

Comments
 (0)