From patchwork Fri Mar 14 02:45:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016164 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 A738E2E3379 for ; Fri, 14 Mar 2025 02:45: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=1741920344; cv=none; b=JsOSuLka8wf0RJOnrIE3+akKw5plPQB+h/THXckEdfu3m45sr8OxuEcxdbCGoKohTgCD9hL2DKmaipNgLSMoE2/fIT+i7LlaeYrcw5/SucGtrdXpc1I+/MRf7L5En7tOfHQezJ3Xeq3AHt7bk/OyeO1zi76Zea9QUXaeiTb1vl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920344; c=relaxed/simple; bh=85ks/A7c17bk/2xpUFa3qFMxjTEYDfN/Hch6nzPeGjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bSHaktKg/xN6T4lk+2XZgcV0N4H2uOcTEACw/NeEXs5u3o/5jpdx+8LCljpqHe6AQkgxa6UzKHNx+5LawqpizfmNBBLtsiFf5tyy7Q4Ra7f2Ns+nyPa1e6IOlj2B3FgAxB0LIvUI4bQlwxOoOyQi6D7RWJdksEy1V2o8RkwF2ZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dORLeh9w; 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="dORLeh9w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8AF4C4CEE9; Fri, 14 Mar 2025 02:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920344; bh=85ks/A7c17bk/2xpUFa3qFMxjTEYDfN/Hch6nzPeGjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dORLeh9w5L4o1gJE+qwY5mAJDUvSQAtYM7Oj4zANWfg/au7LkjBrEh4QSId7ROq7t Kh0wCa7OZAdPiTRIzpI7HEtm1jBzIz1qTpU8ilwwfro07M7oGUfLp08zlNNEFecP6G Hs35CLtQsSVrOZ1aZKa9Pwo5WJIoR8jU/XkR89lWEJbxe7T0QMyoRcn8f6rKS5X1px TupMW4MuTh+y+A5Gdf8xT35BeYgs2EP1jrGEEzrO90QgkNmkw1UhddiX6vVKs1OFB4 8QVXotk53AKteB23wjVmR/dajfFJPly5VtznIFshLhbd+vrL6tH0YAoan41NvIXepJ x79mZ9RMXs3pQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 01/10] mptcp: pm: drop redundant MPTCP_MIB_ADDADDRDROP Date: Fri, 14 Mar 2025 10:45:22 +0800 Message-ID: <7a5ea952636052357b4f10902253a654cf4e29ff.1741919893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 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 MPTCP_MIB_ADDADDRDROP MIB counter is incremented from both the in-kernel PM and the userspace PM. This can be called only once to reduce redundant code. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index ba7424582ebf..4895318b94cc 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -592,6 +592,7 @@ void mptcp_pm_add_addr_received(const struct sock *ssk, struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct mptcp_pm_data *pm = &msk->pm; + int ret = 0; pr_debug("msk=%p remote_id=%d accept=%d\n", msk, addr->id, READ_ONCE(pm->accept_addr)); @@ -605,7 +606,7 @@ void mptcp_pm_add_addr_received(const struct sock *ssk, mptcp_pm_announce_addr(msk, addr, true); mptcp_pm_add_addr_send_ack(msk); } else { - __MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP); + ret = -EINVAL; } /* id0 should not have a different address */ } else if ((addr->id == 0 && !mptcp_pm_is_init_remote_addr(msk, addr)) || @@ -615,9 +616,12 @@ void mptcp_pm_add_addr_received(const struct sock *ssk, } else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) { pm->remote = *addr; } else { - __MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP); + ret = -EINVAL; } + if (ret) + __MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP); + spin_unlock_bh(&pm->lock); } From patchwork Fri Mar 14 02:45:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016165 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 04B972E3379 for ; Fri, 14 Mar 2025 02:45: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=1741920347; cv=none; b=U/1JnWULvun8J4rJ6bb4KSYQxWkV0G+gce7pm2x5+DcRfXsMEC4VrpusDGgllxTZxkx23ZT/R5ezQ1JmlsO7jnzw6JLoTZzwpGtZHcCmIWbWEirxSorYuX+Zo6+lKppDlq0jL45SYJXWTIXn/w6yTSqP9Dzfd3h23xtf3s5Mps4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920347; c=relaxed/simple; bh=jxN6Jp3cF7jlyth5tUdvMOCnefAqTq9+QLNcAbbt8W0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+6VDCxWpveujk5jURWj9UKPNTcFan8lkTcZyq0gOxy0AwNsQicvkw1f+OL+/cHV/iMWEtYXombqDVrnbWe820y5A303t5g/Ul3I+rdn2TjV6lIqhoKAIPCP3cZuRi4CmQ4l42XEDbtXpnzjXWdNIvFEe42BVSnBmwsfjGfsL5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MpuXFzFV; 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="MpuXFzFV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED2AEC4CEEA; Fri, 14 Mar 2025 02:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920346; bh=jxN6Jp3cF7jlyth5tUdvMOCnefAqTq9+QLNcAbbt8W0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpuXFzFVTxbV/KXiUvV/i9xU0XZ6HmIg2U5L29Z2F/zoou6cadbfwK6LcXQ0Fg+qe cTLLDbd22TfMRvZvafi/cgF+lvPBFt9egPkZKdvH8q0uWJL2oSJA30/uPjGu0DK54J cKeNy1LBRBLjTj/aLXGsnPv+7e6+24fPbGdOAuKaMJtQXce3iLzr6KwR1a4SXKFUW1 vP3CLr3ZEe38kZeHiNTOi+8bEzhFNEAm9J6FckZPO0F+k5DX3+TflAchQcTmMQcDLG xSSL7r7+B+sqK0884kWvlSMdnkLzqQUijCv+9s8aj++rNk2H6htJsFo6LBx93CcKv0 3EjM2L7M3OQWQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 02/10] Squash to "mptcp: pm: add get_local_id() interface" Date: Fri, 14 Mar 2025 10:45:23 +0800 Message-ID: <37165e0d3996fa182e40c743c1b9f5575b38998a.1741919893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 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 Add /* required */ comment for get_local_id and get_priority. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 6a08ac862bbe..9f28ef550e10 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -118,6 +118,7 @@ struct mptcp_sched_ops { #define MPTCP_PM_BUF_MAX (MPTCP_PM_NAME_MAX * MPTCP_PM_MAX) struct mptcp_pm_ops { + /* required */ int (*get_local_id)(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *skc); bool (*get_priority)(struct mptcp_sock *msk, From patchwork Fri Mar 14 02:45:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016166 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 5D3332E3379 for ; Fri, 14 Mar 2025 02:45: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=1741920349; cv=none; b=u0iUaVxiGxKMx1a/G3IJ+8fbITISGn3+DPyjKE85vzUx17kulQF+CDko/6gSRYaH93dV1Y5BQQwKGsfpoX4E5k99OG/GLF8Y+vD5nPZOAQCetWGAPYWs0Hk6wWxMBJbPBobEbUmo/D3Q/MaU3dTVmUHrnrXvOGb65VqAiQgO/SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920349; c=relaxed/simple; bh=e6aDsMwhZ7jauxMmgnbg78UWu4GVVhFJ3Mq6QPfwqcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S68Uc5YhvDLRRSEuKeAUDRGPREi2ZEXmCiZsClhfJpgz61/owhbVdf+Fnmf6jftOSZb/9zrobLsMdYDENuykQlZzB2QGpS72UoYClbUEYUhbah+WE3vqAbtQtjqDfxYkIE2cD4il/Yr1n/i9nUAB79qkKXBK0lVmRubpOLmvEOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kmFVEXkN; 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="kmFVEXkN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44BF0C4CEDD; Fri, 14 Mar 2025 02:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920348; bh=e6aDsMwhZ7jauxMmgnbg78UWu4GVVhFJ3Mq6QPfwqcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kmFVEXkNbJAk+3M0DTZV4aByYOMV5SExFXDbhwt77IkQhH6EiFfvYnoNvbYlG9Rr5 XACme3zddWHkLwKchgA4BzUfXXiabXeOMG18Rm4gKtbD7I+ztlihpPgSEbGrBfHhiR NlCMIvBzKiew0mWOW5qtvhtUwrQuON0IaDHLVC7aPZEaA4gQzYRVet2PBJOjjs/AfQ cHI3udXi+Y5tkxDW//adCGIxZ+JR105r24MVOGGvzHuU25ONv8Q5kiZAChfUIM/wAM /bPh2ZcFY9mY4lMn5N6z2hwwXv/5+8ShCHOzzFMmjZIXAf4KBHVnNVTsfBfuNd24M0 6IZ+sxsXlgS8g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 03/10] mptcp: pm: add established() interface Date: Fri, 14 Mar 2025 10:45:24 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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(). Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 +++ net/mptcp/pm.c | 7 ++++++- net/mptcp/pm_kernel.c | 7 ++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 9f28ef550e10..d7410f08399e 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -124,6 +124,9 @@ struct mptcp_pm_ops { bool (*get_priority)(struct mptcp_sock *msk, struct mptcp_addr_info *skc); + /* optional */ + 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 4895318b94cc..3dcece1c6fef 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -516,7 +516,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) @@ -964,6 +965,10 @@ void mptcp_pm_worker(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); mptcp_pm_rm_addr_recv(msk); } + if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { + pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); + pm->ops->established(msk); + } __mptcp_pm_kernel_worker(msk); spin_unlock_bh(&msk->pm.lock); diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 7ec81d5195d4..1234066b5bcc 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -367,7 +367,7 @@ 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_kernel_established(struct mptcp_sock *msk) { mptcp_pm_create_subflow_or_signal_addr(msk); } @@ -1348,10 +1348,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); @@ -1422,6 +1418,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, + .established = mptcp_pm_kernel_established, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, From patchwork Fri Mar 14 02:45:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016167 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 C0F8FF510 for ; Fri, 14 Mar 2025 02:45:51 +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=1741920351; cv=none; b=f3OBqrAZMqlmTtbcYK2BRJ906KicScg7+l40+F+ZG87+4Kkd+9TmQGmQjRnJcQdEH/NGB2Z6AoMOz72MLccaKqs2/jcOXYnTv/fi6rVuOY+MNRL1AYA1690INZSuPV7rSFzhOhVfZFWmZTEx669K+EW1SRRI4JdC/b5+3gQz5Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920351; c=relaxed/simple; bh=/LNGkYJzR2zeuvw9HwZoU4iTrqekQ2ciCtreeh80hQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kqH4ELAOHPREpctcNP+93Dtb0r0NZ6ZAktjIqgyjGs6HIuFGzUH62VUY7L5xPz4t8ZfMKrUxw/lir3WA/xrvSDA0/j27JPXR0Uri1RQkKNPeMHTCpsIjrNdxoPMIoM8ySXxMZtJ08KQ2UmwzZKgGxrirbICOeTN82ThDsWZMNP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NaJNMXKR; 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="NaJNMXKR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFE96C4AF09; Fri, 14 Mar 2025 02:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920351; bh=/LNGkYJzR2zeuvw9HwZoU4iTrqekQ2ciCtreeh80hQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NaJNMXKR3RD8aQHENMs3Lw+LsGZK/nXshtbzepPUmiZY64qnVnbKDPyQATwJfESOQ bf5v6mLUg5w4jAA69ejhTmIHtJmkoC/RgljP6/0kecKpVm07wjqg/D3PELuY5tHRAM KKTUFMKmbT5N0uT4p7nObYlvt4dNKGp+b2AKTghBI5edgGFw49+yE+1mu74fuY421T 6pL/TRmTwOnIEtfRN/38p1LZekBSIugRqVFbJcIlPyHo56dGFRmV2T03AV7Y1zv8lb S5KbGmpIDElRhX2WWcHBRtV6L7H60HCv5IGOkBofcuah6BM1R5jlyzk0QRByIuhbUY zZjMvpxdMQHJQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 04/10] mptcp: pm: add subflow_established() interface Date: Fri, 14 Mar 2025 10:45:25 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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(). Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/pm.c | 11 +++++++++-- net/mptcp/pm_kernel.c | 7 ++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index d7410f08399e..4ac936e4ce0d 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -126,6 +126,7 @@ struct mptcp_pm_ops { /* optional */ 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 3dcece1c6fef..b90134152b92 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -544,7 +544,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); @@ -571,6 +571,9 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, return; } + if (!pm->ops->subflow_established) + return; + if (!READ_ONCE(pm->work_pending) && !update_subflows) return; @@ -633,7 +636,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); @@ -969,6 +972,10 @@ void mptcp_pm_worker(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); pm->ops->established(msk); } + if (pm->status & BIT(MPTCP_PM_SUBFLOW_ESTABLISHED)) { + pm->status &= ~BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); + pm->ops->subflow_established(msk); + } __mptcp_pm_kernel_worker(msk); spin_unlock_bh(&msk->pm.lock); diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 1234066b5bcc..e21fefc0aca9 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -372,7 +372,7 @@ 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); } @@ -1348,10 +1348,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) @@ -1419,6 +1415,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .get_local_id = mptcp_pm_kernel_get_local_id, .get_priority = mptcp_pm_kernel_get_priority, .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 14 02:45:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016168 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 BA0CE7DA93 for ; Fri, 14 Mar 2025 02:45:54 +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=1741920355; cv=none; b=e8IdUpTyF7kiHuH2mdIOhZgK7K3bajYmK2z7O1zY+y7I82bVVXot1ZpjMK2nLG0kuMPZJ1k7goEc4SayyPa1ExyQ6hJU0V+W4YQReHPpAZp8vq651Byenwd4nj4hemMpxOAOy6xMkMZCnZst3ZBUZLieUCYs9DuO2j//S2CB8Sc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920355; c=relaxed/simple; bh=ZvJRU5Tzt99gW3U083XEXzYShqgCON9fSS6JBdZMlms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pj9i21Lu3OgPkm+qkFYQhYOJZdFF++9ZTScY8j/fVe5LtQsSGfDSvWh2HyRizFIs4VX6jQ3P3onp76v6mpPhihDlP7o8bIRtAAuVQvdZ+NM/nKfpM2pyRzDffK06IR7YKl036bXXC5S2pYDgxKPk3ZYVJactj9iDuMWgMCvdZeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Spvhkij1; 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="Spvhkij1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C14C4CEEE; Fri, 14 Mar 2025 02:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920354; bh=ZvJRU5Tzt99gW3U083XEXzYShqgCON9fSS6JBdZMlms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Spvhkij18vvc9i/8VvsuEVJqGZoiVesEeQYEXTJ2mhx9+V5wCfugkXH4ZtH5aJu8k 4nw5TXpGCoERBVmDf1rMRtGduUsEeMd+fQsueYPuZOIeg1p9NzrnGJSnnqg4ERzOSF kShrCY+rXSwibMvyhmkyh0KII4Rkhrhz5dcOyEcYbxmZ+HDbwQiAVA0QLuBI84bRpG yAquh2BgfoFgQ1owdfZJ2o2lHMf7P5jde+bqg6x0uFofbdwr2TFcN9fZ0au23SE1+5 MrEdsrpT5h0U4gYyVankMxxKnRYF62ns2cheIkJaJLL4o6gpKT4K7jzkvgQnR1rbVg brEqu7VnyxebA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 05/10] mptcp: pm: add allow_new_subflow() interface Date: Fri, 14 Mar 2025 10:45:26 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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_pm_allow_new_subflow(). It seems reasonable to add a mandatory .allow_new_subflow interface for struct mptcp_pm_ops. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 3 +++ net/mptcp/pm.c | 36 +++--------------------------------- net/mptcp/pm_kernel.c | 27 +++++++++++++++++++++++++++ net/mptcp/pm_userspace.c | 14 ++++++++++++++ 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 4ac936e4ce0d..e15d6b5680f6 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -128,6 +128,9 @@ struct mptcp_pm_ops { void (*established)(struct mptcp_sock *msk); void (*subflow_established)(struct mptcp_sock *msk); + /* required */ + bool (*allow_new_subflow)(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 b90134152b92..03152a1a157e 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -452,38 +452,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int 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)) - 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); - } - spin_unlock_bh(&pm->lock); - - return ret; + return msk->pm.ops->allow_new_subflow(msk); } /* return true if the new status bit is currently cleared, that is, this event @@ -1063,7 +1032,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->allow_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 e21fefc0aca9..eb498b17e67f 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1391,6 +1391,32 @@ static struct pernet_operations mptcp_pm_pernet_ops = { .size = sizeof(struct pm_nl_pernet), }; +static bool mptcp_pm_kernel_allow_new_subflow(struct mptcp_sock *msk) +{ + struct mptcp_pm_data *pm = &msk->pm; + unsigned int subflows_max; + int ret = 0; + + 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)) + 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); + } + spin_unlock_bh(&pm->lock); + + return ret; +} + static void mptcp_pm_kernel_init(struct mptcp_sock *msk) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -1416,6 +1442,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .get_priority = mptcp_pm_kernel_get_priority, .established = mptcp_pm_kernel_established, .subflow_established = mptcp_pm_kernel_subflow_established, + .allow_new_subflow = mptcp_pm_kernel_allow_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 7fc19b844384..3a9962ac77b2 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -683,6 +683,19 @@ int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, return ret; } +static bool mptcp_pm_userspace_allow_new_subflow(struct mptcp_sock *msk) +{ + struct mptcp_pm_data *pm = &msk->pm; + + if (mptcp_userspace_pm_active(msk)) { + spin_lock_bh(&pm->lock); + pm->subflows++; + spin_unlock_bh(&pm->lock); + return true; + } + return false; +} + static void mptcp_pm_userspace_release(struct mptcp_sock *msk) { mptcp_userspace_pm_free_local_addr_list(msk); @@ -691,6 +704,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, + .allow_new_subflow = mptcp_pm_userspace_allow_new_subflow, .release = mptcp_pm_userspace_release, .name = "userspace", .owner = THIS_MODULE, From patchwork Fri Mar 14 02:45:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016169 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 3D5B182C60 for ; Fri, 14 Mar 2025 02:45:56 +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=1741920356; cv=none; b=bAExpS2XVTJUtwEqlMinAzZGqIPNauMSnUVXvx/w7NSenoa0YyJGOwQdkXfYYlmKirz2CyzZXojFRXwL6ICmEp6RkfGB29MHOgd0ao8QdDdQBx2PbtqFgA/+zp01fsh4DbCq6yYYvOwTnF+FN0I/qYRZLfZbFDIoSuaADdAnor8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920356; c=relaxed/simple; bh=n55XM3TVAxG2MrcD3UvQHSj7BM32SHOwLVwPts6bc10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nBEtDBOuDOCjIggw6TTHTthI/iLaxyYnYUZ593oBUs7QWy9zrEwHHbECXgf34kxas/YUFo5wkE8pllgTdAITirW5kTF+V9/25zfy7CSmKfhW3wcKDY6NC3lTtdlpZiUn2Pp1GDJtIqXVzJ4Tq1hJ4XZ7v7kNwDaExKRvLOKcfAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZCDNmHZw; 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="ZCDNmHZw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAB9DC4CEEA; Fri, 14 Mar 2025 02:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920356; bh=n55XM3TVAxG2MrcD3UvQHSj7BM32SHOwLVwPts6bc10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZCDNmHZwa4zwnNMbz15she8ly9WVwWnSRJML82xsK5qmgj2erY/pUQglncGa/PMLv AsD08xe/2osB+8AgiUEg64Nv6+JgG/lNpTTT+kBLsDpY8NkGPJ8lnaFHowWsxlxE/0 jqqt34J5tzanBuw4MS7fa40TvFhQOcaUKBYZl/MmfuvWoJk6xmc875r9eBSB0rk1om bDJUw7N9BOps9OoaYM35cByoK85OHHYf+CxCw4SLIsP13b2iCYctVyE7DgcG0ZoSSE pa2YNKrmGsB1/jFficbfYgymkG9QwsEamttI4gsbPo+CtCcNU9APIBcNM62Zj5HbGQ gZRsqrLazaCHg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 06/10] mptcp: pm: add accept_new_subflow() interface Date: Fri, 14 Mar 2025 10:45:27 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/pm.c | 2 +- net/mptcp/pm_kernel.c | 6 ++++++ net/mptcp/pm_userspace.c | 6 ++++++ net/mptcp/subflow.c | 4 +--- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index e15d6b5680f6..de9838ea37c4 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -130,6 +130,7 @@ struct mptcp_pm_ops { /* required */ bool (*allow_new_subflow)(struct mptcp_sock *msk); + bool (*accept_new_subflow)(const 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 03152a1a157e..7ae706669c80 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -1033,7 +1033,7 @@ 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 || - !pm_ops->allow_new_subflow) { + !pm_ops->allow_new_subflow || !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 eb498b17e67f..38542d62767d 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1417,6 +1417,11 @@ static bool mptcp_pm_kernel_allow_new_subflow(struct mptcp_sock *msk) return ret; } +static bool mptcp_pm_kernel_accept_new_subflow(const struct mptcp_sock *msk) +{ + return READ_ONCE(msk->pm.accept_subflow); +} + static void mptcp_pm_kernel_init(struct mptcp_sock *msk) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -1443,6 +1448,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .established = mptcp_pm_kernel_established, .subflow_established = mptcp_pm_kernel_subflow_established, .allow_new_subflow = mptcp_pm_kernel_allow_new_subflow, + .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 3a9962ac77b2..4cd9a84477c8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -696,6 +696,11 @@ static bool mptcp_pm_userspace_allow_new_subflow(struct mptcp_sock *msk) return false; } +static bool mptcp_pm_userspace_accept_new_subflow(const struct mptcp_sock *msk) +{ + return mptcp_userspace_pm_active(msk); +} + static void mptcp_pm_userspace_release(struct mptcp_sock *msk) { mptcp_userspace_pm_free_local_addr_list(msk); @@ -705,6 +710,7 @@ static struct mptcp_pm_ops mptcp_pm_userspace = { .get_local_id = mptcp_pm_userspace_get_local_id, .get_priority = mptcp_pm_userspace_get_priority, .allow_new_subflow = mptcp_pm_userspace_allow_new_subflow, + .accept_new_subflow = mptcp_pm_userspace_accept_new_subflow, .release = mptcp_pm_userspace_release, .name = "userspace", .owner = THIS_MODULE, diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index efe8d86496db..defef7aa5b28 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -61,9 +61,7 @@ static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2, static bool mptcp_can_accept_new_subflow(const 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)); + msk->pm.ops->accept_new_subflow(msk); } /* validate received token and create truncated hmac and nonce for SYN-ACK */ From patchwork Fri Mar 14 02:45:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016170 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 52E782AF19 for ; Fri, 14 Mar 2025 02:45:58 +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=1741920358; cv=none; b=Pug/uCf24ESjzYfeYaWfQUq6f9NASUb1maNIm6NEn1wRx815UJNdV+01wtdJ1NDydjiBNwo1mZFln5YtQJwHPq+p2rk8jt5lQhvC7sodV0US4+7PSPNrwLMyYquZufv4nyMEBaZDJUkffwqKwOpAyPO5WMHO+o8pML7ZMqCYgxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920358; c=relaxed/simple; bh=ubu6yVYvrAY1v0Xmrs2obxU2nU7RAEMVb1catBGiU8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pBOLSlBms70d6CxrOrgzW+/HHvbGhj12U3lXgK1/LCSYIS0CCWn82w4R0MYjoxR15NdG+8/KuZJcNCVNAjzxjwKvQsWZkzpTQs+7T+wE4M4gBAm0YXzQmcoS8G6L/9Ue/vlQ/KWOFzTMaZ8NCcMy5A3RgShOKhkWtmy3zSTGLw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hAIDh1yo; 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="hAIDh1yo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE98CC4CEDD; Fri, 14 Mar 2025 02:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920358; bh=ubu6yVYvrAY1v0Xmrs2obxU2nU7RAEMVb1catBGiU8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAIDh1yoLPr5ZW+cCa9+JEpwRAgIMow6wJlIdAsMJelxavKZ0CLzvcG7fSzfgXQOW lwzhMQyF492FwG6BN/DDbhGxw337GS07uPvngm10fOvIXdlVcAcXqKzw79i8n6yokc +zMLKIx/QsSGnZhyzH3IK50icgE6NGjg9rgXlT2c/VH91NykBSjBVKaonEmAd58dA5 cVhiSzi33vl2/A2PuItD35QZbtc82v0tam1iqYFxJMeLTqCX04IPBJUK51VOX0Q068 P7lVGoEdH1tc6OrLdIjCCy05YxyWVIun8tI3cZ7DL3nfBIX4TQRSa89zblf9LiXqJk K2DfQSEYyJ17g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 07/10] mptcp: pm: add add_addr_received() interface Date: Fri, 14 Mar 2025 10:45:28 +0800 Message-ID: <98316342c985b097b352535a53a2b00c0788580e.1741919893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 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 an optional .add_addr_received interface for struct mptcp_pm_ops and invokes it in mptcp_pm_add_addr_received(). A new helper mptcp_pm_add_addr_recv() is added to allow the MPTCP_PM_ADD_ADDR_RECEIVED worker can be invoke from the in-kernel PM. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 4 ++++ net/mptcp/pm.c | 10 +++++++--- net/mptcp/pm_kernel.c | 12 ++++++++++++ net/mptcp/protocol.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index de9838ea37c4..37a84b4c661e 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -132,6 +132,10 @@ struct mptcp_pm_ops { bool (*allow_new_subflow)(struct mptcp_sock *msk); bool (*accept_new_subflow)(const struct mptcp_sock *msk); + /* optional */ + int (*add_addr_received)(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr); + 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 7ae706669c80..522dd2df4097 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -559,6 +559,11 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, spin_unlock_bh(&pm->lock); } +bool mptcp_pm_add_addr_recv(struct mptcp_sock *msk) +{ + return mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED); +} + void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr) { @@ -586,10 +591,9 @@ void mptcp_pm_add_addr_received(const struct sock *ssk, (addr->id > 0 && !READ_ONCE(pm->accept_addr))) { mptcp_pm_announce_addr(msk, addr, true); mptcp_pm_add_addr_send_ack(msk); - } else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) { - pm->remote = *addr; } else { - ret = -EINVAL; + ret = pm->ops->add_addr_received ? + pm->ops->add_addr_received(msk, addr) : -EINVAL; } if (ret) diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 38542d62767d..6a5d6d374b0d 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1422,6 +1422,17 @@ static bool mptcp_pm_kernel_accept_new_subflow(const struct mptcp_sock *msk) return READ_ONCE(msk->pm.accept_subflow); } +static int mptcp_pm_kernel_add_addr_received(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr) +{ + if (mptcp_pm_add_addr_recv(msk)) { + msk->pm.remote = *addr; + return 0; + } + + return -EINVAL; +} + static void mptcp_pm_kernel_init(struct mptcp_sock *msk) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -1449,6 +1460,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .subflow_established = mptcp_pm_kernel_subflow_established, .allow_new_subflow = mptcp_pm_kernel_allow_new_subflow, .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, + .add_addr_received = mptcp_pm_kernel_add_addr_received, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d9ca3a19a218..d65fe3748427 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1013,6 +1013,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk); bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk); void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct mptcp_subflow_context *subflow); +bool mptcp_pm_add_addr_recv(struct mptcp_sock *msk); void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr); void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, From patchwork Fri Mar 14 02:45:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016171 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 897195223 for ; Fri, 14 Mar 2025 02:46:00 +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=1741920360; cv=none; b=fk4YyUnFEiaDQwel0k5HLJGWDhKSzmKL6h2W4EESs+IqDys/czTQ/HY3acgD9dsayebgrCihdJN32oiMzGQZFRlNTjJQVZWX0MHg/JGASPeBnCyw3hW4/CpIRRH93JETf7ZkLh4LzVBEyckTqW0fQNPmrXlM4iu5nOCFiHwlF84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920360; c=relaxed/simple; bh=uqYM/HF/uxFQ+yf3qc7k3oTxKmA8Y++BMczq9BRoGGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FLdmgg5FFRKmVnNIpRhyK2EljyIpApz1tg2QV8NC5HLIjRqF8O5gBrtSAZXuKBhB0SBtm1DvCwDxc3nia2UthMz9QjL5lzYiDKBRlVQKJ8p93JRph248zk0W1DXH7j4KHAFobFbWRXgBtMgYj3InPOGHsTuEv8Z/eq1wksndmSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mlijyGF9; 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="mlijyGF9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECBDEC4CEEE; Fri, 14 Mar 2025 02:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920360; bh=uqYM/HF/uxFQ+yf3qc7k3oTxKmA8Y++BMczq9BRoGGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlijyGF9XfH/nWn0GzvhghP12PFQqexK7Gxv4SjgHfCwFQCGXrCHi36o4ZACSLI+a PxcPAOsQemxXfcPTk4LKAQfe/NVkDgtxoEZi5MZ2C37lDPyaP60EDlIRqOkcveYz1+ B3LNa3qBjmSG582bjm7SyGBAlmqjLV93K0losqtjOj/BU5FuwylikYV92HXN0VzVvj NQCPIKSz03qh1cQ8yH+rE6WigjWXiPRBpRkO0Hp7dJCoiKe0by4+iESWvj7mQYLM+Z N7hjNtnAmfsoj4NA5xXqvdX6JNVq/aoxT4qzPXuXggognz20IAISzWWEtNsbqZUKQz YXlHJKVxWBBXw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 08/10] mptcp: pm: add add_addr_echo() interface Date: Fri, 14 Mar 2025 10:45:29 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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_pm_add_addr_received(). It seems reasonable to add a mandatory .add_addr_echo interface for struct mptcp_pm_ops. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 2 ++ net/mptcp/pm.c | 18 +++++------------- net/mptcp/pm_kernel.c | 9 +++++++++ net/mptcp/pm_userspace.c | 7 +++++++ net/mptcp/protocol.h | 2 ++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 37a84b4c661e..90fda6d1468c 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -131,6 +131,8 @@ struct mptcp_pm_ops { /* required */ bool (*allow_new_subflow)(struct mptcp_sock *msk); bool (*accept_new_subflow)(const struct mptcp_sock *msk); + bool (*add_addr_echo)(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr); /* optional */ int (*add_addr_received)(struct mptcp_sock *msk, diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 522dd2df4097..d5cb7c60d177 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -104,8 +104,8 @@ void mptcp_remote_address(const struct sock_common *skc, #endif } -static bool mptcp_pm_is_init_remote_addr(struct mptcp_sock *msk, - const struct mptcp_addr_info *remote) +bool mptcp_pm_is_init_remote_addr(struct mptcp_sock *msk, + const struct mptcp_addr_info *remote) { struct mptcp_addr_info mpc_remote; @@ -579,16 +579,7 @@ void mptcp_pm_add_addr_received(const struct sock *ssk, spin_lock_bh(&pm->lock); - if (mptcp_pm_is_userspace(msk)) { - if (mptcp_userspace_pm_active(msk)) { - mptcp_pm_announce_addr(msk, addr, true); - mptcp_pm_add_addr_send_ack(msk); - } else { - ret = -EINVAL; - } - /* id0 should not have a different address */ - } else if ((addr->id == 0 && !mptcp_pm_is_init_remote_addr(msk, addr)) || - (addr->id > 0 && !READ_ONCE(pm->accept_addr))) { + if (pm->ops->add_addr_echo(msk, addr)) { mptcp_pm_announce_addr(msk, addr, true); mptcp_pm_add_addr_send_ack(msk); } else { @@ -1037,7 +1028,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 || - !pm_ops->allow_new_subflow || !pm_ops->accept_new_subflow) { + !pm_ops->allow_new_subflow || !pm_ops->accept_new_subflow || + !pm_ops->add_addr_echo) { 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 6a5d6d374b0d..74838e2c66ba 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1422,6 +1422,14 @@ static bool mptcp_pm_kernel_accept_new_subflow(const struct mptcp_sock *msk) return READ_ONCE(msk->pm.accept_subflow); } +static bool mptcp_pm_kernel_add_addr_echo(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr) +{ + /* id0 should not have a different address */ + return (addr->id == 0 && !mptcp_pm_is_init_remote_addr(msk, addr)) || + (addr->id > 0 && !READ_ONCE(msk->pm.accept_addr)); +} + static int mptcp_pm_kernel_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr) { @@ -1460,6 +1468,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .subflow_established = mptcp_pm_kernel_subflow_established, .allow_new_subflow = mptcp_pm_kernel_allow_new_subflow, .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, + .add_addr_echo = mptcp_pm_kernel_add_addr_echo, .add_addr_received = mptcp_pm_kernel_add_addr_received, .init = mptcp_pm_kernel_init, .name = "kernel", diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4cd9a84477c8..6016d5669b9b 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -701,6 +701,12 @@ static bool mptcp_pm_userspace_accept_new_subflow(const struct mptcp_sock *msk) return mptcp_userspace_pm_active(msk); } +static bool mptcp_pm_userspace_add_addr_echo(struct mptcp_sock *msk, + const struct mptcp_addr_info *addr) +{ + return mptcp_userspace_pm_active(msk); +} + static void mptcp_pm_userspace_release(struct mptcp_sock *msk) { mptcp_userspace_pm_free_local_addr_list(msk); @@ -711,6 +717,7 @@ static struct mptcp_pm_ops mptcp_pm_userspace = { .get_priority = mptcp_pm_userspace_get_priority, .allow_new_subflow = mptcp_pm_userspace_allow_new_subflow, .accept_new_subflow = mptcp_pm_userspace_accept_new_subflow, + .add_addr_echo = mptcp_pm_userspace_add_addr_echo, .release = mptcp_pm_userspace_release, .name = "userspace", .owner = THIS_MODULE, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d65fe3748427..8663350fac2f 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1013,6 +1013,8 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk); bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk); void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct mptcp_subflow_context *subflow); +bool mptcp_pm_is_init_remote_addr(struct mptcp_sock *msk, + const struct mptcp_addr_info *remote); bool mptcp_pm_add_addr_recv(struct mptcp_sock *msk); void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr); From patchwork Fri Mar 14 02:45:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14016172 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 A30072AF19 for ; Fri, 14 Mar 2025 02:46:02 +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=1741920362; cv=none; b=MJM/sS16h6zWpKtreS23mwXGcJTuYWw6WEsV9TgGtkGWx3m/ci8X+ufxFweBncjZvUPIaX4fCsocZCfWZGMS2z2vk9YPTo6RsbX7WJoTi/QiOflrOwCCOX2lkFs1lwnaTVvE2BHY7g3bVx2yJY09JGN5YHqDGwoDfJQlcQOoRLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920362; c=relaxed/simple; bh=DXehY/hf7fb5Y4qysM9rBUyyA6EYM29TmGKigFlw4ms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DploRq/JP/3hBc0e+UjplC7Wx+LHGKrXnbtadgBIVJ0w/7jK3aFRP3y/S8jPzneua8jK/047qa2oqVmW1n9mnUbktNt59xWzuyrtuqfZr9j31e+gxYNh6qQxynLaU3Iy0sxqVh3BVIRyPVK7Rkcmxo5kws+GBfqVZq5kjZ3uLn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BDCXG9KI; 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="BDCXG9KI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05524C4CEDD; Fri, 14 Mar 2025 02:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920362; bh=DXehY/hf7fb5Y4qysM9rBUyyA6EYM29TmGKigFlw4ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDCXG9KIfcGO80jNLrcW1u6xoc8XTZpweMxMrMRQOlewsN52JTFHUIeLezO2B45xe PeajZluIxLGvbRV7dWFF0RSK1lR7tWC7cXPtK81moQxaDnqfPPllYO1eTnG/knNSiY g92BQDqL7ykf/k+Nvph+6C+uyM577eq6TEMl5z9HyNr2bXIA+Gc+nXu1HdQN3HyG4V V0yxkGNBVqpJui8FjwGSp5sLU6rGIKiQ9erDpY7dmOo09jz50g0nRz4erw52BqdtxT CjPA4owG6rBrbpxAliyvdogvNUggCOCnevyQWmqj7Hx8nmR1o8I7xLTGjGB4urTmwu U5W43LwIyQYNw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 09/10] mptcp: pm: add rm_addr_received() interface Date: Fri, 14 Mar 2025 10:45:30 +0800 Message-ID: <9489a0504d552aa158824dc80e14143316fa714b.1741919893.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 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 an optional .rm_addr_received interface for struct mptcp_pm_ops and invokes it in mptcp_pm_worker() without PM lock. Since mptcp_subflow_shutdown() and mptcp_close_ssk() are sleepable kfuncs, .rm_addr_received interface of BPF PM should be invoked by __bpf_prog_enter_sleepable(), which can't be invoked under a lock. Export mptcp_pm_rm_addr_recv() is to allow the MPTCP_PM_RM_ADDR_RECEIVED worker can be invoke from the in-kernel PM. With this, mptcp_pm_is_kernel() in mptcp_pm_rm_addr_or_subflow() can be dropped. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 1 + net/mptcp/pm.c | 13 ++++++++++--- net/mptcp/pm_kernel.c | 6 ++++++ net/mptcp/protocol.h | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 90fda6d1468c..bd8a20b9d02b 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -137,6 +137,7 @@ struct mptcp_pm_ops { /* optional */ int (*add_addr_received)(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); + void (*rm_addr_received)(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 d5cb7c60d177..70611946dfbf 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -676,15 +676,17 @@ static void mptcp_pm_rm_addr_or_subflow(struct mptcp_sock *msk, if (rm_type == MPTCP_MIB_RMADDR) { __MPTCP_INC_STATS(sock_net(sk), rm_type); - if (removed && mptcp_pm_is_kernel(msk)) + if (removed) mptcp_pm_nl_rm_addr(msk, rm_id); } } } -static void mptcp_pm_rm_addr_recv(struct mptcp_sock *msk) +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, @@ -704,6 +706,9 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, for (i = 0; i < rm_list->nr; i++) mptcp_event_addr_removed(msk, rm_list->ids[i]); + if (!pm->ops->rm_addr_received) + return; + spin_lock_bh(&pm->lock); if (mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED)) pm->rm_list_rx = *rm_list; @@ -930,7 +935,9 @@ void mptcp_pm_worker(struct mptcp_sock *msk) } if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); - mptcp_pm_rm_addr_recv(msk); + spin_unlock_bh(&msk->pm.lock); + pm->ops->rm_addr_received(msk); + return; } if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 74838e2c66ba..d04dd1cece09 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1441,6 +1441,11 @@ static int mptcp_pm_kernel_add_addr_received(struct mptcp_sock *msk, return -EINVAL; } +static void mptcp_pm_kernel_rm_addr_received(struct mptcp_sock *msk) +{ + mptcp_pm_rm_addr_recv(msk); +} + static void mptcp_pm_kernel_init(struct mptcp_sock *msk) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -1470,6 +1475,7 @@ struct mptcp_pm_ops mptcp_pm_kernel = { .accept_new_subflow = mptcp_pm_kernel_accept_new_subflow, .add_addr_echo = mptcp_pm_kernel_add_addr_echo, .add_addr_received = mptcp_pm_kernel_add_addr_received, + .rm_addr_received = mptcp_pm_kernel_rm_addr_received, .init = mptcp_pm_kernel_init, .name = "kernel", .owner = THIS_MODULE, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8663350fac2f..d8b46f8ef8d3 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1030,6 +1030,7 @@ void mptcp_pm_rm_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); +void mptcp_pm_rm_addr_recv(struct mptcp_sock *msk); void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup); void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq); int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk, From patchwork Fri Mar 14 02:45: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: 14016173 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 D592C7081A for ; Fri, 14 Mar 2025 02:46:04 +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=1741920364; cv=none; b=Ougq9PKQ3+EBMxcadSVVD5wLav4RxKTTxs84uTxHYTNIrkWJaQDDYD1AIPBA+aX7HvhZpm/mplCa756OqGWJVvR1SfsgId3YYXWq8Om8ZCGUUe1fOJ0XtbA2Su8M1atwvMl2zMn6pRQAol+t48JgXUqI32g3CZEruuYztjls/LM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741920364; c=relaxed/simple; bh=dQEnEuQeD5gGnnYHi82ZoZfB7qorisjBt0SwIahvlVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZNJ+Nzp//rK+8ClFPK04c69Sm6hxEGXSyeCMK802aHcsQGOxZGhdfp/avbQImwKkEvM7ufoGHUMZf5DEnHjpiLXInic1WMFNYchBneYQnuD9Mb7aE8RsqWjL4welYqsA2b/QMFnODsYw/UpJZJnOIUXS42D4jBuy8xVXL+16Ygk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HWcVIDi8; 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="HWcVIDi8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 041E6C4CEE9; Fri, 14 Mar 2025 02:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741920364; bh=dQEnEuQeD5gGnnYHi82ZoZfB7qorisjBt0SwIahvlVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWcVIDi8oDSaHFWeqDB6v49m0n4FaPafWtyAuOfSOhz6yOSlTDlPErImWGuOV/HZ+ xssXE7Y96+MXvskQl+DXrx59xWK++SGhnIwztxV8TDTgmZLymiC1gn0pHQ/UWliTyW L0s1OwDuvvOmp395G1n4K/CVm+FiYih+ptKGiyBWHPzuRLhbiZUXjwapn89v34NvJo JlHP7D67WwuK1xUHCkJrAdXLa+EpZ48b2mpVcY+FWZ/GdSSE7EA9842Gd5cZJs7f2L Vs10JaQS7lp13WkY5HvvuaSVcYwCnsLcpHinK+aHBwzKeXmZtHvaAS5IG4nmtXJAl1 s9g9RNc2qWcYA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 10/10] mptcp: pm: drop is_userspace in subflow_check_next Date: Fri, 14 Mar 2025 10:45:31 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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 In mptcp_pm_subflow_check_next(), instead of reducing "pm->subflows" for the in-kernel PM in __mptcp_pm_close_subflow(), this patch moves "pm->subflows--;" forward to let it be used by both the userspace PM and the in-kernel PM. Then mptcp_pm_is_userspace() here can be dropped. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 70611946dfbf..d504f9b31893 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -531,13 +531,10 @@ 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) { + spin_lock_bh(&pm->lock); + pm->subflows--; + spin_unlock_bh(&pm->lock); } if (!pm->ops->subflow_established) @@ -547,8 +544,8 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, return; spin_lock_bh(&pm->lock); - if (update_subflows) - __mptcp_pm_close_subflow(msk); + if (update_subflows && msk->pm.subflows < mptcp_pm_get_subflows_max(msk)) + WRITE_ONCE(msk->pm.accept_subflow, true); /* Even if this subflow is not really established, tell the PM to try * to pick the next ones, if possible.