]> Git Repo - linux.git/commitdiff
mptcp: pm: only decrement add_addr_accepted for MPJ req
authorMatthieu Baerts (NGI0) <[email protected]>
Mon, 19 Aug 2024 19:45:27 +0000 (21:45 +0200)
committerJakub Kicinski <[email protected]>
Wed, 21 Aug 2024 00:40:13 +0000 (17:40 -0700)
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: d0876b2284cf ("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]>
net/mptcp/pm_netlink.c

index 4cf7cc851f80a5e40f38455f5475e17ae351d443..882781571c7b4a124dfd6480a88ea594ce36bb5f 100644 (file)
@@ -829,7 +829,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
                        mptcp_close_ssk(sk, ssk, subflow);
                        spin_lock_bh(&msk->pm.lock);
 
-                       removed = true;
+                       removed |= subflow->request_join;
                        if (rm_type == MPTCP_MIB_RMSUBFLOW)
                                __MPTCP_INC_STATS(sock_net(sk), rm_type);
                }
@@ -843,7 +843,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
                if (!mptcp_pm_is_kernel(msk))
                        continue;
 
-               if (rm_type == MPTCP_MIB_RMADDR) {
+               if (rm_type == MPTCP_MIB_RMADDR && rm_id &&
+                   !WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) {
+                       /* Note: if the subflow has been closed before, this
+                        * add_addr_accepted counter will not be decremented.
+                        */
                        msk->pm.add_addr_accepted--;
                        WRITE_ONCE(msk->pm.accept_addr, true);
                }
This page took 0.05938 seconds and 4 git commands to generate.