summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/network_helpers.c
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2024-05-25 20:08:17 +0800
committerMartin KaFai Lau <martin.lau@kernel.org>2024-05-28 17:53:04 -0700
commite078255abd53ac44c9133fd98d51645dbd196123 (patch)
tree1046081598c5ee4209a49cd82b4a5aadb55b565f /tools/testing/selftests/bpf/network_helpers.c
parent6f802cb8988e8e41f2fdb74ac949d3a0ef9a9594 (diff)
selftests/bpf: Use post_socket_cb in connect_to_fd_opts
Since the post_socket_cb() callback is added in struct network_helper_opts, it's make sense to use it not only in __start_server(), but also in connect_to_fd_opts(). Then it can be used to set TCP_CONGESTION sockopt. Add a "void *" type member cb_opts into struct network_helper_opts, and add a new struct named cb_opts in prog_tests/bpf_tcp_ca.c, then cc can be moved into struct cb_opts from network_helper_opts. Define a new callback cc_cb() to set TCP_CONGESTION sockopt, and set it to post_socket_cb pointer of opts. Define a new cb_opts cubic, set it to cb_opts of opts. Pass this opts to connect_to_fd_opts() in test_dctcp_fallback(). Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Link: https://lore.kernel.org/r/b512bb8d8f6854c9ea5c409b69d1bf37c6f272c6.1716638248.git.tanggeliang@kylinos.cn Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/network_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/network_helpers.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index 0e8266f439e4..8502917b6c7b 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -348,9 +348,8 @@ int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts)
if (settimeo(fd, opts->timeout_ms))
goto error_close;
- if (opts->cc && opts->cc[0] &&
- setsockopt(fd, SOL_TCP, TCP_CONGESTION, opts->cc,
- strlen(opts->cc) + 1))
+ if (opts->post_socket_cb &&
+ opts->post_socket_cb(fd, opts->cb_opts))
goto error_close;
if (!opts->noconnect)