@@ -338,9 +338,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)
@@ -21,16 +21,18 @@ typedef __u16 __sum16;
#define VIP_NUM 5
#define MAGIC_BYTES 123
-struct post_socket_opts {};
+struct post_socket_opts {
+ const char *cc;
+};
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, const struct post_socket_opts *opts);
+ struct post_socket_opts cb_opts;
};
/* ipv4 test vector */
@@ -80,6 +80,12 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
close(fd);
}
+static int cc_cb(int fd, const struct post_socket_opts *opts)
+{
+ return setsockopt(fd, SOL_TCP, TCP_CONGESTION, opts->cc,
+ strlen(opts->cc) + 1);
+}
+
static void test_cubic(void)
{
struct bpf_cubic *cubic_skel;
@@ -171,7 +177,8 @@ static void test_dctcp_fallback(void)
{
int err, lfd = -1, cli_fd = -1, srv_fd = -1;
struct network_helper_opts opts = {
- .cc = "cubic",
+ .cb_opts.cc = "cubic",
+ .post_socket_cb = cc_cb,
};
struct bpf_dctcp *dctcp_skel;
struct bpf_link *link = NULL;