Skip to content

Commit ca188a2

Browse files
kmaloordavem330
authored andcommitted
selftests: mptcp: userspace PM support for MP_PRIO signals
This change updates the testing sample (pm_nl_ctl) to exercise the updated MPTCP_PM_CMD_SET_FLAGS command for userspace PMs to issue MP_PRIO signals over the selected subflow. E.g. ./pm_nl_ctl set 10.0.1.2 port 47234 flags backup token 823274047 rip 10.0.1.1 rport 50003 userspace_pm.sh has a new selftest that invokes this command. Fixes: 259a834 ("selftests: mptcp: functional tests for the userspace PM type") Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Kishen Maloor <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 892f396 commit ca188a2

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed

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

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void syntax(char *argv[])
3939
fprintf(stderr, "\tdsf lip <local-ip> lport <local-port> rip <remote-ip> rport <remote-port> token <token>\n");
4040
fprintf(stderr, "\tdel <id> [<ip>]\n");
4141
fprintf(stderr, "\tget <id>\n");
42-
fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>]\n");
42+
fprintf(stderr, "\tset [<ip>] [id <nr>] flags [no]backup|[no]fullmesh [port <nr>] [token <token>] [rip <ip>] [rport <port>]\n");
4343
fprintf(stderr, "\tflush\n");
4444
fprintf(stderr, "\tdump\n");
4545
fprintf(stderr, "\tlimits [<rcv addr max> <subflow max>]\n");
@@ -1279,7 +1279,10 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
12791279
struct rtattr *rta, *nest;
12801280
struct nlmsghdr *nh;
12811281
u_int32_t flags = 0;
1282+
u_int32_t token = 0;
1283+
u_int16_t rport = 0;
12821284
u_int16_t family;
1285+
void *rip = NULL;
12831286
int nest_start;
12841287
int use_id = 0;
12851288
u_int8_t id;
@@ -1339,7 +1342,13 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
13391342
error(1, 0, " missing flags keyword");
13401343

13411344
for (; arg < argc; arg++) {
1342-
if (!strcmp(argv[arg], "flags")) {
1345+
if (!strcmp(argv[arg], "token")) {
1346+
if (++arg >= argc)
1347+
error(1, 0, " missing token value");
1348+
1349+
/* token */
1350+
token = atoi(argv[arg]);
1351+
} else if (!strcmp(argv[arg], "flags")) {
13431352
char *tok, *str;
13441353

13451354
/* flags */
@@ -1378,12 +1387,72 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
13781387
rta->rta_len = RTA_LENGTH(2);
13791388
memcpy(RTA_DATA(rta), &port, 2);
13801389
off += NLMSG_ALIGN(rta->rta_len);
1390+
} else if (!strcmp(argv[arg], "rport")) {
1391+
if (++arg >= argc)
1392+
error(1, 0, " missing remote port");
1393+
1394+
rport = atoi(argv[arg]);
1395+
} else if (!strcmp(argv[arg], "rip")) {
1396+
if (++arg >= argc)
1397+
error(1, 0, " missing remote ip");
1398+
1399+
rip = argv[arg];
13811400
} else {
13821401
error(1, 0, "unknown keyword %s", argv[arg]);
13831402
}
13841403
}
13851404
nest->rta_len = off - nest_start;
13861405

1406+
/* token */
1407+
if (token) {
1408+
rta = (void *)(data + off);
1409+
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
1410+
rta->rta_len = RTA_LENGTH(4);
1411+
memcpy(RTA_DATA(rta), &token, 4);
1412+
off += NLMSG_ALIGN(rta->rta_len);
1413+
}
1414+
1415+
/* remote addr/port */
1416+
if (rip) {
1417+
nest_start = off;
1418+
nest = (void *)(data + off);
1419+
nest->rta_type = NLA_F_NESTED | MPTCP_PM_ATTR_ADDR_REMOTE;
1420+
nest->rta_len = RTA_LENGTH(0);
1421+
off += NLMSG_ALIGN(nest->rta_len);
1422+
1423+
/* addr data */
1424+
rta = (void *)(data + off);
1425+
if (inet_pton(AF_INET, rip, RTA_DATA(rta))) {
1426+
family = AF_INET;
1427+
rta->rta_type = MPTCP_PM_ADDR_ATTR_ADDR4;
1428+
rta->rta_len = RTA_LENGTH(4);
1429+
} else if (inet_pton(AF_INET6, rip, RTA_DATA(rta))) {
1430+
family = AF_INET6;
1431+
rta->rta_type = MPTCP_PM_ADDR_ATTR_ADDR6;
1432+
rta->rta_len = RTA_LENGTH(16);
1433+
} else {
1434+
error(1, errno, "can't parse ip %s", (char *)rip);
1435+
}
1436+
off += NLMSG_ALIGN(rta->rta_len);
1437+
1438+
/* family */
1439+
rta = (void *)(data + off);
1440+
rta->rta_type = MPTCP_PM_ADDR_ATTR_FAMILY;
1441+
rta->rta_len = RTA_LENGTH(2);
1442+
memcpy(RTA_DATA(rta), &family, 2);
1443+
off += NLMSG_ALIGN(rta->rta_len);
1444+
1445+
if (rport) {
1446+
rta = (void *)(data + off);
1447+
rta->rta_type = MPTCP_PM_ADDR_ATTR_PORT;
1448+
rta->rta_len = RTA_LENGTH(2);
1449+
memcpy(RTA_DATA(rta), &rport, 2);
1450+
off += NLMSG_ALIGN(rta->rta_len);
1451+
}
1452+
1453+
nest->rta_len = off - nest_start;
1454+
}
1455+
13871456
do_nl_req(fd, nh, off, 0);
13881457
return 0;
13891458
}

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,42 @@ test_subflows()
770770
rm -f "$evts"
771771
}
772772

773+
test_prio()
774+
{
775+
local count
776+
777+
# Send MP_PRIO signal from client to server machine
778+
ip netns exec "$ns2" ./pm_nl_ctl set 10.0.1.2 port "$client4_port" flags backup token "$client4_token" rip 10.0.1.1 rport "$server4_port"
779+
sleep 0.5
780+
781+
# Check TX
782+
stdbuf -o0 -e0 printf "MP_PRIO TX \t"
783+
count=$(ip netns exec "$ns2" nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}')
784+
[ -z "$count" ] && count=0
785+
if [ $count != 1 ]; then
786+
stdbuf -o0 -e0 printf "[FAIL]\n"
787+
exit 1
788+
else
789+
stdbuf -o0 -e0 printf "[OK]\n"
790+
fi
791+
792+
# Check RX
793+
stdbuf -o0 -e0 printf "MP_PRIO RX \t"
794+
count=$(ip netns exec "$ns1" nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}')
795+
[ -z "$count" ] && count=0
796+
if [ $count != 1 ]; then
797+
stdbuf -o0 -e0 printf "[FAIL]\n"
798+
exit 1
799+
else
800+
stdbuf -o0 -e0 printf "[OK]\n"
801+
fi
802+
}
803+
773804
make_connection
774805
make_connection "v6"
775806
test_announce
776807
test_remove
777808
test_subflows
809+
test_prio
778810

779811
exit 0

0 commit comments

Comments
 (0)