Skip to content

Commit dce1c6d

Browse files
matttbePaolo Abeni
authored andcommitted
mptcp: pm: reset MPC endp ID when re-added
The initial subflow has a special local ID: 0. It is specific per connection. When a global endpoint is deleted and re-added later, it can have a different ID -- most services managing the endpoints automatically don't force the ID to be the same as before. It is then important to track these modifications to be consistent with the ID being used for the address used by the initial subflow, not to confuse the other peer or to send the ID 0 for the wrong address. Now when removing an endpoint, msk->mpc_endpoint_id is reset if it corresponds to this endpoint. When adding a new endpoint, the same variable is updated if the address match the one of the initial subflow. Fixes: 3ad14f5 ("mptcp: more accurate MPC endpoint tracking") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent bc19ff5 commit dce1c6d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

net/mptcp/pm_netlink.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,20 +1318,27 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)
13181318
return pm_nl_get_pernet(genl_info_net(info));
13191319
}
13201320

1321-
static int mptcp_nl_add_subflow_or_signal_addr(struct net *net)
1321+
static int mptcp_nl_add_subflow_or_signal_addr(struct net *net,
1322+
struct mptcp_addr_info *addr)
13221323
{
13231324
struct mptcp_sock *msk;
13241325
long s_slot = 0, s_num = 0;
13251326

13261327
while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
13271328
struct sock *sk = (struct sock *)msk;
1329+
struct mptcp_addr_info mpc_addr;
13281330

13291331
if (!READ_ONCE(msk->fully_established) ||
13301332
mptcp_pm_is_userspace(msk))
13311333
goto next;
13321334

1335+
/* if the endp linked to the init sf is re-added with a != ID */
1336+
mptcp_local_address((struct sock_common *)msk, &mpc_addr);
1337+
13331338
lock_sock(sk);
13341339
spin_lock_bh(&msk->pm.lock);
1340+
if (mptcp_addresses_equal(addr, &mpc_addr, addr->port))
1341+
msk->mpc_endpoint_id = addr->id;
13351342
mptcp_pm_create_subflow_or_signal_addr(msk);
13361343
spin_unlock_bh(&msk->pm.lock);
13371344
release_sock(sk);
@@ -1404,7 +1411,7 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
14041411
goto out_free;
14051412
}
14061413

1407-
mptcp_nl_add_subflow_or_signal_addr(sock_net(skb->sk));
1414+
mptcp_nl_add_subflow_or_signal_addr(sock_net(skb->sk), &entry->addr);
14081415
return 0;
14091416

14101417
out_free:
@@ -1525,6 +1532,8 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net,
15251532
spin_unlock_bh(&msk->pm.lock);
15261533
}
15271534

1535+
if (msk->mpc_endpoint_id == entry->addr.id)
1536+
msk->mpc_endpoint_id = 0;
15281537
release_sock(sk);
15291538

15301539
next:

0 commit comments

Comments
 (0)