[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250905-redir-test-pass-drop-v1-3-9d9e43ff40df@rbox.co>
Date: Fri, 05 Sep 2025 13:11:43 +0200
From: Michal Luczaj <mhal@...x.co>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>
Cc: bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org, Michal Luczaj <mhal@...x.co>
Subject: [PATCH bpf-next 3/5] selftests/bpf: sockmap_redir: Rename
functions
Preparatory patch before adding SK_PASS/SK_DROP support:
test_redir() => test_sockets()
test_socket() => test_redir()
test_send_redir_recv() => test_send_recv()
After the change (and the following patch) the call stack will be:
serial_test_sockmap_redir
test_map
test_sockets
test_redir
test_send_recv
(test_verdict)
(test_send_recv)
Signed-off-by: Michal Luczaj <mhal@...x.co>
---
.../selftests/bpf/prog_tests/sockmap_redir.c | 25 +++++++++++-----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
index 4997e72c14345b274367f3f2f4115c39d1ae48c9..9fc5b4dd323d8554e6dc89d06be9054612e41020 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_redir.c
@@ -210,9 +210,8 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
fail_recv("recv(sd_out, OOB)", sd_out, MSG_OOB);
}
-static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,
- int sd_in, int sd_out, int sd_recv,
- struct maps *maps, int status)
+static void test_send_recv(int sd_send, int send_flags, int sd_peer, int sd_in,
+ int sd_out, int sd_recv, struct maps *maps, int status)
{
unsigned int drop, pass;
char *send_buf = "ab";
@@ -335,9 +334,9 @@ static int get_support_status(enum prog_type type, const char *in,
return status;
}
-static void test_socket(enum bpf_map_type type, struct redir_spec *redir,
- struct maps *maps, struct socket_spec *s_in,
- struct socket_spec *s_out)
+static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
+ struct maps *maps, struct socket_spec *s_in,
+ struct socket_spec *s_out)
{
int fd_in, fd_out, fd_send, fd_peer, fd_recv, flags, status;
const char *in_str, *out_str;
@@ -367,12 +366,12 @@ static void test_socket(enum bpf_map_type type, struct redir_spec *redir,
if (!test__start_subtest(s))
return;
- test_send_redir_recv(fd_send, flags, fd_peer, fd_in, fd_out, fd_recv,
- maps, status);
+ test_send_recv(fd_send, flags, fd_peer, fd_in, fd_out, fd_recv, maps,
+ status);
}
-static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
- struct maps *maps)
+static void test_sockets(enum bpf_map_type type, struct redir_spec *redir,
+ struct maps *maps)
{
struct socket_spec *s, sockets[] = {
{ AF_INET, SOCK_STREAM },
@@ -395,7 +394,7 @@ static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
/* Intra-proto */
for (s = sockets; s < sockets + ARRAY_SIZE(sockets); s++)
- test_socket(type, redir, maps, s, s);
+ test_redir(type, redir, maps, s, s);
/* Cross-proto */
for (int i = 0; i < ARRAY_SIZE(sockets); i++) {
@@ -409,7 +408,7 @@ static void test_redir(enum bpf_map_type type, struct redir_spec *redir,
in->sotype == out->sotype))
continue;
- test_socket(type, redir, maps, in, out);
+ test_redir(type, redir, maps, in, out);
}
}
out:
@@ -460,7 +459,7 @@ static void test_map(enum bpf_map_type type)
if (xbpf_prog_attach(prog_fd, maps.in, attach_type, 0))
return;
- test_redir(type, r, &maps);
+ test_sockets(type, r, &maps);
if (xbpf_prog_detach2(prog_fd, maps.in, attach_type))
return;
--
2.50.1
Powered by blists - more mailing lists