Skip to contentSkip to conversation

add bpf_iter_task

PATCH Superseded Geliang Tang 3 participants 16 messages Mar 7, 2025 – Mar 8, 2025

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v2 cover add bpf_iter_task

From: Geliang Tang <[email protected]>

v2:
- Keep mptcp scheduler API unchanged.
- Add back struct mptcp_sched_data.
- add bpf_iter_task in mptcp_sched_data instead of mptcp_sock
- Add wrapper bpf_iter mptcp_subflow_sched.
- Use mptcp_subflow_sched iter instead of mptcp_subflow.

v1:
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/

Geliang Tang (11):
Revert "mptcp: sched: remove mptcp_sched_data" Squash to "bpf: Add bpf_mptcp_sched_ops"
mptcp: add bpf_iter_task for mptcp_sched_data
mptcp: set and clear bpf_iter_task
mptcp: add mptcp_subflow_sched bpf_iter
Squash to "selftests/bpf: Add bpf_first scheduler & test" Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Squash to "selftests/bpf: Add bpf_rr scheduler & test" Squash to "selftests/bpf: Add bpf_red scheduler & test" Squash to "selftests/bpf: Add bpf_burst scheduler & test"
mptcp: drop subflow contexts in mptcp_sched_data

 include/net/mptcp.h                           | 10 ++++--
 net/mptcp/bpf.c                               | 34 +++++++++++++++++--
 net/mptcp/protocol.h                          | 19 +++++++++++
 net/mptcp/sched.c                             | 31 +++++++++++++----
 .../testing/selftests/bpf/bpf_experimental.h  |  9 +++++
 .../selftests/bpf/progs/mptcp_bpf_bkup.c      |  5 +--
 .../selftests/bpf/progs/mptcp_bpf_burst.c     | 10 +++---
 .../selftests/bpf/progs/mptcp_bpf_first.c     |  3 +-
 .../selftests/bpf/progs/mptcp_bpf_red.c       |  5 +--
 .../selftests/bpf/progs/mptcp_bpf_rr.c        |  7 ++--
 10 files changed, 110 insertions(+), 23 deletions(-)
Signature · 1 line
2.43.0
author reviewer
#1 lore raw

PATCH v2 1/11 Revert "mptcp: sched: remove mptcp_sched_data"

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.
Add back struct mptcp_sched_data.

---
 include/net/mptcp.h | 13 +++++++++++--
 net/mptcp/sched.c   | 18 +++++++++++-------
 2 files changed, 22 insertions(+), 9 deletions(-)
include/net/mptcp.h +11 -2
index e9832a8f981e..2c85ca92bb1c 100644
@@ -100,9 +100,18 @@ struct mptcp_out_options {
 #define MPTCP_SCHED_MAX		128
 #define MPTCP_SCHED_BUF_MAX	(MPTCP_SCHED_NAME_MAX * MPTCP_SCHED_MAX)
 
+#define MPTCP_SUBFLOWS_MAX	8
+
+struct mptcp_sched_data {
+	u8	subflows;
+	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
+};
+
 struct mptcp_sched_ops {
-	int (*get_send)(struct mptcp_sock *msk);
-	int (*get_retrans)(struct mptcp_sock *msk);
+	int (*get_send)(struct mptcp_sock *msk,
+			struct mptcp_sched_data *data);
+	int (*get_retrans)(struct mptcp_sock *msk,
+			   struct mptcp_sched_data *data);
 
 	char			name[MPTCP_SCHED_NAME_MAX];
 	struct module		*owner;
net/mptcp/sched.c +11 -7
index f09f7eb1d63f..c16c6fbd4ba2 100644
@@ -16,7 +16,8 @@
 static DEFINE_SPINLOCK(mptcp_sched_list_lock);
 static LIST_HEAD(mptcp_sched_list);
 
-static int mptcp_sched_default_get_send(struct mptcp_sock *msk)
+static int mptcp_sched_default_get_send(struct mptcp_sock *msk,
+					struct mptcp_sched_data *data)
 {
 	struct sock *ssk;
 
@@ -28,7 +29,8 @@ static int mptcp_sched_default_get_send(struct mptcp_sock *msk)
 	return 0;
 }
 
-static int mptcp_sched_default_get_retrans(struct mptcp_sock *msk)
+static int mptcp_sched_default_get_retrans(struct mptcp_sock *msk,
+					   struct mptcp_sched_data *data)
 {
 	struct sock *ssk;
 
@@ -155,6 +157,7 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 int mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
+	struct mptcp_sched_data *data = NULL;
 
 	msk_owned_by_me(msk);
 
@@ -175,13 +178,14 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_send(msk);
-	return msk->sched->get_send(msk);
+		return mptcp_sched_default_get_send(msk, data);
+	return msk->sched->get_send(msk, data);
 }
 
 int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
+	struct mptcp_sched_data *data = NULL;
 
 	msk_owned_by_me(msk);
 
@@ -195,8 +199,8 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_retrans(msk);
+		return mptcp_sched_default_get_retrans(msk, data);
 	if (msk->sched->get_retrans)
-		return msk->sched->get_retrans(msk);
-	return msk->sched->get_send(msk);
+		return msk->sched->get_retrans(msk, data);
+	return msk->sched->get_send(msk, data);
 }
Signature · 1 line
2.43.0
author reviewer
#2 lore raw

PATCH v2 2/11 Squash to "bpf: Add bpf_mptcp_sched_ops"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.

---
 net/mptcp/bpf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/mptcp/bpf.c +4 -2
index c0da9ac077e4..3921261b4fd4 100644
@@ -156,12 +156,14 @@ static int bpf_mptcp_sched_init(struct btf *btf)
 	return 0;
 }
 
-static int __bpf_mptcp_sched_get_send(struct mptcp_sock *msk)
+static int __bpf_mptcp_sched_get_send(struct mptcp_sock *msk,
+				      struct mptcp_sched_data *data)
 {
 	return 0;
 }
 
-static int __bpf_mptcp_sched_get_retrans(struct mptcp_sock *msk)
+static int __bpf_mptcp_sched_get_retrans(struct mptcp_sock *msk,
+					 struct mptcp_sched_data *data)
 {
 	return 0;
 }
Signature · 1 line
2.43.0
author reviewer
#3 lore raw

PATCH v2 3/11 mptcp: add bpf_iter_task for mptcp_sched_data

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

To make sure the mptcp_subflow bpf_iter is running in the MPTCP context. This patch adds a simplified version of tracking for it:

1. Add a 'struct task_struct *bpf_iter_task' field to struct mptcp_sched_data.

2. Do a WRITE_ONCE(data->bpf_iter_task, current) before calling a MPTCP BPF hook, and WRITE_ONCE(data->bpf_iter_task, NULL) after the hook returns.

3. In bpf_iter_mptcp_subflow_new(), check

	"READ_ONCE(data->bpf_scheduler_task) == current"

to confirm the correct task, return -EINVAL if it doesn't match.

Also creates helpers for setting, clearing and checking that value.

---
 include/net/mptcp.h  |  1 +
 net/mptcp/protocol.h | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
include/net/mptcp.h +1 -0
index 2c85ca92bb1c..bd3d1b3654dd 100644
@@ -105,6 +105,7 @@ struct mptcp_out_options {
 struct mptcp_sched_data {
 	u8	subflows;
 	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
+	struct task_struct *bpf_iter_task;
 };
 
 struct mptcp_sched_ops {
net/mptcp/protocol.h +19 -0
index 3492b256ecba..0875b3cf4aba 100644
@@ -1291,4 +1291,23 @@ mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subflow_re
 static inline void mptcp_join_cookie_init(void) {}
 #endif
 
+static inline void mptcp_sched_set_bpf_iter_task(struct mptcp_sched_data *data)
+{
+	WRITE_ONCE(data->bpf_iter_task, current);
+}
+
+static inline void mptcp_sched_clear_bpf_iter_task(struct mptcp_sched_data *data)
+{
+	WRITE_ONCE(data->bpf_iter_task, NULL);
+}
+
+static inline bool mptcp_sched_check_bpf_iter_task(struct mptcp_sched_data *data)
+{
+	struct task_struct *task = READ_ONCE(data->bpf_iter_task);
+
+	if (task && task == current)
+		return true;
+	return false;
+}
+
 #endif /* __MPTCP_PROTOCOL_H */
Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH mptcp-next v2 03/11] mptcp: add bpf_iter_task for mptcp_sched_data

Hi Geliang,

Quoted 13 lines · Geliang Tang

From: Geliang Tang <[email protected]>

To make sure the mptcp_subflow bpf_iter is running in the MPTCP context. This patch adds a simplified version of tracking for it:

1. Add a 'struct task_struct *bpf_iter_task' field to struct mptcp_sched_data.

2. Do a WRITE_ONCE(data->bpf_iter_task, current) before calling a MPTCP BPF hook, and WRITE_ONCE(data->bpf_iter_task, NULL) after the hook returns.

Quoted 7 lines

3. In bpf_iter_mptcp_subflow_new(), check

	"READ_ONCE(data->bpf_scheduler_task) == current"

to confirm the correct task, return -EINVAL if it doesn't match.

Also creates helpers for setting, clearing and checking that value.

I think it is better not to have dedicated patches introducing helpers without using them: for the reviewers, it is not clear how they are exactly going to be used, then it is needed to check the next patch(es), go back to this one, etc.

Maybe better to introduce the helper when you actually use them? Especially for such simple helpers.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#5 lore raw

PATCH v2 4/11 mptcp: set and clear bpf_iter_task

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Set bpf_iter_task before invoking get_send() and get_retrans(), and clear it afterwords.

---
 net/mptcp/sched.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
net/mptcp/sched.c +20 -7
index c16c6fbd4ba2..ffb531b5a4d6 100644
@@ -157,7 +157,8 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 int mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data *data = NULL;
+	struct mptcp_sched_data data;
+	int ret;
 
 	msk_owned_by_me(msk);
 
@@ -178,14 +179,20 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_send(msk, data);
-	return msk->sched->get_send(msk, data);
+		return mptcp_sched_default_get_send(msk, &data);
+
+	mptcp_sched_set_bpf_iter_task(&data);
+	ret = msk->sched->get_send(msk, &data);
+	mptcp_sched_clear_bpf_iter_task(&data);
+
+	return ret;
 }
 
 int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-	struct mptcp_sched_data *data = NULL;
+	struct mptcp_sched_data data;
+	int ret;
 
 	msk_owned_by_me(msk);
 
@@ -199,8 +206,14 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
 	}
 
 	if (msk->sched == &mptcp_sched_default || !msk->sched)
-		return mptcp_sched_default_get_retrans(msk, data);
+		return mptcp_sched_default_get_retrans(msk, &data);
+
+	mptcp_sched_set_bpf_iter_task(&data);
 	if (msk->sched->get_retrans)
-		return msk->sched->get_retrans(msk, data);
-	return msk->sched->get_send(msk, data);
+		ret = msk->sched->get_retrans(msk, &data);
+	else
+		ret = msk->sched->get_send(msk, &data);
+	mptcp_sched_clear_bpf_iter_task(&data);
+
+	return ret;
 }
Signature · 1 line
2.43.0
author reviewer
#6 lore raw

PATCH v2 5/11 mptcp: add mptcp_subflow_sched bpf_iter

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Add a new bpt_iter mptcp_subflow_sched, it's a wrapper of mptcp_subflow.

---
 net/mptcp/bpf.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
net/mptcp/bpf.c +28 -0
index 3921261b4fd4..c31f7b407b84 100644
@@ -288,6 +288,31 @@ bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it)
 {
 }
 
+struct bpf_iter_mptcp_subflow_sched {
+	struct bpf_iter_mptcp_subflow it;
+};
+
+__bpf_kfunc static int
+bpf_iter_mptcp_subflow_sched_new(struct bpf_iter_mptcp_subflow_sched *it,
+				 struct sock *sk, struct mptcp_sched_data *data)
+{
+	if (!mptcp_sched_check_bpf_iter_task(data))
+		return -EINVAL;
+
+	return bpf_iter_mptcp_subflow_new(&it->it, sk);
+}
+
+__bpf_kfunc static struct mptcp_subflow_context *
+bpf_iter_mptcp_subflow_sched_next(struct bpf_iter_mptcp_subflow_sched *it)
+{
+	return bpf_iter_mptcp_subflow_next(&it->it);
+}
+
+__bpf_kfunc static void
+bpf_iter_mptcp_subflow_sched_destroy(struct bpf_iter_mptcp_subflow_sched *it)
+{
+}
+
 __bpf_kfunc static bool bpf_mptcp_subflow_queues_empty(struct sock *sk)
 {
 	return tcp_rtx_queue_empty(sk);
@@ -312,6 +337,9 @@ BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock, KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
 BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_destroy, KF_ITER_DESTROY)
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_sched_new, KF_ITER_NEW | KF_TRUSTED_ARGS)
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_sched_next, KF_ITER_NEXT | KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_iter_mptcp_subflow_sched_destroy, KF_ITER_DESTROY)
 BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled)
 BTF_ID_FLAGS(func, mptcp_subflow_active)
 BTF_ID_FLAGS(func, mptcp_set_timeout)
Signature · 1 line
2.43.0
maintainer
#7 lore raw

Re: [PATCH mptcp-next v2 05/11] mptcp: add mptcp_subflow_sched bpf_iter

Hi Geliang,

Quoted 19 lines · Geliang Tang

From: Geliang Tang <[email protected]>

Add a new bpt_iter mptcp_subflow_sched, it's a wrapper of mptcp_subflow.

---
 net/mptcp/bpf.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
net/mptcp/bpf.c +2 -0
index 3921261b4fd4..c31f7b407b84 100644
@@ -288,6 +288,31 @@ bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it)
 {
 }
 
+struct bpf_iter_mptcp_subflow_sched {
+	struct bpf_iter_mptcp_subflow it;

net/mptcp/bpf.c bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it) · line 302

Quoted 10 lines
net/mptcp/bpf.c +10 -0
+};
+
+__bpf_kfunc static int
+bpf_iter_mptcp_subflow_sched_new(struct bpf_iter_mptcp_subflow_sched *it,
+				 struct sock *sk, struct mptcp_sched_data *data)
+{
+	if (!mptcp_sched_check_bpf_iter_task(data))
+		return -EINVAL;
+
+	return bpf_iter_mptcp_subflow_new(&it->it, sk);

We would need the same thing for the BPF PM I suppose, no?

Then, why not having something more generic, either:

- add "struct task_struct *" in the msk structure

- or pass a "const struct task_struct *bpf_iter_task" instead of
something sched specific?

For the first idea, I guess it should work because the helper will be called when the msk lock will be owned by the caller. So we should not have the PM and scheduler setting it at the same time from different context, right?
Also, if this helper receives a msk in argument, no need to check that it is a valid MPTCP socket, etc., right?

If one of these two ideas is used, no need to re-introduce mptcp_sched_data. The API is not settled yet, so no need to worry about that. It is even a good time to change it.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#8 lore raw

PATCH v2 6/11 Squash to "selftests/bpf: Add bpf_first scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +2 -1
index d71c50c7f441..73b18eeeb62f 100644
@@ -17,7 +17,8 @@ void BPF_PROG(mptcp_sched_first_release, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_first_get_send, struct mptcp_sock *msk)
+int BPF_PROG(bpf_first_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct mptcp_subflow_context *subflow;
 
Signature · 1 line
2.43.0
author reviewer
#9 lore raw

PATCH v2 7/11 Squash to "selftests/bpf: Add bpf_bkup scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.
Use mptcp_subflow_sched iter instead of mptcp_subflow.

---
 tools/testing/selftests/bpf/bpf_experimental.h     | 9 +++++++++
 tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/bpf_experimental.h +9 -0
index 6a96c56f0725..b8edad5c8bf0 100644
@@ -583,6 +583,15 @@ bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ksym;
 extern void
 bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it) __weak __ksym;
 
+struct bpf_iter_mptcp_subflow_sched;
+extern int bpf_iter_mptcp_subflow_sched_new(struct bpf_iter_mptcp_subflow_sched *it,
+					    struct sock *sk,
+					    struct mptcp_sched_data *data) __weak __ksym;
+extern struct mptcp_subflow_context *
+bpf_iter_mptcp_subflow_sched_next(struct bpf_iter_mptcp_subflow_sched *it) __weak __ksym;
+extern void
+bpf_iter_mptcp_subflow_sched_destroy(struct bpf_iter_mptcp_subflow_sched *it) __weak __ksym;
+
 extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) __weak __ksym;
 extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym;
 extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,
tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +3 -2
index 284cca708de0..1719b0b2a182 100644
@@ -17,11 +17,12 @@ void BPF_PROG(mptcp_sched_bkup_release, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_bkup_get_send, struct mptcp_sock *msk)
+int BPF_PROG(bpf_bkup_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct mptcp_subflow_context *subflow;
 
-	bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk) {
+	bpf_for_each(mptcp_subflow_sched, subflow, (struct sock *)msk, data) {
 		if (!BPF_CORE_READ_BITFIELD_PROBED(subflow, backup) ||
 		    !BPF_CORE_READ_BITFIELD_PROBED(subflow, request_bkup)) {
 			mptcp_subflow_set_scheduled(subflow, true);
Signature · 1 line
2.43.0
author reviewer
#10 lore raw

PATCH v2 8/11 Squash to "selftests/bpf: Add bpf_rr scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.
Use mptcp_subflow_sched iter instead of mptcp_subflow.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +4 -3
index 5128a886119d..5a3910fb0aa7 100644
@@ -31,7 +31,8 @@ void BPF_PROG(mptcp_sched_rr_release, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk)
+int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct mptcp_subflow_context *subflow, *next;
 	struct mptcp_rr_storage *ptr;
@@ -48,9 +49,9 @@ int BPF_PROG(bpf_rr_get_send, struct mptcp_sock *msk)
 	if (!ptr->last_snd)
 		goto out;
 
-	bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk) {
+	bpf_for_each(mptcp_subflow_sched, subflow, (struct sock *)msk, data) {
 		if (mptcp_subflow_tcp_sock(subflow) == ptr->last_snd) {
-			subflow = bpf_iter_mptcp_subflow_next(&___it);
+			subflow = bpf_iter_mptcp_subflow_sched_next(&___it);
 			if (!subflow)
 				break;
 
Signature · 1 line
2.43.0
author reviewer
#11 lore raw

PATCH v2 9/11 Squash to "selftests/bpf: Add bpf_red scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.
Use mptcp_subflow_sched iter instead of mptcp_subflow.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_red.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +3 -2
index b2efd6db7f8b..64bf3c48cc82 100644
@@ -17,11 +17,12 @@ void BPF_PROG(mptcp_sched_red_release, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk)
+int BPF_PROG(bpf_red_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct mptcp_subflow_context *subflow;
 
-	bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk)
+	bpf_for_each(mptcp_subflow_sched, subflow, (struct sock *)msk, data)
 		mptcp_subflow_set_scheduled(subflow, true);
 
 	return 0;
Signature · 1 line
2.43.0
author reviewer
#12 lore raw

PATCH v2 10/11 Squash to "selftests/bpf: Add bpf_burst scheduler & test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Keep mptcp scheduler API unchanged.
Use mptcp_subflow_sched iter instead of mptcp_subflow.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +6 -4
index 6d930ff0f09f..3828af40fa50 100644
@@ -50,7 +50,8 @@ void BPF_PROG(mptcp_sched_burst_release, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk)
+int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct subflow_send_info send_info[SSK_MODE_MAX];
 	struct mptcp_subflow_context *subflow;
@@ -66,7 +67,7 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk)
 		send_info[i].linger_time = -1;
 	}
 
-	bpf_for_each(mptcp_subflow, subflow, sk) {
+	bpf_for_each(mptcp_subflow_sched, subflow, sk, data) {
 		bool backup = subflow->backup || subflow->request_bkup;
 
 		ssk = mptcp_subflow_tcp_sock(subflow);
@@ -120,13 +121,14 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk)
 }
 
 SEC("struct_ops")
-int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock *msk)
+int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock *msk,
+	     struct mptcp_sched_data *data)
 {
 	struct sock *backup = NULL, *pick = NULL;
 	struct mptcp_subflow_context *subflow;
 	int min_stale_count = INT_MAX;
 
-	bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk) {
+	bpf_for_each(mptcp_subflow_sched, subflow, (struct sock *)msk, data) {
 		struct sock *ssk = bpf_mptcp_subflow_tcp_sock(subflow);
 
 		if (!ssk || !mptcp_subflow_active(subflow))
Signature · 1 line
2.43.0
author reviewer
#13 lore raw

PATCH v2 11/11 mptcp: drop subflow contexts in mptcp_sched_data

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

The mptcp_subflow_sched bpf_iter is added now, it's better to use the helper bpf_for_each(mptcp_subflow_sched) to traverse all subflows on the conn_list of an MPTCP socket and then call kfunc to modify the fields of each subflow in the WIP MPTCP BPF packet scheduler examples, instead of converting them to a fixed array. With this helper, we can get rid of this subflow array "contexts" and the size of it "subflows" in struct mptcp_sched_data.

---
 include/net/mptcp.h | 4 ----
 1 file changed, 4 deletions(-)
include/net/mptcp.h +0 -4
index bd3d1b3654dd..0083af204000 100644
@@ -100,11 +100,7 @@ struct mptcp_out_options {
 #define MPTCP_SCHED_MAX		128
 #define MPTCP_SCHED_BUF_MAX	(MPTCP_SCHED_NAME_MAX * MPTCP_SCHED_MAX)
 
-#define MPTCP_SUBFLOWS_MAX	8
-
 struct mptcp_sched_data {
-	u8	subflows;
-	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
 	struct task_struct *bpf_iter_task;
 };
 
Signature · 1 line
2.43.0
#14 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/13719922193

Status: failure
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/76b642669ea6
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=941486

Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

#15 lore raw
In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/13719922203

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/76b642669ea6
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=941486

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-normal

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 (NGI0 Core)