Skip to content

Commit

Permalink
send_byte
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Mar 29, 2024
1 parent 6183c9a commit 08c7ace
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
6 changes: 4 additions & 2 deletions tools/testing/selftests/bpf/network_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,13 @@ int get_socket_local_port(int sock_fd)
return -1;
}

void send_single_byte(int fd)
int send_byte(int fd)
{
char b = 0x55;

ASSERT_EQ(write(fd, &b, sizeof(b)), 1, "send single byte");
if (!ASSERT_EQ(write(fd, &b, sizeof(b)), 1, "send single byte"))
return -1;
return 0;
}

static const unsigned int total_bytes = 10 * 1024 * 1024;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/network_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct nstoken;
*/
struct nstoken *open_netns(const char *name);
void close_netns(struct nstoken *token);
void send_single_byte(int fd);
int send_byte(int fd);
void send_recv_data(int lfd, int fd);

static __u16 csum_fold(__u32 csum)
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static void run_mptcpify(int cgroup_fd, struct mptcpify *skel)
if (!ASSERT_GE(client_fd, 0, "connect to fd"))
goto close_server;

send_single_byte(client_fd);
send_byte(client_fd);

err = verify_mptcpify(server_fd, client_fd);
ASSERT_OK(err, "verify_mptcpify");
Expand Down Expand Up @@ -358,7 +358,7 @@ static void run_mptcp_subflow(int cgroup_fd, struct mptcp_subflow *skel)
if (!ASSERT_GE(client_fd, 0, "connect to fd"))
goto close_server;

send_single_byte(client_fd);
send_byte(client_fd);

ASSERT_OK(ss_search(ADDR1, "fwmark:0x1"), "ss_search fwmark:0x1");
ASSERT_OK(ss_search(ADDR2, "fwmark:0x2"), "ss_search fwmark:0x2");
Expand Down
13 changes: 0 additions & 13 deletions tools/testing/selftests/bpf/prog_tests/sk_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,6 @@ static int fill_sk_lookup_ctx(struct bpf_sk_lookup *ctx, const char *local_ip, _
return 0;
}

static int send_byte(int fd)
{
ssize_t n;

errno = 0;
n = send(fd, "a", 1, 0);
if (CHECK(n <= 0, "send_byte", "send")) {
log_err("failed/partial send");
return -1;
}
return 0;
}

static int recv_byte(int fd)
{
char buf[1];
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static int run_test(int cgroup_fd, int server_fd)
/*delivered_ce=*/0,
/*icsk_retransmits=*/0);

send_single_byte(client_fd);
send_byte(client_fd);
if (wait_for_ack(client_fd, 100) < 0) {
err = -1;
goto close_client_fd;
Expand Down

0 comments on commit 08c7ace

Please sign in to comment.