Skip to content

Commit 2398e39

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: always include dack if possible.
Currently passive MPTCP socket can skip including the DACK option - if the peer sends data before accept() completes. The above happens because the msk 'can_ack' flag is set only after the accept() call. Such missing DACK option may cause - as per RFC spec - unwanted fallback to TCP. This change addresses the issue using the key material available in the current subflow, if any, to create a suitable dack option when msk ack seq is not yet available. v1 -> v2: - adavance the generated ack after the initial MPC packet Fixes: d22f498 ("mptcp: process MP_CAPABLE data option") Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3aefbf commit 2398e39

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

net/mptcp/options.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
334334
struct mptcp_sock *msk;
335335
unsigned int ack_size;
336336
bool ret = false;
337+
bool can_ack;
338+
u64 ack_seq;
337339
u8 tcp_fin;
338340

339341
if (skb) {
@@ -360,9 +362,22 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
360362
ret = true;
361363
}
362364

365+
/* passive sockets msk will set the 'can_ack' after accept(), even
366+
* if the first subflow may have the already the remote key handy
367+
*/
368+
can_ack = true;
363369
opts->ext_copy.use_ack = 0;
364370
msk = mptcp_sk(subflow->conn);
365-
if (!msk || !READ_ONCE(msk->can_ack)) {
371+
if (likely(msk && READ_ONCE(msk->can_ack))) {
372+
ack_seq = msk->ack_seq;
373+
} else if (subflow->can_ack) {
374+
mptcp_crypto_key_sha(subflow->remote_key, NULL, &ack_seq);
375+
ack_seq++;
376+
} else {
377+
can_ack = false;
378+
}
379+
380+
if (unlikely(!can_ack)) {
366381
*size = ALIGN(dss_size, 4);
367382
return ret;
368383
}
@@ -375,7 +390,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
375390

376391
dss_size += ack_size;
377392

378-
opts->ext_copy.data_ack = msk->ack_seq;
393+
opts->ext_copy.data_ack = ack_seq;
379394
opts->ext_copy.ack64 = 1;
380395
opts->ext_copy.use_ack = 1;
381396

0 commit comments

Comments
 (0)