From 4e6834ceebfc55a5245b2056edf4d511791c6202 Mon Sep 17 00:00:00 2001 From: YonglongLi Date: Fri, 24 May 2024 17:44:25 +0800 Subject: [PATCH] mptcp: update add_addr_accepted and accept_add after subflow added receive RM_ADDR will update pm.add_addr_accepted and pm.add_addr_accepted only if remove id match remote id of subflow. so receive ADD_ADDR should update pm.add_addr_accepted and pm.add_addr_accepted after subflow added to conn_list. Fixes: f7d6a237d742 ("mptcp: fix per socket endpoint accounting") Signed-off-by: YonglongLi --- net/mptcp/pm_netlink.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 7f53e022e27ece..fd929b6e815891 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -676,6 +676,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) struct sock *sk = (struct sock *)msk; unsigned int add_addr_accept_max; struct mptcp_addr_info remote; + bool subflow_added = false; unsigned int subflows_max; int i, nr; @@ -704,15 +705,18 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) if (nr == 0) return; - 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); - spin_unlock_bh(&msk->pm.lock); for (i = 0; i < nr; i++) - __mptcp_subflow_connect(sk, &addrs[i], &remote); + if (!__mptcp_subflow_connect(sk, &addrs[i], &remote)) + subflow_added = true; spin_lock_bh(&msk->pm.lock); + + if (subflow_added) { + 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); + } } void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk)