Skip to contentSkip to conversation

fixes for "new MPTCP subflow subtest v4"

PATCH Superseded Geliang Tang 3 participants 9 messages Aug 30, 2024 – Sep 3, 2024

Subsystems (4)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

v6 cover fixes for "new MPTCP subflow subtest v4"

From: Geliang Tang <[email protected]>

v6:
- address Matt's comments in v5.
- use mptcp_for_each_subflow in _check_getsockopt_subflow_mark.
- check msk->pm.subflows in _check_getsockopt_subflow_mark/cc.
- add wait_for_new_subflows helper.

v5:
- rename _check_getsockopt_subflows_mark in patch 1.
- address Matt's comments in v4.

v4:
- address Matt's comments in v3.

v3:
- drop "ss_search" from subflow subtest
- fix mptcp_for_each_subflow_safe
- add cond_break in list_for_each_entry/_safe

Two fixes address Martin's comments in "new MPTCP subflow subtest" v4. Patch 2 will conflict with "selftests/bpf: Add bpf_first scheduler & test".

Geliang Tang (4):
Squash to "selftests/bpf: Add mptcp subflow example" selftests/bpf: Add getsockopt to inspect mptcp subflow Squash to "selftests/bpf: Add mptcp subflow subtest" Squash to "selftests/bpf: Add bpf scheduler test"

 .../testing/selftests/bpf/prog_tests/mptcp.c  | 65 +++++++++++------
 tools/testing/selftests/bpf/progs/mptcp_bpf.h | 35 +++++++++
 .../selftests/bpf/progs/mptcp_subflow.c       | 71 ++++++++++++++++++-
 3 files changed, 149 insertions(+), 22 deletions(-)
Signature · 1 line
2.43.0
author reviewer
#1 lore raw

PATCH v6 1/4 Squash to "selftests/bpf: Add mptcp subflow example"

From: Geliang Tang <[email protected]>

For easier verification of cc, set cc of the second subflow as "reno", instead of the first one.

---
 tools/testing/selftests/bpf/progs/mptcp_subflow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/mptcp_subflow.c +1 -1
index bc572e1d6df8..2e28f4a215b5 100644
@@ -52,7 +52,7 @@ int mptcp_subflow(struct bpf_sock_ops *skops)
 	err = bpf_setsockopt(skops, SOL_SOCKET, SO_MARK, &mark, sizeof(mark));
 	if (err < 0)
 		return 1;
-	if (mark == 1)
+	if (mark == 2)
 		err = bpf_setsockopt(skops, SOL_TCP, TCP_CONGESTION, cc, TCP_CA_NAME_MAX);
 
 	return 1;
Signature · 1 line
2.43.0
author reviewer
#2 lore raw

PATCH v6 2/4 selftests/bpf: Add getsockopt to inspect mptcp subflow

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

This patch adds a "cgroup/getsockopt" way to inspect the subflows of a mptcp socket.

mptcp_for_each_stubflow() and other helpers related to list_dentry are added into progs/mptcp_bpf.h.

Add an extra "cgroup/getsockopt" prog to walk the msk->conn_list and use bpf_core_cast to cast a pointer to tcp_sock for readonly. It will allow to inspect all the fields in a tcp_sock.

---
 tools/testing/selftests/bpf/progs/mptcp_bpf.h | 35 ++++++++++
 .../selftests/bpf/progs/mptcp_subflow.c       | 69 +++++++++++++++++++
 2 files changed, 104 insertions(+)
tools/testing/selftests/bpf/progs/mptcp_bpf.h +35 -0
index 782f36ed027e..d60e3c8f85a1 100644
@@ -4,9 +4,44 @@
 
 #include <vmlinux.h>
 #include <bpf/bpf_core_read.h>
+#include "bpf_experimental.h"
 
 #define MPTCP_SUBFLOWS_MAX 8
 
+static inline int list_is_head(const struct list_head *list,
+			       const struct list_head *head)
+{
+	return list == head;
+}
+
+#define list_entry(ptr, type, member)					\
+	container_of(ptr, type, member)
+
+#define list_first_entry(ptr, type, member)				\
+	list_entry((ptr)->next, type, member)
+
+#define list_next_entry(pos, member)					\
+	list_entry((pos)->member.next, typeof(*(pos)), member)
+
+#define list_entry_is_head(pos, head, member)				\
+	list_is_head(&pos->member, (head))
+
+#define list_for_each_entry(pos, head, member)				\
+	for (pos = list_first_entry(head, typeof(*pos), member);	\
+	     cond_break, !list_entry_is_head(pos, head, member);	\
+	     pos = list_next_entry(pos, member))
+
+#define list_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = list_first_entry(head, typeof(*pos), member),	\
+		n = list_next_entry(pos, member);			\
+	     cond_break, !list_entry_is_head(pos, head, member);	\
+	     pos = n, n = list_next_entry(n, member))
+
+#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)
+
 extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 					bool scheduled) __ksym;
 
tools/testing/selftests/bpf/progs/mptcp_subflow.c +69 -0

78 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#3 lore raw

Re: [PATCH mptcp-next v6 2/4] selftests/bpf: Add getsockopt to inspect mptcp subflow

Hi Geliang,

Thank you for the new version. I still have one opened question about what is printed in case of error: do we have enough info to debug issues? Please see below.

Quoted 11 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This patch adds a "cgroup/getsockopt" way to inspect the subflows of a mptcp socket.

mptcp_for_each_stubflow() and other helpers related to list_dentry are added into progs/mptcp_bpf.h.

Add an extra "cgroup/getsockopt" prog to walk the msk->conn_list and use bpf_core_cast to cast a pointer to tcp_sock for readonly. It will allow to inspect all the fields in a tcp_sock.

(...)

Quoted 14 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +1 -0
index 2e28f4a215b5..18396532f016 100644
@@ -4,6 +4,7 @@
 
 /* vmlinux.h, bpf_helpers.h and other 'define' */
 #include "bpf_tracing_net.h"
+#include "mptcp_bpf.h"
 
 char _license[] SEC("license") = "GPL";
 
@@ -57,3 +58,71 @@ int mptcp_subflow(struct bpf_sock_ops *skops)
 

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 68

Quoted 10 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +8 -0
 	return 1;
 }
+
+static int _check_getsockopt_subflow_mark(struct mptcp_sock *msk, struct bpf_sockopt *ctx)
+{
+	struct mptcp_subflow_context *subflow;
+	int i = 0;
+
+	if (msk->pm.subflows != 1) {
+		bpf_printk("subflows=%u", msk->pm.subflows);

I think the message should be a bit longer, e.g.

"MPTCP Subflow: expected 1 extra subflows, got %u"

It looks like you didn't reply to my question from v5: if there is an issue with the verifications that are done in BPF, are these bpf_printk printed somewhere? e.g. if you force it to fail here, do you see the new message in the logs of the BPF selftests?

If the test is unstable, we need to have a way understand where is the issue exactly, not somewhere where we set 'ctx->retval = -1'. The best would be to have a comprehensive message like what I'm suggesting here. If not, we should at least have a unique retval or errno somehow.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 79

Quoted 11 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +11 -0
+		ctx->retval = -1;
+	}
+
+	mptcp_for_each_subflow(msk, subflow) {
+		struct sock *ssk;
+
+		ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
+							   struct mptcp_subflow_context));
+
+		if (ssk->sk_mark != ++i)
+			ctx->retval = -1;

Please add an error message here, e.g.

MPTCP Subflow: expected %d mark, got %d

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 82

Quoted 3 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +3 -0
+	}
+
+	return 1;

(no need to change if you prefer, but your helper is always returning -1, maybe it doesn't need to return anything?)

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 90

Quoted 8 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +8 -0
+}
+
+static int _check_getsockopt_subflow_cc(struct mptcp_sock *msk, struct bpf_sockopt *ctx)
+{
+	struct mptcp_subflow_context *subflow;
+
+	if (msk->pm.subflows != 1) {
+		bpf_printk("subflows=%u", msk->pm.subflows);

Same here.

Quoted 4 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +4 -0
+		ctx->retval = -1;
+	}
+
+	mptcp_for_each_subflow(msk, subflow) {

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 104

Quoted 10 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +10 -0
+		struct inet_connection_sock *icsk;
+		struct sock *ssk;
+
+		ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
+							   struct mptcp_subflow_context));
+		icsk = bpf_core_cast(ssk, struct inet_connection_sock);
+
+		if (ssk->sk_mark == 2 &&
+		    __builtin_memcmp(icsk->icsk_ca_ops->name, cc, TCP_CA_NAME_MAX))
+			ctx->retval = -1;

Same here.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 117

Quoted 13 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +13 -0
+	}
+
+	return 1;
+}
+
+SEC("cgroup/getsockopt")
+int _getsockopt_subflow(struct bpf_sockopt *ctx)
+{
+	struct bpf_sock *sk = ctx->sk;
+	struct mptcp_sock *msk;
+
+	if (!sk || sk->protocol != IPPROTO_MPTCP) {
+		ctx->retval = -1;

Same here.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 121

Quoted 4 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +4 -0
+		return 1;
+	}
+
+	msk = bpf_core_cast(sk, struct mptcp_sock);

Just to be sure: this cast can never fail, and no need to check if 'msk' is NULL, right?

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 128

Quoted 7 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +7 -0
+	if (ctx->level == SOL_SOCKET && ctx->optname == SO_MARK)
+		return _check_getsockopt_subflow_mark(msk, ctx);
+	if (ctx->level == SOL_TCP && ctx->optname == TCP_CONGESTION)
+		return _check_getsockopt_subflow_cc(msk, ctx);
+
+	return 1;
+}

Cheers,
Matt

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

Re: [PATCH mptcp-next v6 2/4] selftests/bpf: Add getsockopt to inspect mptcp subflow

Hi Matt,

Quoted 54 lines · Matthieu Baerts

Hi Geliang,

Thank you for the new version. I still have one opened question about what is printed in case of error: do we have enough info to debug issues? Please see below.

Quoted 15 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This patch adds a "cgroup/getsockopt" way to inspect the subflows of a
mptcp socket.

mptcp_for_each_stubflow() and other helpers related to list_dentry are
added into progs/mptcp_bpf.h.

Add an extra "cgroup/getsockopt" prog to walk the msk->conn_list and use
bpf_core_cast to cast a pointer to tcp_sock for readonly. It will allow
to inspect all the fields in a tcp_sock.

(...)

Quoted 20 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +0 -0
index 2e28f4a215b5..18396532f016 100644
@@ -4,6 +4,7 @@


 /* vmlinux.h, bpf_helpers.h and other 'define' */ #include "bpf_tracing_net.h"
+#include "mptcp_bpf.h"

 char _license[] SEC("license") = "GPL";

tools/testing/selftests/bpf/progs/mptcp_subflow.c +0 -0
@@ -57,3 +58,71 @@ int mptcp_subflow(struct bpf_sock_ops *skops)


  return 1;
 }

tools/testing/selftests/bpf/progs/mptcp_subflow.c +2 -0
+
+static int _check_getsockopt_subflow_mark(struct mptcp_sock *msk,

struct bpf_sockopt *ctx)

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 68

Quoted 6 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +6 -0
+{
+ struct mptcp_subflow_context *subflow;
+ int i = 0;
+
+ if (msk->pm.subflows != 1) {
+ bpf_printk("subflows=%u", msk->pm.subflows);

I think the message should be a bit longer, e.g.

Quoted 8 lines

  "MPTCP Subflow: expected 1 extra subflows, got %u"

It looks like you didn't reply to my question from v5: if there is an issue with the verifications that are done in BPF, are these bpf_printk
printed somewhere? e.g. if you force it to fail here, do you see the new
message in the logs of the BPF selftests?

Yes, bpf_printk works. These logs are found in /sys/kernel/debug/tracing/trace if force it to fail here:

      test_progs-75858   [003] ...11  2338.270065: bpf_trace_printk:

MPTCP Subflow: expected 1 extra subflows, got 1

Quoted 23 lines

If the test is unstable, we need to have a way understand where is the
issue exactly, not somewhere where we set 'ctx->retval = -1'. The best
would be to have a comprehensive message like what I'm suggesting here.
If not, we should at least have a unique retval or errno somehow.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 79

Quoted 11 lines

+ ctx->retval = -1;
+ }

tools/testing/selftests/bpf/progs/mptcp_subflow.c +9 -0
+
+ mptcp_for_each_subflow(msk, subflow) {
+ struct sock *ssk;
+
+ ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
+    struct mptcp_subflow_context));
+
+ if (ssk->sk_mark != ++i)
+ ctx->retval = -1;

Please add an error message here, e.g.

Quoted 8 lines

  MPTCP Subflow: expected %d mark, got %d

Quoted 3 lines

+ }
+
+ return 1;

(no need to change if you prefer, but your helper is always returning -1, maybe it doesn't need to return anything?)

Set the return value to ctx->retval in v7:

ctx->retval = _check_getsockopt_subflow_mark()

Quoted 47 lines

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 68

Quoted 10 lines
tools/testing/selftests/bpf/progs/mptcp_subflow.c +3 -0
+}
+
+static int _check_getsockopt_subflow_cc(struct mptcp_sock *msk,

struct bpf_sockopt *ctx)

tools/testing/selftests/bpf/progs/mptcp_subflow.c +5 -0
+{
+ struct mptcp_subflow_context *subflow;
+
+ if (msk->pm.subflows != 1) {
+ bpf_printk("subflows=%u", msk->pm.subflows);

Same here.

Quoted 13 lines

+ ctx->retval = -1;
+ }

tools/testing/selftests/bpf/progs/mptcp_subflow.c +11 -0
+
+ mptcp_for_each_subflow(msk, subflow) {
+ struct inet_connection_sock *icsk;
+ struct sock *ssk;
+
+ ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
+    struct mptcp_subflow_context));
+ icsk = bpf_core_cast(ssk, struct inet_connection_sock);
+
+ if (ssk->sk_mark == 2 &&
+     __builtin_memcmp(icsk->icsk_ca_ops->name, cc,
Quoted 2 lines

TCP_CA_NAME_MAX))
+ ctx->retval = -1;

Same here.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 117

Quoted 13 lines

+ }

tools/testing/selftests/bpf/progs/mptcp_subflow.c +12 -0
+
+ return 1;
+}
+
+SEC("cgroup/getsockopt")
+int _getsockopt_subflow(struct bpf_sockopt *ctx)
+{
+ struct bpf_sock *sk = ctx->sk;
+ struct mptcp_sock *msk;
+
+ if (!sk || sk->protocol != IPPROTO_MPTCP) {
+ ctx->retval = -1;

Same here.

Quoted 8 lines
Quoted 4 lines

+ return 1;
+ }
+
+ msk = bpf_core_cast(sk, struct mptcp_sock);

Just to be sure: this cast can never fail, and no need to check if 'msk'
is NULL, right?

Yes, no need to check if msk is NULL.

Thanks,
-Geliang

Quoted 11 lines

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 83

Quoted 8 lines

+ if (ctx->level == SOL_SOCKET && ctx->optname == SO_MARK)
+ return _check_getsockopt_subflow_mark(msk, ctx);
+ if (ctx->level == SOL_TCP && ctx->optname == TCP_CONGESTION)
+ return _check_getsockopt_subflow_cc(msk, ctx);

tools/testing/selftests/bpf/progs/mptcp_subflow.c +3 -0
+
+ return 1;
+}

Cheers,
Matt

maintainer
#5 lore raw

Re: [PATCH mptcp-next v6 2/4] selftests/bpf: Add getsockopt to inspect mptcp subflow

Hi Geliang,

Quoted 2 lines · Geliang Tang
Quoted 1 line · Matthieu Baerts

On 30/08/2024 08:55, Geliang Tang wrote:

(...)

Quoted 7 lines
Quoted 6 lines

It looks like you didn't reply to my question from v5: if there is an issue with the verifications that are done in BPF, are these bpf_printk
printed somewhere? e.g. if you force it to fail here, do you see the new
message in the logs of the BPF selftests?

Quoted 5 lines

Yes, bpf_printk works. These logs are found in /sys/kernel/debug/tracing/trace if force it to fail here:

      test_progs-75858   [003] ...11  2338.270065: bpf_trace_printk:

MPTCP Subflow: expected 1 extra subflows, got 1

Good, but is it visible when launching the test or did you have to do something else to see them?

Said differently: if such issue happens on the CI side, will we see the logs? Or do we need to modify the CI to get them in case of error?

Quoted 28 lines
Quoted 28 lines

If the test is unstable, we need to have a way understand where is the
issue exactly, not somewhere where we set 'ctx->retval = -1'. The best
would be to have a comprehensive message like what I'm suggesting here.
If not, we should at least have a unique retval or errno somehow.

tools/testing/selftests/bpf/progs/mptcp_subflow.c int mptcp_subflow(struct bpf_sock_ops *skops) · line 79

Quoted 11 lines

+ ctx->retval = -1;
+ }

tools/testing/selftests/bpf/progs/mptcp_subflow.c +9 -0
+
+ mptcp_for_each_subflow(msk, subflow) {
+ struct sock *ssk;
+
+ ssk = mptcp_subflow_tcp_sock(bpf_core_cast(subflow,
+    struct mptcp_subflow_context));
+
+ if (ssk->sk_mark != ++i)
+ ctx->retval = -1;

Please add an error message here, e.g.

  MPTCP Subflow: expected %d mark, got %d

Quoted 3 lines

+ }
+
+ return 1;

Quoted 6 lines
Quoted 2 lines

(no need to change if you prefer, but your helper is always returning -1, maybe it doesn't need to return anything?)

Set the return value to ctx->retval in v7:

ctx->retval = _check_getsockopt_subflow_mark()

Can 'ctx->retval' be != 0 before _getsockopt_subflow()? Not to override an error if there was already one before.

(...)

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

+ return 1;
+ }
+
+ msk = bpf_core_cast(sk, struct mptcp_sock);

Just to be sure: this cast can never fail, and no need to check if 'msk'
is NULL, right?

Yes, no need to check if msk is NULL.

Good, thank you for your reply!

Cheers,
Matt

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

PATCH v6 3/4 Squash to "selftests/bpf: Add mptcp subflow subtest"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Drop ss_search() from run_subflow().

Use the "cgroup/getsockopt" way to inspect the subflows.

---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 57 ++++++++++++-------
 1 file changed, 37 insertions(+), 20 deletions(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +37 -20
index 73adc58cd776..6085aaf61b27 100644
@@ -368,21 +368,29 @@ static int endpoint_init(char *flags)
 	return -1;
 }
 
-static int _ss_search(char *src, char *dst, char *port, char *keyword)
+static void wait_for_new_subflows(int fd)
 {
-	return SYS_NOFAIL("ip netns exec %s ss -enita src %s dst %s %s %d | grep -q '%s'",
-			  NS_TEST, src, dst, port, PORT_1, keyword);
-}
+	socklen_t len;
+	u8 subflows;
+	int err, i;
 
-static int ss_search(char *src, char *keyword)
-{
-	return _ss_search(src, ADDR_1, "dport", keyword);
+	len = sizeof(subflows);
+	/* Wait max 1 sec for new subflows to be created */
+	for (i = 0; i < 10; i++) {
+		err = getsockopt(fd, SOL_MPTCP, MPTCP_INFO, &subflows, &len);
+		if (!err && subflows > 0)
+			break;
+
+		sleep(0.1);
+	}
 }
 
-static void run_subflow(char *new)
+static void run_subflow(void)
 {
 	int server_fd, client_fd, err;
+	char new[TCP_CA_NAME_MAX];
 	char cc[TCP_CA_NAME_MAX];
+	unsigned int mark;
 	socklen_t len;
 
 	server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0);
@@ -393,19 +401,21 @@ static void run_subflow(char *new)
 	if (!ASSERT_GE(client_fd, 0, "connect to fd"))
 		goto close_server;
 
-	len = sizeof(cc);
-	err = getsockopt(server_fd, SOL_TCP, TCP_CONGESTION, cc, &len);
-	if (!ASSERT_OK(err, "getsockopt(server_fd, TCP_CONGESTION)"))
-		goto close_client;
-
 	send_byte(client_fd);
+	wait_for_new_subflows(client_fd);
+
+	len = sizeof(mark);
+	err = getsockopt(client_fd, SOL_SOCKET, SO_MARK, &mark, &len);
+	if (ASSERT_OK(err, "getsockopt(client_fd, SO_MARK)"))
+		ASSERT_EQ(mark, 0, "mark");
+
+	len = sizeof(new);
+	err = getsockopt(client_fd, SOL_TCP, TCP_CONGESTION, new, &len);
+	if (ASSERT_OK(err, "getsockopt(client_fd, TCP_CONGESTION)")) {
+		get_msk_ca_name(cc);
+		ASSERT_STREQ(new, cc, "cc");
+	}
 
-	ASSERT_OK(ss_search(ADDR_1, "fwmark:0x1"), "ss_search fwmark:0x1");
-	ASSERT_OK(ss_search(ADDR_2, "fwmark:0x2"), "ss_search fwmark:0x2");
-	ASSERT_OK(ss_search(ADDR_1, new), "ss_search new cc");
-	ASSERT_OK(ss_search(ADDR_2, cc), "ss_search default cc");
-
-close_client:
 	close(client_fd);
 close_server:
 	close(server_fd);
@@ -416,6 +426,7 @@ static void test_subflow(void)
 	int cgroup_fd, prog_fd, err;
 	struct mptcp_subflow *skel;
 	struct nstoken *nstoken;
+	struct bpf_link *link;
 
 	cgroup_fd = test__join_cgroup("/mptcp_subflow");
 	if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup: mptcp_subflow"))
@@ -441,8 +452,14 @@ static void test_subflow(void)
 	if (endpoint_init("subflow") < 0)
 		goto close_netns;
 
-	run_subflow(skel->data->cc);
+	link = bpf_program__attach_cgroup(skel->progs._getsockopt_subflow,
+					  cgroup_fd);
+	if (!ASSERT_OK_PTR(link, "getsockopt prog"))
+		goto close_netns;
+
+	run_subflow();
 
+	bpf_link__destroy(link);
 close_netns:
 	cleanup_netns(nstoken);
 skel_destroy:
Signature · 1 line
2.43.0
author reviewer
#7 lore raw

PATCH v6 4/4 Squash to "selftests/bpf: Add bpf scheduler test"

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Now ss_search() are only used by bpf_sched tests. It will be dropped in next step.

---
 tools/testing/selftests/bpf/prog_tests/mptcp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/mptcp.c +7 -1
index 6085aaf61b27..8f22416e00fb 100644
@@ -487,9 +487,15 @@ static struct nstoken *sched_init(char *flags, char *sched)
 	return NULL;
 }
 
+static int ss_search(char *src, char *dst, char *port, char *keyword)
+{
+	return SYS_NOFAIL("ip netns exec %s ss -enita src %s dst %s %s %d | grep -q '%s'",
+			  NS_TEST, src, dst, port, PORT_1, keyword);
+}
+
 static int has_bytes_sent(char *dst)
 {
-	return _ss_search(ADDR_1, dst, "sport", "bytes_sent:");
+	return ss_search(ADDR_1, dst, "sport", "bytes_sent:");
 }
 
 static void send_data_and_verify(char *sched, bool addr1, bool addr2)
Signature · 1 line
2.43.0
#8 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 (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/10670890802

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

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)