From 8d0bbdc7488d82403f856039f8543421cc5e5ff6 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Fri, 19 Apr 2024 15:47:12 +0800 Subject: [PATCH] Revert "selftests/bpf: Support nonblock for send_recv_data" This reverts commit 8fdb31d2697e665792906f97d8cd6a654891136f. --- tools/testing/selftests/bpf/network_helpers.c | 6 ------ tools/testing/selftests/bpf/prog_tests/mptcp.c | 16 ---------------- 2 files changed, 22 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index e09df4980800..71253909eb3f 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -587,7 +587,6 @@ struct send_recv_arg { static void *send_recv_server(void *arg) { struct send_recv_arg *a = (struct send_recv_arg *)arg; - int flags = fcntl(a->fd, F_GETFL); ssize_t nr_sent = 0, bytes = 0; char batch[1500]; int err = 0, fd; @@ -611,8 +610,6 @@ static void *send_recv_server(void *arg) if (nr_sent == -1 && errno == EINTR) continue; if (nr_sent == -1) { - if (flags & O_NONBLOCK && errno == EWOULDBLOCK) - continue; err = -errno; break; } @@ -637,7 +634,6 @@ static void *send_recv_server(void *arg) int send_recv_data(int lfd, int fd, uint32_t total_bytes) { - int flags = fcntl(lfd, F_GETFL); ssize_t nr_recv = 0, bytes = 0; struct send_recv_arg arg = { .fd = lfd, @@ -662,8 +658,6 @@ int send_recv_data(int lfd, int fd, uint32_t total_bytes) if (nr_recv == -1 && errno == EINTR) continue; if (nr_recv == -1) { - if (flags & O_NONBLOCK && errno == EWOULDBLOCK) - continue; err = -errno; break; } diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 828ad6bac70d..78bc091da60c 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -358,16 +358,6 @@ static void test_mptcpify(void) close(cgroup_fd); } -static inline int set_nonblock(int fd) -{ - int flags = fcntl(fd, F_GETFL); - - if (flags == -1 || flags & O_NONBLOCK) - return -1; - - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - static int endpoint_init(char *flags) { SYS(fail, "ip -net %s link add veth1 type veth peer name veth2", NS_TEST); @@ -411,9 +401,6 @@ static void run_subflow(char *new) if (!ASSERT_GE(client_fd, 0, "connect to fd")) goto fail; - if (set_nonblock(server_fd)) - goto fail; - err = getsockopt(server_fd, SOL_TCP, TCP_CONGESTION, cc, &len); if (!ASSERT_OK(err, "getsockopt(srv_fd, TCP_CONGESTION)")) goto fail; @@ -508,9 +495,6 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2) if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n", errno)) goto fail; - if (set_nonblock(server_fd)) - goto fail; - if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) goto fail;