mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH mptcp-next v7 00/13] BPF packet scheduler
@ 2022-06-02  4:53 Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 01/13] Squash to "mptcp: add struct mptcp_sched_ops" Geliang Tang
                   ` (13 more replies)
  0 siblings, 14 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

v7:
 - Compared with v6, only one line of code is modified, adding the
   missing preserve_access_index for mptcp_sched_data:

'''
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -241,7 +241,7 @@ struct mptcp_subflow_context {
 struct mptcp_sched_data {
 	bool	reinject;
 	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
-};
+} __attribute__((preserve_access_index));
 
 struct mptcp_sched_ops {
 	char name[MPTCP_SCHED_NAME_MAX];
'''

 - split the changes to bpf_tcp_helpers.h into "selftests/bpf: Add mptcp
sched structs" as Mat suggested.

 - split the commit "mptcp: add subflow_set_scheduled helper" in v6 into
two: "mptcp: add scheduled in mptcp_subflow_context" and "bpf: Add
bpf_mptcp_sched_kfunc_set".

 - update subjects and commit logs.

 - full patches of this series are in my git tree: https://github.com/geliangtang/mptcp_net-next
24744c54b1ff selftests/bpf: Add bpf_rr test
38025f9d475d selftests/bpf: Add bpf_rr scheduler
3a3ff68c3a5c selftests/bpf: Add bpf_bkup test
dca2db73fbf7 selftests/bpf: Add bpf_bkup scheduler
1c4aa6d66fa4 selftests/bpf: Add bpf_first test
22e828c59707 selftests/bpf: Add bpf_first scheduler
fec3332cdd65 selftests/bpf: Add mptcp sched structs
9827fdb964a3 bpf: Add bpf_mptcp_sched_kfunc_set
43422ac185dc bpf: Add bpf_mptcp_sched_ops
4d1b800070ec mptcp: add get_subflow wrappers
ae39f16c28a5 mptcp: add scheduled in mptcp_subflow_context
83e578b46253 mptcp: add sched in mptcp_sock
e69ba4ac0a70 mptcp: add a new sysctl scheduler
1f6ee94e97a0 mptcp: add struct mptcp_sched_ops

v6:
 - fix the warning reported by kernel test robot:

>> net/mptcp/bpf.c:165:6: warning: no previous prototype for 'bpf_mptcp_subflow_set_scheduled' [-Wmissing-prototypes]
     165 | void bpf_mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 - rename bpf_mptcp_subflow_set_scheduled to mptcp_subflow_set_scheduled

v5:
 - add bpf_mptcp_subflow_set_scheduled helper.
 - drop padding bits before backup, use BPF_CORE_READ_BITFIELD_PROBED()
   instead.
 - The new patch "mptcp: add bpf set scheduled helper" should be inserted
   between the commits "mptcp: add bpf_mptcp_sched_ops" and
   "selftests/bpf: add bpf_first scheduler"

v4:
 - merge "mptcp: move is_scheduled into mptcp_subflow_context"
 - rename bpf_backup tp bpf_bkup

v3:
 - use new BPF scheduler API:
 - add backup scheduler
 - add round-robin scheduler
 - check bytes_sent of 'ss' output.

v2:
- Use new BPF scheduler API:
 unsigned long (*get_subflow)(const struct mptcp_sock *msk, bool reinject,
                              struct mptcp_sched_data *data);

Geliang Tang (13):
  Squash to "mptcp: add struct mptcp_sched_ops"
  Squash to "mptcp: add sched in mptcp_sock"
  mptcp: add scheduled in mptcp_subflow_context
  Squash to "mptcp: add get_subflow wrappers"
  Squash to "mptcp: add bpf_mptcp_sched_ops"
  bpf: Add bpf_mptcp_sched_kfunc_set
  selftests/bpf: Add mptcp sched structs
  Squash to "selftests/bpf: add bpf_first scheduler"
  Squash to "selftests/bpf: add bpf_first test"
  selftests/bpf: Add bpf_bkup scheduler
  selftests/bpf: Add bpf_bkup test
  selftests/bpf: Add bpf_rr scheduler
  selftests/bpf: Add bpf_rr test

 include/net/mptcp.h                           |  7 +-
 net/mptcp/bpf.c                               | 34 ++++---
 net/mptcp/protocol.h                          |  3 +
 net/mptcp/sched.c                             | 60 ++++++++++---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h | 19 ++--
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 89 ++++++++++++++++++-
 .../selftests/bpf/progs/mptcp_bpf_bkup.c      | 43 +++++++++
 .../selftests/bpf/progs/mptcp_bpf_first.c     |  5 +-
 .../selftests/bpf/progs/mptcp_bpf_rr.c        | 46 ++++++++++
 9 files changed, 273 insertions(+), 33 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 01/13] Squash to "mptcp: add struct mptcp_sched_ops"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 02/13] Squash to "mptcp: add sched in mptcp_sock" Geliang Tang
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

Use new BPF API.

Please update the commit log:

'''
This patch defines struct mptcp_sched_ops, which has three struct members,
name, owner and list, and three function pointers, init(), release() and
get_subflow().

The scheduler function get_subflow() has a struct mptcp_sched_data
parameter, which contains a reinject flag and a mptcp_subflow_context
array.

Add the scheduler registering, unregistering and finding functions to add,
delete and find a packet scheduler on the global list mptcp_sched_list.
'''

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 include/net/mptcp.h                           |  7 ++++---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h | 18 ------------------
 2 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 6456ea26e4c7..7af7fd48acc7 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -97,14 +97,15 @@ struct mptcp_out_options {
 };
 
 #define MPTCP_SCHED_NAME_MAX	16
+#define MPTCP_SUBFLOWS_MAX	8
 
 struct mptcp_sched_data {
-	struct sock	*sock;
-	bool		call_again;
+	bool	reinject;
+	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
 };
 
 struct mptcp_sched_ops {
-	void (*get_subflow)(const struct mptcp_sock *msk, bool reinject,
+	void (*get_subflow)(const struct mptcp_sock *msk,
 			    struct mptcp_sched_data *data);
 
 	char			name[MPTCP_SCHED_NAME_MAX];
diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
index aca4e3c6ac48..65bd2c6ab1d2 100644
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -230,24 +230,6 @@ static __always_inline bool tcp_cc_eq(const char *a, const char *b)
 extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked) __ksym;
 extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
 
-#define MPTCP_SCHED_NAME_MAX	16
-
-struct mptcp_sched_data {
-	struct sock	*sock;
-	bool		call_again;
-};
-
-struct mptcp_sched_ops {
-	char name[MPTCP_SCHED_NAME_MAX];
-
-	void (*init)(const struct mptcp_sock *msk);
-	void (*release)(const struct mptcp_sock *msk);
-
-	void (*get_subflow)(const struct mptcp_sock *msk, bool reinject,
-			    struct mptcp_sched_data *data);
-	void *owner;
-};
-
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 02/13] Squash to "mptcp: add sched in mptcp_sock"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 01/13] Squash to "mptcp: add struct mptcp_sched_ops" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 03/13] mptcp: add scheduled in mptcp_subflow_context Geliang Tang
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

No need to export sched in bpf_tcp_helpers.h, drop it.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
index 65bd2c6ab1d2..82a7c9de95f9 100644
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -235,7 +235,6 @@ struct mptcp_sock {
 
 	__u32		token;
 	struct sock	*first;
-	struct mptcp_sched_ops	*sched;
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 03/13] mptcp: add scheduled in mptcp_subflow_context
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 01/13] Squash to "mptcp: add struct mptcp_sched_ops" Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 02/13] Squash to "mptcp: add sched in mptcp_sock" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 04/13] Squash to "mptcp: add get_subflow wrappers" Geliang Tang
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch adds a new member scheduled in struct mptcp_subflow_context,
which will be set in the MPTCP scheduler context when the scheduler
picks this subflow to send data.

Add a new helper mptcp_subflow_set_scheduled() to set this flag using
WRITE_ONCE().

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/protocol.h | 3 +++
 net/mptcp/sched.c    | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 8739794166d8..d406b5afbee4 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -469,6 +469,7 @@ struct mptcp_subflow_context {
 		valid_csum_seen : 1;        /* at least one csum validated */
 	enum mptcp_data_avail data_avail;
 	bool	mp_fail_response_expect;
+	bool	scheduled;
 	u32	remote_nonce;
 	u64	thmac;
 	u32	local_nonce;
@@ -628,6 +629,8 @@ void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
 int mptcp_init_sched(struct mptcp_sock *msk,
 		     struct mptcp_sched_ops *sched);
 void mptcp_release_sched(struct mptcp_sock *msk);
+void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
+				 bool scheduled);
 struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
 struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
 struct sock *mptcp_sched_get_send(struct mptcp_sock *msk);
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 3ceb721e6489..5a6f289ad985 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -88,6 +88,12 @@ void mptcp_release_sched(struct mptcp_sock *msk)
 	bpf_module_put(sched, sched->owner);
 }
 
+void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
+				 bool scheduled)
+{
+	WRITE_ONCE(subflow->scheduled, scheduled);
+}
+
 static int mptcp_sched_data_init(struct mptcp_sock *msk,
 				 struct mptcp_sched_data *data)
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 04/13] Squash to "mptcp: add get_subflow wrappers"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (2 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 03/13] mptcp: add scheduled in mptcp_subflow_context Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 05/13] Squash to "mptcp: add bpf_mptcp_sched_ops" Geliang Tang
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

Please update the commit log:

'''
This patch defines two new wrappers mptcp_sched_get_send() and
mptcp_sched_get_retrans(), invoke get_subflow() of msk->sched in them.
Use them instead of using mptcp_subflow_get_send() or
mptcp_subflow_get_retrans() directly.

Set the subflow pointers array in struct mptcp_sched_data before invoking
get_subflow(), then it can be used in get_subflow() in the BPF contexts.

Check the subflow scheduled flags to test which subflow or subflows are
picked by the scheduler.
'''

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/sched.c | 54 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 43 insertions(+), 11 deletions(-)

diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 5a6f289ad985..8858e1fc8b74 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -94,11 +94,25 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 	WRITE_ONCE(subflow->scheduled, scheduled);
 }
 
-static int mptcp_sched_data_init(struct mptcp_sock *msk,
+static int mptcp_sched_data_init(struct mptcp_sock *msk, bool reinject,
 				 struct mptcp_sched_data *data)
 {
-	data->sock = NULL;
-	data->call_again = 0;
+	struct mptcp_subflow_context *subflow;
+	int i = 0;
+
+	data->reinject = reinject;
+
+	mptcp_for_each_subflow(msk, subflow) {
+		if (i == MPTCP_SUBFLOWS_MAX) {
+			pr_warn_once("too many subflows");
+			break;
+		}
+		mptcp_subflow_set_scheduled(subflow, false);
+		data->contexts[i++] = subflow;
+	}
+
+	for (; i < MPTCP_SUBFLOWS_MAX; i++)
+		data->contexts[i] = NULL;
 
 	return 0;
 }
@@ -106,6 +120,8 @@ static int mptcp_sched_data_init(struct mptcp_sock *msk,
 struct sock *mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_sched_data data;
+	struct sock *ssk = NULL;
+	int i;
 
 	sock_owned_by_me((struct sock *)msk);
 
@@ -119,16 +135,25 @@ struct sock *mptcp_sched_get_send(struct mptcp_sock *msk)
 	if (!msk->sched)
 		return mptcp_subflow_get_send(msk);
 
-	mptcp_sched_data_init(msk, &data);
-	msk->sched->get_subflow(msk, false, &data);
+	mptcp_sched_data_init(msk, false, &data);
+	msk->sched->get_subflow(msk, &data);
+
+	for (i = 0; i < MPTCP_SUBFLOWS_MAX; i++) {
+		if (data.contexts[i] && READ_ONCE(data.contexts[i]->scheduled)) {
+			ssk = data.contexts[i]->tcp_sock;
+			msk->last_snd = ssk;
+			break;
+		}
+	}
 
-	msk->last_snd = data.sock;
-	return data.sock;
+	return ssk;
 }
 
 struct sock *mptcp_sched_get_retrans(struct mptcp_sock *msk)
 {
 	struct mptcp_sched_data data;
+	struct sock *ssk = NULL;
+	int i;
 
 	sock_owned_by_me((const struct sock *)msk);
 
@@ -139,9 +164,16 @@ struct sock *mptcp_sched_get_retrans(struct mptcp_sock *msk)
 	if (!msk->sched)
 		return mptcp_subflow_get_retrans(msk);
 
-	mptcp_sched_data_init(msk, &data);
-	msk->sched->get_subflow(msk, true, &data);
+	mptcp_sched_data_init(msk, true, &data);
+	msk->sched->get_subflow(msk, &data);
+
+	for (i = 0; i < MPTCP_SUBFLOWS_MAX; i++) {
+		if (data.contexts[i] && READ_ONCE(data.contexts[i]->scheduled)) {
+			ssk = data.contexts[i]->tcp_sock;
+			msk->last_snd = ssk;
+			break;
+		}
+	}
 
-	msk->last_snd = data.sock;
-	return data.sock;
+	return ssk;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 05/13] Squash to "mptcp: add bpf_mptcp_sched_ops"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (3 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 04/13] Squash to "mptcp: add get_subflow wrappers" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set Geliang Tang
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

Please update the subject and commit log:

'''
bpf: Add bpf_mptcp_sched_ops

This patch implements a new struct bpf_struct_ops, bpf_mptcp_sched_ops.
Register and unregister the bpf scheduler in .reg and .unreg.

Add write access for the scheduled flag of struct mptcp_subflow_context
in .btf_struct_access.

This MPTCP BPF scheduler implementation is similar to BPF TCP CC. And
net/ipv4/bpf_tcp_ca.c is a frame of reference for this patch.
'''

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/bpf.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 338146d173f4..0529e70d53b1 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -42,29 +42,27 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log,
 {
 	size_t end;
 
-	if (atype == BPF_READ)
+	if (atype == BPF_READ) {
 		return btf_struct_access(log, btf, t, off, size, atype,
 					 next_btf_id, flag);
+	}
 
 	if (t != mptcp_sched_type) {
-		bpf_log(log, "only access to mptcp_sched_data is supported\n");
+		bpf_log(log, "only access to mptcp_subflow_context is supported\n");
 		return -EACCES;
 	}
 
 	switch (off) {
-	case offsetof(struct mptcp_sched_data, sock):
-		end = offsetofend(struct mptcp_sched_data, sock);
-		break;
-	case offsetof(struct mptcp_sched_data, call_again):
-		end = offsetofend(struct mptcp_sched_data, call_again);
+	case offsetof(struct mptcp_subflow_context, scheduled):
+		end = offsetofend(struct mptcp_subflow_context, scheduled);
 		break;
 	default:
-		bpf_log(log, "no write support to mptcp_sched_data at off %d\n", off);
+		bpf_log(log, "no write support to mptcp_subflow_context at off %d\n", off);
 		return -EACCES;
 	}
 
 	if (off + size > end) {
-		bpf_log(log, "access beyond mptcp_sched_data at off %u size %u ended at %zu",
+		bpf_log(log, "access beyond mptcp_subflow_context at off %u size %u ended at %zu",
 			off, size, end);
 		return -EACCES;
 	}
@@ -144,7 +142,7 @@ static int bpf_mptcp_sched_init(struct btf *btf)
 {
 	s32 type_id;
 
-	type_id = btf_find_by_name_kind(btf, "mptcp_sched_data",
+	type_id = btf_find_by_name_kind(btf, "mptcp_subflow_context",
 					BTF_KIND_STRUCT);
 	if (type_id < 0)
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (4 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 05/13] Squash to "mptcp: add bpf_mptcp_sched_ops" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-07-25  7:56   ` Matthieu Baerts
  2022-06-02  4:53 ` [PATCH mptcp-next v7 07/13] selftests/bpf: Add mptcp sched structs Geliang Tang
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch adds a new struct btf_kfunc_id_set for MPTCP scheduler. Add
mptcp_subflow_set_scheduled() helper into this id_set, and register it
in bpf_mptcp_sched_kfunc_init() to make sure this helper can be accessed
from the BPF context.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/bpf.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
index 0529e70d53b1..e86dff4272d5 100644
--- a/net/mptcp/bpf.c
+++ b/net/mptcp/bpf.c
@@ -161,6 +161,22 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = {
 	.init		= bpf_mptcp_sched_init,
 	.name		= "mptcp_sched_ops",
 };
+
+BTF_SET_START(bpf_mptcp_sched_kfunc_ids)
+BTF_ID(func, mptcp_subflow_set_scheduled)
+BTF_SET_END(bpf_mptcp_sched_kfunc_ids)
+
+static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = {
+	.owner		= THIS_MODULE,
+	.check_set	= &bpf_mptcp_sched_kfunc_ids,
+};
+
+static int __init bpf_mptcp_sched_kfunc_init(void)
+{
+	return register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
+					 &bpf_mptcp_sched_kfunc_set);
+}
+late_initcall(bpf_mptcp_sched_kfunc_init);
 #endif /* CONFIG_BPF_JIT */
 
 struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 07/13] selftests/bpf: Add mptcp sched structs
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (5 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 08/13] Squash to "selftests/bpf: add bpf_first scheduler" Geliang Tang
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch adds three MPTCP scheduler structures: struct mptcp_sched_ops,
struct mptcp_sched_data and struct mptcp_subflow_context; and exports
mptcp_subflow_set_scheduled() helper for bpf selftests.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
index 82a7c9de95f9..c8792e6f125a 100644
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -230,6 +230,30 @@ static __always_inline bool tcp_cc_eq(const char *a, const char *b)
 extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked) __ksym;
 extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
 
+#define MPTCP_SCHED_NAME_MAX	16
+#define MPTCP_SUBFLOWS_MAX	8
+
+struct mptcp_subflow_context {
+	__u32	backup : 1;
+	struct	sock *tcp_sock;	    /* tcp sk backpointer */
+} __attribute__((preserve_access_index));
+
+struct mptcp_sched_data {
+	bool	reinject;
+	struct mptcp_subflow_context *contexts[MPTCP_SUBFLOWS_MAX];
+} __attribute__((preserve_access_index));
+
+struct mptcp_sched_ops {
+	char name[MPTCP_SCHED_NAME_MAX];
+
+	void (*init)(const struct mptcp_sock *msk);
+	void (*release)(const struct mptcp_sock *msk);
+
+	void (*get_subflow)(const struct mptcp_sock *msk,
+			    struct mptcp_sched_data *data);
+	void *owner;
+};
+
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
@@ -238,4 +262,7 @@ struct mptcp_sock {
 	char		ca_name[TCP_CA_NAME_MAX];
 } __attribute__((preserve_access_index));
 
+extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
+					bool scheduled) __ksym;
+
 #endif
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 08/13] Squash to "selftests/bpf: add bpf_first scheduler"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (6 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 07/13] selftests/bpf: Add mptcp sched structs Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 09/13] Squash to "selftests/bpf: add bpf_first test" Geliang Tang
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

Use new get_subflow API.

Please update the subject:

'''
selftests/bpf: Add bpf_first scheduler
'''

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/progs/mptcp_bpf_first.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c
index fd67b5f42964..fcd733e88b02 100644
--- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c
@@ -17,10 +17,9 @@ void BPF_PROG(mptcp_sched_first_release, const struct mptcp_sock *msk)
 }
 
 void BPF_STRUCT_OPS(bpf_first_get_subflow, const struct mptcp_sock *msk,
-		    bool reinject, struct mptcp_sched_data *data)
+		    struct mptcp_sched_data *data)
 {
-	data->sock = msk->first;
-	data->call_again = 0;
+	mptcp_subflow_set_scheduled(data->contexts[0], true);
 }
 
 SEC(".struct_ops")
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 09/13] Squash to "selftests/bpf: add bpf_first test"
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (7 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 08/13] Squash to "selftests/bpf: add bpf_first scheduler" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 10/13] selftests/bpf: Add bpf_bkup scheduler Geliang Tang
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

Add two helpers, add_veth() and cleanup().

Please update the subject and commit log:

'''
selftests/bpf: Add bpf_first test

This patch expends the MPTCP test base to support MPTCP packet scheduler
tests. Add the bpf_first scheduler test in it.

Use sysctl to set net.mptcp.scheduler to use this sched. The new helper
add_veth() adds a veth net device to simulate the multiple addresses case.
Use 'ip mptcp endpoint' command to add this new endpoint to PM netlink.

Some code in send_data() is from prog_tests/bpf_tcp_ca.c.

Check bytes_sent of 'ss' output after send_data() to make sure no data
has been sent on the new veth net device. All data has been sent on the
first subflow.

Invoke the new helper cleanup() to set back net.mptcp.scheduler to default,
flush all mptcp endpoints, and delete the veth net device.
'''

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 8e9764275b07..eaea4105728d 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -250,6 +250,20 @@ static void send_data(int lfd, int fd)
 	      PTR_ERR(thread_ret));
 }
 
+static void add_veth(void)
+{
+	system("ip link add veth1 type veth");
+	system("ip addr add 10.0.1.1/24 dev veth1");
+	system("ip link set veth1 up");
+}
+
+static void cleanup(void)
+{
+	system("sysctl -qw net.mptcp.scheduler=default");
+	system("ip mptcp endpoint flush");
+	system("ip link del veth1");
+}
+
 static void test_first(void)
 {
 	struct mptcp_bpf_first *first_skel;
@@ -266,15 +280,18 @@ static void test_first(void)
 		return;
 	}
 
+	add_veth();
+	system("ip mptcp endpoint add 10.0.1.1 subflow");
 	system("sysctl -qw net.mptcp.scheduler=bpf_first");
 	server_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
 	client_fd = connect_to_fd(server_fd, 0);
 
 	send_data(server_fd, client_fd);
+	ASSERT_GT(system("ss -MOenita | grep '10.0.1.1' | grep 'bytes_sent:'"), 0, "ss");
 
 	close(client_fd);
 	close(server_fd);
-	system("sysctl -qw net.mptcp.scheduler=default");
+	cleanup();
 	bpf_link__destroy(link);
 	mptcp_bpf_first__destroy(first_skel);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 10/13] selftests/bpf: Add bpf_bkup scheduler
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (8 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 09/13] Squash to "selftests/bpf: add bpf_first test" Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 11/13] selftests/bpf: Add bpf_bkup test Geliang Tang
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch implements the backup flag test scheduler, named bpf_bkup,
which picks the first non-backup subflow to send data.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../selftests/bpf/progs/mptcp_bpf_bkup.c      | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c

diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c
new file mode 100644
index 000000000000..949e053e980c
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022, SUSE. */
+
+#include <linux/bpf.h>
+#include "bpf_tcp_helpers.h"
+
+char _license[] SEC("license") = "GPL";
+
+SEC("struct_ops/mptcp_sched_bkup_init")
+void BPF_PROG(mptcp_sched_bkup_init, const struct mptcp_sock *msk)
+{
+}
+
+SEC("struct_ops/mptcp_sched_bkup_release")
+void BPF_PROG(mptcp_sched_bkup_release, const struct mptcp_sock *msk)
+{
+}
+
+void BPF_STRUCT_OPS(bpf_bkup_get_subflow, const struct mptcp_sock *msk,
+		    struct mptcp_sched_data *data)
+{
+	int nr = 0;
+
+	for (int i = 0; i < MPTCP_SUBFLOWS_MAX; i++) {
+		if (!data->contexts[i])
+			break;
+
+		if (!BPF_CORE_READ_BITFIELD_PROBED(data->contexts[i], backup)) {
+			nr = i;
+			break;
+		}
+	}
+
+	mptcp_subflow_set_scheduled(data->contexts[nr], true);
+}
+
+SEC(".struct_ops")
+struct mptcp_sched_ops bkup = {
+	.init		= (void *)mptcp_sched_bkup_init,
+	.release	= (void *)mptcp_sched_bkup_release,
+	.get_subflow	= (void *)bpf_bkup_get_subflow,
+	.name		= "bpf_bkup",
+};
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 11/13] selftests/bpf: Add bpf_bkup test
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (9 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 10/13] selftests/bpf: Add bpf_bkup scheduler Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 12/13] selftests/bpf: Add bpf_rr scheduler Geliang Tang
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch adds the backup BPF MPTCP scheduler test. Use sysctl to
set net.mptcp.scheduler to use this sched. Add a veth net device to
simulate the multiple addresses case. Use 'ip mptcp endpoint' command
to add this new endpoint to PM netlink with backup flag. Send data,
check bytes_sent of 'ss' output, and do some cleanups.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index eaea4105728d..f3c73cd2c786 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -7,6 +7,7 @@
 #include "network_helpers.h"
 #include "mptcp_sock.skel.h"
 #include "mptcp_bpf_first.skel.h"
+#include "mptcp_bpf_bkup.skel.h"
 
 #ifndef TCP_CA_NAME_MAX
 #define TCP_CA_NAME_MAX	16
@@ -296,10 +297,44 @@ static void test_first(void)
 	mptcp_bpf_first__destroy(first_skel);
 }
 
+static void test_bkup(void)
+{
+	struct mptcp_bpf_bkup *bkup_skel;
+	int server_fd, client_fd;
+	struct bpf_link *link;
+
+	bkup_skel = mptcp_bpf_bkup__open_and_load();
+	if (!ASSERT_OK_PTR(bkup_skel, "bpf_bkup__open_and_load"))
+		return;
+
+	link = bpf_map__attach_struct_ops(bkup_skel->maps.bkup);
+	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
+		mptcp_bpf_bkup__destroy(bkup_skel);
+		return;
+	}
+
+	add_veth();
+	system("ip mptcp endpoint add 10.0.1.1 subflow backup");
+	system("sysctl -qw net.mptcp.scheduler=bpf_bkup");
+	server_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
+	client_fd = connect_to_fd(server_fd, 0);
+
+	send_data(server_fd, client_fd);
+	ASSERT_GT(system("ss -MOenita | grep '10.0.1.1' | grep 'bytes_sent:'"), 0, "ss");
+
+	close(client_fd);
+	close(server_fd);
+	cleanup();
+	bpf_link__destroy(link);
+	mptcp_bpf_bkup__destroy(bkup_skel);
+}
+
 void test_mptcp(void)
 {
 	if (test__start_subtest("base"))
 		test_base();
 	if (test__start_subtest("first"))
 		test_first();
+	if (test__start_subtest("bkup"))
+		test_bkup();
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 12/13] selftests/bpf: Add bpf_rr scheduler
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (10 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 11/13] selftests/bpf: Add bpf_bkup test Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  4:53 ` [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test Geliang Tang
  2022-06-04 10:39 ` [PATCH mptcp-next v7 00/13] BPF packet scheduler Matthieu Baerts
  13 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch implements the round-robin BPF MPTCP scheduler, named bpf_rr,
which always picks the next available subflow to send data. If no such
next subflow available, picks the first one.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/bpf_tcp_helpers.h |  1 +
 .../selftests/bpf/progs/mptcp_bpf_rr.c        | 46 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c

diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
index c8792e6f125a..c7d4a9a69cfc 100644
--- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h
@@ -257,6 +257,7 @@ struct mptcp_sched_ops {
 struct mptcp_sock {
 	struct inet_connection_sock	sk;
 
+	struct sock	*last_snd;
 	__u32		token;
 	struct sock	*first;
 	char		ca_name[TCP_CA_NAME_MAX];
diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
new file mode 100644
index 000000000000..ce4e98f83e43
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022, SUSE. */
+
+#include <linux/bpf.h>
+#include "bpf_tcp_helpers.h"
+
+char _license[] SEC("license") = "GPL";
+
+SEC("struct_ops/mptcp_sched_rr_init")
+void BPF_PROG(mptcp_sched_rr_init, const struct mptcp_sock *msk)
+{
+}
+
+SEC("struct_ops/mptcp_sched_rr_release")
+void BPF_PROG(mptcp_sched_rr_release, const struct mptcp_sock *msk)
+{
+}
+
+void BPF_STRUCT_OPS(bpf_rr_get_subflow, const struct mptcp_sock *msk,
+		    struct mptcp_sched_data *data)
+{
+	int nr = 0;
+
+	for (int i = 0; i < MPTCP_SUBFLOWS_MAX; i++) {
+		if (!msk->last_snd || !data->contexts[i])
+			break;
+
+		if (data->contexts[i]->tcp_sock == msk->last_snd) {
+			if (i + 1 == MPTCP_SUBFLOWS_MAX || !data->contexts[i + 1])
+				break;
+
+			nr = i + 1;
+			break;
+		}
+	}
+
+	mptcp_subflow_set_scheduled(data->contexts[nr], true);
+}
+
+SEC(".struct_ops")
+struct mptcp_sched_ops rr = {
+	.init		= (void *)mptcp_sched_rr_init,
+	.release	= (void *)mptcp_sched_rr_release,
+	.get_subflow	= (void *)bpf_rr_get_subflow,
+	.name		= "bpf_rr",
+};
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (11 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 12/13] selftests/bpf: Add bpf_rr scheduler Geliang Tang
@ 2022-06-02  4:53 ` Geliang Tang
  2022-06-02  5:20   ` selftests/bpf: Add bpf_rr test: Build Failure MPTCP CI
  2022-06-02  6:36   ` selftests/bpf: Add bpf_rr test: Tests Results MPTCP CI
  2022-06-04 10:39 ` [PATCH mptcp-next v7 00/13] BPF packet scheduler Matthieu Baerts
  13 siblings, 2 replies; 19+ messages in thread
From: Geliang Tang @ 2022-06-02  4:53 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch adds the round-robin BPF MPTCP scheduler test. Use sysctl to
set net.mptcp.scheduler to use this sched. Add a veth net device to
simulate the multiple addresses case. Use 'ip mptcp endpoint' command to
add this new endpoint to PM netlink. Send data and check bytes_sent of
'ss' output after it to make sure the data has been sent on the new veth
net device.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index f3c73cd2c786..1ecc8a2b76b6 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -8,6 +8,7 @@
 #include "mptcp_sock.skel.h"
 #include "mptcp_bpf_first.skel.h"
 #include "mptcp_bpf_bkup.skel.h"
+#include "mptcp_bpf_rr.skel.h"
 
 #ifndef TCP_CA_NAME_MAX
 #define TCP_CA_NAME_MAX	16
@@ -329,6 +330,38 @@ static void test_bkup(void)
 	mptcp_bpf_bkup__destroy(bkup_skel);
 }
 
+static void test_rr(void)
+{
+	struct mptcp_bpf_rr *rr_skel;
+	int server_fd, client_fd;
+	struct bpf_link *link;
+
+	rr_skel = mptcp_bpf_rr__open_and_load();
+	if (!ASSERT_OK_PTR(rr_skel, "bpf_rr__open_and_load"))
+		return;
+
+	link = bpf_map__attach_struct_ops(rr_skel->maps.rr);
+	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
+		mptcp_bpf_rr__destroy(rr_skel);
+		return;
+	}
+
+	add_veth();
+	system("ip mptcp endpoint add 10.0.1.1 subflow");
+	system("sysctl -qw net.mptcp.scheduler=bpf_rr");
+	server_fd = start_mptcp_server(AF_INET, NULL, 0, 0);
+	client_fd = connect_to_fd(server_fd, 0);
+
+	send_data(server_fd, client_fd);
+	ASSERT_OK(system("ss -MOenita | grep '10.0.1.1' | grep -q 'bytes_sent:'"), "ss");
+
+	close(client_fd);
+	close(server_fd);
+	cleanup();
+	bpf_link__destroy(link);
+	mptcp_bpf_rr__destroy(rr_skel);
+}
+
 void test_mptcp(void)
 {
 	if (test__start_subtest("base"))
@@ -337,4 +370,6 @@ void test_mptcp(void)
 		test_first();
 	if (test__start_subtest("bkup"))
 		test_bkup();
+	if (test__start_subtest("rr"))
+		test_rr();
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: selftests/bpf: Add bpf_rr test: Build Failure
  2022-06-02  4:53 ` [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test Geliang Tang
@ 2022-06-02  5:20   ` MPTCP CI
  2022-06-02  6:36   ` selftests/bpf: Add bpf_rr test: Tests Results MPTCP CI
  1 sibling, 0 replies; 19+ messages in thread
From: MPTCP CI @ 2022-06-02  5:20 UTC (permalink / raw)
  To: Geliang Tang; +Cc: mptcp

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://patchwork.kernel.org/project/mptcp/patch/f26165cd8b5d4380c16b4d13607e219e376bdb19.1654143895.git.geliang.tang@suse.com/
  https://github.com/multipath-tcp/mptcp_net-next/actions/runs/2426166438

Status: failure
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/09f1dd4b0a46

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 (Tessares)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: selftests/bpf: Add bpf_rr test: Tests Results
  2022-06-02  4:53 ` [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test Geliang Tang
  2022-06-02  5:20   ` selftests/bpf: Add bpf_rr test: Build Failure MPTCP CI
@ 2022-06-02  6:36   ` MPTCP CI
  1 sibling, 0 replies; 19+ messages in thread
From: MPTCP CI @ 2022-06-02  6:36 UTC (permalink / raw)
  To: Geliang Tang; +Cc: mptcp

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

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

- KVM Validation: debug:
  - Unstable: 3 failed test(s): packetdrill_add_addr selftest_diag selftest_mptcp_join 🔴:
  - Task: https://cirrus-ci.com/task/5623405071302656
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5623405071302656/summary/summary.txt

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


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)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH mptcp-next v7 00/13] BPF packet scheduler
  2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
                   ` (12 preceding siblings ...)
  2022-06-02  4:53 ` [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test Geliang Tang
@ 2022-06-04 10:39 ` Matthieu Baerts
  13 siblings, 0 replies; 19+ messages in thread
From: Matthieu Baerts @ 2022-06-04 10:39 UTC (permalink / raw)
  To: Geliang Tang, mptcp

Hi Geliang, Mat,

On 02/06/2022 06:53, Geliang Tang wrote:
> Geliang Tang (13):
>   Squash to "mptcp: add struct mptcp_sched_ops"
>   Squash to "mptcp: add sched in mptcp_sock"
>   mptcp: add scheduled in mptcp_subflow_context
>   Squash to "mptcp: add get_subflow wrappers"
>   Squash to "mptcp: add bpf_mptcp_sched_ops"
>   bpf: Add bpf_mptcp_sched_kfunc_set
>   selftests/bpf: Add mptcp sched structs
>   Squash to "selftests/bpf: add bpf_first scheduler"
>   Squash to "selftests/bpf: add bpf_first test"
>   selftests/bpf: Add bpf_bkup scheduler
>   selftests/bpf: Add bpf_bkup test
>   selftests/bpf: Add bpf_rr scheduler
>   selftests/bpf: Add bpf_rr test

Thank you for the patches and the reviews!

- 2431156a8332: "squashed" patch 01/13 in "mptcp: add struct
mptcp_sched_ops"
- 5b4922afdc1a: tg:msg: import new commit message

- b3d4e9dd2732: "squashed" patch 02/13 in "mptcp: add sched in mptcp_sock"

- 31d67d8b3333: mptcp: add scheduled in mptcp_subflow_context
- a7bcb7a07c78: conflict in t/mptcp-add-get_subflow-wrappers

- 3e48ef252d67: "squashed" patch 04/13 in "mptcp: add get_subflow wrappers"
- 1b7fdba99880: tg:msg: import new commit message

- 50c2231c8ce0: "squashed" patch 05/13 in "mptcp: add bpf_mptcp_sched_ops"
- a5b6b12b168c: tg:msg: import new commit message

- da7c63ae4dae: bpf: Add bpf_mptcp_sched_kfunc_set
- ee9fd7d0cfc7: selftests/bpf: Add mptcp sched structs

- 4807c07b7208: "squashed" patch 08/13 in "selftests/bpf: add bpf_first
scheduler"
- e260618e476d: tg:msg: import new commit message

- a4e4bdabb97f: "squashed" patch 09/13 in "selftests/bpf: add bpf_first
test"
e98520b49d7c] tg:msg: import new commit message

- 39cea72f7d32: selftests/bpf: Add bpf_bkup scheduler
- fc3d564c3a1a: selftests/bpf: Add bpf_bkup test
- a468ad32a683: selftests/bpf: Add bpf_rr scheduler
- 98c84f06cc1d: selftests/bpf: Add bpf_rr test

- Results: 643dd3bb8650..293143ba65b0 (export)

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220604T103853
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set
  2022-06-02  4:53 ` [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set Geliang Tang
@ 2022-07-25  7:56   ` Matthieu Baerts
  2022-07-26  3:33     ` Geliang Tang
  0 siblings, 1 reply; 19+ messages in thread
From: Matthieu Baerts @ 2022-07-25  7:56 UTC (permalink / raw)
  To: Geliang Tang, mptcp

Hi Geliang, Mat,

On 02/06/2022 06:53, Geliang Tang wrote:
> This patch adds a new struct btf_kfunc_id_set for MPTCP scheduler. Add
> mptcp_subflow_set_scheduled() helper into this id_set, and register it
> in bpf_mptcp_sched_kfunc_init() to make sure this helper can be accessed
> from the BPF context.
> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
>  net/mptcp/bpf.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
> index 0529e70d53b1..e86dff4272d5 100644
> --- a/net/mptcp/bpf.c
> +++ b/net/mptcp/bpf.c
> @@ -161,6 +161,22 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = {
>  	.init		= bpf_mptcp_sched_init,
>  	.name		= "mptcp_sched_ops",
>  };
> +
> +BTF_SET_START(bpf_mptcp_sched_kfunc_ids)
> +BTF_ID(func, mptcp_subflow_set_scheduled)
> +BTF_SET_END(bpf_mptcp_sched_kfunc_ids)
> +
> +static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = {
> +	.owner		= THIS_MODULE,
> +	.check_set	= &bpf_mptcp_sched_kfunc_ids,

FYI, I had to change this commit in our tree, see 556f2a5949dd ("mptcp:
bpf: fix compilation error").

In short, I had to adapt the code due to modification on BPF side,
related to commit a4703e318432 ("bpf: Switch to new kfunc flags
infrastructure"). I hope I did the proper modification.

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set
  2022-07-25  7:56   ` Matthieu Baerts
@ 2022-07-26  3:33     ` Geliang Tang
  0 siblings, 0 replies; 19+ messages in thread
From: Geliang Tang @ 2022-07-26  3:33 UTC (permalink / raw)
  To: Matthieu Baerts; +Cc: mptcp

On Mon, Jul 25, 2022 at 09:56:10AM +0200, Matthieu Baerts wrote:
> Hi Geliang, Mat,
> 
> On 02/06/2022 06:53, Geliang Tang wrote:
> > This patch adds a new struct btf_kfunc_id_set for MPTCP scheduler. Add
> > mptcp_subflow_set_scheduled() helper into this id_set, and register it
> > in bpf_mptcp_sched_kfunc_init() to make sure this helper can be accessed
> > from the BPF context.
> > 
> > Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> > ---
> >  net/mptcp/bpf.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
> > index 0529e70d53b1..e86dff4272d5 100644
> > --- a/net/mptcp/bpf.c
> > +++ b/net/mptcp/bpf.c
> > @@ -161,6 +161,22 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = {
> >  	.init		= bpf_mptcp_sched_init,
> >  	.name		= "mptcp_sched_ops",
> >  };
> > +
> > +BTF_SET_START(bpf_mptcp_sched_kfunc_ids)
> > +BTF_ID(func, mptcp_subflow_set_scheduled)
> > +BTF_SET_END(bpf_mptcp_sched_kfunc_ids)
> > +
> > +static const struct btf_kfunc_id_set bpf_mptcp_sched_kfunc_set = {
> > +	.owner		= THIS_MODULE,
> > +	.check_set	= &bpf_mptcp_sched_kfunc_ids,
> 
> FYI, I had to change this commit in our tree, see 556f2a5949dd ("mptcp:
> bpf: fix compilation error").
> 
> In short, I had to adapt the code due to modification on BPF side,
> related to commit a4703e318432 ("bpf: Switch to new kfunc flags
> infrastructure"). I hope I did the proper modification.

Thanks for this modification, Matt, it looks good to me.

-Geliang

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-07-26  3:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  4:53 [PATCH mptcp-next v7 00/13] BPF packet scheduler Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 01/13] Squash to "mptcp: add struct mptcp_sched_ops" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 02/13] Squash to "mptcp: add sched in mptcp_sock" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 03/13] mptcp: add scheduled in mptcp_subflow_context Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 04/13] Squash to "mptcp: add get_subflow wrappers" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 05/13] Squash to "mptcp: add bpf_mptcp_sched_ops" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 06/13] bpf: Add bpf_mptcp_sched_kfunc_set Geliang Tang
2022-07-25  7:56   ` Matthieu Baerts
2022-07-26  3:33     ` Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 07/13] selftests/bpf: Add mptcp sched structs Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 08/13] Squash to "selftests/bpf: add bpf_first scheduler" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 09/13] Squash to "selftests/bpf: add bpf_first test" Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 10/13] selftests/bpf: Add bpf_bkup scheduler Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 11/13] selftests/bpf: Add bpf_bkup test Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 12/13] selftests/bpf: Add bpf_rr scheduler Geliang Tang
2022-06-02  4:53 ` [PATCH mptcp-next v7 13/13] selftests/bpf: Add bpf_rr test Geliang Tang
2022-06-02  5:20   ` selftests/bpf: Add bpf_rr test: Build Failure MPTCP CI
2022-06-02  6:36   ` selftests/bpf: Add bpf_rr test: Tests Results MPTCP CI
2022-06-04 10:39 ` [PATCH mptcp-next v7 00/13] BPF packet scheduler Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).