Skip to content

Commit

Permalink
selftests: mptcp: pm_nl_ctl: fix 32-bit support
Browse files Browse the repository at this point in the history
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 change" when manually looking at the
results from LKFT.

Fixes: 9a0b365 ("selftests: mptcp: support MPTCP_PM_CMD_ANNOUNCE")
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]>
  • Loading branch information
matttbe authored and intel-lab-lkp committed Jul 4, 2023
1 parent 619c3c3 commit 76e0372
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/testing/selftests/net/mptcp/pm_nl_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
}

/* token */
token = atoi(params[4]);
token = strtoul(params[4], NULL, 10);
rta = (void *)(data + off);
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
rta->rta_len = RTA_LENGTH(4);
Expand Down Expand Up @@ -551,7 +551,7 @@ int csf(int fd, int pm_family, int argc, char *argv[])
}

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

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

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

/* token */
token = atoi(argv[arg]);
token = strtoul(argv[arg], NULL, 10);
} else if (!strcmp(argv[arg], "flags")) {
char *tok, *str;

Expand Down

0 comments on commit 76e0372

Please sign in to comment.