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>
This commit is contained in:
Geliang Tang
2024-05-25 20:08:17 +08:00
committed by Martin KaFai Lau
parent 6f802cb898
commit e078255abd
3 changed files with 19 additions and 5 deletions

View File

@@ -22,13 +22,13 @@ typedef __u16 __sum16;
#define MAGIC_BYTES 123
struct network_helper_opts {
const char *cc;
int timeout_ms;
bool must_fail;
bool noconnect;
int type;
int proto;
int (*post_socket_cb)(int fd, void *opts);
void *cb_opts;
};
/* ipv4 test vector */