Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gang Yan and committed by
Jakub Kicinski
cd732d51 dd367e81

+11 -5
+11 -5
tools/testing/selftests/net/mptcp/mptcp_diag.c
··· 19 19 #define IPPROTO_MPTCP 262 20 20 #endif 21 21 22 + struct params { 23 + __u32 target_token; 24 + }; 25 + 22 26 struct mptcp_info { 23 27 __u8 mptcpi_subflows; 24 28 __u8 mptcpi_add_addr_signal; ··· 241 237 close(fd); 242 238 } 243 239 244 - static void parse_opts(int argc, char **argv, __u32 *target_token) 240 + static void parse_opts(int argc, char **argv, struct params *p) 245 241 { 246 242 int c; 247 243 ··· 254 250 die_usage(0); 255 251 break; 256 252 case 't': 257 - sscanf(optarg, "%x", target_token); 253 + sscanf(optarg, "%x", &p->target_token); 258 254 break; 259 255 default: 260 256 die_usage(1); ··· 265 261 266 262 int main(int argc, char *argv[]) 267 263 { 268 - __u32 target_token; 264 + struct params p = { 0 }; 269 265 270 - parse_opts(argc, argv, &target_token); 271 - get_mptcpinfo(target_token); 266 + parse_opts(argc, argv, &p); 267 + 268 + if (p.target_token) 269 + get_mptcpinfo(p.target_token); 272 270 273 271 return 0; 274 272 }