Skip to content

Commit

Permalink
selftests/bpf: Use connect_to_fd in bpf_nf
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed May 27, 2024
1 parent e42930f commit 17c2d51
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions tools/testing/selftests/bpf/prog_tests/bpf_nf.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ enum {
IPS_SRC_NAT_DONE | IPS_DST_NAT_DONE | \
IPS_SRC_NAT | IPS_DST_NAT)

static int connect_to_server(int srv_fd)
{
int fd = -1;

fd = socket(AF_INET, SOCK_STREAM, 0);
if (!ASSERT_GE(fd, 0, "socket"))
goto out;

if (!ASSERT_EQ(connect_fd_to_fd(fd, srv_fd, TIMEOUT_MS), 0, "connect_fd_to_fd")) {
close(fd);
fd = -1;
}
out:
return fd;
}

static void test_bpf_nf_ct(int mode)
{
const char *iptables = "iptables-legacy -t raw %s PREROUTING -j CONNMARK --set-mark 42/0";
Expand Down Expand Up @@ -77,7 +61,7 @@ static void test_bpf_nf_ct(int mode)
if (!ASSERT_GE(srv_fd, 0, "start_server"))
goto end;

client_fd = connect_to_server(srv_fd);
client_fd = connect_to_fd(srv_fd, TIMEOUT_MS);
if (!ASSERT_GE(client_fd, 0, "connect_to_server"))
goto end;

Expand Down

0 comments on commit 17c2d51

Please sign in to comment.