Skip to content

Commit b08fbf2

Browse files
Paolo Abenidavem330
authored andcommitted
selftests: add test-cases for MPTCP MP_JOIN
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]>
1 parent eedbc68 commit b08fbf2

File tree

3 files changed

+383
-4
lines changed

3 files changed

+383
-4
lines changed

tools/testing/selftests/net/mptcp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ KSFT_KHDR_INSTALL := 1
55

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

8-
TEST_PROGS := mptcp_connect.sh pm_netlink.sh
8+
TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh
99

1010
TEST_GEN_FILES = mptcp_connect pm_nl_ctl
1111

tools/testing/selftests/net/mptcp/mptcp_connect.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static bool tcpulp_audit;
5151
static int pf = AF_INET;
5252
static int cfg_sndbuf;
5353
static int cfg_rcvbuf;
54+
static bool cfg_join;
5455

5556
static void die_usage(void)
5657
{
@@ -250,17 +251,27 @@ static int sock_connect_mptcp(const char * const remoteaddr,
250251

251252
static size_t do_rnd_write(const int fd, char *buf, const size_t len)
252253
{
254+
static bool first = true;
253255
unsigned int do_w;
254256
ssize_t bw;
255257

256258
do_w = rand() & 0xffff;
257259
if (do_w == 0 || do_w > len)
258260
do_w = len;
259261

262+
if (cfg_join && first && do_w > 100)
263+
do_w = 100;
264+
260265
bw = write(fd, buf, do_w);
261266
if (bw < 0)
262267
perror("write");
263268

269+
/* let the join handshake complete, before going on */
270+
if (cfg_join && first) {
271+
usleep(200000);
272+
first = false;
273+
}
274+
264275
return bw;
265276
}
266277

@@ -385,8 +396,11 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd)
385396
break;
386397

387398
/* ... but we still receive.
388-
* Close our write side.
399+
* Close our write side, ev. give some time
400+
* for address notification
389401
*/
402+
if (cfg_join)
403+
usleep(400000);
390404
shutdown(peerfd, SHUT_WR);
391405
} else {
392406
if (errno == EINTR)
@@ -403,6 +417,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd)
403417
}
404418
}
405419

420+
/* leave some time for late join/announce */
421+
if (cfg_join)
422+
usleep(400000);
423+
406424
close(peerfd);
407425
return 0;
408426
}
@@ -658,7 +676,7 @@ static void maybe_close(int fd)
658676
{
659677
unsigned int r = rand();
660678

661-
if (r & 1)
679+
if (!cfg_join && (r & 1))
662680
close(fd);
663681
}
664682

@@ -794,8 +812,12 @@ static void parse_opts(int argc, char **argv)
794812
{
795813
int c;
796814

797-
while ((c = getopt(argc, argv, "6lp:s:hut:m:S:R:")) != -1) {
815+
while ((c = getopt(argc, argv, "6jlp:s:hut:m:S:R:")) != -1) {
798816
switch (c) {
817+
case 'j':
818+
cfg_join = true;
819+
cfg_mode = CFG_MODE_POLL;
820+
break;
799821
case 'l':
800822
listen_mode = true;
801823
break;

0 commit comments

Comments
 (0)