Skip to content

Commit

Permalink
Squash to "selftests/bpf: Add bpf scheduler test"
Browse files Browse the repository at this point in the history
Use endpoint_init in sched_init and use _ss_search in has_bytes_sent.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Apr 24, 2024
1 parent 0890264 commit 0bcc693
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,28 +536,22 @@ static struct nstoken *sched_init(char *flags, char *sched)

nstoken = create_netns();
if (!ASSERT_OK_PTR(nstoken, "create_netns"))
return NULL;

if (!ASSERT_OK(endpoint_init("subflow"), "endpoint_init"))
goto fail;

SYS(fail, "ip -net %s link add veth1 type veth peer name veth2", NS_TEST);
SYS(fail, "ip -net %s addr add %s/24 dev veth1", NS_TEST, ADDR_1);
SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST);
SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2);
SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST);
SYS(fail, "ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags);
SYS(fail, "ip netns exec %s sysctl -qw net.mptcp.scheduler=%s", NS_TEST, sched);

return nstoken;
fail:
cleanup_netns(nstoken);
return NULL;
}

static int has_bytes_sent(char *addr)
static int has_bytes_sent(char *dst)
{
char cmd[128];

snprintf(cmd, sizeof(cmd), "ip netns exec %s ss -it src %s sport %d dst %s | %s",
NS_TEST, ADDR_1, PORT_1, addr, "grep -q bytes_sent:");
return system(cmd);
return _ss_search(ADDR_1, dst, "sport", "bytes_sent:");
}

static void send_data_and_verify(char *sched, bool addr1, bool addr2)
Expand Down

0 comments on commit 0bcc693

Please sign in to comment.