Skip to content

Commit

Permalink
selftests/net: udpgso_bench_rx: fix port argument
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wdebruij authored and davem330 committed Nov 11, 2021
1 parent 29cd386 commit d336509
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/testing/selftests/net/udpgso_bench_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,17 @@ static void usage(const char *filepath)

static void parse_opts(int argc, char **argv)
{
const char *bind_addr = NULL;
int c;

/* bind to any by default */
setup_sockaddr(PF_INET6, "::", &cfg_bind_addr);
while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) {
switch (c) {
case '4':
cfg_family = PF_INET;
cfg_alen = sizeof(struct sockaddr_in);
setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr);
break;
case 'b':
setup_sockaddr(cfg_family, optarg, &cfg_bind_addr);
bind_addr = optarg;
break;
case 'C':
cfg_connect_timeout_ms = strtoul(optarg, NULL, 0);
Expand Down Expand Up @@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv)
}
}

if (!bind_addr)
bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0";

setup_sockaddr(cfg_family, bind_addr, &cfg_bind_addr);

if (optind != argc)
usage(argv[0]);

Expand Down

0 comments on commit d336509

Please sign in to comment.