From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: mptcp@lists.linux.dev
Cc: Geliang Tang <geliang@kernel.org>,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH mptcp-next v2 08/14] mptcp: pm: avoid calling PM specific code from core
Date: Fri, 28 Feb 2025 14:31:28 +0100 [thread overview]
Message-ID: <20250228-mptcp-pm-reorg-code-v2-8-fa8b2542b7a5@kernel.org> (raw)
In-Reply-To: <20250228-mptcp-pm-reorg-code-v2-0-fa8b2542b7a5@kernel.org>
When destroying an MPTCP socket, some userspace PM specific code was
called from mptcp_destroy_common() in protocol.c. That feels wrong, and
it is the only case.
Instead, the core now calls mptcp_pm_destroy() from pm.c which is now in
charge of cleaning the announced addresses list, and ask the different
PMs to do extra cleaning if needed, e.g. the userspace PM, if used, will
clean the local addresses list.
While at it, the userspace PM specific helper has been prefixed with
'mptcp_userspace_pm_' like the other ones.
No behavioural changes intended.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm.c | 8 ++++++++
net/mptcp/pm_userspace.c | 5 +----
net/mptcp/protocol.c | 3 +--
net/mptcp/protocol.h | 3 ++-
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index ab443b9f9c5f28e34791fa75ce42ee013ed70d78..17f99924dfa0ee307cd10beea90465daf7c84aed 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -599,6 +599,14 @@ bool mptcp_pm_addr_families_match(const struct sock *sk,
#endif
}
+void mptcp_pm_destroy(struct mptcp_sock *msk)
+{
+ mptcp_pm_free_anno_list(msk);
+
+ if (mptcp_pm_is_userspace(msk))
+ mptcp_userspace_pm_free_local_addr_list(msk);
+}
+
void mptcp_pm_data_reset(struct mptcp_sock *msk)
{
u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk));
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 434f59b793ef9a581ab37667fc904927c1600199..8f9e749e9b1aec9c5afeac6a6fcce9481d246948 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -12,15 +12,12 @@
list_for_each_entry(__entry, \
&((__msk)->pm.userspace_pm_local_addr_list), list)
-void mptcp_free_local_addr_list(struct mptcp_sock *msk)
+void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk)
{
struct mptcp_pm_addr_entry *entry, *tmp;
struct sock *sk = (struct sock *)msk;
LIST_HEAD(free_list);
- if (!mptcp_pm_is_userspace(msk))
- return;
-
spin_lock_bh(&msk->pm.lock);
list_splice_init(&msk->pm.userspace_pm_local_addr_list, &free_list);
spin_unlock_bh(&msk->pm.lock);
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 0c8cbdcbea303c1f3be3518985b5bbb3be10a697..bf94aeeec667ff3159fa4a1a8daa3abcb495c82c 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3305,8 +3305,7 @@ void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags)
* inet_sock_destruct() will dispose it
*/
mptcp_token_destroy(msk);
- mptcp_pm_free_anno_list(msk);
- mptcp_free_local_addr_list(msk);
+ mptcp_pm_destroy(msk);
}
static void mptcp_destroy(struct sock *sk)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 5e9708e4416da6dd4dfa2269436a4943bdb1c903..a91e6abfd64f9da555052386dd267e1ad1c16f5f 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -988,6 +988,7 @@ __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum su
void __init mptcp_pm_init(void);
void mptcp_pm_data_init(struct mptcp_sock *msk);
void mptcp_pm_data_reset(struct mptcp_sock *msk);
+void mptcp_pm_destroy(struct mptcp_sock *msk);
int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
struct mptcp_addr_info *addr);
int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info,
@@ -1047,7 +1048,7 @@ 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);
-void mptcp_free_local_addr_list(struct mptcp_sock *msk);
+void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk);
void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
const struct sock *ssk, gfp_t gfp);
--
2.47.1
next prev parent reply other threads:[~2025-02-28 13:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 13:31 [PATCH mptcp-next v2 00/14] mptcp: pm: code reorganisation Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 01/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_addr_send_ack Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 02/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_mp_prio_send_ack Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 03/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_work Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 04/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_rm_addr_received Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 05/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_subflow_chk_stale() Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 06/14] mptcp: pm: remove '_nl' from mptcp_pm_nl_is_init_remote_addr Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 07/14] mptcp: pm: kernel: add '_pm' to mptcp_nl_set_flags Matthieu Baerts (NGI0)
2025-02-28 13:31 ` Matthieu Baerts (NGI0) [this message]
2025-02-28 13:31 ` [PATCH mptcp-next v2 09/14] mptcp: pm: worker: split in-kernel and common tasks Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 10/14] mptcp: pm: export mptcp_remote_address Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 11/14] mptcp: pm: move generic helper at the top Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 12/14] mptcp: pm: move generic PM helpers to pm.c Matthieu Baerts (NGI0)
2025-02-28 13:31 ` [PATCH mptcp-next v2 13/14] mptcp: pm: split in-kernel PM specific code Matthieu Baerts (NGI0)
2025-03-03 10:51 ` Matthieu Baerts
2025-02-28 13:31 ` [PATCH mptcp-next v2 14/14] mptcp: pm: move Netlink PM helpers to pm_netlink.c Matthieu Baerts (NGI0)
2025-02-28 14:44 ` [PATCH mptcp-next v2 00/14] mptcp: pm: code reorganisation MPTCP CI
2025-03-01 0:19 ` Geliang Tang
2025-03-01 0:20 ` Geliang Tang
2025-03-01 0:21 ` Geliang Tang
2025-03-01 11:10 ` Matthieu Baerts
2025-03-03 10:55 ` Geliang Tang
2025-03-03 11:07 ` Matthieu Baerts
2025-03-03 14:14 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250228-mptcp-pm-reorg-code-v2-8-fa8b2542b7a5@kernel.org \
--to=matttbe@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.