diff options
author | Gang Yan <yangang@kylinos.cn> | 2025-05-02 14:29:23 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2025-05-05 16:52:00 -0700 |
commit | cd732d5110a22ea6d555c69a60a440b59ba281e3 (patch) | |
tree | e7d98344c3ddfaa7df7cf6dccb499fe9b5556cfb | |
parent | dd367e81b79a68a080c5f03f690fe829b093bd21 (diff) |
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>
-rw-r--r-- | tools/testing/selftests/net/mptcp/mptcp_diag.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/testing/selftests/net/mptcp/mptcp_diag.c b/tools/testing/selftests/net/mptcp/mptcp_diag.c index 37d5015ad08c..ea7cb1128044 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_diag.c +++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c @@ -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, &p); - parse_opts(argc, argv, &target_token); - get_mptcpinfo(target_token); + if (p.target_token) + get_mptcpinfo(p.target_token); return 0; } |