diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 27784946b01b..26fff876a1b2 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -622,6 +622,7 @@ int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param) struct send_recv_arg { int fd; uint32_t bytes; + int tout; int stop; }; @@ -640,7 +641,7 @@ static void *send_recv_server(void *arg) goto done; } - if (settimeo(fd, 0)) { + if (settimeo(fd, a->tout)) { err = -errno; goto done; } @@ -673,12 +674,13 @@ static void *send_recv_server(void *arg) return NULL; } -int send_recv_data(int lfd, int fd, uint32_t total_bytes) +int send_recv_data(int lfd, int fd, uint32_t total_bytes, int timeout_ms) { ssize_t nr_recv = 0, bytes = 0; struct send_recv_arg arg = { .fd = lfd, .bytes = total_bytes, + .tout = timeout_ms, .stop = 0, }; pthread_t srv_thread; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index 5764155b6d25..e3a4a5f1dd38 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -93,7 +93,7 @@ struct nstoken; */ struct nstoken *open_netns(const char *name); void close_netns(struct nstoken *token); -int send_recv_data(int lfd, int fd, uint32_t total_bytes); +int send_recv_data(int lfd, int fd, uint32_t total_bytes, int timeout_ms); int make_netns(const char *name); int remove_netns(const char *name); diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index b7d1b52309d0..090d876e0da4 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -70,7 +70,7 @@ static void do_test(const struct network_helper_opts *opts) if (!start_test(NULL, opts, opts, &lfd, &fd)) goto done; - ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data"); + ASSERT_OK(send_recv_data(lfd, fd, total_bytes, 0), "send_recv_data"); done: if (lfd != -1) @@ -169,7 +169,7 @@ static void test_dctcp(void) !ASSERT_EQ(errno, ENOENT, "bpf_map_lookup_elem(sk_stg_map)")) goto done; - ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data"); + ASSERT_OK(send_recv_data(lfd, fd, total_bytes, 0), "send_recv_data"); ASSERT_EQ(dctcp_skel->bss->stg_result, expected_stg, "stg_result"); done: