Skip to content

Commit d336509

Browse files
wdebruijdavem330
authored andcommitted
selftests/net: udpgso_bench_rx: fix port argument
The below commit added optional support for passing a bind address. It configures the sockaddr bind arguments before parsing options and reconfigures on options -b and -4. This broke support for passing port (-p) on its own. Configure sockaddr after parsing all arguments. Fixes: 3327a9c ("selftests: add functionals test for UDP GRO") Reported-by: Eric Dumazet <[email protected]> Signed-off-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 29cd386 commit d336509

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/testing/selftests/net/udpgso_bench_rx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,17 @@ static void usage(const char *filepath)
293293

294294
static void parse_opts(int argc, char **argv)
295295
{
296+
const char *bind_addr = NULL;
296297
int c;
297298

298-
/* bind to any by default */
299-
setup_sockaddr(PF_INET6, "::", &cfg_bind_addr);
300299
while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) {
301300
switch (c) {
302301
case '4':
303302
cfg_family = PF_INET;
304303
cfg_alen = sizeof(struct sockaddr_in);
305-
setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr);
306304
break;
307305
case 'b':
308-
setup_sockaddr(cfg_family, optarg, &cfg_bind_addr);
306+
bind_addr = optarg;
309307
break;
310308
case 'C':
311309
cfg_connect_timeout_ms = strtoul(optarg, NULL, 0);
@@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv)
341339
}
342340
}
343341

342+
if (!bind_addr)
343+
bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0";
344+
345+
setup_sockaddr(cfg_family, bind_addr, &cfg_bind_addr);
346+
344347
if (optind != argc)
345348
usage(argv[0]);
346349

0 commit comments

Comments
 (0)