@@ -303,21 +303,20 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add
return -1;
}
-int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts)
+int __connect_to_fd_opts(int server_fd, int type,
+ const struct network_helper_opts *opts)
{
struct sockaddr_storage addr;
struct sockaddr_in *addr_in;
socklen_t addrlen, optlen;
- int fd, type, protocol;
+ int fd, protocol;
if (!opts)
opts = &default_opts;
optlen = sizeof(type);
- if (opts->type) {
- type = opts->type;
- } else {
+ if (!type) {
if (getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &type, &optlen)) {
log_err("getsockopt(SOL_TYPE)");
return -1;
@@ -364,6 +363,11 @@ int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts)
return -1;
}
+int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts)
+{
+ return __connect_to_fd_opts(server_fd, 0, opts);
+}
+
int connect_to_fd(int server_fd, int timeout_ms)
{
struct network_helper_opts opts = {
@@ -25,7 +25,6 @@ struct network_helper_opts {
int timeout_ms;
bool must_fail;
bool noconnect;
- int type;
int proto;
int (*post_socket_cb)(int fd, void *opts);
void *cb_opts;
@@ -61,6 +60,8 @@ void free_fds(int *fds, unsigned int nr_close_fds);
int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t len,
const struct network_helper_opts *opts);
int connect_to_fd(int server_fd, int timeout_ms);
+int __connect_to_fd_opts(int server_fd, int type,
+ const struct network_helper_opts *opts);
int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts);
int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms);
int fastopen_connect(int server_fd, const char *data, unsigned int data_len,
@@ -164,7 +164,6 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
};
struct network_helper_opts tx_ops = {
.timeout_ms = 1000,
- .type = SOCK_RAW,
.proto = IPPROTO_RAW,
.noconnect = true,
};
@@ -201,7 +200,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
nstoken = open_netns(NS0);
if (!ASSERT_OK_PTR(nstoken, "setns ns0"))
goto out;
- client_tx_fd = connect_to_fd_opts(srv_fd, &tx_ops);
+ client_tx_fd = __connect_to_fd_opts(srv_fd, SOCK_RAW, &tx_ops);
close_netns(nstoken);
if (!ASSERT_GE(client_tx_fd, 0, "connect_to_fd_opts"))
goto out;
@@ -210,7 +209,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
nstoken = open_netns(NS0);
if (!ASSERT_OK_PTR(nstoken, "setns ns0"))
goto out;
- client_rx_fd = connect_to_fd_opts(srv_fd, &rx_opts);
+ client_rx_fd = __connect_to_fd_opts(srv_fd, 0, &rx_opts);
close_netns(nstoken);
if (!ASSERT_GE(client_rx_fd, 0, "connect_to_fd_opts"))
goto out;