From patchwork Thu Feb 20 02:57: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: 13983246 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 572FD13A3ED for ; Thu, 20 Feb 2025 02:57:43 +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=1740020264; cv=none; b=dGAPoTJWI+cWp2BJXWHJI3w+5XrRKjMbpDJOO4fCN7ZoXoed0pIKkcogDvRqVLuFvIGX5DsdnjBJmOlNJlfYe6biK1HlP4t/6UqoVohR1VYUUSRgH/XAumzl7DvQs0ULk5CrfWGH+3GlGR1qimi4QzZX+p6WZXIm3Wvtz8S/U98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020264; c=relaxed/simple; bh=NvBKnowwkziP6+cF88wJgnfAErBA1AV+AVSaTZm9bFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FXsaVmmF+z3JztZGxPbvhpB93AaRWx/1G2pYbMamFwa6jYywfy+EVTghkZk0hAF0587k2W3RXFEstvfO8nKmSpazdATDSdmJwElW8E/DRulQ47UKOTcpLN/Nqu7ERkSA10tZmacB+c+5aFwkutE3j+5n1CZpZrY3QVXPq2GwD34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L9UYIt4C; 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="L9UYIt4C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D4BC4CEE0; Thu, 20 Feb 2025 02:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020263; bh=NvBKnowwkziP6+cF88wJgnfAErBA1AV+AVSaTZm9bFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9UYIt4C+h9VkRU+IpuZW4Ec8kZ0M0Szx1oxh/WRQsTU+omNy3wMUnEaOOcMZZ/Ed Qa7TTbHWaw+e+GTJFhB7OJKNDYbk2oLnoyzXMJqnY0ncz8WSnRSuqh/Xc8z1wDBeS3 7mSg01BQ/80Ikb3mkSQY1M5AWNSduMmuWsZLUzgJk83N2EWaofeCJ2kpfAz3OQUXxF 2nrfz4k+gaJBvZ46z3OSJ+QMPzac76tsc1UgldO88l3WPGF5Dslpc0sDQZuJeRV/Ko Ig8Jz7S378zZQnXdxV8Xp+ocYw/9GSaPbJaefIUVgEW2UqZ9KlCPSAP5tJSebb8gIU KtdwS6Kh5SpLg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 1/9] mptcp: pm: use addr entry for get_local_id Date: Thu, 20 Feb 2025 10:57:25 +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 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 | 11 ++++++++--- net/mptcp/pm_netlink.c | 9 ++++----- net/mptcp/pm_userspace.c | 17 ++++++----------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 16cacce6c10f..94620ab172b7 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -403,20 +403,25 @@ 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; struct mptcp_addr_info msk_local; if (WARN_ON_ONCE(!msk)) return -1; + memset(&skc_local, 0, sizeof(struct mptcp_pm_addr_entry)); + /* The 0 ID mapping is defined by the first subflow, copied into the msk * 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..0a0fe890c53d 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,11 +1160,9 @@ 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) 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 3d72ca155322..ef1d43406f9b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1126,8 +1126,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 Thu Feb 20 02:57: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: 13983247 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 999A91D8A0B for ; Thu, 20 Feb 2025 02:57:45 +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=1740020265; cv=none; b=OZZdOxyytM441sf6sJvDmpjKsOftEXxQiMlDqNPGdG4v7k08Eq2YxP85s645rR4a3NDS/L8fVewfjIINKyNwiC7LzGZJP8VI54zlUx/JdKBPMczQ9lEWco3acBtzOQNtYQ+FnKMU4jPKxtP7ezw3hJH4ElGg9dyd1jgQj+jnhgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020265; c=relaxed/simple; bh=CSgaIKuH2iv+hZflFk8QF6oobcfESTuAQGBWGQ2OUdY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lxglCkoqyNYrTZcNL+NYmoiScZAZcZNbbp0hG/wAxZmE7yTEfV8emXVZcwawv0ArNPtDf1GjiYhjfI5qEDmAnhk+HNzfnuRSzuRnOHejjEMZDPDY0bkYHpY/77MBJtRE0mXONWVcI4WnfLAjTsquc86qXmFhqSghrzP8kXDspHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PVrzCtrU; 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="PVrzCtrU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56876C4CEE8; Thu, 20 Feb 2025 02:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020265; bh=CSgaIKuH2iv+hZflFk8QF6oobcfESTuAQGBWGQ2OUdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PVrzCtrUGvXvZLlt87RpogTVTnoozLF+9nxxZbjCXgj4dONsDTHqr5hO1tkGCxneR 9He5BMiQds+3RC0H1aeBlyWzkq4ZdRESQ/xuQWnWrbG7m46Eh54yEL1L2yvylngqIp fw3GDrcu0VEJYIOfItQNhJbOmAy7CUQeZ7TBEX8H3+CH6xo0K0QEtSmALU9pBbQrZG pI+ztevXRrvr3iq3gPA0kVF+TDyJTPNbp8hZbj5IozL4n4+lUrwnIe41yOyWNb9rFI rUlNC/vupxei5wWHn6onkMmiVJuhlr+Eym9bkZs8/zDzVdSyDxW7ALfo9zmJPEH2WQ Eol73A8ET68YQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 2/9] mptcp: pm: add struct mptcp_pm_param Date: Thu, 20 Feb 2025 10:57:26 +0800 Message-ID: <2f68d8851458f6f5acfd9a6ea549f3b73029d4bc.1740019794.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 Generally, in the path manager interfaces, the local address is defined as an mptcp_pm_addr_entry type address, while the remote address is defined as an mptcp_addr_info type one: (struct mptcp_pm_addr_entry *local, struct mptcp_addr_info *remote) In order to make these interfaces more flexible and extensible, a struct mptcp_pm_param is defined here to pass parameters. "entry" can be used as the local address entry, and "addr" can be used as the remote address. Also add a new helper mptcp_pm_param_set_contexts() to set a struct mptcp_pm_param type parameter. Signed-off-by: Geliang Tang --- include/net/mptcp.h | 13 +++++++++++++ net/mptcp/pm.c | 10 ++++++++++ net/mptcp/protocol.h | 11 +++-------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 72d6e6597add..a41d6c74760f 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -121,6 +121,19 @@ struct mptcp_sched_ops { void (*release)(struct mptcp_sock *msk); } ____cacheline_aligned_in_smp; +struct mptcp_pm_addr_entry { + struct list_head list; + struct mptcp_addr_info addr; + u8 flags; + int ifindex; + struct socket *lsk; +}; + +struct mptcp_pm_param { + struct mptcp_pm_addr_entry entry; + struct mptcp_addr_info addr; +}; + #ifdef CONFIG_MPTCP void mptcp_init(void); diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 94620ab172b7..6a504c870e1a 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -401,6 +401,16 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, return ret; } +void mptcp_pm_param_set_contexts(struct mptcp_pm_param *param, + const struct mptcp_pm_addr_entry *entry, + const struct mptcp_addr_info *addr) +{ + if (entry) + param->entry = *entry; + if (addr) + param->addr = *addr; +} + int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) { struct mptcp_pm_addr_entry skc_local; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index ef1d43406f9b..dbcf4b84e0f0 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -246,14 +246,6 @@ struct mptcp_pm_local { int ifindex; }; -struct mptcp_pm_addr_entry { - struct list_head list; - struct mptcp_addr_info addr; - u8 flags; - int ifindex; - struct socket *lsk; -}; - struct mptcp_data_frag { struct list_head list; u64 data_seq; @@ -1125,6 +1117,9 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, bool *drop_other_suboptions); bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, struct mptcp_rm_list *rm_list); +void mptcp_pm_param_set_contexts(struct mptcp_pm_param *param, + const struct mptcp_pm_addr_entry *entry, + const struct mptcp_addr_info *addr); 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); From patchwork Thu Feb 20 02:57: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: 13983248 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 D8F781DA62E for ; Thu, 20 Feb 2025 02:57: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=1740020266; cv=none; b=dJxMlQ3o15fLKwhoeLaJ4NW1iFzgj9pffDlHXLMWh3/3RCE9W4C0K6RoMTWg+x6PurpNarZoj9n31G4ozRBk+beU5UXEsEvQ0yEqOzrT+A1hMQPyaCcDXTmEXl0GBnwwiJxFxb71Pphtx/nYI8oLE4DS189MZnrslonHqfYmg4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020266; c=relaxed/simple; bh=qHlwxH/3odovgKnCENyhjorue50FrKpzQdg/YoZHamg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bvVj6n8OsddmmbA1GjGK9V4u01poNpwV/H02vHH0m9K6UnHjrCmxmjNQT1/bBy+nYQ2VWyIUlSCVpXvwun9cxvp9Z0bCiCk2bAdjlibVC00PeCkwSHq6feWLORUuc0womxXFR7aAvd5iL5B4xcLopyP1dxCeVFkWtovC1frMHe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nIi23OKy; 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="nIi23OKy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99238C4CED1; Thu, 20 Feb 2025 02:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020266; bh=qHlwxH/3odovgKnCENyhjorue50FrKpzQdg/YoZHamg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIi23OKyIwFlsulgbioZWxpcwD6pGkuB332oCKnp8luY/1QmanvKp21Y7NXFpYHSq HT7OLLA9wXKhWZytzKj7cYw1OC7YQf6IhJ+YMceykx1UtYMxlJD8oG+k988dnnIVDj TxBWa8vvAlS3AgDIvCL5ofx5aQcmoGMN3kJEBb9ZHfz+180QDVT6iyplDYZpoVu2oo ryvZRmFn40cJ9ysHIgo9p1GqYEJQA7l/16gWRzlEzzdF3zkPiw4U86k2x+MBtVnAPp CgaiKcZF/Qo5BIlMiK0ilo8Z50NSMNV5qnU1G9R5eIhs9xR+GXHa423n/Pp52Z3ekJ 7Cjdfn84DQEag== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 3/9] mptcp: pm: pass pm_param to get_local_id Date: Thu, 20 Feb 2025 10:57:27 +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 changes the 2nd parameter of get_local_id() interface as "struct mptcp_pm_param" type. Only "entry" member of this struct is used. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 6 ++++-- net/mptcp/pm_netlink.c | 3 ++- net/mptcp/pm_userspace.c | 3 ++- net/mptcp/protocol.h | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 6a504c870e1a..e3457f34621c 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -415,6 +415,7 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) { struct mptcp_pm_addr_entry skc_local; struct mptcp_addr_info msk_local; + struct mptcp_pm_param param; if (WARN_ON_ONCE(!msk)) return -1; @@ -432,9 +433,10 @@ 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; + mptcp_pm_param_set_contexts(¶m, &skc_local, NULL); 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 mptcp_userspace_pm_get_local_id(msk, ¶m); + return mptcp_pm_nl_get_local_id(msk, ¶m); } 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 0a0fe890c53d..3709ad2c06ef 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1140,8 +1140,9 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, } int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc) + struct mptcp_pm_param *param) { + struct mptcp_pm_addr_entry *skc = ¶m->entry; struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; int ret; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 5b3ee43130be..bd235b2d18b3 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -131,10 +131,11 @@ 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_pm_addr_entry *skc) + struct mptcp_pm_param *param) { __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; + struct mptcp_pm_addr_entry *skc = ¶m->entry; struct mptcp_pm_addr_entry *entry; spin_lock_bh(&msk->pm.lock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index dbcf4b84e0f0..7987beaa730e 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1122,9 +1122,9 @@ void mptcp_pm_param_set_contexts(struct mptcp_pm_param *param, const struct mptcp_addr_info *addr); 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); + struct mptcp_pm_param *param); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *skc); + struct mptcp_pm_param *param); 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 Thu Feb 20 02:57: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: 13983249 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 C97441D89FD for ; Thu, 20 Feb 2025 02:57:47 +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=1740020267; cv=none; b=l2HA1xlDMuU6GC2rnJDJUB1YhCWn9/d33rRZ8Mw2GCkpfZCrdXYO47bjLwGOl8DxKpmD2hc/uBD34Q30gBad76FAWiNBAdfuYC+ChyePSRGu6lnCJDOA++xm7BmMt/LWcLSkNx4Nx9Kvk1G1jzh/yqht9LMYqzzqT1cwrF3MO6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020267; c=relaxed/simple; bh=9duXCSVpsOsVIcRSOo3WLC2kYJWoM5cGbKSXZ6U+bQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=umyij6okJ0YLBkzlHd249MZTxePnVwpeGYxDpJbfLQjqtD2CmnFHWm6e2+FiOFssOrSphWzhCNoMXtDspXC9SJNEZA1dfPXmHfyU6Np+H2bcZAPgqcT+t7TDwuDkD2WwJuZrXF98K/8fFCgd6Cgcuhc/b93LCfmO9jb3CUnNhBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tKhloYND; 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="tKhloYND" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9FF0C4CED6; Thu, 20 Feb 2025 02:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020267; bh=9duXCSVpsOsVIcRSOo3WLC2kYJWoM5cGbKSXZ6U+bQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tKhloYNDtsUuLBStjSyA6dEJx/qqSF/ZJTVvWwusQsMJRC/UVDtRgX6SVHCjVWPpa kskXA2kukN7qKn9QjNrEsIFM/JQ0x2LU2xhzuYFfQCMDAtwNOmGXEoIIwUxZ5poyyS /vWmBfahTTlXzWRV6gBydwxPfxxlFyGfrwaKWnhdVfxDkhkMt1alhqwnyqxw83KNi8 mPQ1LZNMwVG0G7nINHEb+6LxtE/PedIajfyA0AesNd21wsOTkALR0hVcBZSpn+X6yC 4YSKVDL6FpKpY+T9pQXlnwa/gbmeUPGoeSTyOU8AzcX0wf6yuq4xyVnoFeSqB3G65c nIV7bZmFAYbug== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 4/9] mptcp: pm: define struct mptcp_pm_ops Date: Thu, 20 Feb 2025 10:57:28 +0800 Message-ID: <5f83856741646b16dde9a741fcfbfa55753eee39.1740019794.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 | 29 ++++++++++++++++++++++ net/mptcp/pm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 5 ++++ 3 files changed, 93 insertions(+) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index a41d6c74760f..f51e75d3882d 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -134,6 +134,35 @@ struct mptcp_pm_param { struct mptcp_addr_info addr; }; +struct mptcp_pm_ops { + int (*created)(struct mptcp_sock *msk); + int (*established)(struct mptcp_sock *msk); + int (*closed)(struct mptcp_sock *msk); + int (*address_announced)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*address_removed)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*subflow_established)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*subflow_closed)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*get_local_id)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + bool (*get_priority)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*set_priority)(struct mptcp_sock *msk, + struct mptcp_pm_param *param); + int (*listener_created)(struct mptcp_sock *msk); + int (*listener_closed)(struct mptcp_sock *msk); + + u8 type; + 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 e3457f34621c..f56b2d1e3409 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, @@ -661,3 +666,57 @@ 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(enum mptcp_pm_type type) +{ + struct mptcp_pm_ops *pm; + + list_for_each_entry_rcu(pm, &mptcp_pm_list, list) { + if (pm->type == type) + return pm; + } + + return NULL; +} + +int mptcp_pm_validate(struct mptcp_pm_ops *pm) +{ + if (!pm->created && !pm->established && !pm->closed && + !pm->address_announced && !pm->address_removed && + !pm->subflow_established && !pm->subflow_closed && + !pm->get_local_id && !pm->get_priority && !pm->set_priority && + !pm->listener_created && !pm->listener_closed) { + 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->type)) { + 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("userspace_pm type %u registered\n", pm->type); + 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 7987beaa730e..f3e04927e214 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1039,6 +1039,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(enum mptcp_pm_type type); +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 Thu Feb 20 02:57: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: 13983250 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 0C80713A3ED for ; Thu, 20 Feb 2025 02:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020269; cv=none; b=rsyDC8R0ErLr5ZFglzVYKBz8Li7d8nk/DVwkRevoHMv8EuBvZFvV+AW9+L7Oxc9kyZQRMAWKu4gQ3txdAYZ965l8Fs1NqsMuIWWdzdygwtaXiZqz52avV4sPcoaRr4hJawzYxhMKGVqJuX5QccxVbGOLRMJTr6DDbZUGawt/1NI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020269; c=relaxed/simple; bh=ldOQrLusbg/Bdv5yC2VnZeszKVKnyVJdeQCc/aR5f2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WpWMqQhvxxWfCGnketCZzDJ4Xi0KHLmwgYKILEK4WdBjoUaGXKbo87kQoGvNiHEhgsca0yRv7+SjSljiOBsTAAhfSj1ixPNbu181wZez0M8OCjQiT4L3caxVeQs/aqYZLq1XGbs9JnODo0PMUMDkHvkoAs5DqziSKYQFQkgleJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F/F+TD3j; 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="F/F+TD3j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23EADC4CED6; Thu, 20 Feb 2025 02:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020268; bh=ldOQrLusbg/Bdv5yC2VnZeszKVKnyVJdeQCc/aR5f2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/F+TD3jXJGyhEIL/nFuGMRS/IHslWBOqO/RpE8+TLcSh+Mw6xAvMIcX67rWUpV9e GOSQlGiuFsGN7dmUQlOJa9oNjzhrzTnVNpDBCUSGekMN50Wp7Y00iWbKWZApY5nldm nh+naVWLCikC8eUqAWvmsE77qTfU8fWJdDGPp1Ky6IghSKOwcQTX0T/n+5vpG73iAF DKibesmpdZjHGumj1lvFo0VpzXcPXDkPMCtiHD+wwSrJLwbUNZ6Q1v/Odoq7QyKLUS i8T5vBp4gOLaalwOp5w1cf/JN+Tfx1CqZe0vh06qGXqFurycuGlf9eoE+2NmQoUDxV iWWYfMFqkaNDg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 5/9] mptcp: pm: in-kernel: register mptcp_netlink_pm Date: Thu, 20 Feb 2025 10:57:29 +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 defines the original in-kernel netlink path manager as a new struct mptcp_pm_ops named "mptcp_netlink_pm", and register it in mptcp_pm_nl_init(). 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_netlink.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 3709ad2c06ef..e0f8754e261e 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1172,9 +1172,11 @@ 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_pm_param *param) { struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); + struct mptcp_addr_info *skc = ¶m->addr; struct mptcp_pm_addr_entry *entry; bool backup; @@ -1186,6 +1188,14 @@ 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) +{ + struct mptcp_pm_param param; + + mptcp_pm_param_set_contexts(¶m, NULL, skc); + return mptcp_pm_nl_get_priority(msk, ¶m); +} + #define MPTCP_PM_CMD_GRP_OFFSET 0 #define MPTCP_PM_EV_GRP_OFFSET 1 @@ -2373,6 +2383,13 @@ static struct pernet_operations mptcp_pm_pernet_ops = { .size = sizeof(struct pm_nl_pernet), }; +static struct mptcp_pm_ops mptcp_netlink_pm = { + .get_local_id = mptcp_pm_nl_get_local_id, + .get_priority = mptcp_pm_nl_get_priority, + .type = MPTCP_PM_TYPE_KERNEL, + .owner = THIS_MODULE, +}; + void __init mptcp_pm_nl_init(void) { if (register_pernet_subsys(&mptcp_pm_pernet_ops) < 0) @@ -2380,4 +2397,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_netlink_pm); } From patchwork Thu Feb 20 02:57: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: 13983251 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 4CFBA1D86ED for ; Thu, 20 Feb 2025 02:57: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=1740020270; cv=none; b=jlj1/tB7ULTyXNFKzIU7jaKFR7cFaRVQgcIHUWR9pwGNNECkDFZ+Hh7jvPrx1ndTBIGP4iT1nOHjpXTfw31Q+GtoHZMd8D2/TG1bklIHTyAAx0MFu4qwjJtAMnOdLGqFRWgD84A7zKT4A2gR6ihnfT5s8rC7sNGWnykynBrO86M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020270; c=relaxed/simple; bh=WN2Pr1MPt7o+UW5Fyfq3vcMYMrHc10UABxqTthJbWdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SuzuFfY6jOf22vKAz/0n4gVi7+Sx/yi3SPWvlwuW96+GZXhZTfZh0GpABoPtgpZFEg422NFjX503QvGuYJekNrXEMocdCVBCKZqoB82iIopDMHmeId9MZs+hYEX2qL5sGtheAvLaE86xIPUJci+nlgkEQVBRIyTXllapKYKB/So= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aDT73H2C; 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="aDT73H2C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63903C4CED6; Thu, 20 Feb 2025 02:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020270; bh=WN2Pr1MPt7o+UW5Fyfq3vcMYMrHc10UABxqTthJbWdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aDT73H2Coo6l2O331+u/Z/soo2Bd01Pw2OPfM1h2q5VULjwssU+DnZWdODgIehXgF dLrzSYEI7ajjv/p0tHhOJtrAupH1/RlC/YKjHQDkkqfRlk/otsIbluPIUqx6y+u28b tRo0skOXji7giFpHDdmuFfym+YdEKiKBuKjG6Lo/5GtLev5zUBWTeRPOGF8q5RhAvF qytITU46/d9y175Vt5mZEnuDybRBG8HWe7AM3caCjnbp7yqCuMi0pUMstORrHmjln6 9+4dn/DkfD/R1zo34h3AGvsnvaR7xtFBBnOAnfg3l28n7sH8HjHUy+mFRMtozuD00o Fo5mXCIEIMplA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 6/9] mptcp: pm: userspace: register mptcp_userspace_pm Date: Thu, 20 Feb 2025 10:57:30 +0800 Message-ID: <79352d1b04b46dc9f5541d466822a518edfb63fd.1740019794.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 | 26 ++++++++++++++++++++++++-- net/mptcp/protocol.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index f56b2d1e3409..91e377058243 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -665,6 +665,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 bd235b2d18b3..6e51335c8bc1 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -150,9 +150,10 @@ 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_pm_param *param) { + struct mptcp_addr_info *skc = ¶m->addr; struct mptcp_pm_addr_entry *entry; bool backup; @@ -164,6 +165,15 @@ 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) +{ + struct mptcp_pm_param param; + + mptcp_pm_param_set_contexts(¶m, NULL, skc); + return mptcp_userspace_pm_get_priority(msk, ¶m); +} + static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *info) { struct mptcp_sock *msk; @@ -687,3 +697,15 @@ 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, + .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 f3e04927e214..021c0f87da1b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1152,6 +1152,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 Thu Feb 20 02:57: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: 13983252 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 E5EA213A3ED for ; Thu, 20 Feb 2025 02:57: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=1740020272; cv=none; b=ekC0Eys3uDro85NBCLRgkNx3M1AltVzTAR20pjxQK5d7IYFUMK+US5WsQdfX8gePm2FBB6bU6sSw3eQxDNqsdxaeA6D/7IMplvA0SFlyHxVXiXQz0jtlveSR+eKHsQOwTgq8rGUpbx2jBwBcoqLYGVatmcycZkv4kQcpffaD1tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020272; c=relaxed/simple; bh=XJBrxtnje2GL9Ak8KcqIPa32ItgN+B54GR6VajxR/K4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XihwGF2CQhwoq89ZKO2Mp10I5kjmrLeOMB+Jxg3hqeUeK10GAkettzfSHtZW6OdfB3MwTnk9xk5fCtVsjzZHHwGpdcXDs0zi40zY3QdU1Bihgek6/lCWod3vSvczR2xeMXV4yQ+QmijXD4qGt0dqXDPtuawCjbvjIO9XwvFAvl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aPNJgKtq; 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="aPNJgKtq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7198C4CED1; Thu, 20 Feb 2025 02:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020271; bh=XJBrxtnje2GL9Ak8KcqIPa32ItgN+B54GR6VajxR/K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aPNJgKtqyMgCeESan5fR0NH5Xs+UOrs01J4o3TE4Mbva4Jhj7nl4I/xf9kWxUqwfH ++BCFexnspu2mySvfVWhtDmfRJicHJnuqTdcVfGlKuqLWWKEWkQeYN8QlbXWLG4xLd m1UU4hK+Kl/J2ykdSc9eEE69BhuSu/Cy4ikYCG6zTFfv0OR65Z/T0wyO+i4Wy9GZJ6 hndQSSO6rLKpIEVtdIfHXOp9rVa29csDS6VZh5+MJraVBlE/5TPhCayEKslpuQMiVe f0ee9OJiUmBEi9NvKskmnxCgkSWWXrupfTONgp9rziyIiySNr4jf3qDt+gQZ6vvzMv 0Q7TsNdR3oX2w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 7/9] mptcp: pm: initialize and release mptcp_pm_ops Date: Thu, 20 Feb 2025 10:57:31 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang 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_sock(). Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 33 +++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 3 +++ 3 files changed, 37 insertions(+) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 91e377058243..9d42aed440a0 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -627,6 +627,9 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) pm->rm_list_tx.nr = 0; pm->rm_list_rx.nr = 0; WRITE_ONCE(pm->pm_type, pm_type); + rcu_read_lock(); + mptcp_pm_initialize(msk, mptcp_pm_find(pm_type)); + rcu_read_unlock(); if (pm_type == MPTCP_PM_TYPE_KERNEL) { bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); @@ -721,3 +724,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) + return -EINVAL; + + 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("userspace_pm type %u initialized\n", msk->pm.ops->type); + 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..de8eb3ec8cdd 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2944,6 +2944,7 @@ static void __mptcp_destroy_sock(struct sock *sk) sk_stop_timer(sk, &sk->sk_timer); msk->pm.status = 0; mptcp_release_sched(msk); + mptcp_pm_release(msk); sk->sk_prot->destroy(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 021c0f87da1b..cddb919fc120 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 */ @@ -1043,6 +1044,8 @@ struct mptcp_pm_ops *mptcp_pm_find(enum mptcp_pm_type type); 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 Thu Feb 20 02:57:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13983253 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 D23891DB148 for ; Thu, 20 Feb 2025 02:57:52 +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=1740020272; cv=none; b=VCs3smcTjhO/EOTfp9od67sU3DCopMu0uSTqsypP/BQ8zrkgGgjF/shWBBiRtDql8YuGNrGOSS0x6M+i8vsvvpCN5IswDN/QpRd7nyAswnkkd5HzRITP6p5hDMca/VXfvXmwv9I0EHfDA6BJtKKBuWLMUvETAHpoorCreAuuUEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020272; c=relaxed/simple; bh=Y6xIYwqk3FgDyG02TrhdxWf39xpI957l/g7Fvj17daA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LsrtiDowErby7AYDV1n5Uc31uPo3gvBGTMTwMIS7xiaAxnDPXkTHtGbQrAzOSWfWaz8BALJB9AoMRkoy+7osYTViknCe+miuVbs6hH/PVuyeKfGwN+4QB1vpEncPl0KhNtlOF3HvND3TBYXNulFHWvTXAg24uK0NX0/R8XQ9ISk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PIz8YJRL; 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="PIz8YJRL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB0F7C4CED6; Thu, 20 Feb 2025 02:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020272; bh=Y6xIYwqk3FgDyG02TrhdxWf39xpI957l/g7Fvj17daA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PIz8YJRLgYZwD/nTQ6QWHTWmIq+gSIDMbyDt34kiEcQCnb5SqXx1njR9uUsQqou5W xnrb89YvhEuH77GCs5dbHqpinYoUEyBBN1kFcr+9ZfyZbmAK3vY1P3a++MV6HS44oI urC8r4qgPVzY+/w6vnrNShveKH0+zKZLDuGg9fV3xs5TWpGXKThfF0XLQYI7T/4Mvl 1OyNt8hyK12usSuJ8HZF31ECH4N49IctyvWryBSIe1i2it+DdiBJNy7waciUkMThp7 lNn7ug9Q5PRNMuPSwiw+9POsOhBshjJyA5yxG49y2rspixuUobZ47OTZe8ZgDErzp6 jPlnbbMfYv5vg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 8/9] mptcp: pm: drop get_local_id helpers Date: Thu, 20 Feb 2025 10:57:32 +0800 Message-ID: <69747874cdc72593caadf51725cf8835bc45661b.1740019794.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_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 | 6 +++--- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/pm_userspace.c | 4 ++-- net/mptcp/protocol.h | 4 ---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 9d42aed440a0..d2cc93e21bee 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -438,10 +438,10 @@ 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 (!msk->pm.ops || !msk->pm.ops->get_local_id) + return -ENOTSUPP; mptcp_pm_param_set_contexts(¶m, &skc_local, NULL); - if (mptcp_pm_is_userspace(msk)) - return mptcp_userspace_pm_get_local_id(msk, ¶m); - return mptcp_pm_nl_get_local_id(msk, ¶m); + return msk->pm.ops->get_local_id(msk, ¶m); } 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 e0f8754e261e..33b19ff7a313 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_param *param) +static int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_param *param) { struct mptcp_pm_addr_entry *skc = ¶m->entry; struct mptcp_pm_addr_entry *entry; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 6e51335c8bc1..b233d8469a48 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_param *param) +static int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, + struct mptcp_pm_param *param) { __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 cddb919fc120..d06add105df5 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1129,10 +1129,6 @@ void mptcp_pm_param_set_contexts(struct mptcp_pm_param *param, const struct mptcp_pm_addr_entry *entry, const struct mptcp_addr_info *addr); 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_param *param); -int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, - struct mptcp_pm_param *param); 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 Thu Feb 20 02:57:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13983254 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 22CF01D90B6 for ; Thu, 20 Feb 2025 02:57: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=1740020274; cv=none; b=PSf/Op2DrP1hrVixjtznzv8nzVtwFdNO7f9R+0TJT/X5IadJ92pkwUFZc/vp+mUwIH+oy9zmwou9Le0HS51czYvxorqlO78H61yvMPiAcgWyJ26fPtHD9ZlQ77SjhG8Cts7j2ycp3klFh+/IpJ1IU5O/M1SGqIQ+rpcRqdp8eZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740020274; c=relaxed/simple; bh=/C5nQ+j9mfPU+MQmgap/V3MqkJfJcpkrTD+IxlsNIKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SEA6dOBeBmBd95sxwA3nFcsQMNXo45GGKYW+n95X9cjLB9GYqRlBDvjHP+NEnFC2AQKeVmY7LEPYHY1xiuERow32ecMM2YBmH5asXxqUg6muGR/vZibompA841MixiKlqV51VVbahRyKH7ppFnNeNb1g6tZDbhsv8ADH9sEx+iE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hu2eufnx; 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="Hu2eufnx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37E46C4CED6; Thu, 20 Feb 2025 02:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740020274; bh=/C5nQ+j9mfPU+MQmgap/V3MqkJfJcpkrTD+IxlsNIKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hu2eufnxA68r1TgqIgqunvXI1r4bAZd9A4IjWxAPu3Fk48NAzrbnMo0DAdJtSg/8Z X+PW84HmHdzcDMWFv5V9EM94zuLaKrZk0sgVCDg2qFxrybwvneB34UGZl7/MNOBMrH bKR5cVMtof7QuMFLy+OH9lAUr2OpbAF8nKQ5YdO+4sMLfPxogRpQjgl3zSTbvlsXLe DVmxTMAoB19L5qG66nnlDzHArdnktPjpfDVOhchGhxK/kqjMPM11Gy/D5U6snbyfC7 x1JSbJbCy5B3Cfg5aLpRwgbv2oT3DYZhsS9R3wfUqkR9srnHEQzYiHc7dvl430nKCt vCzBYGMXgj+Dw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v5 9/9] mptcp: pm: drop is_backup helpers Date: Thu, 20 Feb 2025 10:57:33 +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_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 | 9 +++++---- net/mptcp/pm_netlink.c | 8 -------- net/mptcp/pm_userspace.c | 9 --------- net/mptcp/protocol.h | 2 -- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index d2cc93e21bee..ea92e72c383f 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -447,13 +447,14 @@ 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) { struct mptcp_addr_info skc_local; + struct mptcp_pm_param param; 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); + if (!msk->pm.ops || !msk->pm.ops->get_priority) + return -ENOTSUPP; + mptcp_pm_param_set_contexts(¶m, NULL, &skc_local); + return msk->pm.ops->get_priority(msk, ¶m); } 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 33b19ff7a313..3859642792db 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1188,14 +1188,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) -{ - struct mptcp_pm_param param; - - mptcp_pm_param_set_contexts(¶m, NULL, skc); - return mptcp_pm_nl_get_priority(msk, ¶m); -} - #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 b233d8469a48..be578f5c3195 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -165,15 +165,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) -{ - struct mptcp_pm_param param; - - mptcp_pm_param_set_contexts(¶m, NULL, skc); - return mptcp_userspace_pm_get_priority(msk, ¶m); -} - 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 d06add105df5..45c948142839 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1130,8 +1130,6 @@ void mptcp_pm_param_set_contexts(struct mptcp_pm_param *param, const struct mptcp_addr_info *addr); 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,