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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/21/23 5:09 AM, Daan De Meyer wrote:
---
  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

[ ... ]

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.

[ ... ]

+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.

+			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.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux