From patchwork Sun Feb 23 14:19:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987046 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 1554026AF3 for ; Sun, 23 Feb 2025 14:20:50 +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=1740320451; cv=none; b=giVoG1Kwib7EnUj2lUxb5ijbWjQiuWOLnIfE42ruf8Mwsyx5nt5QMPMedpJyd6jkMjWOM2ViOTcR3jaq1TCA+e74ye2hv2vi4eL2M8hNmiUjSEEmP8vv1BVCiljKLrft76jiehrOAupsutRExJqvsbkIPBPXwb0aSV0GAEoebKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320451; c=relaxed/simple; bh=yvdh4YUh2x711JLyYBI1nW2uNfo9Sma+aFTx6VoJvj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3FIFm/6z8VD6C3LLJftcxpdr66aUEmSo06kL3BM1MBG8nC1J5Am/U8R8sOoVLVJtL1RSRcTsmDZhZyuEucU6ZN6B/T6M6kmF9tD+L46rbHDeK+rzz/bEldrxQoUvT8CnI+/Q9YmkJmp6H6AIbdmz3UeC7KPxLrkM/QPjGlwZ2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rQdTvFd8; 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="rQdTvFd8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89229C4CEE8; Sun, 23 Feb 2025 14:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320450; bh=yvdh4YUh2x711JLyYBI1nW2uNfo9Sma+aFTx6VoJvj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rQdTvFd8V0b4xt4fpgsZgRZWNrk6GaynfhlFZQ78P+D0Ya6ZrI5n0ybZ+epgIvsM5 ANl45pSUXDsTi4JGRSquip+PK13KxOWK8z4xMM3/in9JykzSWQ/SGYlvGLFMcozQ4K nX3XeQYwKtudLIbVGH8o4zh60dZPdeetkP09QmbrlQFoUtKL5E2LkMtD7wwmGAAlFV QdIcbA1qx9P61OiHiarB6DU7FRgXa2qy3skc23HG0SEscg0Jsg5xNftEt7HjaMyhVv notxlftJYyiItwCFZs634kHa6yCJc9UeYV91PV7mjlLAIx2Fv1C6xmvFhcdKQqa15y sbviIcpizMFOA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 01/13] mptcp: sysctl: use index for sysctl table Date: Sun, 23 Feb 2025 22:19:49 +0800 Message-ID: <3e40ffced396775b7e3056b6f0934c112d8e8513.1740320007.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 sysctl table needs to be updated when a new sysctl is added or an old sysctl is deleted. It's inconvenient to use fixed index numbers, since the index number that needs to be changed and all subsequent index numbers need to be updated accordingly. This patch adds an "i" variable to access each sysctl in the sysctl table incrementally. Signed-off-by: Geliang Tang --- net/mptcp/ctrl.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index be6c0237e10b..030dbe46cc8a 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -259,6 +259,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) { struct ctl_table_header *hdr; struct ctl_table *table; + int i = 0; table = mptcp_sysctl_table; if (!net_eq(net, &init_net)) { @@ -267,17 +268,17 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) goto err_alloc; } - table[0].data = &pernet->mptcp_enabled; - table[1].data = &pernet->add_addr_timeout; - table[2].data = &pernet->checksum_enabled; - table[3].data = &pernet->allow_join_initial_addr_port; - table[4].data = &pernet->stale_loss_cnt; - table[5].data = &pernet->pm_type; - table[6].data = &pernet->scheduler; - /* table[7] is for available_schedulers which is read-only info */ - table[8].data = &pernet->close_timeout; - table[9].data = &pernet->blackhole_timeout; - table[10].data = &pernet->syn_retrans_before_tcp_fallback; + table[i++].data = &pernet->mptcp_enabled; + table[i++].data = &pernet->add_addr_timeout; + table[i++].data = &pernet->checksum_enabled; + table[i++].data = &pernet->allow_join_initial_addr_port; + table[i++].data = &pernet->stale_loss_cnt; + table[i++].data = &pernet->pm_type; + table[i++].data = &pernet->scheduler; + i++; /* table[i] is for available_schedulers which is read-only info */ + table[i++].data = &pernet->close_timeout; + table[i++].data = &pernet->blackhole_timeout; + table[i++].data = &pernet->syn_retrans_before_tcp_fallback; hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table, ARRAY_SIZE(mptcp_sysctl_table)); From patchwork Sun Feb 23 14:19:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987047 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 4DDE226AF3 for ; Sun, 23 Feb 2025 14:20: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=1740320453; cv=none; b=QMdTSF6Pji4vfjiW4OkAPP4KjYwvakSX/mCjV7vk0onqXdp47CesZx4PT1DFqLJflMsInLQe7IbmEjEuFyTVFp+TS4YaLKswegXQSPsetK1bfft76siwZakkM0qz/v71xSFgVCsE8+R+XRRV2HdJrFxneSaSkx5WNgqJRDbH0/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320453; c=relaxed/simple; bh=2gkDybpH395OIbIaKZa2a1mkllL/GXzJNOIUnEymSGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oAdWadVSLWDDbdRlcF2UGh0Jrx1GsUk+u9BU9bPxfkpuYMO439MvZJYaSA0Puy/x+Q4DH1KtYwSO2IybPwFB5Q9aCvA5+JzMB8cMsoEasoNOlTZTPQ+QSnEKyaYsvUb+PMuN90LyoLSF3U8clTPyJJY9Mw5ivSrcJU275/d6KdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MlWXAVu7; 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="MlWXAVu7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F363FC4CEDD; Sun, 23 Feb 2025 14:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320451; bh=2gkDybpH395OIbIaKZa2a1mkllL/GXzJNOIUnEymSGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlWXAVu7CfoH4xIOLFAFE9+EOeguOKXckWU5Pr8eO83cloDflYvVH6jlZezAy9Nyx E4IzkJsAU349xfM1M2gdWlZeT+GsMiXbUNqsj/yYab6yOmJx4D2pKsWaq/73Fa62bO cF9aWYSWcyK3N3xv/BdAFIIJk3MU6U2grmxHgzGJ/4auYe9lu0Ztlilwi2E+D80fIU o5OmohoSHDFX3V248Xb9Puz4d9YeEEn3t4vcdeNxeSFokugQrowgbxBo4fBHjGS7+l nJSlpH/Ly9fRIuIQ75d65xVUKMZ3eg20dGn+Dt9HHyYq9YSGaoPMR6SpIUnvKA+js+ fHZInIgOGWOUg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 02/13] mptcp: sysctl: add path_manager to set pm name Date: Sun, 23 Feb 2025 22:19:50 +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 A new net.mptcp.path_manager sysctl is added to determine which path manager will be used by each newly-created MPTCP socket by setting the name of it. This sysctl will replace the old one pm_type. Signed-off-by: Geliang Tang --- Documentation/networking/mptcp-sysctl.rst | 17 ++++++++ net/mptcp/ctrl.c | 50 +++++++++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 68 insertions(+) diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst index 03e1d3610333..a3218e35a328 100644 --- a/Documentation/networking/mptcp-sysctl.rst +++ b/Documentation/networking/mptcp-sysctl.rst @@ -89,6 +89,23 @@ pm_type - INTEGER Default: 0 +path_manager - STRING + Set the default path manager name to use for each new MPTCP + socket. In-kernel path management will control subflow + connections and address advertisements according to + per-namespace values configured over the MPTCP netlink + API. Userspace path management puts per-MPTCP-connection subflow + connection decisions and address advertisements under control of + a privileged userspace program, at the cost of more netlink + traffic to propagate all of the related events and commands. + + This is a per-namespace sysctl. + + * "in-kernel" - In-kernel path manager + * "userspace" - Userspace path manager + + Default: "in-kernel" + scheduler - STRING Select the scheduler of your choice. diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 030dbe46cc8a..759ce4c30392 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -38,6 +38,7 @@ struct mptcp_pernet { u8 checksum_enabled; u8 allow_join_initial_addr_port; u8 pm_type; + char path_manager[MPTCP_PM_NAME_MAX]; char scheduler[MPTCP_SCHED_NAME_MAX]; }; @@ -83,6 +84,11 @@ int mptcp_get_pm_type(const struct net *net) return mptcp_get_pernet(net)->pm_type; } +const char *mptcp_get_path_manager(const struct net *net) +{ + return mptcp_get_pernet(net)->path_manager; +} + const char *mptcp_get_scheduler(const struct net *net) { return mptcp_get_pernet(net)->scheduler; @@ -100,10 +106,47 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) pernet->allow_join_initial_addr_port = 1; pernet->stale_loss_cnt = 4; pernet->pm_type = MPTCP_PM_TYPE_KERNEL; + strscpy(pernet->path_manager, "in-kernel", sizeof(pernet->path_manager)); strscpy(pernet->scheduler, "default", sizeof(pernet->scheduler)); } #ifdef CONFIG_SYSCTL +static int mptcp_set_path_manager(char *path_manager, const char *name) +{ + struct mptcp_pm_ops *pm; + int ret = 0; + + rcu_read_lock(); + pm = mptcp_pm_find(name); + if (pm) + strscpy(path_manager, name, MPTCP_PM_NAME_MAX); + else + ret = -ENOENT; + rcu_read_unlock(); + + return ret; +} + +static int proc_path_manager(const struct ctl_table *ctl, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + char (*path_manager)[MPTCP_PM_NAME_MAX] = ctl->data; + char val[MPTCP_PM_NAME_MAX]; + const struct ctl_table tbl = { + .data = val, + .maxlen = MPTCP_PM_NAME_MAX, + }; + int ret; + + strscpy(val, *path_manager, MPTCP_PM_NAME_MAX); + + ret = proc_dostring(&tbl, write, buffer, lenp, ppos); + if (write && ret == 0) + ret = mptcp_set_path_manager(*path_manager, val); + + return ret; +} + static int mptcp_set_scheduler(char *scheduler, const char *name) { struct mptcp_sched_ops *sched; @@ -222,6 +265,12 @@ static struct ctl_table mptcp_sysctl_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = &mptcp_pm_type_max }, + { + .procname = "path_manager", + .maxlen = MPTCP_PM_NAME_MAX, + .mode = 0644, + .proc_handler = proc_path_manager, + }, { .procname = "scheduler", .maxlen = MPTCP_SCHED_NAME_MAX, @@ -274,6 +323,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[i++].data = &pernet->allow_join_initial_addr_port; table[i++].data = &pernet->stale_loss_cnt; table[i++].data = &pernet->pm_type; + table[i++].data = &pernet->path_manager; table[i++].data = &pernet->scheduler; i++; /* table[i] is for available_schedulers which is read-only info */ table[i++].data = &pernet->close_timeout; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3d72ca155322..ae4544663f06 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -694,6 +694,7 @@ int mptcp_allow_join_id0(const struct net *net); unsigned int mptcp_stale_loss_cnt(const struct net *net); unsigned int mptcp_close_timeout(const struct sock *sk); int mptcp_get_pm_type(const struct net *net); +const char *mptcp_get_path_manager(const struct net *net); const char *mptcp_get_scheduler(const struct net *net); void mptcp_active_disable(struct sock *sk); From patchwork Sun Feb 23 14:19:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987048 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 8CD2320011D for ; Sun, 23 Feb 2025 14:20:53 +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=1740320453; cv=none; b=FP/1YybcY9oPigQx5C+S4TXQpV/ciYHNlux2/HvpbD5l7Q0oKRmgeuz9J0QMtzuyhnMReH1sBiyqhv/aXsVWXJLyJlk3+dXiXFfUwdwhZNNsufnBSYvqiY16ymz5hl7URoRlDQUFxr1xxT4fhrFD3RrwRmWCBbY92vZ1oNP76LM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320453; c=relaxed/simple; bh=rJNbYgViLMPII9wpo4/Db54VHTnqpsYpeOxy1MCo//A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SLqBAD3k7gOSAuR4j2hu+TEA5DJcE8UIs5L1Wupe1P3YxBKGzkmtZmTHaQByNrGPRQsP1Aq0OpztU7PG8Bb+90cv8mzut8fi7bZiitziRkTEmo2rFfvY2VKs9IHb12io2UmEBeWIJ30l4549E4/A2ltPxr9P3Pf4zMJ2FtehX0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RuR5TiyK; 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="RuR5TiyK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FFB6C4CEE7; Sun, 23 Feb 2025 14:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320453; bh=rJNbYgViLMPII9wpo4/Db54VHTnqpsYpeOxy1MCo//A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RuR5TiyKTop1rrse/80tZ/z87/+cxXHu3oEYijSR0Rcy4wP8munD04t3Y2u4Le7OH d0JJE6tnrxGv3gS7ekX+R2NXQ6R6Il27FRt8UNENyWg0ddZivNYTKyihhkkKVY7zXU e5sqyW6mBJ0/L0O4z4zaYOEr0efbgXrTncEUgMgee5kOAygkyj8+qeK1u2eW2jfq+e PQAnZyYZ3X++23/4CH2SooWDMxQLM/IuX6Y8D7IjGhPlpnhiO3F/d8hRbhhi4fkA4d /qLeiH8cR51xkYHD42aMzwSWm5vufkkCUkMi51AFfL7zwV8Kg1v7d/Kqtz2JfOTWL7 cP+Z0CmcUTjOg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 03/13] mptcp: pm: use addr entry for get_local_id Date: Sun, 23 Feb 2025 22:19:51 +0800 Message-ID: <889e6bbf8352886fadca89ea653a3e735a7ae106.1740320007.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 following code in mptcp_userspace_pm_get_local_id() that assigns "skc" to "new_entry" is not allowed in BPF if we use the same code to implement the get_local_id() interface of a BFP path manager: memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr = *skc; new_entry.addr.id = 0; new_entry.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; To solve the issue, this patch moves this assignment to "new_entry" forward to mptcp_pm_get_local_id(), and then passing "new_entry" as a parameter to both mptcp_pm_nl_get_local_id() and mptcp_userspace_pm_get_local_id(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 9 ++++++--- net/mptcp/pm_netlink.c | 11 ++++------- net/mptcp/pm_userspace.c | 17 ++++++----------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 16cacce6c10f..ac7b39148bd3 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -403,7 +403,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) { - struct mptcp_addr_info skc_local; + struct mptcp_pm_addr_entry skc_local = { 0 }; struct mptcp_addr_info msk_local; if (WARN_ON_ONCE(!msk)) @@ -413,10 +413,13 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) * addr */ mptcp_local_address((struct sock_common *)msk, &msk_local); - mptcp_local_address((struct sock_common *)skc, &skc_local); - if (mptcp_addresses_equal(&msk_local, &skc_local, false)) + mptcp_local_address((struct sock_common *)skc, &skc_local.addr); + if (mptcp_addresses_equal(&msk_local, &skc_local.addr, false)) return 0; + skc_local.addr.id = 0; + skc_local.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; + if (mptcp_pm_is_userspace(msk)) return mptcp_userspace_pm_get_local_id(msk, &skc_local); return mptcp_pm_nl_get_local_id(msk, &skc_local); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d4328443d844..69a2f7aa1825 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1139,7 +1139,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, return err; } -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) +int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc) { struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; @@ -1148,7 +1149,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc pernet = pm_nl_get_pernet_from_msk(msk); rcu_read_lock(); - entry = __lookup_addr(pernet, skc); + entry = __lookup_addr(pernet, &skc->addr); ret = entry ? entry->addr.id : -1; rcu_read_unlock(); if (ret >= 0) @@ -1159,12 +1160,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc if (!entry) return -ENOMEM; - entry->addr = *skc; - entry->addr.id = 0; + *entry = *skc; entry->addr.port = 0; - entry->ifindex = 0; - entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; - entry->lsk = NULL; ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true); if (ret < 0) kfree(entry); diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 6bf6a20ef7f3..5b3ee43130be 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -131,27 +131,22 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) } int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, - struct mptcp_addr_info *skc) + struct mptcp_pm_addr_entry *skc) { - struct mptcp_pm_addr_entry *entry = NULL, new_entry; __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; + struct mptcp_pm_addr_entry *entry; spin_lock_bh(&msk->pm.lock); - entry = mptcp_userspace_pm_lookup_addr(msk, skc); + entry = mptcp_userspace_pm_lookup_addr(msk, &skc->addr); spin_unlock_bh(&msk->pm.lock); if (entry) return entry->addr.id; - memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); - new_entry.addr = *skc; - new_entry.addr.id = 0; - new_entry.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; - - if (new_entry.addr.port == msk_sport) - new_entry.addr.port = 0; + if (skc->addr.port == msk_sport) + skc->addr.port = 0; - return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry, true); + return mptcp_userspace_pm_append_new_local_addr(msk, skc, true); } bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index ae4544663f06..a6815d02706b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1127,8 +1127,10 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, struct mptcp_rm_list *rm_list); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc); -int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc); +int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc); +int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc); bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc); bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); From patchwork Sun Feb 23 14:19:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987049 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 E937220011D for ; Sun, 23 Feb 2025 14:20: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=1740320456; cv=none; b=T5QuD8v6tiS8ongGq54AVJKbOVFMGoaA3y9Khn3LvxmkaK33zrQJW5TvAj8THrDBGtBZa+wdVZvTWZfXaF36JHUk4bKSnStEmkPVVV367qbrBZuRMRvMEBirocmaKoF56wyqGTnxK55NfcM/h+j8Xble3iYEyqCoPoCGHptUUpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320456; c=relaxed/simple; bh=tUo7fAUsUlVW9dhMcz6cWBTsNmCTkuaHucUn4GoXxz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cxvxligoyf977th/yBWfHCEUy68vzSpF1+0JgE/oT9QGA+DvN/EP0KqI4Z4gy+VFHkoqdhWSa09muJsYnBTm7FFDXJbd3EsorSmQ4VAlSLYDTgeSyHOWAiNmDSTTfbrQ+uOK+nePUNz+Y/fLwAV0E8QiFvcRfSlJ8FlDRrZ7O5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rE+1XCJD; 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="rE+1XCJD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A012AC4CEE9; Sun, 23 Feb 2025 14:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320454; bh=tUo7fAUsUlVW9dhMcz6cWBTsNmCTkuaHucUn4GoXxz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rE+1XCJDxSPj97gPmQs+EPq9zkH4YTPnsblKiQ4rr8JooWBMs2a22M9n7WGMa4R2P 1wiBSH/o7HFHh6JZk+3sE2BgxLE2FQt2reG0DpIPohfrhUS8udktW7rLlj+36rFBDL +jEJDyJnel6MfHzTWgrw9AssJcjX6WP0KhI/iqzZupq0OlCggIfLq30lH8OiX8fnMB 1jtN6bUfYmZKFLYYIFzVekm83m4yl2Sr3ptr089HXTA0CPLo4tXhErARO06EF90f4p IFvsabY2UFfxf46tQzea1lhOj3Kt8SZSivjK1L4EqGUCRuHuIF34ymt4qxUmYQd9WT K+boBWFSE4FEw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 04/13] mptcp: pm: define struct mptcp_pm_ops Date: Sun, 23 Feb 2025 22:19:52 +0800 Message-ID: <2e8ac1bb8447a52cd7fdf716076f0df3a2cfacb4.1740320007.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 In order to allow users to develop their own BPF-based path manager, this patch defines a struct ops "mptcp_pm_ops" for a userspace path manager, which contains a set of interfaces. Add a set of functions to register, unregister, find and validate a given struct ops. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 37 +++++++++++++++++++++++++++++ net/mptcp/pm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 5 ++++ 3 files changed, 97 insertions(+) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 72d6e6597add..689926d1f39f 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -14,6 +14,7 @@ struct mptcp_info; struct mptcp_sock; +struct mptcp_pm_addr_entry; struct seq_file; /* MPTCP sk_buff extension data */ @@ -121,6 +122,42 @@ struct mptcp_sched_ops { void (*release)(struct mptcp_sock *msk); } ____cacheline_aligned_in_smp; +#define MPTCP_PM_NAME_MAX 16 + +struct mptcp_pm_ops { + int (*created)(struct mptcp_sock *msk); + int (*established)(struct mptcp_sock *msk); + int (*closed)(struct mptcp_sock *msk); + int (*get_local_id)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc); + bool (*get_priority)(struct mptcp_sock *msk, + struct mptcp_addr_info *skc); + int (*address_announced)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local); + int (*address_removed)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local); + int (*subflow_established)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local, + struct mptcp_addr_info *remote); + int (*subflow_closed)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local, + struct mptcp_addr_info *remote); + int (*set_priority)(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local, + struct mptcp_addr_info *remote, + u8 changed); + int (*listener_created)(struct mptcp_sock *msk); + int (*listener_closed)(struct mptcp_sock *msk); + + u8 type; + char name[MPTCP_PM_NAME_MAX]; + struct module *owner; + struct list_head list; + + void (*init)(struct mptcp_sock *msk); + void (*release)(struct mptcp_sock *msk); +} ____cacheline_aligned_in_smp; + #ifdef CONFIG_MPTCP void mptcp_init(void); diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index ac7b39148bd3..97fccd930cd0 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -6,12 +6,17 @@ #define pr_fmt(fmt) "MPTCP: " fmt #include +#include +#include #include #include "protocol.h" #include "mib.h" #include "mptcp_pm_gen.h" +static DEFINE_SPINLOCK(mptcp_pm_list_lock); +static LIST_HEAD(mptcp_pm_list); + /* path manager command handlers */ int mptcp_pm_announce_addr(struct mptcp_sock *msk, @@ -647,3 +652,53 @@ void __init mptcp_pm_init(void) { mptcp_pm_nl_init(); } + +/* Must be called with rcu read lock held */ +struct mptcp_pm_ops *mptcp_pm_find(const char *name) +{ + struct mptcp_pm_ops *pm; + + list_for_each_entry_rcu(pm, &mptcp_pm_list, list) { + if (!strcmp(pm->name, name)) + return pm; + } + + return NULL; +} + +int mptcp_pm_validate(struct mptcp_pm_ops *pm) +{ + if (!pm->get_local_id || !pm->get_priority) { + pr_err("%u does not implement required ops\n", pm->type); + return -EINVAL; + } + + return 0; +} + +int mptcp_pm_register(struct mptcp_pm_ops *pm) +{ + int ret; + + ret = mptcp_pm_validate(pm); + if (ret) + return ret; + + spin_lock(&mptcp_pm_list_lock); + if (mptcp_pm_find(pm->name)) { + spin_unlock(&mptcp_pm_list_lock); + return -EEXIST; + } + list_add_tail_rcu(&pm->list, &mptcp_pm_list); + spin_unlock(&mptcp_pm_list_lock); + + pr_debug("%s registered\n", pm->name); + return 0; +} + +void mptcp_pm_unregister(struct mptcp_pm_ops *pm) +{ + spin_lock(&mptcp_pm_list_lock); + list_del_rcu(&pm->list); + spin_unlock(&mptcp_pm_list_lock); +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a6815d02706b..3c24e8e1bc13 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1048,6 +1048,11 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry); +struct mptcp_pm_ops *mptcp_pm_find(const char *name); +int mptcp_pm_validate(struct mptcp_pm_ops *pm); +int mptcp_pm_register(struct mptcp_pm_ops *pm); +void mptcp_pm_unregister(struct mptcp_pm_ops *pm); + void mptcp_free_local_addr_list(struct mptcp_sock *msk); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, From patchwork Sun Feb 23 14:19:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987050 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 4296D20011D for ; Sun, 23 Feb 2025 14:20:55 +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=1740320456; cv=none; b=dH+2BVbiDi77fbMNM+FFYx/C5CP5j33fdTxBFST5olOuSgIVsV9U3Q6yaJfiLQQKAgbzBqpb1kbJcqS3+EsRtoeBICZe0JjGsD9eVGITCSWpxHgDH2v4RrKKIlWXC8nnFIvCfbfSri1VgTuby8Kd/e9IxVyj2+IZSrhIslp1n4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320456; c=relaxed/simple; bh=Xsc8dui0N0ialzW3PijFlPR13UYv7hzFKefGCv5ILD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=athtSQoue+pUv9R0Vuz24QGpj6CTw5z/YrOSJr9zFKTRdXbwiOC0ZrKLWlMFwNnU3dW16hcHobyXF0qBW/sGJttJif+Ezywi7Q5kqzVAvO/HzLpL7h8QrE7YMrV11HlKI7i6VaISxt9/I1Wex5kf5z4eShbL4wVN55wgwqrdlhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DfWTMBxo; 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="DfWTMBxo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1DF3C4CEDD; Sun, 23 Feb 2025 14:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320455; bh=Xsc8dui0N0ialzW3PijFlPR13UYv7hzFKefGCv5ILD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DfWTMBxovK3uSyoJQAkY2o3Tg1Ny3Uzr4ZVRqLYUebiIg8AiTF7GJis07KCYVbTol /ihdVEo0fRbHnNdOpJqVsnvZ+2ERQBtzy4kRYVlRNimBdzWEgSXrx6tpoRYlVdO9a8 jJI68wHH0bKIJZhew1etvgRMtfSkjd3lgAGICvpeWmNCH1q2BYvrKHKjckMsT96Ywm T4L2zbqniDfkLLTesinoGCGFah71Y6u/MagKGTWOOfMSsd4m2In/pzRCfH9iSFjRXb CLrDbW//V2aMRqjuEvyoX4ZjW57q6BfFv4iJNQyIQQ9FgDSgGO/ga0vHR1GuNSgUzv +XVO26FV4Pd7w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 05/13] mptcp: pm: in-kernel: register mptcp_in_kernel_pm Date: Sun, 23 Feb 2025 22:19:53 +0800 Message-ID: <31c3324f479d9a59c579d8cc3434aebf48eff252.1740320007.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 defines the original in-kernel netlink path manager as a new struct mptcp_pm_ops named "mptcp_in_kernel_pm", and register it in mptcp_pm_nl_init(). This mptcp_pm_ops will be skipped in mptcp_pm_unregister(). Only get_local_id() and get_priority() interfaces are implemented here. mptcp_pm_nl_is_backup() becomes a wrapper of get_priority(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 3 +++ net/mptcp/pm_netlink.c | 18 +++++++++++++++++- net/mptcp/protocol.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 97fccd930cd0..07789526eecc 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -698,6 +698,9 @@ int mptcp_pm_register(struct mptcp_pm_ops *pm) void mptcp_pm_unregister(struct mptcp_pm_ops *pm) { + if (pm == &mptcp_in_kernel_pm) + return; + spin_lock(&mptcp_pm_list_lock); list_del_rcu(&pm->list); spin_unlock(&mptcp_pm_list_lock); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 69a2f7aa1825..aa9be671293d 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1169,7 +1169,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, return ret; } -bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc) +static bool mptcp_pm_nl_get_priority(struct mptcp_sock *msk, + struct mptcp_addr_info *skc) { struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_addr_entry *entry; @@ -1183,6 +1184,11 @@ bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc) return backup; } +bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc) +{ + return mptcp_pm_nl_get_priority(msk, skc); +} + #define MPTCP_PM_CMD_GRP_OFFSET 0 #define MPTCP_PM_EV_GRP_OFFSET 1 @@ -2370,6 +2376,14 @@ static struct pernet_operations mptcp_pm_pernet_ops = { .size = sizeof(struct pm_nl_pernet), }; +struct mptcp_pm_ops mptcp_in_kernel_pm = { + .get_local_id = mptcp_pm_nl_get_local_id, + .get_priority = mptcp_pm_nl_get_priority, + .type = MPTCP_PM_TYPE_KERNEL, + .name = "in-kernel", + .owner = THIS_MODULE, +}; + void __init mptcp_pm_nl_init(void) { if (register_pernet_subsys(&mptcp_pm_pernet_ops) < 0) @@ -2377,4 +2391,6 @@ void __init mptcp_pm_nl_init(void) if (genl_register_family(&mptcp_genl_family)) panic("Failed to register MPTCP PM netlink family\n"); + + mptcp_pm_register(&mptcp_in_kernel_pm); } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3c24e8e1bc13..2b1fd10b4b7e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1048,6 +1048,8 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry); +extern struct mptcp_pm_ops mptcp_in_kernel_pm; + struct mptcp_pm_ops *mptcp_pm_find(const char *name); int mptcp_pm_validate(struct mptcp_pm_ops *pm); int mptcp_pm_register(struct mptcp_pm_ops *pm); From patchwork Sun Feb 23 14:19:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987051 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 9BC9926AF3 for ; Sun, 23 Feb 2025 14:20:57 +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=1740320457; cv=none; b=d9P7oURlzXL8QZ+7GfganBJE45f2wje9eMZiZXjD2aOSsiitmqXr1p/Rmk3nM0iomGh6cUBMYX0V2q2+bojiQgeDtx5SVo6JfQD74qbc1uiCOisZJBYq5oyflY6+1+ltsaSlg4CFoCnq00B5dYj3YBrZa5B/6cdeofbf7CWoerI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320457; c=relaxed/simple; bh=5Sn0zIAVm9N4vMd5hNctTQH/4eEQPRs8hY+rvaSfGvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=faxd59HcgdC338+Bc51SfbtLTTN4PPUK89/XgMegzMnwS0g3v0e32df/RgBULbpbyRa6CTMPGv1Ha0z95BVGAShwVrMagRdDS0OCgCUneZDvVnmpLPhXO6LUcl/fqdups6KlZ8OH4yQ8dTrZj+CEgVtHnundDvwalC4AatRNYag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eLxmr8AS; 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="eLxmr8AS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E90FC4CEE7; Sun, 23 Feb 2025 14:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320457; bh=5Sn0zIAVm9N4vMd5hNctTQH/4eEQPRs8hY+rvaSfGvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLxmr8ASq7xpT+JUP5o31AoPW85Ri5JxUVmPJos/jn8IaoS8nDrCpHgrQF1/Ecuwl QIep96nmKLLfpP758/9xueJt7Fsv0dkA/BHpIi+so1TYVPXdbz0KPmXrCA87Y92z+E XB/ilOSLTgKzoWJz3kgC3HfQ3ajAHwCAUOs3j518P2jMIeWkiLL1gSfnoE+CjCI0yt 2unwquQp7cpPU6gmKQdB6ELRZRsBy1MZu3njZr/KwcCBqCdnxs8Gz1uktickXc9FX7 Wlzc11OcFMIGT1ygtR2NQvLecZNvN3oEKf42xUq2wqVvQ5FqiaBWgGrPJx5Cyn1DPK gmXga+UfnB8BQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 06/13] mptcp: pm: userspace: register mptcp_userspace_pm Date: Sun, 23 Feb 2025 22:19:54 +0800 Message-ID: <98a4bc2ad44a9152fc60af934cca874e235f6b01.1740320007.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 defines the original userspace path manager as a new struct mptcp_pm_ops named "mptcp_userspace_pm", and register it in mptcp_pm_data_init(). Only get_local_id() and get_priority() interfaces are implemented here. mptcp_userspace_pm_is_backup() becomes a wrapper of get_priority(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 1 + net/mptcp/pm_userspace.c | 23 +++++++++++++++++++++-- net/mptcp/protocol.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 07789526eecc..9e1a2e6d9c03 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -651,6 +651,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) void __init mptcp_pm_init(void) { mptcp_pm_nl_init(); + mptcp_userspace_pm_init(); } /* Must be called with rcu read lock held */ diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 5b3ee43130be..17450cf8f920 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -149,8 +149,8 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, return mptcp_userspace_pm_append_new_local_addr(msk, skc, true); } -bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, - struct mptcp_addr_info *skc) +static bool mptcp_userspace_pm_get_priority(struct mptcp_sock *msk, + struct mptcp_addr_info *skc) { struct mptcp_pm_addr_entry *entry; bool backup; @@ -163,6 +163,12 @@ bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, return backup; } +bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, + struct mptcp_addr_info *skc) +{ + return mptcp_userspace_pm_get_priority(msk, skc); +} + static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *info) { struct mptcp_sock *msk; @@ -686,3 +692,16 @@ int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, sock_put(sk); return ret; } + +static struct mptcp_pm_ops mptcp_userspace_pm = { + .get_local_id = mptcp_userspace_pm_get_local_id, + .get_priority = mptcp_userspace_pm_get_priority, + .type = MPTCP_PM_TYPE_USERSPACE, + .name = "userspace", + .owner = THIS_MODULE, +}; + +void __init mptcp_userspace_pm_init(void) +{ + mptcp_pm_register(&mptcp_userspace_pm); +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2b1fd10b4b7e..301a0f192305 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1160,6 +1160,7 @@ static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflo } void __init mptcp_pm_nl_init(void); +void __init mptcp_userspace_pm_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk); From patchwork Sun Feb 23 14:19:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987052 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 ECCA926AF3 for ; Sun, 23 Feb 2025 14:20: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=1740320459; cv=none; b=qgfgT7VPP5IEPCVqt7s4FcAJrabMGVGAveYMV3FlMu/AVCfd8aiLj+uuppHINmR9X8pRX9ZP4P0Ob9cbGEITYaYIfLxBKwZlJgSSNe4mQh9BC5E3ow3XB36iyfZsnO+n+cwEQXsjgsHW2Omi93RTILykbMNWZLv0H5eaPwPXFKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320459; c=relaxed/simple; bh=mC7H3aG+h1s33nerifzrjdGPji+Z890hZ+BO7dhM1HM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SWvwpKnXSQo2ykS/jUFStNSl4w6I5IGrvnnxkfymGvMGQWkouaw0WNMBJ1sUqx/OJxO8b97e4DIRWRq8yIMZ/j5Y86eoSv8rtm1DuSPoOMF2PK2gPAUOwDQp8K+AlYdT/fN945HVeeUefB3+q5mcqSNok5+f3fFHmzQQbJhzqUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ucFwYvnV; 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="ucFwYvnV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE1EC4CEDD; Sun, 23 Feb 2025 14:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320458; bh=mC7H3aG+h1s33nerifzrjdGPji+Z890hZ+BO7dhM1HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucFwYvnVApQdW+xghc3n8DRLx39X6Yry6XCpWmTKkVU90abmPgh7sdxvLBdi/wEJn C9ueG1UPFL322LRwjnwIRHTBasCDm/zDmqGUMR1DLQS9FdYqjKLopwAhZJXoY5fAJK 5szieEYEyvrcvUkrr3f1SNBjhsjz7EWw9IJ7B9wloQrxIBAgecELSiTC6fM2lXFBWO ioiVKmZ1Zxp/qTgqmR1sJYazVPkAMyM0tRZczsDMfMfWwMr+1aBmcKuJa2eRB5H7TY FvnYopI9AUsrwi3mYX5c4HPE3BnDpMe8oSg6pNVgF5IjM3TQLCdTq2uNpLlSZb67AI mh4YR95xndtUw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 07/13] mptcp: pm: initialize and release mptcp_pm_ops Date: Sun, 23 Feb 2025 22:19:55 +0800 Message-ID: <41eb1ea07d50f942e1cdca81cfc4cd07688b689f.1740320007.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 Add a struct mptcp_pm_ops pointer "ops" in struct mptcp_pm_data, and two functions mptcp_pm_initialize() and mptcp_pm_release(), to set and release this pointer. mptcp_pm_initialize() is invoked in mptcp_pm_data_reset(), while mptcp_pm_release() is invoked in mptcp_destroy_common(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 38 ++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 3 +++ 3 files changed, 42 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 9e1a2e6d9c03..147d9289e477 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -603,8 +603,10 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, void mptcp_pm_data_reset(struct mptcp_sock *msk) { + const char *path_manager = mptcp_get_path_manager(sock_net((struct sock *)msk)); u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk)); struct mptcp_pm_data *pm = &msk->pm; + int ret; pm->add_addr_signaled = 0; pm->add_addr_accepted = 0; @@ -614,6 +616,12 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) pm->rm_list_rx.nr = 0; WRITE_ONCE(pm->pm_type, pm_type); + rcu_read_lock(); + ret = mptcp_pm_initialize(msk, mptcp_pm_find(path_manager)); + rcu_read_unlock(); + if (ret) + return; + if (pm_type == MPTCP_PM_TYPE_KERNEL) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -706,3 +714,33 @@ void mptcp_pm_unregister(struct mptcp_pm_ops *pm) list_del_rcu(&pm->list); spin_unlock(&mptcp_pm_list_lock); } + +int mptcp_pm_initialize(struct mptcp_sock *msk, struct mptcp_pm_ops *pm) +{ + if (!pm) + pm = &mptcp_in_kernel_pm; + + if (!bpf_try_module_get(pm, pm->owner)) + return -EBUSY; + + msk->pm.ops = pm; + if (msk->pm.ops->init) + msk->pm.ops->init(msk); + + pr_debug("pm %s initialized\n", pm->name); + return 0; +} + +void mptcp_pm_release(struct mptcp_sock *msk) +{ + struct mptcp_pm_ops *pm = msk->pm.ops; + + if (!pm) + return; + + msk->pm.ops = NULL; + if (pm->release) + pm->release(msk); + + bpf_module_put(pm, pm->owner); +} diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2b48cf648346..b5cfe0a6e594 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3307,6 +3307,7 @@ void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags) mptcp_token_destroy(msk); mptcp_pm_free_anno_list(msk); mptcp_free_local_addr_list(msk); + mptcp_pm_release(msk); } static void mptcp_destroy(struct sock *sk) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 301a0f192305..1fea29f52c35 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -220,6 +220,7 @@ struct mptcp_pm_data { struct mptcp_addr_info remote; struct list_head anno_list; struct list_head userspace_pm_local_addr_list; + struct mptcp_pm_ops *ops; spinlock_t lock; /*protects the whole PM data */ @@ -1054,6 +1055,8 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name); int mptcp_pm_validate(struct mptcp_pm_ops *pm); int mptcp_pm_register(struct mptcp_pm_ops *pm); void mptcp_pm_unregister(struct mptcp_pm_ops *pm); +int mptcp_pm_initialize(struct mptcp_sock *msk, struct mptcp_pm_ops *pm); +void mptcp_pm_release(struct mptcp_sock *msk); void mptcp_free_local_addr_list(struct mptcp_sock *msk); From patchwork Sun Feb 23 14:26:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987053 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 3CB9918EA2 for ; Sun, 23 Feb 2025 14:27:14 +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=1740320835; cv=none; b=iEhjrvkqKtiHrnfVnoYDPE7+GQlwNgZMKp1qJV34U9tOa5gg8DtH692cVIeoRBjFbte2nEzza7TYFfXhLVqe1UNY6V7OuND6E3HN/V4tRwElE7o8VcLvYkoa1uK4f084c2UC6faNzfcK5970Sha5hxVM70es7cwB2TXjtODEORc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320835; c=relaxed/simple; bh=GhCzxxxeMESAA5d73n7nTzV9B9qXIWu37yyaj73oZHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=no8EVAgcpfBtiUJOtm2Zysm5zGiTaoMQSw8xBtbziS611rSaDXzu8nTqNPlogTO7M63cAlFI7pXz6DP+Tr+U3smWL9h/0IxVJdbjTpbHCcMsVEmIgSKvgXL43YUW33c3PDNPaQr0Sz56hqAMnVvSiwyk9aFNuDsUH8nsBxiYyLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KueuZsuc; 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="KueuZsuc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED15FC4CEE8; Sun, 23 Feb 2025 14:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320834; bh=GhCzxxxeMESAA5d73n7nTzV9B9qXIWu37yyaj73oZHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KueuZsuc/qpUdHgBuXJlFWynG8deSf+KzOUog2TF3o/DYaLzu9e4wFWvf3jCwS8SD /eyN+3EjAo1GfogajVgV/3WuzNMrfyVdeLJZmuDKdT2SNJvDPntrkDmHqeFBFInKR7 ZuKN98Uef8YfHaBKgjlPmlYHp+E+yxcFiYJBK9bDdVPfZ0knbHYc+KvTlzu9j9OsGI JdgECKdVGr0GOUXBmebzknmDdycyzZNW0SXQysLLEvnKZWK9X6gniQpmHGy31Kb1VB qjNubea7fhe/wMykdr5yWvg0yTkGbwO7pm7XsXS7cS54A5whdPGa8PIr2gdJvj7ZxG HjaPWbi4r3faA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 08/13] mptcp: pm: drop pm_type in mptcp_pm_data Date: Sun, 23 Feb 2025 22:26:13 +0800 Message-ID: <9bd55b3cfc33211b89d8ad0dc734ff2ed4287ab9.1740320007.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 Now pm->pm_type can be replaced by pm->ops->type, then "pm_type" filed of struct mptcp_pm_data can be dropped. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 6 ++---- net/mptcp/protocol.h | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 147d9289e477..9f9e9cf18847 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -604,7 +604,6 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, void mptcp_pm_data_reset(struct mptcp_sock *msk) { const char *path_manager = mptcp_get_path_manager(sock_net((struct sock *)msk)); - u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk)); struct mptcp_pm_data *pm = &msk->pm; int ret; @@ -614,7 +613,6 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) pm->subflows = 0; pm->rm_list_tx.nr = 0; pm->rm_list_rx.nr = 0; - WRITE_ONCE(pm->pm_type, pm_type); rcu_read_lock(); ret = mptcp_pm_initialize(msk, mptcp_pm_find(path_manager)); @@ -622,11 +620,11 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) if (ret) return; - if (pm_type == MPTCP_PM_TYPE_KERNEL) { + if (pm->ops->type == MPTCP_PM_TYPE_KERNEL) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); /* pm->work_pending must be only be set to 'true' when - * pm->pm_type is set to MPTCP_PM_TYPE_KERNEL + * pm->ops->type is set to MPTCP_PM_TYPE_KERNEL */ WRITE_ONCE(pm->work_pending, (!!mptcp_pm_get_local_addr_max(msk) && diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 1fea29f52c35..a5b0fbb3a272 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -233,7 +233,6 @@ struct mptcp_pm_data { u8 add_addr_signaled; u8 add_addr_accepted; u8 local_addr_used; - u8 pm_type; u8 subflows; u8 status; DECLARE_BITMAP(id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); @@ -1099,12 +1098,12 @@ static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk) static inline bool mptcp_pm_is_userspace(const struct mptcp_sock *msk) { - return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_USERSPACE; + return msk->pm.ops->type == MPTCP_PM_TYPE_USERSPACE; } static inline bool mptcp_pm_is_kernel(const struct mptcp_sock *msk) { - return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_KERNEL; + return msk->pm.ops->type == MPTCP_PM_TYPE_KERNEL; } static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port) From patchwork Sun Feb 23 14:26:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987055 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 9B557200B85 for ; Sun, 23 Feb 2025 14:27:16 +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=1740320837; cv=none; b=XiL0rrU6wcfXejLNfv38icDH4R+Hx4kOZF4f0AshmaXiWJj8NxBb4pnQIjZd7xJxUN/4xQ0fZW7JfLSNSNSDU2+/zjt28f//K7pJ3vfztS0Wj1HgSMgx7hRRlvvu+JBRUXE29kBPNtCyxq53J+k7nRJSDKQnxQzr+qzjEXRikgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320837; c=relaxed/simple; bh=lHpC8OchawP77y2I/KZAzGjHOLlMNTkgnRXnxd5oSTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UweNZ3P9DAafUJjgKVyWM6jRVoSsGGelayaJS4zX1fCeP3MnijvKXn9frcmXADCjP+McLqPfnJ1Bd8pXgHQDbjpBeJiUITDNAiTFsSgNE/qmWSaRpJ2U6fRIqbdNUqxibcOFItdYT2VDwVMUybS3/70JxCZsPd0D1mzANLKUIWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W+f4qEbD; 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="W+f4qEbD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4262BC4CEE7; Sun, 23 Feb 2025 14:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320836; bh=lHpC8OchawP77y2I/KZAzGjHOLlMNTkgnRXnxd5oSTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+f4qEbDnR9WHP3f50TOPdI1P2TyAd8f9mXB6/Jqn0Rgyg9NgqjlOsBwa81YVee/O Xb5QPUsBl136M2OZmujBHPwWe7y0HjfGl4Zjyqg9TXvYvdVlIveMya8v9AsJlmpbJp XESP0eI6s/FELUZxHMg1slTW/P1nAMIIIgPgdIqcc3qHuz0o0crJhFYbU5n0ergGtO Zm9yVeNi8ce7Gk0YjQCzvkXqpsY2w6IRv7NPwjCLxty3H2g+hbobX0SdO8MMcTKofF dkgoOw6CdYLqavI0scitZpMGQxtXX/YJhldNP//eDl9+GQ4m8i2UZZPQK2jD4798I6 rWbV00eJJVN7A== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 09/13] mptcp: sysctl: drop old pm_type sysctl Date: Sun, 23 Feb 2025 22:26:14 +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 Old path manager sysctl "pm_type" can be replaced by the newly added "path_manager". Drop it together with mptcp_get_pm_type() helper. Signed-off-by: Geliang Tang --- Documentation/networking/mptcp-sysctl.rst | 17 ----------------- net/mptcp/ctrl.c | 20 -------------------- net/mptcp/protocol.h | 1 - 3 files changed, 38 deletions(-) diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst index a3218e35a328..454ce87bc1c5 100644 --- a/Documentation/networking/mptcp-sysctl.rst +++ b/Documentation/networking/mptcp-sysctl.rst @@ -72,23 +72,6 @@ enabled - BOOLEAN Default: 1 (enabled) -pm_type - INTEGER - Set the default path manager type to use for each new MPTCP - socket. In-kernel path management will control subflow - connections and address advertisements according to - per-namespace values configured over the MPTCP netlink - API. Userspace path management puts per-MPTCP-connection subflow - connection decisions and address advertisements under control of - a privileged userspace program, at the cost of more netlink - traffic to propagate all of the related events and commands. - - This is a per-namespace sysctl. - - * 0 - In-kernel path manager - * 1 - Userspace path manager - - Default: 0 - path_manager - STRING Set the default path manager name to use for each new MPTCP socket. In-kernel path management will control subflow diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 759ce4c30392..b8eaf1f58ab2 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -18,10 +18,6 @@ static int mptcp_pernet_id; -#ifdef CONFIG_SYSCTL -static int mptcp_pm_type_max = __MPTCP_PM_TYPE_MAX; -#endif - struct mptcp_pernet { #ifdef CONFIG_SYSCTL struct ctl_table_header *ctl_table_hdr; @@ -37,7 +33,6 @@ struct mptcp_pernet { u8 mptcp_enabled; u8 checksum_enabled; u8 allow_join_initial_addr_port; - u8 pm_type; char path_manager[MPTCP_PM_NAME_MAX]; char scheduler[MPTCP_SCHED_NAME_MAX]; }; @@ -79,11 +74,6 @@ unsigned int mptcp_close_timeout(const struct sock *sk) return mptcp_get_pernet(sock_net(sk))->close_timeout; } -int mptcp_get_pm_type(const struct net *net) -{ - return mptcp_get_pernet(net)->pm_type; -} - const char *mptcp_get_path_manager(const struct net *net) { return mptcp_get_pernet(net)->path_manager; @@ -105,7 +95,6 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet) pernet->checksum_enabled = 0; pernet->allow_join_initial_addr_port = 1; pernet->stale_loss_cnt = 4; - pernet->pm_type = MPTCP_PM_TYPE_KERNEL; strscpy(pernet->path_manager, "in-kernel", sizeof(pernet->path_manager)); strscpy(pernet->scheduler, "default", sizeof(pernet->scheduler)); } @@ -257,14 +246,6 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_douintvec_minmax, }, - { - .procname = "pm_type", - .maxlen = sizeof(u8), - .mode = 0644, - .proc_handler = proc_dou8vec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = &mptcp_pm_type_max - }, { .procname = "path_manager", .maxlen = MPTCP_PM_NAME_MAX, @@ -322,7 +303,6 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[i++].data = &pernet->checksum_enabled; table[i++].data = &pernet->allow_join_initial_addr_port; table[i++].data = &pernet->stale_loss_cnt; - table[i++].data = &pernet->pm_type; table[i++].data = &pernet->path_manager; table[i++].data = &pernet->scheduler; i++; /* table[i] is for available_schedulers which is read-only info */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a5b0fbb3a272..e5917b9ecd74 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -693,7 +693,6 @@ int mptcp_is_checksum_enabled(const struct net *net); int mptcp_allow_join_id0(const struct net *net); unsigned int mptcp_stale_loss_cnt(const struct net *net); unsigned int mptcp_close_timeout(const struct sock *sk); -int mptcp_get_pm_type(const struct net *net); const char *mptcp_get_path_manager(const struct net *net); const char *mptcp_get_scheduler(const struct net *net); From patchwork Sun Feb 23 14:26:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987054 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 843CE163 for ; Sun, 23 Feb 2025 14:27:17 +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=1740320837; cv=none; b=jWt45MXtWQcHqtFOeXc/iMHT0MUpffwwqO/uIzaFeh7t3Y1u2OyH53BdhpBq2N4bNHtPHzGvW39JIJ5uJlgPwZMf0Kdryw60sOJMaGbyB8wVUrekBK2IxPmW15ms2S0gsFcOo4vvhJXPUVxSte+UA1MEUg019yDg1DcPOVnUpAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320837; c=relaxed/simple; bh=jNsIlt+t75DHMSdUG6Q/zqYgq9/oGhPX2TmB5pgjyUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QIQyzwWgPB9RJzr/2IuNC5bf9qmPRif2Ifc+C53foWUBmOB+OixfGsvHbWY8398KP+azmg1tTYhevej91Lpbk+w8adhRPi+45W+QK79UTuJTTFK84cYZk+mSnvKyaFZeOxKpR4cTyQcPNLN2LKin+t7am3LZcTIMbX1XZNFVNC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ROuABeAt; 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="ROuABeAt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AC59C4CEDD; Sun, 23 Feb 2025 14:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320837; bh=jNsIlt+t75DHMSdUG6Q/zqYgq9/oGhPX2TmB5pgjyUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ROuABeAteqCjyeb77O/UOAqeT+muBXcTHOCygaW5qZkD6UDP3PrPo/ZaYht7VQxiw w6YumY8whH23TLKeZCboAFF6aPw8KuCwtrj9HUC9i5jAebBoJDwEVhDu8ba2qv17kq efzXGoTMAJ+rtB49F+87Iqqrzno4dR/Ei8IMwo8+d+3v8DU2LPAJddJIlRxJjif6DE KkbhaHtzXtvAun6GfcUyr56ijqwHpDt3OX4ccEQ9SAjdQ9axA86Zel7G9jLpp714Ry uixv0d0NfPfxS9tUI5lpRBGq1DWH/tKCyLzBrUWF8mKKL0LQxp0trYnKJuJRIBxDK+ Eh7nTw49NuCNQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 10/13] mptcp: sysctl: add available_path_managers Date: Sun, 23 Feb 2025 22:26:15 +0800 Message-ID: <6d1a4f40c9116c66d96486c8e56adb37cc659d5f.1740320007.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 Similarly to net.mptcp.available_schedulers, this patch adds a new one net.mptcp.available_path_managers to list the available path mangers. Signed-off-by: Geliang Tang --- Documentation/networking/mptcp-sysctl.rst | 4 ++++ include/net/mptcp.h | 2 ++ net/mptcp/ctrl.c | 25 +++++++++++++++++++++++ net/mptcp/pm.c | 20 ++++++++++++++++++ net/mptcp/protocol.h | 1 + 5 files changed, 52 insertions(+) diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst index 454ce87bc1c5..ee0b553b51a1 100644 --- a/Documentation/networking/mptcp-sysctl.rst +++ b/Documentation/networking/mptcp-sysctl.rst @@ -89,6 +89,10 @@ path_manager - STRING Default: "in-kernel" +available_path_managers - STRING + Shows the available path managers choices that are registered. More + path managers may be available, but not loaded. + scheduler - STRING Select the scheduler of your choice. diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 689926d1f39f..bcddaf0a588a 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -123,6 +123,8 @@ struct mptcp_sched_ops { } ____cacheline_aligned_in_smp; #define MPTCP_PM_NAME_MAX 16 +#define MPTCP_PM_MAX 128 +#define MPTCP_PM_BUF_MAX (MPTCP_PM_NAME_MAX * MPTCP_PM_MAX) struct mptcp_pm_ops { int (*created)(struct mptcp_sock *msk); diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index b8eaf1f58ab2..b61778c51706 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -136,6 +136,24 @@ static int proc_path_manager(const struct ctl_table *ctl, int write, return ret; } +static int proc_available_path_managers(const struct ctl_table *ctl, + int write, void *buffer, + size_t *lenp, loff_t *ppos) +{ + struct ctl_table tbl = { .maxlen = MPTCP_PM_BUF_MAX, }; + int ret; + + tbl.data = kmalloc(tbl.maxlen, GFP_USER); + if (!tbl.data) + return -ENOMEM; + + mptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX); + ret = proc_dostring(&tbl, write, buffer, lenp, ppos); + kfree(tbl.data); + + return ret; +} + static int mptcp_set_scheduler(char *scheduler, const char *name) { struct mptcp_sched_ops *sched; @@ -252,6 +270,12 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_path_manager, }, + { + .procname = "available_path_managers", + .maxlen = MPTCP_PM_BUF_MAX, + .mode = 0444, + .proc_handler = proc_available_path_managers, + }, { .procname = "scheduler", .maxlen = MPTCP_SCHED_NAME_MAX, @@ -304,6 +328,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[i++].data = &pernet->allow_join_initial_addr_port; table[i++].data = &pernet->stale_loss_cnt; table[i++].data = &pernet->path_manager; + i++; /* table[i] is for available_path_managers which is read-only info */ table[i++].data = &pernet->scheduler; i++; /* table[i] is for available_schedulers which is read-only info */ table[i++].data = &pernet->close_timeout; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 9f9e9cf18847..103b6b205dca 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -673,6 +673,26 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name) return NULL; } +/* Build string with list of available path manager values. + * Similar to tcp_get_available_congestion_control() + */ +void mptcp_pm_get_available(char *buf, size_t maxlen) +{ + struct mptcp_pm_ops *pm; + size_t offs = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(pm, &mptcp_pm_list, list) { + offs += snprintf(buf + offs, maxlen - offs, + "%s%s", + offs == 0 ? "" : " ", pm->name); + + if (WARN_ON_ONCE(offs >= maxlen)) + break; + } + rcu_read_unlock(); +} + int mptcp_pm_validate(struct mptcp_pm_ops *pm) { if (!pm->get_local_id || !pm->get_priority) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e5917b9ecd74..809611125c5e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1050,6 +1050,7 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk, extern struct mptcp_pm_ops mptcp_in_kernel_pm; struct mptcp_pm_ops *mptcp_pm_find(const char *name); +void mptcp_pm_get_available(char *buf, size_t maxlen); int mptcp_pm_validate(struct mptcp_pm_ops *pm); int mptcp_pm_register(struct mptcp_pm_ops *pm); void mptcp_pm_unregister(struct mptcp_pm_ops *pm); From patchwork Sun Feb 23 14:26:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987056 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 44622163 for ; Sun, 23 Feb 2025 14:27:18 +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=1740320839; cv=none; b=mKlb01DCZG3sLh75C0T9L48TyAW97VwU9uhhvXB43dwaunWnwsXqj0a0THRxC0XR1zPOerqAHA0tuYus/m5fLcVDzMXSOEGQNeYAB0WJX/nnZpEU9AItFx9jE9GEA6lAHAm70T24TKWFKuRYNfQRe46/osnAsZRUbvqAAUc0AGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320839; c=relaxed/simple; bh=mWMQIscGsc1KtkIz5+A8nwazjkwu2I68JeJ23qduncA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SXTZBw0bIlL9IE2QXkbY5FVPrh/vxm4B0PEcCgVqi7Ajvf1G6ROsMgr7J09JUo/j1juT/cEgP7ANrUQlCGxR810g6qx7nUvXBS5IJDj1x0uLMFiP5AJWwHIqcQg4JcJMwzmtWUPiEhC4mPGzB9ww6ykcyH2h2NyQW50ACa395ZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7FF20lY; 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="M7FF20lY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAE3AC4CEEA; Sun, 23 Feb 2025 14:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320838; bh=mWMQIscGsc1KtkIz5+A8nwazjkwu2I68JeJ23qduncA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7FF20lYc14R+xgF3dsh7gOMDvtFLYoFuUspXMXNkbyNc3hEBJVOggmbO7qNQyE/m fPjYmScyqG+4BZRKRG9BjTFYnLcBRkMMRnBvakbX1oumgykqylz7H0qWDCLQxRilyp EiZAbFlwGGZ2WxImVanLUC0BxB9LCcU+27rTy+yKMAk2rxYwTeJuXMcBDOZqRKT3r4 RWTpek1b7NfdW51BRNnu60IjtjxL37aRH1PNXgugW+kT7t3KbKTkE1Osadd6tGBrnH nkftmcso9Xcsh4rcHInh7KaD56sGQfKo43b7wut4q8bLhVWar7qQB7BIzLTg/dXHPq bM8eEkeOSNMmQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 11/13] mptcp: pm: drop get_local_id helpers Date: Sun, 23 Feb 2025 22:26:16 +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 Now mptcp_pm_nl_get_local_id() and mptcp_userspace_pm_get_local_id() helpers can be dropped, and mptcp_pm_get_local_id() can directly invoke get_local_id() interface through "ops" of "msk->pm". Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 4 +--- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/pm_userspace.c | 4 ++-- net/mptcp/protocol.h | 4 ---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 103b6b205dca..06be751fea21 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -425,9 +425,7 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) skc_local.addr.id = 0; skc_local.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; - if (mptcp_pm_is_userspace(msk)) - return mptcp_userspace_pm_get_local_id(msk, &skc_local); - return mptcp_pm_nl_get_local_id(msk, &skc_local); + return msk->pm.ops->get_local_id(msk, &skc_local); } bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index aa9be671293d..64808f4e7808 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1139,8 +1139,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, return err; } -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc) +static int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc) { struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 17450cf8f920..3c8b61ed345b 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -130,8 +130,8 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) return NULL; } -int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc) +static int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *skc) { __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 809611125c5e..b6441328dc3c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1136,10 +1136,6 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, struct mptcp_rm_list *rm_list); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc); -int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc); bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc); bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); From patchwork Sun Feb 23 14:26:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987057 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 893FD163 for ; Sun, 23 Feb 2025 14:27:20 +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=1740320840; cv=none; b=HrQGitNpZWcuIlRRnA2fRGkeKkEE5apZCCdMlKfMxaHRfxtxZ6Mfv5SKTM3vZOBlB2jLcUSg3ew5A3KEZeHksqkNmmwBEw/AkicmtSYH+uCbV7xH+Cuqf5xLtG//Nxsn+5jN4MkJ+Ev0y8RcPhEnD9/1/cyHdjLndkZ5RyW+57w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320840; c=relaxed/simple; bh=VaxlueEpyL6CFmRKiJDLB1qXryLZmlosRKG6JmfCLeo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nB+lsQt3Iz1OXJtL/G6huj6z7ya2gAiy8sMYiXwkZ7Bk83sYvow6zXd6M0i+vcznCOtMccs4tfWIfYKS65/qXSDVQz2BszaWhes5NqQ93TSOKtKt5mren4YwOTg16QNcd4QxjgtfYmiInliz7DG3AAnPXRW+GpJv7TdE+zk7+z0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WHj9YUtJ; 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="WHj9YUtJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 477CBC4CEE7; Sun, 23 Feb 2025 14:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320840; bh=VaxlueEpyL6CFmRKiJDLB1qXryLZmlosRKG6JmfCLeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WHj9YUtJVGN6pH/JX2kp/ljIKALR6SpYkJAvuCrZBSL6Oow8fdoOc9mPQ5MCpMZ6D 9ZDWjVVdy5owCr1d1KsWr+vmtQKPlTt4zIIBluNa/5hzC5bl5Vpr6A/zY+mlB/wI0f BEhbSaPxIbRNzItZncAl2fzGf76m9WsJ6VnHOtMgS268K9Fb1I2TeVsXsPdMqY4wu6 IDOICTy73Q81b+V0Rk/a+woMs1ZfZUNbhmTvmh2N4+6aahQysetAyoO236Wb9ng7KP k4ZWfL9pCunzbdRQZ0NlGONX0ico+98gqLN6H0z4Ce8TLZxoH+80Z+WYRQilzbVMW4 +ihnAe0kAoA6Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 12/13] mptcp: pm: drop is_backup helpers Date: Sun, 23 Feb 2025 22:26:17 +0800 Message-ID: <0262f8f4937db2daebaffd8f375dd8dc623b45fb.1740320007.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 Now mptcp_pm_nl_is_backup() and mptcp_userspace_pm_is_backup() helpers can be dropped, and mptcp_pm_is_backup() can directly invoke get_priority() interface through "ops" of "msk->pm". Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 5 +---- net/mptcp/pm_netlink.c | 5 ----- net/mptcp/pm_userspace.c | 6 ------ net/mptcp/protocol.h | 2 -- 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 06be751fea21..9db1c62ae0cd 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,10 +434,7 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) mptcp_local_address((struct sock_common *)skc, &skc_local); - if (mptcp_pm_is_userspace(msk)) - return mptcp_userspace_pm_is_backup(msk, &skc_local); - - return mptcp_pm_nl_is_backup(msk, &skc_local); + return msk->pm.ops->get_priority(msk, &skc_local); } static int mptcp_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 64808f4e7808..5932be406bde 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1184,11 +1184,6 @@ static bool mptcp_pm_nl_get_priority(struct mptcp_sock *msk, return backup; } -bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc) -{ - return mptcp_pm_nl_get_priority(msk, skc); -} - #define MPTCP_PM_CMD_GRP_OFFSET 0 #define MPTCP_PM_EV_GRP_OFFSET 1 diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 3c8b61ed345b..b618dc7c916a 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -163,12 +163,6 @@ static bool mptcp_userspace_pm_get_priority(struct mptcp_sock *msk, return backup; } -bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, - struct mptcp_addr_info *skc) -{ - return mptcp_userspace_pm_get_priority(msk, skc); -} - static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *info) { struct mptcp_sock *msk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b6441328dc3c..0aa882e175f1 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1137,8 +1137,6 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, struct mptcp_rm_list *rm_list); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc); -bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); -bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, From patchwork Sun Feb 23 14:26:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13987058 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 8DEAF204F85 for ; Sun, 23 Feb 2025 14:27:21 +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=1740320841; cv=none; b=jIppcArLtS/1toktCYBeTmF7QpU0hR4RjVzs51uoNJpLhqsj4h4inftGugG5+ECEhHOmC7iu2ZxEjT5gEacYOuXrHraHPl7vkPPV3OEI2BSwbte6s9O1x9via8xOqAqsW4YoJF0lKBkV00CgrjcrKrZTGTMQwpIOF8DGd68cImQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740320841; c=relaxed/simple; bh=6tJXIO1uBlnJtX4cdl4ZPNu21fXkU7RaqColePmyvfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z/o9BiC1U2dm/W5TShlt9DCtHEDdpl2Bw72UZ/0N5QNzHxCpGF4BrYSp8wUWDRRaX7DRe3E7UvQz2FRVesoibB9k4TtKkNlMkYpPw+YBkjVOOI9ferhOGii4Yfne4vmXUtkSC77PkxOwPkIhummNzezNvoHniGhVs9ZRZ4vcPVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZxCbzMYq; 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="ZxCbzMYq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99CBCC4CEDD; Sun, 23 Feb 2025 14:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740320841; bh=6tJXIO1uBlnJtX4cdl4ZPNu21fXkU7RaqColePmyvfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZxCbzMYqbQP6lojB/ITSuNSaKy0PfkmwLn6sNZK0nTL2SbiQLbzUjXRZBaUOyeMLK GhksyK0SXZVcZ3N4vr3LHAANIMWMOEC0gvpUDTBGVDS7Oo23nhbTJnjo3PR/mtIos2 p6/tMo/OoHz0OAze5Ie6ExxE3XHK56ezrkwd5RFO8CWBciKnqo2h2Z3BAc/Jq2+pKK 1a2bXsDA8+XYZ4ldOE29dKPhaiQqiW6DWmb2nlJUa2vKq7zfOAlzTNEq+TKdRGpyxC dRQV2T6WBaVJaDBDe5oxF2k9X7SyFuEsbLQxAiFP/BT2VVHGplmSKDbCDcAW0fUoLg uII3SIGSwgmDQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v6 13/13] selftests/mptcp: use path_manager instead of pm_type Date: Sun, 23 Feb 2025 22:26:18 +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 uses the newly added net.mptcp.path_manager instead of the old net.mptcp.pm_type for all path manager selftests in mptcp_join.sh and userspace_pm.sh. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 26 +++++++++---------- .../selftests/net/mptcp/userspace_pm.sh | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 13a3b68181ee..ed04e7dedf23 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -99,7 +99,7 @@ init_partial() local netns for netns in "$ns1" "$ns2"; do - ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true + ip netns exec $netns sysctl -q net.mptcp.path_manager="in-kernel" 2>/dev/null || true if $checksum; then ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1 fi @@ -1920,7 +1920,7 @@ set_userspace_pm() { local ns=$1 - ip netns exec $ns sysctl -q net.mptcp.pm_type=1 + ip netns exec $ns sysctl -q net.mptcp.path_manager="userspace" } subflows_tests() @@ -3497,7 +3497,7 @@ userspace_tests() { # userspace pm type prevents add_addr if reset "userspace pm type prevents add_addr" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 0 2 @@ -3509,7 +3509,7 @@ userspace_tests() # userspace pm type does not echo add_addr without daemon if reset "userspace pm no echo w/o daemon" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 0 2 @@ -3521,7 +3521,7 @@ userspace_tests() # userspace pm type rejects join if reset "userspace pm type rejects join" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 pm_nl_set_limits $ns1 1 1 pm_nl_set_limits $ns2 1 1 @@ -3532,7 +3532,7 @@ userspace_tests() # userspace pm type does not send join if reset "userspace pm type does not send join" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 1 1 pm_nl_set_limits $ns2 1 1 @@ -3543,7 +3543,7 @@ userspace_tests() # userspace pm type prevents mp_prio if reset "userspace pm type prevents mp_prio" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 pm_nl_set_limits $ns1 1 1 pm_nl_set_limits $ns2 1 1 @@ -3556,7 +3556,7 @@ userspace_tests() # userspace pm type prevents rm_addr if reset "userspace pm type prevents rm_addr" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 @@ -3570,7 +3570,7 @@ userspace_tests() # userspace pm add & remove address if reset_with_events "userspace pm add & remove address" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 pm_nl_set_limits $ns2 2 2 { speed=5 \ @@ -3603,7 +3603,7 @@ userspace_tests() # userspace pm create destroy subflow if reset_with_events "userspace pm create destroy subflow" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 { speed=5 \ @@ -3631,7 +3631,7 @@ userspace_tests() # userspace pm create id 0 subflow if reset_with_events "userspace pm create id 0 subflow" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 { speed=5 \ @@ -3652,7 +3652,7 @@ userspace_tests() # userspace pm remove initial subflow if reset_with_events "userspace pm remove initial subflow" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 { speed=5 \ @@ -3676,7 +3676,7 @@ userspace_tests() # userspace pm send RM_ADDR for ID 0 if reset_with_events "userspace pm send RM_ADDR for ID 0" && - continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then set_userspace_pm $ns1 pm_nl_set_limits $ns2 1 1 { speed=5 \ diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 3651f73451cf..dfeec8d4aecf 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -13,7 +13,7 @@ mptcp_lib_check_mptcp mptcp_lib_check_kallsyms -if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then +if ! mptcp_lib_has_file '/proc/sys/net/mptcp/path_manager'; then echo "userspace pm tests are not supported by the kernel: SKIP" exit ${KSFT_SKIP} fi @@ -119,7 +119,7 @@ trap cleanup EXIT # Create and configure network namespaces for testing mptcp_lib_ns_init ns1 ns2 for i in "$ns1" "$ns2" ;do - ip netns exec "$i" sysctl -q net.mptcp.pm_type=1 + ip netns exec "$i" sysctl -q net.mptcp.path_manager="userspace" done # "$ns1" ns2