Skip to content

Commit

Permalink
mptcp: pm: fix ID 0 endp usage after multiple re-creations
Browse files Browse the repository at this point in the history
'local_addr_used' and 'add_addr_accepted' are decremented for addresses
not related to the initial subflow (ID0), because the source and
destination addresses of the initial subflows are known from the
beginning: they don't count as "additional local address being used" or
"ADD_ADDR being accepted".

It is then required not to increment them when the entrypoint used by
the initial subflow is removed and re-added during a connection. Without
this modification, this entrypoint cannot be removed and re-added more
than once.

Reported-by: Arınç ÜNAL <[email protected]>
Closes: multipath-tcp/mptcp_net-next#512
Fixes: 3ad14f5 ("mptcp: more accurate MPC endpoint tracking")
Reported-by: [email protected]
Closes: https://lore.kernel.org/[email protected]
Cc: [email protected]
Tested-by: Arınç ÜNAL <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
matttbe authored and Paolo Abeni committed Aug 29, 2024
1 parent 58e1b66 commit 9366922
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,13 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)

fullmesh = !!(local.flags & MPTCP_PM_ADDR_FLAG_FULLMESH);

msk->pm.local_addr_used++;
__clear_bit(local.addr.id, msk->pm.id_avail_bitmap);

/* Special case for ID0: set the correct ID */
if (local.addr.id == msk->mpc_endpoint_id)
local.addr.id = 0;
else /* local_addr_used is not decr for ID 0 */
msk->pm.local_addr_used++;

nr = fill_remote_addresses_vec(msk, &local.addr, fullmesh, addrs);
if (nr == 0)
Expand Down Expand Up @@ -750,7 +751,9 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
spin_lock_bh(&msk->pm.lock);

if (sf_created) {
msk->pm.add_addr_accepted++;
/* add_addr_accepted is not decr for ID 0 */
if (remote.id)
msk->pm.add_addr_accepted++;
if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
msk->pm.subflows >= subflows_max)
WRITE_ONCE(msk->pm.accept_addr, false);
Expand Down

0 comments on commit 9366922

Please sign in to comment.