Skip to content

Commit e72e403

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: set msk local address earlier
The mptcp_pm_nl_get_local_id() code assumes that the msk local address is available at that point. For passive sockets, we initialize such address at accept() time. Depending on the running configuration and the user-space timing, a passive MPJ subflow can join the msk socket before accept() completes. In such case, the PM assigns a wrong local id to the MPJ subflow and later PM netlink operations will end-up touching the wrong/unexpected subflow. All the above causes sporadic self-tests failures, especially when the host is heavy loaded. Closes: multipath-tcp/mptcp_net-next#308 Fixes: 01cacb0 ("mptcp: add netlink-based PM") Fixes: d045b9e ("mptcp: introduce implicit endpoints") Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4a4b684 commit e72e403

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

net/mptcp/protocol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ static void mptcp_close(struct sock *sk, long timeout)
29522952
sock_put(sk);
29532953
}
29542954

2955-
static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
2955+
void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
29562956
{
29572957
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
29582958
const struct ipv6_pinfo *ssk6 = inet6_sk(ssk);
@@ -3699,7 +3699,6 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
36993699
if (mptcp_is_fully_established(newsk))
37003700
mptcp_pm_fully_established(msk, msk->first, GFP_KERNEL);
37013701

3702-
mptcp_copy_inaddrs(newsk, msk->first);
37033702
mptcp_rcv_space_init(msk, msk->first);
37043703
mptcp_propagate_sndbuf(newsk, msk->first);
37053704

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ int mptcp_is_checksum_enabled(const struct net *net);
599599
int mptcp_allow_join_id0(const struct net *net);
600600
unsigned int mptcp_stale_loss_cnt(const struct net *net);
601601
int mptcp_get_pm_type(const struct net *net);
602+
void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk);
602603
void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow,
603604
struct mptcp_options_received *mp_opt);
604605
bool __mptcp_retransmit_pending_data(struct sock *sk);

net/mptcp/subflow.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
723723
goto dispose_child;
724724
}
725725

726+
if (new_msk)
727+
mptcp_copy_inaddrs(new_msk, child);
726728
subflow_drop_ctx(child);
727729
goto out;
728730
}
@@ -750,6 +752,11 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
750752
ctx->conn = new_msk;
751753
new_msk = NULL;
752754

755+
/* set msk addresses early to ensure mptcp_pm_get_local_id()
756+
* uses the correct data
757+
*/
758+
mptcp_copy_inaddrs(ctx->conn, child);
759+
753760
/* with OoO packets we can reach here without ingress
754761
* mpc option
755762
*/

0 commit comments

Comments
 (0)