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)
static const unsigned int total_bytes = 10 * 1024 * 1024;
static int expected_stg = 0xeB9F;
+struct cb_opts {
+ const char *cc;
+};
+
static int settcpca(int fd, const char *tcp_ca)
{
int err;
close(fd);
}
+static int cc_cb(int fd, void *opts)
+{
+ struct cb_opts *cb_opts = (struct cb_opts *)opts;
+
+ return settcpca(fd, cb_opts->cc);
+}
+
static void test_cubic(void)
{
struct bpf_cubic *cubic_skel;
{
int err, lfd = -1, cli_fd = -1, srv_fd = -1;
struct network_helper_opts opts = {
- .cc = "cubic",
+ .post_socket_cb = cc_cb,
};
struct bpf_dctcp *dctcp_skel;
struct bpf_link *link = NULL;
+ struct cb_opts cubic = {
+ .cc = "cubic",
+ };
char srv_cc[16];
socklen_t cc_len = sizeof(srv_cc);
!ASSERT_OK(settcpca(lfd, "bpf_dctcp"), "lfd=>bpf_dctcp"))
goto done;
+ opts.cb_opts = &cubic;
cli_fd = connect_to_fd_opts(lfd, &opts);
if (!ASSERT_GE(cli_fd, 0, "cli_fd"))
goto done;