Skip to content

Commit

Permalink
timeout_ms
Browse files Browse the repository at this point in the history
TODO

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Nov 29, 2024
1 parent 2a4f437 commit 58e31d1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,

if (!timeo) {
copied = -EAGAIN;
pr_info("%s return EAGAIN\n", __func__);
break;
}

Expand Down
18 changes: 8 additions & 10 deletions tools/testing/selftests/bpf/network_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,10 @@ int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
struct send_recv_arg {
int fd;
uint32_t bytes;
int timeout_ms;
int stop;
int (*cb)(int fd);
};

static int settimeo_cb(int fd)
{
return settimeo(fd, 0);
}

static void *send_recv_server(void *arg)
{
struct send_recv_arg *a = (struct send_recv_arg *)arg;
Expand All @@ -646,7 +641,7 @@ static void *send_recv_server(void *arg)
goto done;
}

if (a->cb && a->cb(fd)) {
if (settimeo(fd, a->timeout_ms)) {
err = -errno;
goto done;
}
Expand All @@ -657,6 +652,8 @@ static void *send_recv_server(void *arg)
if (nr_sent == -1 && errno == EINTR)
continue;
if (nr_sent == -1) {
//if (errno == EAGAIN)
// continue;
err = -errno;
break;
}
Expand All @@ -679,15 +676,14 @@ static void *send_recv_server(void *arg)
return NULL;
}

int send_recv_data(int lfd, int fd, uint32_t total_bytes,
int (*post_accept_cb)(int fd))
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,
.timeout_ms = timeout_ms,
.stop = 0,
.cb = post_accept_cb ? : settimeo_cb,
};
pthread_t srv_thread;
void *thread_ret;
Expand All @@ -707,6 +703,8 @@ int send_recv_data(int lfd, int fd, uint32_t total_bytes,
if (nr_recv == -1 && errno == EINTR)
continue;
if (nr_recv == -1) {
//if (errno == EAGAIN)
// continue;
err = -errno;
break;
}
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/bpf/network_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +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 (*post_accept_cb)(int fd));
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);

Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, NULL), "send_recv_data");
ASSERT_OK(send_recv_data(lfd, fd, total_bytes, 0), "send_recv_data");

done:
if (lfd != -1)
Expand Down Expand Up @@ -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, NULL), "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:
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2)
if (clock_gettime(CLOCK_MONOTONIC, &start) < 0)
goto close_client;

if (!ASSERT_OK(send_recv_data(server_fd, client_fd, total_bytes, NULL),
if (!ASSERT_OK(send_recv_data(server_fd, client_fd, total_bytes, 30000),
"send_recv_data"))
goto close_client;

Expand Down
3 changes: 3 additions & 0 deletions tools/testing/selftests/bpf/progs/mptcp_bpf_bytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ int BPF_PROG(trace_mptcp_sched_get_send, struct mptcp_sock *msk)
if (!msk->pm.server_side)
return 0;

bytes_sent_1 = 0;
bytes_sent_2 = 0;

mptcp_for_each_subflow(msk, subflow) {
struct tcp_sock *tp;
struct sock *ssk;
Expand Down

0 comments on commit 58e31d1

Please sign in to comment.