[PATCH mptcp-next] mptcp: add mptcp_for_each_subflow_safe helper

Matthieu Baerts posted 1 patch 2 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20220712160236.3668376-1-matthieu.baerts@tessares.net
Maintainers: "David S. Miller" <davem@davemloft.net>, Paolo Abeni <pabeni@redhat.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>
net/mptcp/pm_netlink.c | 2 +-
net/mptcp/protocol.c   | 6 +++---
net/mptcp/protocol.h   | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
[PATCH mptcp-next] mptcp: add mptcp_for_each_subflow_safe helper
Posted by Matthieu Baerts 2 months, 2 weeks ago
Similar to mptcp_for_each_subflow(): this is clearer now that the _safe
version is used in multiple places.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 net/mptcp/pm_netlink.c | 2 +-
 net/mptcp/protocol.c   | 6 +++---
 net/mptcp/protocol.h   | 2 ++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 291b5da42fdb..62471aaedb6d 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -796,7 +796,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
 		u8 rm_id = rm_list->ids[i];
 		bool removed = false;
 
-		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+		mptcp_for_each_subflow_safe(msk, subflow, tmp) {
 			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
 			u8 id = subflow->local_id;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index c92f91cb2c8d..48fdef304309 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2338,7 +2338,7 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk)
 
 	might_sleep();
 
-	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
 		if (inet_sk_state_load(ssk) != TCP_CLOSE)
@@ -2381,7 +2381,7 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
 
 	mptcp_token_destroy(msk);
 
-	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
 		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
 		bool slow;
 
@@ -2886,7 +2886,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 
 	inet_sk_state_store(sk, TCP_CLOSE);
 
-	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
+	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
 		__mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_FASTCLOSE);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index b9333e7f380a..13b76f86f749 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -315,6 +315,8 @@ struct mptcp_sock {
 
 #define mptcp_for_each_subflow(__msk, __subflow)			\
 	list_for_each_entry(__subflow, &((__msk)->conn_list), node)
+#define mptcp_for_each_subflow_safe(__msk, __subflow, __tmp)			\
+	list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node)
 
 static inline void msk_owned_by_me(const struct mptcp_sock *msk)
 {
-- 
2.36.1


Re: mptcp: add mptcp_for_each_subflow_safe helper: Tests Results
Posted by MPTCP CI 2 months, 2 weeks ago
Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Unstable: 2 failed test(s): selftest_mptcp_join selftest_simult_flows 🔴:
  - Task: https://cirrus-ci.com/task/4969640886534144
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/4969640886534144/summary/summary.txt

- KVM Validation: debug:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/6095540793376768
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6095540793376768/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a95c064741f6


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-debug

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
Re: [PATCH mptcp-next] mptcp: add mptcp_for_each_subflow_safe helper
Posted by Mat Martineau 2 months, 2 weeks ago
On Tue, 12 Jul 2022, Matthieu Baerts wrote:

> Similar to mptcp_for_each_subflow(): this is clearer now that the _safe
> version is used in multiple places.
>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Looks good to me, thanks Matthieu

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

> ---
> net/mptcp/pm_netlink.c | 2 +-
> net/mptcp/protocol.c   | 6 +++---
> net/mptcp/protocol.h   | 2 ++
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 291b5da42fdb..62471aaedb6d 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -796,7 +796,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
> 		u8 rm_id = rm_list->ids[i];
> 		bool removed = false;
>
> -		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
> +		mptcp_for_each_subflow_safe(msk, subflow, tmp) {
> 			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> 			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
> 			u8 id = subflow->local_id;
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index c92f91cb2c8d..48fdef304309 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2338,7 +2338,7 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk)
>
> 	might_sleep();
>
> -	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
> +	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
> 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
>
> 		if (inet_sk_state_load(ssk) != TCP_CLOSE)
> @@ -2381,7 +2381,7 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
>
> 	mptcp_token_destroy(msk);
>
> -	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
> +	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
> 		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
> 		bool slow;
>
> @@ -2886,7 +2886,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
>
> 	inet_sk_state_store(sk, TCP_CLOSE);
>
> -	list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
> +	mptcp_for_each_subflow_safe(msk, subflow, tmp) {
> 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
>
> 		__mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_FASTCLOSE);
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index b9333e7f380a..13b76f86f749 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -315,6 +315,8 @@ struct mptcp_sock {
>
> #define mptcp_for_each_subflow(__msk, __subflow)			\
> 	list_for_each_entry(__subflow, &((__msk)->conn_list), node)
> +#define mptcp_for_each_subflow_safe(__msk, __subflow, __tmp)			\
> +	list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node)
>
> static inline void msk_owned_by_me(const struct mptcp_sock *msk)
> {
> -- 
> 2.36.1
>
>
>

--
Mat Martineau
Intel

Re: [PATCH mptcp-next] mptcp: add mptcp_for_each_subflow_safe helper
Posted by Matthieu Baerts 2 months, 2 weeks ago
Hi Mat,

On 12/07/2022 19:25, Mat Martineau wrote:
> On Tue, 12 Jul 2022, Matthieu Baerts wrote:
> 
>> Similar to mptcp_for_each_subflow(): this is clearer now that the _safe
>> version is used in multiple places.
>>
>> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> 
> Looks good to me, thanks Matthieu
> 
> Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Thank you for the review!

Now in our tree (feat. for net-next):

New patches for t/upstream:
- 9b920d84b10d: mptcp: add mptcp_for_each_subflow_safe helper
- Results: bd3c22dfa097..ca68291a7562 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20220713T084449

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net