Skip to content

Commit

Permalink
selftests: add test-cases for MPTCP MP_JOIN
Browse files Browse the repository at this point in the history
Use the pm netlink to configure the creation of several
subflows, and verify that via MIB counters.

Update the mptcp_connect program to allow reliable MP_JOIN
handshake even on small data file

Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Paolo Abeni authored and davem330 committed Mar 30, 2020
1 parent eedbc68 commit b08fbf2
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ KSFT_KHDR_INSTALL := 1

CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include

TEST_PROGS := mptcp_connect.sh pm_netlink.sh
TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh

TEST_GEN_FILES = mptcp_connect pm_nl_ctl

Expand Down
28 changes: 25 additions & 3 deletions tools/testing/selftests/net/mptcp/mptcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static bool tcpulp_audit;
static int pf = AF_INET;
static int cfg_sndbuf;
static int cfg_rcvbuf;
static bool cfg_join;

static void die_usage(void)
{
Expand Down Expand Up @@ -250,17 +251,27 @@ static int sock_connect_mptcp(const char * const remoteaddr,

static size_t do_rnd_write(const int fd, char *buf, const size_t len)
{
static bool first = true;
unsigned int do_w;
ssize_t bw;

do_w = rand() & 0xffff;
if (do_w == 0 || do_w > len)
do_w = len;

if (cfg_join && first && do_w > 100)
do_w = 100;

bw = write(fd, buf, do_w);
if (bw < 0)
perror("write");

/* let the join handshake complete, before going on */
if (cfg_join && first) {
usleep(200000);
first = false;
}

return bw;
}

Expand Down Expand Up @@ -385,8 +396,11 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd)
break;

/* ... but we still receive.
* Close our write side.
* Close our write side, ev. give some time
* for address notification
*/
if (cfg_join)
usleep(400000);
shutdown(peerfd, SHUT_WR);
} else {
if (errno == EINTR)
Expand All @@ -403,6 +417,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd)
}
}

/* leave some time for late join/announce */
if (cfg_join)
usleep(400000);

close(peerfd);
return 0;
}
Expand Down Expand Up @@ -658,7 +676,7 @@ static void maybe_close(int fd)
{
unsigned int r = rand();

if (r & 1)
if (!cfg_join && (r & 1))
close(fd);
}

Expand Down Expand Up @@ -794,8 +812,12 @@ static void parse_opts(int argc, char **argv)
{
int c;

while ((c = getopt(argc, argv, "6lp:s:hut:m:S:R:")) != -1) {
while ((c = getopt(argc, argv, "6jlp:s:hut:m:S:R:")) != -1) {
switch (c) {
case 'j':
cfg_join = true;
cfg_mode = CFG_MODE_POLL;
break;
case 'l':
listen_mode = true;
break;
Expand Down
Loading

0 comments on commit b08fbf2

Please sign in to comment.