Skip to content

Commit fca5c82

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: drop req socket remote_key* fields
We don't need them, as we can use the current ingress opt data instead. Setting them in syn_recv_sock() may causes inconsistent mptcp socket status, as per previous commit. Fixes: cc7972e ("mptcp: parse and emit MP_CAPABLE option according to v1 spec") Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c8941d commit fca5c82

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

net/mptcp/protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,9 @@ static struct ipv6_pinfo *mptcp_inet6_sk(const struct sock *sk)
13321332
}
13331333
#endif
13341334

1335-
struct sock *mptcp_sk_clone(const struct sock *sk, struct request_sock *req)
1335+
struct sock *mptcp_sk_clone(const struct sock *sk,
1336+
const struct tcp_options_received *opt_rx,
1337+
struct request_sock *req)
13361338
{
13371339
struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);
13381340
struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC);
@@ -1370,9 +1372,9 @@ struct sock *mptcp_sk_clone(const struct sock *sk, struct request_sock *req)
13701372

13711373
msk->write_seq = subflow_req->idsn + 1;
13721374
atomic64_set(&msk->snd_una, msk->write_seq);
1373-
if (subflow_req->remote_key_valid) {
1375+
if (opt_rx->mptcp.mp_capable) {
13741376
msk->can_ack = true;
1375-
msk->remote_key = subflow_req->remote_key;
1377+
msk->remote_key = opt_rx->mptcp.sndr_key;
13761378
mptcp_crypto_key_sha(msk->remote_key, NULL, &ack_seq);
13771379
ack_seq++;
13781380
msk->ack_seq = ack_seq;

net/mptcp/protocol.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,10 @@ struct mptcp_subflow_request_sock {
206206
struct tcp_request_sock sk;
207207
u16 mp_capable : 1,
208208
mp_join : 1,
209-
backup : 1,
210-
remote_key_valid : 1;
209+
backup : 1;
211210
u8 local_id;
212211
u8 remote_id;
213212
u64 local_key;
214-
u64 remote_key;
215213
u64 idsn;
216214
u32 token;
217215
u32 ssn_offset;
@@ -332,7 +330,9 @@ void mptcp_proto_init(void);
332330
int mptcp_proto_v6_init(void);
333331
#endif
334332

335-
struct sock *mptcp_sk_clone(const struct sock *sk, struct request_sock *req);
333+
struct sock *mptcp_sk_clone(const struct sock *sk,
334+
const struct tcp_options_received *opt_rx,
335+
struct request_sock *req);
336336
void mptcp_get_options(const struct sk_buff *skb,
337337
struct tcp_options_received *opt_rx);
338338

net/mptcp/subflow.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ static void subflow_init_req(struct request_sock *req,
133133

134134
subflow_req->mp_capable = 0;
135135
subflow_req->mp_join = 0;
136-
subflow_req->remote_key_valid = 0;
137136

138137
#ifdef CONFIG_TCP_MD5SIG
139138
/* no MPTCP if MD5SIG is enabled on this socket or we may run out of
@@ -404,6 +403,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
404403

405404
pr_debug("listener=%p, req=%p, conn=%p", listener, req, listener->conn);
406405

406+
opt_rx.mptcp.mp_capable = 0;
407407
if (tcp_rsk(req)->is_mptcp == 0)
408408
goto create_child;
409409

@@ -418,18 +418,14 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
418418
goto create_msk;
419419
}
420420

421-
opt_rx.mptcp.mp_capable = 0;
422421
mptcp_get_options(skb, &opt_rx);
423-
if (opt_rx.mptcp.mp_capable) {
424-
subflow_req->remote_key = opt_rx.mptcp.sndr_key;
425-
subflow_req->remote_key_valid = 1;
426-
} else {
422+
if (!opt_rx.mptcp.mp_capable) {
427423
fallback = true;
428424
goto create_child;
429425
}
430426

431427
create_msk:
432-
new_msk = mptcp_sk_clone(listener->conn, req);
428+
new_msk = mptcp_sk_clone(listener->conn, &opt_rx, req);
433429
if (!new_msk)
434430
fallback = true;
435431
} else if (subflow_req->mp_join) {
@@ -473,6 +469,13 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
473469
mptcp_pm_new_connection(mptcp_sk(new_msk), 1);
474470
ctx->conn = new_msk;
475471
new_msk = NULL;
472+
473+
/* with OoO packets we can reach here without ingress
474+
* mpc option
475+
*/
476+
ctx->remote_key = opt_rx.mptcp.sndr_key;
477+
ctx->fully_established = opt_rx.mptcp.mp_capable;
478+
ctx->can_ack = opt_rx.mptcp.mp_capable;
476479
} else if (ctx->mp_join) {
477480
struct mptcp_sock *owner;
478481

@@ -1134,9 +1137,6 @@ static void subflow_ulp_clone(const struct request_sock *req,
11341137
* is fully established only after we receive the remote key
11351138
*/
11361139
new_ctx->mp_capable = 1;
1137-
new_ctx->fully_established = subflow_req->remote_key_valid;
1138-
new_ctx->can_ack = subflow_req->remote_key_valid;
1139-
new_ctx->remote_key = subflow_req->remote_key;
11401140
new_ctx->local_key = subflow_req->local_key;
11411141
new_ctx->token = subflow_req->token;
11421142
new_ctx->ssn_offset = subflow_req->ssn_offset;

0 commit comments

Comments
 (0)