Commit d336509c authored by Willem de Bruijn's avatar Willem de Bruijn Committed by David S. Miller

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: 3327a9c4 ("selftests: add functionals test for UDP GRO")
Reported-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29cd3867
...@@ -293,19 +293,17 @@ static void usage(const char *filepath) ...@@ -293,19 +293,17 @@ static void usage(const char *filepath)
static void parse_opts(int argc, char **argv) static void parse_opts(int argc, char **argv)
{ {
const char *bind_addr = NULL;
int c; 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) { while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) {
switch (c) { switch (c) {
case '4': case '4':
cfg_family = PF_INET; cfg_family = PF_INET;
cfg_alen = sizeof(struct sockaddr_in); cfg_alen = sizeof(struct sockaddr_in);
setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr);
break; break;
case 'b': case 'b':
setup_sockaddr(cfg_family, optarg, &cfg_bind_addr); bind_addr = optarg;
break; break;
case 'C': case 'C':
cfg_connect_timeout_ms = strtoul(optarg, NULL, 0); cfg_connect_timeout_ms = strtoul(optarg, NULL, 0);
...@@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv) ...@@ -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) if (optind != argc)
usage(argv[0]); usage(argv[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment