Skip to content

Commit 4194212

Browse files
Dwyane-Yanintel-lab-lkp
authored andcommitted
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 <[email protected]> Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Gang Yan <[email protected]>
1 parent 1a19548 commit 4194212

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tools/testing/selftests/net/mptcp/mptcp_diag.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#define IPPROTO_MPTCP 262
2020
#endif
2121

22+
struct params {
23+
__u32 target_token;
24+
};
25+
2226
struct mptcp_info {
2327
__u8 mptcpi_subflows;
2428
__u8 mptcpi_add_addr_signal;
@@ -237,7 +241,7 @@ static void get_mptcpinfo(__u32 token)
237241
close(fd);
238242
}
239243

240-
static void parse_opts(int argc, char **argv, __u32 *target_token)
244+
static void parse_opts(int argc, char **argv, struct params *p)
241245
{
242246
int c;
243247

@@ -250,7 +254,7 @@ static void parse_opts(int argc, char **argv, __u32 *target_token)
250254
die_usage(0);
251255
break;
252256
case 't':
253-
sscanf(optarg, "%x", target_token);
257+
sscanf(optarg, "%x", &p->target_token);
254258
break;
255259
default:
256260
die_usage(1);
@@ -261,10 +265,12 @@ static void parse_opts(int argc, char **argv, __u32 *target_token)
261265

262266
int main(int argc, char *argv[])
263267
{
264-
__u32 target_token;
268+
struct params p = { 0 };
269+
270+
parse_opts(argc, argv, &p);
265271

266-
parse_opts(argc, argv, &target_token);
267-
get_mptcpinfo(target_token);
272+
if (p.target_token)
273+
get_mptcpinfo(p.target_token);
268274

269275
return 0;
270276
}

0 commit comments

Comments
 (0)