Skip to content

Commit 1c1f721

Browse files
matttbekuba-moo
authored andcommitted
mptcp: pm: only decrement add_addr_accepted for MPJ req
Adding the following warning ... WARN_ON_ONCE(msk->pm.add_addr_accepted == 0) ... before decrementing the add_addr_accepted counter helped to find a bug when running the "remove single subflow" subtest from the mptcp_join.sh selftest. Removing a 'subflow' endpoint will first trigger a RM_ADDR, then the subflow closure. Before this patch, and upon the reception of the RM_ADDR, the other peer will then try to decrement this add_addr_accepted. That's not correct because the attached subflows have not been created upon the reception of an ADD_ADDR. A way to solve that is to decrement the counter only if the attached subflow was an MP_JOIN to a remote id that was not 0, and initiated by the host receiving the RM_ADDR. Fixes: d0876b2 ("mptcp: add the incoming RM_ADDR support") Cc: [email protected] Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 322ea37 commit 1c1f721

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/mptcp/pm_netlink.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
829829
mptcp_close_ssk(sk, ssk, subflow);
830830
spin_lock_bh(&msk->pm.lock);
831831

832-
removed = true;
832+
removed |= subflow->request_join;
833833
if (rm_type == MPTCP_MIB_RMSUBFLOW)
834834
__MPTCP_INC_STATS(sock_net(sk), rm_type);
835835
}
@@ -843,7 +843,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
843843
if (!mptcp_pm_is_kernel(msk))
844844
continue;
845845

846-
if (rm_type == MPTCP_MIB_RMADDR) {
846+
if (rm_type == MPTCP_MIB_RMADDR && rm_id &&
847+
!WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) {
848+
/* Note: if the subflow has been closed before, this
849+
* add_addr_accepted counter will not be decremented.
850+
*/
847851
msk->pm.add_addr_accepted--;
848852
WRITE_ONCE(msk->pm.accept_addr, true);
849853
}

0 commit comments

Comments
 (0)