Skip to content

Commit 3f83d8a

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: fix more tx path fields initialization
The 'msk->write_seq' and 'msk->snd_nxt' are always updated under the msk socket lock, except at MPC handshake completiont time. Builds-up on the previous commit to move such init under the relevant lock. There are no known problems caused by the potential race, the primary goal is consistency. Fixes: 6d0060f ("mptcp: Write MPTCP DSS headers to outgoing data packets") Cc: [email protected] Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 013e317 commit 3f83d8a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

net/mptcp/protocol.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,10 +3478,8 @@ void mptcp_finish_connect(struct sock *ssk)
34783478
* accessing the field below
34793479
*/
34803480
WRITE_ONCE(msk->local_key, subflow->local_key);
3481-
WRITE_ONCE(msk->write_seq, subflow->idsn + 1);
3482-
WRITE_ONCE(msk->snd_nxt, msk->write_seq);
3483-
WRITE_ONCE(msk->snd_una, msk->write_seq);
3484-
WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd);
3481+
WRITE_ONCE(msk->snd_una, subflow->idsn + 1);
3482+
WRITE_ONCE(msk->wnd_end, subflow->idsn + 1 + tcp_sk(ssk)->snd_wnd);
34853483

34863484
mptcp_pm_new_connection(msk, ssk, 0);
34873485
}

net/mptcp/subflow.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,21 @@ static bool subflow_use_different_dport(struct mptcp_sock *msk, const struct soc
421421

422422
void __mptcp_sync_state(struct sock *sk, int state)
423423
{
424+
struct mptcp_subflow_context *subflow;
424425
struct mptcp_sock *msk = mptcp_sk(sk);
426+
struct sock *ssk = msk->first;
425427

426-
__mptcp_propagate_sndbuf(sk, msk->first);
428+
subflow = mptcp_subflow_ctx(ssk);
429+
__mptcp_propagate_sndbuf(sk, ssk);
427430
if (!msk->rcvspace_init)
428-
mptcp_rcv_space_init(msk, msk->first);
431+
mptcp_rcv_space_init(msk, ssk);
432+
429433
if (sk->sk_state == TCP_SYN_SENT) {
434+
/* subflow->idsn is always available is TCP_SYN_SENT state,
435+
* even for the FASTOPEN scenarios
436+
*/
437+
WRITE_ONCE(msk->write_seq, subflow->idsn + 1);
438+
WRITE_ONCE(msk->snd_nxt, msk->write_seq);
430439
mptcp_set_state(sk, state);
431440
sk->sk_state_change(sk);
432441
}

0 commit comments

Comments
 (0)