From 17c2d51df7a3fb5f17f166e78352d33a39da1dc6 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Mon, 27 May 2024 13:52:54 +0800 Subject: [PATCH] selftests/bpf: Use connect_to_fd in bpf_nf Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/bpf_nf.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_nf.c b/tools/testing/selftests/bpf/prog_tests/bpf_nf.c index b30ff6b3b81ae..0a54cd2c3fe25 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_nf.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_nf.c @@ -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"; @@ -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;