Skip to content

Commit 61d9658

Browse files
matttbedavem330
authored andcommitted
selftests: mptcp: pm_nl_ctl: fix 32-bit support
When using pm_nl_ctl to validate userspace path-manager's behaviours, it was failing on 32-bit architectures ~half of the time. pm_nl_ctl was not reporting any error but the command was not doing what it was expected to do. As a result, the expected linked event was not triggered after and the test failed. This is due to the fact the token given in argument to the application was parsed as an integer with atoi(): in a 32-bit arch, if the number was bigger than INT_MAX, 2147483647 was used instead. This can simply be fixed by using strtoul() instead of atoi(). The errors have been seen "by chance" when manually looking at the results from LKFT. Fixes: 9a0b365 ("selftests: mptcp: support MPTCP_PM_CMD_ANNOUNCE") Cc: [email protected] Fixes: ecd2a77 ("selftests: mptcp: support MPTCP_PM_CMD_REMOVE") Fixes: cf8d0a6 ("selftests: mptcp: support MPTCP_PM_CMD_SUBFLOW_CREATE") Fixes: 57cc361 ("selftests: mptcp: support MPTCP_PM_CMD_SUBFLOW_DESTROY") Fixes: ca188a2 ("selftests: mptcp: userspace PM support for MP_PRIO signals") Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c8880f commit 61d9658

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
425425
}
426426

427427
/* token */
428-
token = atoi(params[4]);
428+
token = strtoul(params[4], NULL, 10);
429429
rta = (void *)(data + off);
430430
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
431431
rta->rta_len = RTA_LENGTH(4);
@@ -551,7 +551,7 @@ int csf(int fd, int pm_family, int argc, char *argv[])
551551
}
552552

553553
/* token */
554-
token = atoi(params[4]);
554+
token = strtoul(params[4], NULL, 10);
555555
rta = (void *)(data + off);
556556
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
557557
rta->rta_len = RTA_LENGTH(4);
@@ -598,7 +598,7 @@ int remove_addr(int fd, int pm_family, int argc, char *argv[])
598598
if (++arg >= argc)
599599
error(1, 0, " missing token value");
600600

601-
token = atoi(argv[arg]);
601+
token = strtoul(argv[arg], NULL, 10);
602602
rta = (void *)(data + off);
603603
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
604604
rta->rta_len = RTA_LENGTH(4);
@@ -710,7 +710,7 @@ int announce_addr(int fd, int pm_family, int argc, char *argv[])
710710
if (++arg >= argc)
711711
error(1, 0, " missing token value");
712712

713-
token = atoi(argv[arg]);
713+
token = strtoul(argv[arg], NULL, 10);
714714
} else
715715
error(1, 0, "unknown keyword %s", argv[arg]);
716716
}
@@ -1347,7 +1347,7 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
13471347
error(1, 0, " missing token value");
13481348

13491349
/* token */
1350-
token = atoi(argv[arg]);
1350+
token = strtoul(argv[arg], NULL, 10);
13511351
} else if (!strcmp(argv[arg], "flags")) {
13521352
char *tok, *str;
13531353

0 commit comments

Comments
 (0)