From patchwork Fri Mar 28 04:01:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14031600 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 411A619E98A for ; Fri, 28 Mar 2025 04:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134503; cv=none; b=uBAuda7B+CV91jn8LpxskT56Y/p4v8V8bYc5IyrglkR1h1erXFQ5UO1AO3BuNDPrjIka6cyjxPez9wMnusOtegd6a/cOcnRNLG4ZgkADMG682gE7mVHYGCzk41xJxsylXUTgwr19cKR9ZM2jdTpmMN/P3LaSHFV2ppOhKghPZ7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134503; c=relaxed/simple; bh=opAU8zbreorxWH8gBC0bjMkyESD1mn1JirG02lh2/ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cFP3eduVOV13p4sn7AXaASgEoTw2HJnfMc9QKkLGJYePA3t7mjI7aDimssYdUYnPeehwBezbZe2Mop5VqT/XFChaafd8Cw/EnzyC5x8q22a2NEMcL8u14H2i2ECAx97qpTTb7skG1V4PBsd3mlSRApdzOTfv7LP+kmQTcoa0F18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iVkX0x+1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iVkX0x+1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8155BC4CEE5; Fri, 28 Mar 2025 04:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743134502; bh=opAU8zbreorxWH8gBC0bjMkyESD1mn1JirG02lh2/ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVkX0x+1tcXrI42J9SfQ0GcX3IXiC+TBSD0htQQheADYDrq5KWRaQWo/y66mnaC0F RxMAGLuXqOp8/jzMvQv43TbmL/YJBme/jDgCuhmpYdKQzdUZfCmhRQx157DTkkPTcM lyC3LArrE/VmsVGIlojvaxuouMX3rwzWbfpWH2vjLlVPlMp4GxgSgpVq6byd9aASlj Cwz6AxHLmxfsB1Vkdu07FayC++qmXbPCtDVmtMEsJEhpU1y28s370c7QM+z4YZWe9J LoaBLPiwAwbAwhagyy+s4QqBQFtEEiAvRcqkSEckEmhAxicuCdVYJAFTdTxB6EHhEe VaHwa6ZeoLPbQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 1/5] mptcp: pm: call pm worker handler without pm lock Date: Fri, 28 Mar 2025 12:01:31 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Later functions that cannot hold the mptcp pm lock will be called from the PM worker, so this patch modifies the order of holding the lock at the beginning of this function and releasing the lock at the end. The new order is to obtain a copy of pm->status and clear the flags of pm->status while holding the mptcp pm lock, then read the copy after releasing the lock. For each PM status flag, call each handling function without locks. Finally, hold the lock before calling __mptcp_pm_kernel_worker() and release it afterwards. Rename mptcp_pm_addr_send_ack() with "__" prefix to indicate that the mptcp pm lock is not held. Hold the mptcp pm lock inside mptcp_pm_rm_addr_recv(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 34 ++++++++++++++++++++++------------ net/mptcp/pm_kernel.c | 4 ++-- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index be1e27ee393e..4ed6a2ccb112 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -211,7 +211,7 @@ void mptcp_pm_send_ack(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); } -void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) +void __mptcp_pm_addr_send_ack(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow, *alt = NULL; @@ -238,6 +238,13 @@ void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) mptcp_pm_send_ack(msk, alt, false, false); } +static void mptcp_pm_addr_send_ack(struct mptcp_sock *msk) +{ + spin_lock_bh(&msk->pm.lock); + __mptcp_pm_addr_send_ack(msk); + spin_unlock_bh(&msk->pm.lock); +} + int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk, struct mptcp_addr_info *addr, struct mptcp_addr_info *rem, @@ -437,7 +444,7 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ msk->pm.rm_list_tx = *rm_list; rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL); WRITE_ONCE(msk->pm.addr_signal, rm_addr); - mptcp_pm_addr_send_ack(msk); + __mptcp_pm_addr_send_ack(msk); return 0; } @@ -715,7 +722,9 @@ static void mptcp_pm_rm_addr_or_subflow(struct mptcp_sock *msk, static void mptcp_pm_rm_addr_recv(struct mptcp_sock *msk) { + spin_lock_bh(&msk->pm.lock); mptcp_pm_rm_addr_or_subflow(msk, &msk->pm.rm_list_rx, MPTCP_MIB_RMADDR); + spin_unlock_bh(&msk->pm.lock); } void mptcp_pm_rm_subflow(struct mptcp_sock *msk, @@ -945,6 +954,8 @@ void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) void mptcp_pm_worker(struct mptcp_sock *msk) { + u8 status, mask = BIT(MPTCP_PM_ADD_ADDR_SEND_ACK) | + BIT(MPTCP_PM_RM_ADDR_RECEIVED); struct mptcp_pm_data *pm = &msk->pm; msk_owned_by_me(msk); @@ -952,20 +963,19 @@ void mptcp_pm_worker(struct mptcp_sock *msk) if (!(pm->status & MPTCP_PM_WORK_MASK)) return; - spin_lock_bh(&msk->pm.lock); + spin_lock_bh(&pm->lock); + status = pm->status; + pm->status &= ~mask; + spin_unlock_bh(&pm->lock); - pr_debug("msk=%p status=%x\n", msk, pm->status); - if (pm->status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) { - pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_SEND_ACK); + pr_debug("msk=%p status=%x\n", msk, status); + if (status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) mptcp_pm_addr_send_ack(msk); - } - if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { - pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); + if (status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) mptcp_pm_rm_addr_recv(msk); - } + spin_lock_bh(&pm->lock); __mptcp_pm_kernel_worker(msk); - - spin_unlock_bh(&msk->pm.lock); + spin_unlock_bh(&pm->lock); } static void mptcp_pm_ops_init(struct mptcp_sock *msk, diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 7ec81d5195d4..8935df61aa50 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -326,7 +326,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) local.addr.id = 0; mptcp_pm_announce_addr(msk, &local.addr, false); - mptcp_pm_addr_send_ack(msk); + __mptcp_pm_addr_send_ack(msk); if (local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) signal_and_subflow = true; @@ -460,7 +460,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) remote = msk->pm.remote; mptcp_pm_announce_addr(msk, &remote, true); - mptcp_pm_addr_send_ack(msk); + __mptcp_pm_addr_send_ack(msk); if (lookup_subflow_by_daddr(&msk->conn_list, &remote)) return; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 7fc19b844384..d9b0a93e42f6 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -231,7 +231,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) if (mptcp_pm_alloc_anno_list(msk, &addr_val.addr)) { msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &addr_val.addr, false); - mptcp_pm_addr_send_ack(msk); + __mptcp_pm_addr_send_ack(msk); } spin_unlock_bh(&msk->pm.lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 64aa091cb685..3d51898a2781 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1022,7 +1022,7 @@ void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk); void mptcp_pm_send_ack(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, bool prio, bool backup); -void mptcp_pm_addr_send_ack(struct mptcp_sock *msk); +void __mptcp_pm_addr_send_ack(struct mptcp_sock *msk); void mptcp_pm_nl_rm_addr(struct mptcp_sock *msk, u8 rm_id); void mptcp_pm_rm_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); From patchwork Fri Mar 28 04:01:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14031601 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1377726AC3 for ; Fri, 28 Mar 2025 04:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134505; cv=none; b=kLuJTBdyZmXKHgCmkBpJyAZwha8OMHqi2f0hHN8zc6BY1LwTLkEHTHNbWIyiaSmc60t7UQzyVBLw9zVQTfGk/w8Nl811uzXJPH5y8qZloeVEdK38nTJHrPQ10xFd7nHqysabU/ilZCqyjaNKhcv7j+I9HTAY7VVTV5nZW7GiQBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134505; c=relaxed/simple; bh=RiBbyTjYRJEaIcJbhWn7VLTL4x5wpbkqXseWb7Fg16E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mtF16MvPEyQ1gc4ZClVwBMhMlFEnKyFRQ2pm/kX1SsapQdCtmpHyKldc1W3q9g+AyQKImjzuE7EJ6vE0XScNNSjAzBt1bKOVq+h2NmkSVo1YuuhhO3DNmC5NWkclStvEyqy8Laofhi1jCJCbr1vhUEIUWxsXenKyJ7JMqir0cGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qFhBN2lO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qFhBN2lO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AC58C4CEE4; Fri, 28 Mar 2025 04:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743134504; bh=RiBbyTjYRJEaIcJbhWn7VLTL4x5wpbkqXseWb7Fg16E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFhBN2lOmBhcq/7592wQcdt2HFiH6MWeyuyEi3EsNAJgSHea6bwiKFHQEZf+bbaAh BHO+hNh82JSFXGcuQ6u8kQorZTNBcZ3Nqb5YXa1+Olh5rO+5m6pz00DuB5e/qB64qU MZSb8vQRKATShMHbp0R0Xa2zLD33ogFxRXT6B3vE1caeFETw8qzMYHYzAESE8J/jeE /gQsIFK0y/yH0Sta9peFYBnN6ShYdqqto5RWoWM9DZYh7lPhyHFmvD40/UCZGLmQ7n SnMHX8IbMPJBEbDWgo/gce5aDvIhF7DC9aZc7M7pkwjyXWvqaeLMZJvFl1UN4E86j7 GUzdPsFOBxEnw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 2/5] mptcp: pm: add accept_new_subflow() interface Date: Fri, 28 Mar 2025 12:01:32 +0800 Message-ID: <2c5a2dc15229df637c5523fd63b2b5dd88619615.1743133948.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang The helper mptcp_pm_is_userspace() is used to distinguish userspace PM operations from in-kernel PM in mptcp_can_accept_new_subflow(). It seems reasonable to add a mandatory .accept_new_subflow interface for struct mptcp_pm_ops. The boolean type 'allow' parameter is used to control whether to allow new subflow unconditionally. A new helper mptcp_pm_accept_new_subflow() is added in pm.c to ensure that pm->ops is only used in pm.c. This interface of the in-kernel PM is implemented as a wrapper of READ_ONCE(pm->accept_subflow), and this interface of the userspace PM is implemented as a wrapper of mptcp_userspace_pm_active(). To reduce the dependency on mptcp_pm_is_userspace() to identify userspace PM from in-kernel PM by using mptcp_pm_accept_new_subflow() helper in mptcp_pm_allow_new_subflow(). Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/pm.c | 38 +++++++++++++------------------------- net/mptcp/pm_kernel.c | 16 ++++++++++++++++ net/mptcp/pm_userspace.c | 7 +++++++ net/mptcp/protocol.h | 25 +++++++++++++++++++++++++ net/mptcp/subflow.c | 6 ++---- 6 files changed, 64 insertions(+), 29 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 4cf59e83c1c5..549b8075cc86 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -123,6 +123,7 @@ struct mptcp_pm_ops { struct mptcp_pm_addr_entry *skc); bool (*get_priority)(struct mptcp_sock *msk, struct mptcp_addr_info *skc); + bool (*accept_new_subflow)(struct mptcp_sock *msk, bool allow); char name[MPTCP_PM_NAME_MAX]; struct module *owner; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 4ed6a2ccb112..a96f3495d220 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -460,38 +460,25 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int mptcp_event(MPTCP_EVENT_CREATED, msk, ssk, GFP_ATOMIC); } +bool mptcp_pm_accept_new_subflow(struct mptcp_sock *msk, bool allow) +{ + return msk->pm.ops->accept_new_subflow(msk, allow); +} + bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) { struct mptcp_pm_data *pm = &msk->pm; - unsigned int subflows_max; int ret = 0; - if (mptcp_pm_is_userspace(msk)) { - if (mptcp_userspace_pm_active(msk)) { - spin_lock_bh(&pm->lock); - pm->subflows++; - spin_unlock_bh(&pm->lock); - return true; - } - return false; - } - - subflows_max = mptcp_pm_get_subflows_max(msk); - - pr_debug("msk=%p subflows=%d max=%d allow=%d\n", msk, pm->subflows, - subflows_max, READ_ONCE(pm->accept_subflow)); - - /* try to avoid acquiring the lock below */ - if (!READ_ONCE(pm->accept_subflow)) + if (!mptcp_pm_accept_new_subflow(msk, true)) return false; - spin_lock_bh(&pm->lock); - if (READ_ONCE(pm->accept_subflow)) { - ret = pm->subflows < subflows_max; - if (ret && ++pm->subflows == subflows_max) - WRITE_ONCE(pm->accept_subflow, false); + ret = mptcp_pm_accept_new_subflow(msk, false); + if (ret) { + spin_lock_bh(&pm->lock); + pm->subflows++; + spin_unlock_bh(&pm->lock); } - spin_unlock_bh(&pm->lock); return ret; } @@ -1060,7 +1047,8 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name) int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops) { - if (!pm_ops->get_local_id || !pm_ops->get_priority) { + if (!pm_ops->get_local_id || !pm_ops->get_priority || + !pm_ops->accept_new_subflow) { pr_err("%s does not implement required ops\n", pm_ops->name); return -EINVAL; } diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 8935df61aa50..eaf73c4cedd3 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1399,6 +1399,21 @@ static struct pernet_operations mptcp_pm_pernet_ops = { .size = sizeof(struct pm_nl_pernet), }; +static bool mptcp_pm_kernel_accept_new_subflow(struct mptcp_sock *msk, + bool allow) +{ + bool ret = false; + + if (READ_ONCE(msk->pm.accept_subflow)) { + if (allow) + return true; + + ret = mptcp_pm_accept_subflow(msk); + } + + return ret; +} + static void mptcp_pm_kernel_init(struct mptcp_sock *msk) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -1422,6 +1437,7 @@ static void mptcp_pm_kernel_init(struct mptcp_sock *msk) struct mptcp_pm_ops mptcp_pm_kernel = { .get_local_id = mptcp_pm_kernel_get_local_id, .get_priority = mptcp_pm_kernel_get_priority, + .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index d9b0a93e42f6..31da3b9f4cc8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -683,6 +683,12 @@ int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, return ret; } +static bool mptcp_pm_userspace_accept_new_subflow(struct mptcp_sock *msk, + bool allow) +{ + return mptcp_userspace_pm_active(msk); +} + static void mptcp_pm_userspace_release(struct mptcp_sock *msk) { mptcp_userspace_pm_free_local_addr_list(msk); @@ -691,6 +697,7 @@ static void mptcp_pm_userspace_release(struct mptcp_sock *msk) static struct mptcp_pm_ops mptcp_pm_userspace = { .get_local_id = mptcp_pm_userspace_get_local_id, .get_priority = mptcp_pm_userspace_get_priority, + .accept_new_subflow = mptcp_pm_userspace_accept_new_subflow, .release = mptcp_pm_userspace_release, .name = "userspace", .owner = THIS_MODULE, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3d51898a2781..134b46b53014 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1008,6 +1008,7 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk); void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side); void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk); +bool mptcp_pm_accept_new_subflow(struct mptcp_sock *msk, bool allow); bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk); void mptcp_pm_connection_closed(struct mptcp_sock *msk); void mptcp_pm_subflow_established(struct mptcp_sock *msk); @@ -1184,6 +1185,30 @@ static inline void mptcp_pm_close_subflow(struct mptcp_sock *msk) spin_unlock_bh(&msk->pm.lock); } +static inline bool __mptcp_pm_accept_subflow(struct mptcp_sock *msk) +{ + unsigned int subflows_max = mptcp_pm_get_subflows_max(msk); + struct mptcp_pm_data *pm = &msk->pm; + bool ret; + + ret = pm->subflows < subflows_max; + if (ret && pm->subflows + 1 == subflows_max) + WRITE_ONCE(pm->accept_subflow, false); + + return ret; +} + +static inline bool mptcp_pm_accept_subflow(struct mptcp_sock *msk) +{ + bool ret; + + spin_lock_bh(&msk->pm.lock); + ret = __mptcp_pm_accept_subflow(msk); + spin_unlock_bh(&msk->pm.lock); + + return ret; +} + void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk); static inline struct mptcp_ext *mptcp_get_ext(const struct sk_buff *skb) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 409bd415ef1d..b13a679bdf05 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -58,12 +58,10 @@ static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2, mptcp_crypto_hmac_sha(key1, key2, msg, 8, hmac); } -static bool mptcp_can_accept_new_subflow(const struct mptcp_sock *msk) +static bool mptcp_can_accept_new_subflow(struct mptcp_sock *msk) { return mptcp_is_fully_established((void *)msk) && - ((mptcp_pm_is_userspace(msk) && - mptcp_userspace_pm_active(msk)) || - READ_ONCE(msk->pm.accept_subflow)); + mptcp_pm_accept_new_subflow(msk, true); } /* validate received token and create truncated hmac and nonce for SYN-ACK */ From patchwork Fri Mar 28 04:01:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14031602 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C703426AC3 for ; Fri, 28 Mar 2025 04:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134506; cv=none; b=b+vwXC1pdOF1st/cC83sL8UMhiDQScvGkm1dXCkQ6k1zCqxU1iZzQEooY7lFiBtY2epHYidqcicqok7GbIbOqkRCg51qT4WqmMxQWpdii55IYsghe/Y0v7ztCaLkSBdwANhIvL4rgBVUiLqIB2kKs6G9GpGPhaOyCkaqHICVetU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134506; c=relaxed/simple; bh=2EtNA7J7eLESaeHO7feiQ/6LA0T0qC1i4mXDfY2vKKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MhTvVsYSvCFyBdZVzCsBfJ9F4gqDuFpyNBpwpX0U8i6392zckBh3RoksiyuN7uu96KNHUGr6XSYkS+nTMGK29BujiWVtwAcA1fcfhLy8KmOBJyrPhmxCyXV9Ut5z4oaF8anNFqjx4jkhjE5vEpmc350nUTd76eIkjUukzU2Q2d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iyblzl1+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iyblzl1+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 349DAC4CEE4; Fri, 28 Mar 2025 04:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743134506; bh=2EtNA7J7eLESaeHO7feiQ/6LA0T0qC1i4mXDfY2vKKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iyblzl1+Xw9NaVEu10rIdoj+adJi8vo7NHheko/PHb7lC/dNBEYLQlSYfzYSRrxxV 2MOHQ3eC/7vDmhbha7gTkWDbpVqWIrL3lRTMC44hx4vNkgEQTrnuy8sU+u2USJRTqJ KJ2Yz0itxt5OxFnzXSzGtwHldxyOiJwBeiCMkhesdeolX2xPdsGHHauOwn0ClQuyzO VZAceGtfnTIF2hTomny82PJSra8R/6Vywlaxd8G6d/3LJdhVsvUyuM4UBA6N5qR/gf t1LMqM8XHvmmdCp17LkSwDKTNADzT6L67NWa9UcRvtUVgsIQ8rMkPXK9ELPI1nDh6n CWfi/ejptvKlA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 3/5] mptcp: pm: add established() interface Date: Fri, 28 Mar 2025 12:01:33 +0800 Message-ID: <99ed8e044c089127c478d8689ed41091a761c306.1743133948.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch adds a .established interface for struct mptcp_pm_ops, and calls pm->ops->established in from mptcp_pm_worker(). Then get rid of the corresponding code from __mptcp_pm_kernel_worker(). Since mptcp_pm_addr_send_ack() is a sleepable kfunc, which is invoked by mptcp_pm_create_subflow_or_signal_addr(), .established() interface of BPF PM should be invoked by __bpf_prog_enter_sleepable(), which can't be invoked under a lock. This patch unlocks the pm lock before invoking this interface in mptcp_pm_worker(), while holding this lock in mptcp_pm_kernel_established(). Add a helper to call mptcp_pm_create_subflow_or_signal_addr() while holding mptcp pm lock, and rename the original one with "__" prefix. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 +++ net/mptcp/pm.c | 8 ++++++-- net/mptcp/pm_kernel.c | 22 +++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 549b8075cc86..97a237c9bfe0 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -125,6 +125,9 @@ struct mptcp_pm_ops { struct mptcp_addr_info *skc); bool (*accept_new_subflow)(struct mptcp_sock *msk, bool allow); + /* optional, call from the msk context */ + void (*established)(struct mptcp_sock *msk); + char name[MPTCP_PM_NAME_MAX]; struct module *owner; struct list_head list; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index a96f3495d220..e7b3600239e0 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -513,7 +513,8 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk) * be sure to serve this event only once. */ if (READ_ONCE(pm->work_pending) && - !(pm->status & BIT(MPTCP_PM_ALREADY_ESTABLISHED))) + !(pm->status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) && + pm->ops->established) mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED); if ((pm->status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0) @@ -942,7 +943,8 @@ void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) void mptcp_pm_worker(struct mptcp_sock *msk) { u8 status, mask = BIT(MPTCP_PM_ADD_ADDR_SEND_ACK) | - BIT(MPTCP_PM_RM_ADDR_RECEIVED); + BIT(MPTCP_PM_RM_ADDR_RECEIVED) | + BIT(MPTCP_PM_ESTABLISHED); struct mptcp_pm_data *pm = &msk->pm; msk_owned_by_me(msk); @@ -960,6 +962,8 @@ void mptcp_pm_worker(struct mptcp_sock *msk) mptcp_pm_addr_send_ack(msk); if (status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) mptcp_pm_rm_addr_recv(msk); + if (status & BIT(MPTCP_PM_ESTABLISHED)) + pm->ops->established(msk); spin_lock_bh(&pm->lock); __mptcp_pm_kernel_worker(msk); spin_unlock_bh(&pm->lock); diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index eaf73c4cedd3..31794193442d 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -253,7 +253,7 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info) return NULL; } -static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) +static void __mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) { struct sock *sk = (struct sock *)msk; unsigned int add_addr_signal_max; @@ -367,14 +367,21 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) mptcp_pm_nl_check_work_pending(msk); } -static void mptcp_pm_nl_fully_established(struct mptcp_sock *msk) +static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) +{ + spin_lock_bh(&msk->pm.lock); + __mptcp_pm_create_subflow_or_signal_addr(msk); + spin_unlock_bh(&msk->pm.lock); +} + +static void mptcp_pm_kernel_established(struct mptcp_sock *msk) { mptcp_pm_create_subflow_or_signal_addr(msk); } static void mptcp_pm_nl_subflow_established(struct mptcp_sock *msk) { - mptcp_pm_create_subflow_or_signal_addr(msk); + __mptcp_pm_create_subflow_or_signal_addr(msk); } /* Fill all the local addresses into the array addrs[], @@ -758,7 +765,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net, spin_lock_bh(&msk->pm.lock); if (mptcp_addresses_equal(addr, &mpc_addr, addr->port)) msk->mpc_endpoint_id = addr->id; - mptcp_pm_create_subflow_or_signal_addr(msk); + __mptcp_pm_create_subflow_or_signal_addr(msk); spin_unlock_bh(&msk->pm.lock); release_sock(sk); @@ -1243,7 +1250,7 @@ static void mptcp_pm_nl_fullmesh(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); mptcp_pm_rm_subflow(msk, &list); __mark_subflow_endp_available(msk, list.ids[0]); - mptcp_pm_create_subflow_or_signal_addr(msk); + __mptcp_pm_create_subflow_or_signal_addr(msk); spin_unlock_bh(&msk->pm.lock); } @@ -1348,10 +1355,6 @@ void __mptcp_pm_kernel_worker(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED); mptcp_pm_nl_add_addr_received(msk); } - if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { - pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); - mptcp_pm_nl_fully_established(msk); - } if (pm->status & BIT(MPTCP_PM_SUBFLOW_ESTABLISHED)) { pm->status &= ~BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); mptcp_pm_nl_subflow_established(msk); @@ -1438,6 +1441,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .get_local_id = mptcp_pm_kernel_get_local_id, .get_priority = mptcp_pm_kernel_get_priority, .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, + .established = mptcp_pm_kernel_established, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, From patchwork Fri Mar 28 04:01:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14031603 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F3F726AC3 for ; Fri, 28 Mar 2025 04:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134508; cv=none; b=uZx8BACqbimTxdjWY3mznkXaTQlIOq1nt0mHfCt5FEERqRCw58ISATgM0nkRm1UCUHwOXAIx2e0GJ8ExVdXrNgWMIWuGKMS1KtCmIdwiM+5sC520DvelSGwc+39c2YmgCkhwq6WMKpXly11zpiJusmodHgYXzLwE9dcC/q/72CQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134508; c=relaxed/simple; bh=GND6xI2k5Hk4P2tk8pnyQ8Xkg2Ozs7rdtaOXxFuNR+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8K67h3XVvZatRoj9FzglsxeFzxTH5C4aiL6L+FsAKAIz9dECADcwzmf9ef2WwsNNpZIueyx2z3H4G/45kEIMgqcJ5PolSO4MUxRuhSOMvEZr9j6Zgb9vY2AomH7NsJvmclsaHVAHokF1a+FP7XQaYvNLrTWRhBAAh1xHwWOqpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZfhKKt6c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZfhKKt6c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA1E3C4CEE4; Fri, 28 Mar 2025 04:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743134507; bh=GND6xI2k5Hk4P2tk8pnyQ8Xkg2Ozs7rdtaOXxFuNR+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZfhKKt6cDmYKisL72oBQX2Dlh0UxAXOWTBR5UiF33nElcSgMjMYi22BIy0jRI5yxD bvpkcKGU0fpcT36wGrJ2hP/c4yDnxaXTsiPGqlwAXl+Vw5cMgRMnGwIyfatGspC9I3 TW5GBcL6Mp1l4kJG5h0nt4BwcPFyPUtFFoda77i+nQscAa0XOcrc4tEA724WM3ua6p 8cCfUoVAczhTnsNjZZakuD4VvcaVNnCtJNc6Hi0fyn55nMUK1iquE2B2jQ6FgiRt0T VR1XBUUp6qwVr6em1fqgdrF2knTzTKEiu34XNpNLBwzDt2iHkWGNRiO2/uS0J9y0tJ e0EV7iGiJNoKQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 4/5] mptcp: pm: add subflow_established() interface Date: Fri, 28 Mar 2025 12:01:34 +0800 Message-ID: <2b2ca63b7c3e1bcb42af404ca3b7203b4ff946bb.1743133948.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch adds a .subflow_established interface for struct mptcp_pm_ops, and calls pm->ops->subflow_established in from mptcp_pm_worker(). Then get rid of the corresponding code from __mptcp_pm_kernel_worker(). Since mptcp_pm_addr_send_ack() is a sleepable kfunc, which is invoked by mptcp_pm_create_subflow_or_signal_addr(), .subflow_established() interface of BPF PM should be invoked by __bpf_prog_enter_sleepable(), which can't be invoked under a lock. This patch unlocks the pm lock before invoking this interface in mptcp_pm_worker(), while holding this lock in mptcp_pm_kernel_subflow_established(). Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/pm.c | 12 ++++++++---- net/mptcp/pm_kernel.c | 9 +++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 97a237c9bfe0..1eae68c9e662 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -127,6 +127,7 @@ struct mptcp_pm_ops { /* optional, call from the msk context */ void (*established)(struct mptcp_sock *msk); + void (*subflow_established)(struct mptcp_sock *msk); char name[MPTCP_PM_NAME_MAX]; struct module *owner; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index e7b3600239e0..673313b9b25f 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -541,7 +541,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk) pr_debug("msk=%p\n", msk); - if (!READ_ONCE(pm->work_pending)) + if (!READ_ONCE(pm->work_pending) || !pm->ops->subflow_established) return; spin_lock_bh(&pm->lock); @@ -568,7 +568,8 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, return; } - if (!READ_ONCE(pm->work_pending) && !update_subflows) + if (!pm->ops->subflow_established || + (!READ_ONCE(pm->work_pending) && !update_subflows)) return; spin_lock_bh(&pm->lock); @@ -626,7 +627,7 @@ void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, pr_debug("msk=%p\n", msk); - if (!READ_ONCE(pm->work_pending)) + if (!READ_ONCE(pm->work_pending) || !pm->ops->subflow_established) return; spin_lock_bh(&pm->lock); @@ -944,7 +945,8 @@ void mptcp_pm_worker(struct mptcp_sock *msk) { u8 status, mask = BIT(MPTCP_PM_ADD_ADDR_SEND_ACK) | BIT(MPTCP_PM_RM_ADDR_RECEIVED) | - BIT(MPTCP_PM_ESTABLISHED); + BIT(MPTCP_PM_ESTABLISHED) | + BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); struct mptcp_pm_data *pm = &msk->pm; msk_owned_by_me(msk); @@ -964,6 +966,8 @@ void mptcp_pm_worker(struct mptcp_sock *msk) mptcp_pm_rm_addr_recv(msk); if (status & BIT(MPTCP_PM_ESTABLISHED)) pm->ops->established(msk); + if (status & BIT(MPTCP_PM_SUBFLOW_ESTABLISHED)) + pm->ops->subflow_established(msk); spin_lock_bh(&pm->lock); __mptcp_pm_kernel_worker(msk); spin_unlock_bh(&pm->lock); diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 31794193442d..000f4f173ad5 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -379,9 +379,9 @@ static void mptcp_pm_kernel_established(struct mptcp_sock *msk) mptcp_pm_create_subflow_or_signal_addr(msk); } -static void mptcp_pm_nl_subflow_established(struct mptcp_sock *msk) +static void mptcp_pm_kernel_subflow_established(struct mptcp_sock *msk) { - __mptcp_pm_create_subflow_or_signal_addr(msk); + mptcp_pm_create_subflow_or_signal_addr(msk); } /* Fill all the local addresses into the array addrs[], @@ -1355,10 +1355,6 @@ void __mptcp_pm_kernel_worker(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED); mptcp_pm_nl_add_addr_received(msk); } - if (pm->status & BIT(MPTCP_PM_SUBFLOW_ESTABLISHED)) { - pm->status &= ~BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); - mptcp_pm_nl_subflow_established(msk); - } } static int __net_init pm_nl_init_net(struct net *net) @@ -1442,6 +1438,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .get_priority = mptcp_pm_kernel_get_priority, .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, .established = mptcp_pm_kernel_established, + .subflow_established = mptcp_pm_kernel_subflow_established, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, From patchwork Fri Mar 28 04:01:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14031604 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAAD9153BF0 for ; Fri, 28 Mar 2025 04:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134509; cv=none; b=ODusfLAlKqq8VmC7xP0rQg4vnbWNo2FsxCJtBHortebfo1XX/AxwBiOiFqVBMbHSB3jVe2M8OW1cR/0pJUvu4UlktWnqGreY9hbDJ+UOR3Lr6lAQd7MC4ebK/z1t40f6meO5zBXlSMiJhl5xAHsbH6d90Ron3ZrfVzI42zcbABI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743134509; c=relaxed/simple; bh=CkwURKMR0Xnl/UHcQBVP6kPm2ThnSRWYyXX3JmyyL7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=spIK0goSkrc3DrfUyDdSrC2jBdQZLyst/nwgtU4qTXaQCbn3xA125ygdoBd/sCBc5XsHG29bQVnJg+2vLzP/z5GfGHLSmfC62ITrp9iv6nmEIfIe0wazppGbu8YmuAdnnpl/23VWypfiCIw7qsXtb0sveWvAoy/eowUeZ5drcC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=phL2Cw3b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="phL2Cw3b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 752D7C4CEE4; Fri, 28 Mar 2025 04:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743134509; bh=CkwURKMR0Xnl/UHcQBVP6kPm2ThnSRWYyXX3JmyyL7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=phL2Cw3bPksAhK5XH31yOEjKuy++mCoE4wEMT6lhVytrBEO5tmGSx1/3G4yzaYKbX YTFGxon/AbBAqC87Sc9vCPl81ilSOKQy1vV5HoiFOKQGRvI4KsOTrFX4JuCkVkZmGG A72XcRNPZE6pwvIB02gCo+Tz+wXfa6kxOa1RzHCOmkbPpBWON/jgylxJ2cyE4Sg2DK 6zH2lQmwalwSmJbHGiEd9qhYMoGBtDafQhEqC6/i3WFfnJdJaF03V6BOKpFF6/rYZ2 zvFZM6URhqIAVwDMVtRvsIqkB8LxUdGPIhgVOjyzuDvKJaI2/ijLPHFJK6eYKom4Lo tE5Sc8CVp0JvA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 5/5] mptcp: pm: drop is_userspace in subflow_check_next Date: Fri, 28 Mar 2025 12:01:35 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch moves mptcp_pm_close_subflow() forward to let it be used by both the userspace PM and the in-kernel PM in mptcp_pm_subflow_check_next(). Then mptcp_pm_is_userspace() here can be dropped. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 673313b9b25f..d576b03a64e1 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -559,22 +559,14 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, bool update_subflows; update_subflows = subflow->request_join || subflow->mp_join; - if (mptcp_pm_is_userspace(msk)) { - if (update_subflows) { - spin_lock_bh(&pm->lock); - pm->subflows--; - spin_unlock_bh(&pm->lock); - } - return; - } + if (update_subflows) + mptcp_pm_close_subflow(msk); if (!pm->ops->subflow_established || - (!READ_ONCE(pm->work_pending) && !update_subflows)) + !READ_ONCE(pm->work_pending)) return; spin_lock_bh(&pm->lock); - if (update_subflows) - __mptcp_pm_close_subflow(msk); /* Even if this subflow is not really established, tell the PM to try * to pick the next ones, if possible.