summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2024-05-30 15:41:10 +0800
committerDaniel Borkmann <daniel@iogearbox.net>2024-06-06 23:04:05 +0200
commit224eeb5598c30ee835dc9fea4c7ad85a8fb7eda4 (patch)
tree19e1f3cd1cec9de326f3728328f7680ee6f484e6 /tools/testing/selftests/bpf
parentfee97d0c9a14b5dd5cce0ec1df3a54a6b963f40c (diff)
selftests/bpf: Use start_test in test_dctcp_fallback in bpf_tcp_ca
The newly added helper start_test() can be used in test_dctcp_fallback() too, to replace start_server_str() and connect_to_fd_opts(). In that way, two network_helper_opts srv_opts and cli_opts are used instead of the previously shared opts. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/792ca3bb013fa06e618176da02d75e4f79a76733.1717054461.git.tanggeliang@kylinos.cn
Diffstat (limited to 'tools/testing/selftests/bpf')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
index 794651ce0629..d10217169ff8 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
@@ -229,17 +229,22 @@ static void test_invalid_license(void)
static void test_dctcp_fallback(void)
{
int err, lfd = -1, cli_fd = -1, srv_fd = -1;
- struct network_helper_opts opts = {
- .post_socket_cb = cc_cb,
- };
struct bpf_dctcp *dctcp_skel;
struct bpf_link *link = NULL;
struct cb_opts dctcp = {
.cc = "bpf_dctcp",
};
+ struct network_helper_opts srv_opts = {
+ .post_socket_cb = cc_cb,
+ .cb_opts = &dctcp,
+ };
struct cb_opts cubic = {
.cc = "cubic",
};
+ struct network_helper_opts cli_opts = {
+ .post_socket_cb = cc_cb,
+ .cb_opts = &cubic,
+ };
char srv_cc[16];
socklen_t cc_len = sizeof(srv_cc);
@@ -254,14 +259,7 @@ static void test_dctcp_fallback(void)
if (!ASSERT_OK_PTR(link, "dctcp link"))
goto done;
- opts.cb_opts = &dctcp;
- lfd = start_server_str(AF_INET6, SOCK_STREAM, "::1", 0, &opts);
- if (!ASSERT_GE(lfd, 0, "lfd"))
- goto done;
-
- opts.cb_opts = &cubic;
- cli_fd = connect_to_fd_opts(lfd, &opts);
- if (!ASSERT_GE(cli_fd, 0, "cli_fd"))
+ if (!start_test("::1", &srv_opts, &cli_opts, &lfd, &cli_fd))
goto done;
srv_fd = accept(lfd, NULL, 0);