Skip to content

Commit

Permalink
selftests: mptcp: add id argument for dsf
Browse files Browse the repository at this point in the history
This patch adds a id argument for userspace PM subflow removing
function dsf(), to remove id 0 subflow.

It can be used like this:

	./pm_nl_ctl dsf token $tk id 0

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Aug 9, 2023
1 parent 47f0900 commit f59fa7c
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tools/testing/selftests/net/mptcp/pm_nl_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
u_int32_t token;
int addr_start;
int off = 0;
u_int8_t id;
int arg;

const char *params[5];
Expand All @@ -358,9 +359,37 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
off = init_genl_req(data, pm_family, MPTCP_PM_CMD_SUBFLOW_DESTROY,
MPTCP_PM_VER);

if (argc < 12)
if (argc < 6)
syntax(argv);

if (argc < 12) {
for (arg = 2; arg < argc; arg++) {
if (!strcmp(argv[arg], "id")) {
if (++arg >= argc)
error(1, 0, " missing id value");

id = atoi(argv[arg]);
rta = (void *)(data + off);
rta->rta_type = MPTCP_PM_ATTR_LOC_ID;
rta->rta_len = RTA_LENGTH(1);
memcpy(RTA_DATA(rta), &id, 1);
off += NLMSG_ALIGN(rta->rta_len);
} else if (!strcmp(argv[arg], "token")) {
if (++arg >= argc)
error(1, 0, " missing token value");

token = strtoul(argv[arg], NULL, 10);
rta = (void *)(data + off);
rta->rta_type = MPTCP_PM_ATTR_TOKEN;
rta->rta_len = RTA_LENGTH(4);
memcpy(RTA_DATA(rta), &token, 4);
off += NLMSG_ALIGN(rta->rta_len);
} else
error(1, 0, "unknown keyword %s", argv[arg]);
}
goto out;
}

/* Params recorded in this order:
* <local-ip>, <local-port>, <remote-ip>, <remote-port>, <token>
*/
Expand Down Expand Up @@ -443,6 +472,7 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
memcpy(RTA_DATA(rta), &token, 4);
off += NLMSG_ALIGN(rta->rta_len);

out:
do_nl_req(fd, nh, off, 0);

return 0;
Expand Down

0 comments on commit f59fa7c

Please sign in to comment.