mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
selftests: mptcp: add token for get_addr
The command get_addr() of pm_nl_ctl can be used like this in in-kernel PM: pm_nl_ctl get $id This patch adds token argument for it to support userspace PM: pm_nl_ctl get $id token $token If 'token $token' is passed to get_addr(), copy it into the kernel netlink. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
564ae6794e
commit
b055671b39
@ -1087,6 +1087,7 @@ int get_addr(int fd, int pm_family, int argc, char *argv[])
|
||||
1024];
|
||||
struct rtattr *rta, *nest;
|
||||
struct nlmsghdr *nh;
|
||||
u_int32_t token = 0;
|
||||
int nest_start;
|
||||
u_int8_t id;
|
||||
int off = 0;
|
||||
@ -1097,10 +1098,12 @@ int get_addr(int fd, int pm_family, int argc, char *argv[])
|
||||
MPTCP_PM_VER);
|
||||
|
||||
/* the only argument is the address id */
|
||||
if (argc != 3)
|
||||
if (argc != 3 && argc != 5)
|
||||
syntax(argv);
|
||||
|
||||
id = atoi(argv[2]);
|
||||
if (argc == 5 && !strcmp(argv[3], "token"))
|
||||
token = strtoul(argv[4], NULL, 10);
|
||||
|
||||
nest_start = off;
|
||||
nest = (void *)(data + off);
|
||||
@ -1116,6 +1119,15 @@ int get_addr(int fd, int pm_family, int argc, char *argv[])
|
||||
off += NLMSG_ALIGN(rta->rta_len);
|
||||
nest->rta_len = off - nest_start;
|
||||
|
||||
/* token */
|
||||
if (token) {
|
||||
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);
|
||||
}
|
||||
|
||||
print_addrs(nh, pm_family, do_nl_req(fd, nh, off, sizeof(data)));
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user