Commit 7f0d5140 authored by Geliang Tang's avatar Geliang Tang Committed by Alexei Starovoitov

selftests/bpf: Drop noconnect from network_helper_opts

In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be
used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut
member "noconnect" of network_helper_opts can be dropped now, always
connect to server in connect_to_fd_opts().
Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Link: https://lore.kernel.org/r/f45760becce51986e4e08283c7df0f933eb0da14.1718932493.git.tanggeliang@kylinos.cnSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent bbca57aa
...@@ -318,9 +318,8 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add ...@@ -318,9 +318,8 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add
return -1; return -1;
} }
if (!opts->noconnect) if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail))
if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) goto error_close;
goto error_close;
return fd; return fd;
......
...@@ -24,7 +24,6 @@ typedef __u16 __sum16; ...@@ -24,7 +24,6 @@ typedef __u16 __sum16;
struct network_helper_opts { struct network_helper_opts {
int timeout_ms; int timeout_ms;
bool must_fail; bool must_fail;
bool noconnect;
int proto; int proto;
int (*post_socket_cb)(int fd, void *opts); int (*post_socket_cb)(int fd, void *opts);
void *cb_opts; void *cb_opts;
......
...@@ -158,14 +158,13 @@ static int send_frags6(int client) ...@@ -158,14 +158,13 @@ static int send_frags6(int client)
void test_bpf_ip_check_defrag_ok(bool ipv6) void test_bpf_ip_check_defrag_ok(bool ipv6)
{ {
int family = ipv6 ? AF_INET6 : AF_INET;
struct network_helper_opts rx_opts = { struct network_helper_opts rx_opts = {
.timeout_ms = 1000, .timeout_ms = 1000,
.noconnect = true,
}; };
struct network_helper_opts tx_ops = { struct network_helper_opts tx_ops = {
.timeout_ms = 1000, .timeout_ms = 1000,
.proto = IPPROTO_RAW, .proto = IPPROTO_RAW,
.noconnect = true,
}; };
struct sockaddr_storage caddr; struct sockaddr_storage caddr;
struct ip_check_defrag *skel; struct ip_check_defrag *skel;
...@@ -191,7 +190,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) ...@@ -191,7 +190,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
nstoken = open_netns(NS1); nstoken = open_netns(NS1);
if (!ASSERT_OK_PTR(nstoken, "setns ns1")) if (!ASSERT_OK_PTR(nstoken, "setns ns1"))
goto out; goto out;
srv_fd = start_server(ipv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, NULL, SERVER_PORT, 0); srv_fd = start_server(family, SOCK_DGRAM, NULL, SERVER_PORT, 0);
close_netns(nstoken); close_netns(nstoken);
if (!ASSERT_GE(srv_fd, 0, "start_server")) if (!ASSERT_GE(srv_fd, 0, "start_server"))
goto out; goto out;
...@@ -200,18 +199,18 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) ...@@ -200,18 +199,18 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
nstoken = open_netns(NS0); nstoken = open_netns(NS0);
if (!ASSERT_OK_PTR(nstoken, "setns ns0")) if (!ASSERT_OK_PTR(nstoken, "setns ns0"))
goto out; goto out;
client_tx_fd = connect_to_fd_opts(srv_fd, SOCK_RAW, &tx_ops); client_tx_fd = client_socket(family, SOCK_RAW, &tx_ops);
close_netns(nstoken); close_netns(nstoken);
if (!ASSERT_GE(client_tx_fd, 0, "connect_to_fd_opts")) if (!ASSERT_GE(client_tx_fd, 0, "client_socket"))
goto out; goto out;
/* Open rx socket in ns0 */ /* Open rx socket in ns0 */
nstoken = open_netns(NS0); nstoken = open_netns(NS0);
if (!ASSERT_OK_PTR(nstoken, "setns ns0")) if (!ASSERT_OK_PTR(nstoken, "setns ns0"))
goto out; goto out;
client_rx_fd = connect_to_fd_opts(srv_fd, SOCK_DGRAM, &rx_opts); client_rx_fd = client_socket(family, SOCK_DGRAM, &rx_opts);
close_netns(nstoken); close_netns(nstoken);
if (!ASSERT_GE(client_rx_fd, 0, "connect_to_fd_opts")) if (!ASSERT_GE(client_rx_fd, 0, "client_socket"))
goto out; goto out;
/* Bind rx socket to a premeditated port */ /* Bind rx socket to a premeditated port */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment