[PATCH mptcp-next 1/2] mptcp: pm: userspace: decrement local_addr_used when remove

Gang Yan <[email protected]> Thu, 23 Jul 2026 17:55:57 +0800
Newsgroups dev.linux.lists.mptcp
Message-ID <[email protected]>
From: Gang Yan <[email protected]>

mptcp_userspace_pm_append_new_local_addr() increments msk->pm.local_addr_used
when a new local address is appended, and mptcp_userspace_pm_delete_local_addr()
decrements it when an entry is removed via the subflow destroy path. The
mptcp_pm_nl_remove_doit() netlink REMOVE_ADDR handler, however, only unlinks
the matching entry from msk->pm.userspace_pm_local_addr_list via
list_del_rcu() without touching the counter, so the counter is not changed every
time userspace removes an address by id.

Decrement msk->pm.local_addr_used under the pm lock right after list_del_rcu(),
mirroring the increment site, so the counter stays in sync with the actual
number of entries left in the list.

Assisted-by: Codex:GLM-5.2
Fixes: 77e4b94a3de6 ("mptcp: update userspace pm infos")
Signed-off-by: Gang Yan <[email protected]>
---
 net/mptcp/pm_userspace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 73094bdbdbf2..6402226a9f0e 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -334,6 +334,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	list_del_rcu(&match->list);
+	msk->pm.local_addr_used--;
 	spin_unlock_bh(&msk->pm.lock);
 
 	mptcp_pm_remove_addr_entry(msk, match);

-- 
2.43.0