All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next] selftests: bpf: exercise bpf_mptcp_sock()
@ 2022-02-24 15:21 Geliang Tang
  2022-02-24 16:42 ` selftests: bpf: exercise bpf_mptcp_sock(): Tests Results MPTCP CI
  2022-03-01 11:56 ` [PATCH mptcp-next] selftests: bpf: exercise bpf_mptcp_sock() Matthieu Baerts
  0 siblings, 2 replies; 5+ messages in thread
From: Geliang Tang @ 2022-02-24 15:21 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch extended the MPTCP test base, to exercise bpf_mptcp_sock() from
C test as Alexei suggested in [1].

[1]
https://lore.kernel.org/netdev/20200922040830.3iis6xiavhvpfq3v@ast-mbp.dhcp.thefacebook.com/

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/prog_tests/mptcp.c |  1 +
 tools/testing/selftests/bpf/progs/mptcp.c      | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 04aef0f147dc..eba1b6d12a8c 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -6,6 +6,7 @@
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
+	__u32 token;
 };
 
 static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 is_mptcp)
diff --git a/tools/testing/selftests/bpf/progs/mptcp.c b/tools/testing/selftests/bpf/progs/mptcp.c
index be5ee8dac2b3..ea614e02c8e1 100644
--- a/tools/testing/selftests/bpf/progs/mptcp.c
+++ b/tools/testing/selftests/bpf/progs/mptcp.c
@@ -8,6 +8,7 @@ __u32 _version SEC("version") = 1;
 struct mptcp_storage {
 	__u32 invoked;
 	__u32 is_mptcp;
+	__u32 token;
 };
 
 struct {
@@ -20,6 +21,7 @@ struct {
 SEC("sockops")
 int _sockops(struct bpf_sock_ops *ctx)
 {
+	char fmt[] = "invoked=%u is_mptcp=%u token=%u\n";
 	struct mptcp_storage *storage;
 	struct bpf_tcp_sock *tcp_sk;
 	int op = (int)ctx->op;
@@ -43,6 +45,20 @@ int _sockops(struct bpf_sock_ops *ctx)
 
 	storage->invoked++;
 	storage->is_mptcp = tcp_sk->is_mptcp;
+	storage->token = 0;
+
+	if (tcp_sk->is_mptcp) {
+		struct bpf_mptcp_sock *msk;
+
+		msk = bpf_mptcp_sock(sk);
+		if (!msk)
+			return 1;
+
+		storage->token = msk->token;
+	}
+
+	bpf_trace_printk(fmt, sizeof(fmt),
+			 storage->invoked, storage->is_mptcp, storage->token);
 
 	return 1;
 }
-- 
2.34.1


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

end of thread, other threads:[~2022-03-03  9:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24 15:21 [PATCH mptcp-next] selftests: bpf: exercise bpf_mptcp_sock() Geliang Tang
2022-02-24 16:42 ` selftests: bpf: exercise bpf_mptcp_sock(): Tests Results MPTCP CI
2022-03-01 11:56 ` [PATCH mptcp-next] selftests: bpf: exercise bpf_mptcp_sock() Matthieu Baerts
2022-03-03  7:31   ` Geliang Tang
2022-03-03  9:55     ` Matthieu Baerts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.