mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 00:15:49 -04:00
selftests: mptcp: add struct params in mptcp_diag
This patch adds a struct named 'params' to save 'target_token' and other future parameters. This structure facilitates future function expansions. Co-developed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Gang Yan <yangang@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20250502-net-next-mptcp-sft-inc-cover-v1-3-68eec95898fb@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -19,6 +19,10 @@
|
||||
#define IPPROTO_MPTCP 262
|
||||
#endif
|
||||
|
||||
struct params {
|
||||
__u32 target_token;
|
||||
};
|
||||
|
||||
struct mptcp_info {
|
||||
__u8 mptcpi_subflows;
|
||||
__u8 mptcpi_add_addr_signal;
|
||||
@@ -237,7 +241,7 @@ static void get_mptcpinfo(__u32 token)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void parse_opts(int argc, char **argv, __u32 *target_token)
|
||||
static void parse_opts(int argc, char **argv, struct params *p)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -250,7 +254,7 @@ static void parse_opts(int argc, char **argv, __u32 *target_token)
|
||||
die_usage(0);
|
||||
break;
|
||||
case 't':
|
||||
sscanf(optarg, "%x", target_token);
|
||||
sscanf(optarg, "%x", &p->target_token);
|
||||
break;
|
||||
default:
|
||||
die_usage(1);
|
||||
@@ -261,10 +265,12 @@ static void parse_opts(int argc, char **argv, __u32 *target_token)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
__u32 target_token;
|
||||
struct params p = { 0 };
|
||||
|
||||
parse_opts(argc, argv, &target_token);
|
||||
get_mptcpinfo(target_token);
|
||||
parse_opts(argc, argv, &p);
|
||||
|
||||
if (p.target_token)
|
||||
get_mptcpinfo(p.target_token);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user