Thread (18 messages) 18 messages, 5 authors, 2023-09-26

Re: [PATCH bpf-next v5 9/9] selftests/bpf: Add tests for cgroup unix socket address hooks

flat view

From: Martin KaFai Lau <martin.lau@linux.dev>
Date: 2023-09-22 22:04:30
Also in: bpf

On 9/21/23 5:09 AM, Daan De Meyer wrote:
quoted hunk ↗ jump to hunk
---
  tools/testing/selftests/bpf/bpf_kfuncs.h      |  14 +
  tools/testing/selftests/bpf/network_helpers.c |  34 ++
  tools/testing/selftests/bpf/network_helpers.h |   1 +
  .../selftests/bpf/prog_tests/section_names.c  |  25 +
  .../selftests/bpf/prog_tests/sock_addr.c      | 570 ++++++++++++++++++
  .../selftests/bpf/progs/connectun_prog.c      |  40 ++
  .../selftests/bpf/progs/recvmsgun_prog.c      |  39 ++
  .../selftests/bpf/progs/sendmsgun_prog.c      |  40 ++
  8 files changed, 763 insertions(+)
  create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_addr.c
  create mode 100644 tools/testing/selftests/bpf/progs/connectun_prog.c
  create mode 100644 tools/testing/selftests/bpf/progs/recvmsgun_prog.c
  create mode 100644 tools/testing/selftests/bpf/progs/sendmsgun_prog.c
[ ... ]
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/bpf/prog_tests/sock_addr.c b/tools/testing/selftests/bpf/prog_tests/sock_addr.c
new file mode 100644
index 000000000000..f92e5f5fb08d
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/sock_addr.c
@@ -0,0 +1,570 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <sys/un.h>
+
+#include "test_progs.h"
+
+#include "connectun_prog.skel.h"
+#include "sendmsgun_prog.skel.h"
+#include "recvmsgun_prog.skel.h"
+#include "getsocknameun_prog.skel.h"
+#include "getpeernameun_prog.skel.h"
The patch is missing the new getsocknameun_prog.c and getpeernameun_prog.c file.

[ ... ]
quoted hunk ↗ jump to hunk
+void test_sock_addr(void)
+{
+	int cgroup_fd = -1;
+	void *skel;
+
+	cgroup_fd = test__join_cgroup("/sock_addr");
+	if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup"))
+		goto cleanup;
+
+	for (size_t i = 0; i < ARRAY_SIZE(tests); ++i) {
+		struct sock_addr_test *test = &tests[i];
+
+		if (!test__start_subtest(test->name))
+			continue;
+
+		skel = test->loadfn(cgroup_fd);
+		if (!skel)
+			continue;
+
+		switch (test->type) {
+		case SOCK_ADDR_TEST_BIND:
+			test_bind(test);
Considering it will help migrating tests from the existing "bpf/test_sock_addr.c", don't mind to leave the SOCK_ADDR_TEST_BIND and test_bind in this patch even it is not used now. Please mention a few words in the commit message and also add a comment here to avoid any future cleanup attempt.
quoted hunk ↗ jump to hunk
+			break;
+		case SOCK_ADDR_TEST_CONNECT:
+			test_connect(test);
+			break;
+		case SOCK_ADDR_TEST_SENDMSG:
+		case SOCK_ADDR_TEST_RECVMSG:
+			test_xmsg(test);
It also needs a recvmsg prog test for the connected stream case.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help