Message ID | 20250227-mptcp-pm-reorg-code-v1-6-cb4677096709@kernel.org (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | mptcp: pm: code reorganisation | expand |
Context | Check | Description |
---|---|---|
matttbe/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 78 lines checked |
matttbe/shellcheck | success | MPTCP selftests files have not been modified |
matttbe/build | fail | Build error with: -Werror |
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! ✅ |
Hi Matt, On Thu, 2025-02-27 at 21:08 +0100, Matthieu Baerts (NGI0) wrote: > To make it clear what actions are in-kernel PM specific and which > ones > are not and done for all PMs, e.g. sending ADD_ADDR and close > associated > subflows when a RM_ADDR is received. > > Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> > --- > net/mptcp/pm.c | 25 +++++++++++++++++++++++++ > net/mptcp/pm_netlink.c | 21 ++------------------- > net/mptcp/protocol.h | 1 + > 3 files changed, 28 insertions(+), 19 deletions(-) > > diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c > index > e1ca90701fd92abbf6d8b92d461ddb18d2652391..c17828981dd6400b2ed74dd28a9 > 5e21f76ed37b9 100644 > --- a/net/mptcp/pm.c > +++ b/net/mptcp/pm.c > @@ -599,6 +599,31 @@ bool mptcp_pm_addr_families_match(const struct > sock *sk, > #endif > } > > +void mptcp_pm_worker(struct mptcp_sock *msk) > +{ > + struct mptcp_pm_data *pm = &msk->pm; > + > + msk_owned_by_me(msk); > + > + if (!(pm->status & MPTCP_PM_WORK_MASK)) > + return; > + > + spin_lock_bh(&msk->pm.lock); > + > + pr_debug("msk=%p status=%x\n", msk, pm->status); > + if (pm->status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) { > + pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_SEND_ACK); > + mptcp_pm_addr_send_ack(msk); > + } > + if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { > + pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); > + mptcp_pm_rm_addr_recv(msk); CI made the following complaint: net/mptcp/pm.c: In function 'mptcp_pm_worker': net/mptcp/pm.c:620:17: error: implicit declaration of function 'mptcp_pm_rm_addr_recv'; did you mean 'mptcp_pm_rm_addr_received'? [- Wimplicit-function-declaration] 620 | mptcp_pm_rm_addr_recv(msk); | ^~~~~~~~~~~~~~~~~~~~~ | mptcp_pm_rm_addr_received > + } > + __mptcp_pm_kernel_worker(msk); > + > + spin_unlock_bh(&msk->pm.lock); > +} > + > void mptcp_pm_destroy(struct mptcp_sock *msk) > { > mptcp_pm_free_anno_list(msk); > diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c > index > 44362b0f7ee4f131482705439eb96c0374177c1d..2a8652886fce6ba9743d0efba57 > 6ac57f35a0077 100644 > --- a/net/mptcp/pm_netlink.c > +++ b/net/mptcp/pm_netlink.c > @@ -924,30 +924,15 @@ static void > mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, > mptcp_pm_rm_addr_or_subflow(msk, rm_list, > MPTCP_MIB_RMSUBFLOW); > } > > -void mptcp_pm_worker(struct mptcp_sock *msk) > +/* Called under PM lock */ > +void __mptcp_pm_kernel_worker(struct mptcp_sock *msk) > { > struct mptcp_pm_data *pm = &msk->pm; > > - msk_owned_by_me(msk); > - > - if (!(pm->status & MPTCP_PM_WORK_MASK)) > - return; > - > - spin_lock_bh(&msk->pm.lock); > - > - pr_debug("msk=%p status=%x\n", msk, pm->status); > if (pm->status & BIT(MPTCP_PM_ADD_ADDR_RECEIVED)) { > pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED); > mptcp_pm_nl_add_addr_received(msk); > } > - if (pm->status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) { > - pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_SEND_ACK); > - mptcp_pm_addr_send_ack(msk); > - } > - if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { > - pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); > - mptcp_pm_rm_addr_recv(msk); > - } > if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { > pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); > mptcp_pm_nl_fully_established(msk); > @@ -956,8 +941,6 @@ void mptcp_pm_worker(struct mptcp_sock *msk) > pm->status &= ~BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); > mptcp_pm_nl_subflow_established(msk); > } > - > - spin_unlock_bh(&msk->pm.lock); > } > > static bool address_use_port(struct mptcp_pm_addr_entry *entry) > diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h > index > 93faf203d987100f22e507c7f443d937284881e4..8742527196887598eb242c82f06 > 004107d29ef92 100644 > --- a/net/mptcp/protocol.h > +++ b/net/mptcp/protocol.h > @@ -1154,6 +1154,7 @@ static inline u8 subflow_get_local_id(const > struct mptcp_subflow_context *subflo > > void __init mptcp_pm_nl_init(void); > void mptcp_pm_worker(struct mptcp_sock *msk); > +void __mptcp_pm_kernel_worker(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); > unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock > *msk); >
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index e1ca90701fd92abbf6d8b92d461ddb18d2652391..c17828981dd6400b2ed74dd28a95e21f76ed37b9 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -599,6 +599,31 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, #endif } +void mptcp_pm_worker(struct mptcp_sock *msk) +{ + struct mptcp_pm_data *pm = &msk->pm; + + msk_owned_by_me(msk); + + if (!(pm->status & MPTCP_PM_WORK_MASK)) + return; + + spin_lock_bh(&msk->pm.lock); + + pr_debug("msk=%p status=%x\n", msk, pm->status); + if (pm->status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) { + pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_SEND_ACK); + mptcp_pm_addr_send_ack(msk); + } + if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { + pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); + mptcp_pm_rm_addr_recv(msk); + } + __mptcp_pm_kernel_worker(msk); + + spin_unlock_bh(&msk->pm.lock); +} + void mptcp_pm_destroy(struct mptcp_sock *msk) { mptcp_pm_free_anno_list(msk); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 44362b0f7ee4f131482705439eb96c0374177c1d..2a8652886fce6ba9743d0efba576ac57f35a0077 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -924,30 +924,15 @@ static void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, mptcp_pm_rm_addr_or_subflow(msk, rm_list, MPTCP_MIB_RMSUBFLOW); } -void mptcp_pm_worker(struct mptcp_sock *msk) +/* Called under PM lock */ +void __mptcp_pm_kernel_worker(struct mptcp_sock *msk) { struct mptcp_pm_data *pm = &msk->pm; - msk_owned_by_me(msk); - - if (!(pm->status & MPTCP_PM_WORK_MASK)) - return; - - spin_lock_bh(&msk->pm.lock); - - pr_debug("msk=%p status=%x\n", msk, pm->status); if (pm->status & BIT(MPTCP_PM_ADD_ADDR_RECEIVED)) { pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED); mptcp_pm_nl_add_addr_received(msk); } - if (pm->status & BIT(MPTCP_PM_ADD_ADDR_SEND_ACK)) { - pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_SEND_ACK); - mptcp_pm_addr_send_ack(msk); - } - if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { - pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); - mptcp_pm_rm_addr_recv(msk); - } if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); mptcp_pm_nl_fully_established(msk); @@ -956,8 +941,6 @@ void mptcp_pm_worker(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_SUBFLOW_ESTABLISHED); mptcp_pm_nl_subflow_established(msk); } - - spin_unlock_bh(&msk->pm.lock); } static bool address_use_port(struct mptcp_pm_addr_entry *entry) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 93faf203d987100f22e507c7f443d937284881e4..8742527196887598eb242c82f06004107d29ef92 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1154,6 +1154,7 @@ static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflo void __init mptcp_pm_nl_init(void); void mptcp_pm_worker(struct mptcp_sock *msk); +void __mptcp_pm_kernel_worker(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); unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk);
To make it clear what actions are in-kernel PM specific and which ones are not and done for all PMs, e.g. sending ADD_ADDR and close associated subflows when a RM_ADDR is received. Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> --- net/mptcp/pm.c | 25 +++++++++++++++++++++++++ net/mptcp/pm_netlink.c | 21 ++------------------- net/mptcp/protocol.h | 1 + 3 files changed, 28 insertions(+), 19 deletions(-)