diff mbox series

[mptcp-next,v6,08/13] mptcp: pm: drop pm_type in mptcp_pm_data

Message ID 9bd55b3cfc33211b89d8ad0dc734ff2ed4287ab9.1740320007.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Delegated to: Matthieu Baerts
Headers show
Series BPF path manager, part 4 | expand

Checks

Context Check Description
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/build success Build and static analysis OK
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang Feb. 23, 2025, 2:26 p.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

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 <tanggeliang@kylinos.cn>
---
 net/mptcp/pm.c       | 6 ++----
 net/mptcp/protocol.h | 5 ++---
 2 files changed, 4 insertions(+), 7 deletions(-)

Comments

Matthieu Baerts Feb. 23, 2025, 4:49 p.m. UTC | #1
Hi Geliang,

On 23/02/2025 15:26, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> Now pm->pm_type can be replaced by pm->ops->type, then "pm_type" filed
> of struct mptcp_pm_data can be dropped.

Do you need this intermediate patch?

If the in-kernel and userspace PM ops are set first, then this patch is
not needed, and mptcp_pm_is_{kernel,userspace}() can be removed in one
patch, when using pm->ops->XXX() everywhere, no?

If it is easier to have this intermediate patch, why not comparing

  pm->ops == &mptcp_in_kernel_pm

instead?

Cheers,
Matt
diff mbox series

Patch

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)