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

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: 3327a9c46352 ("selftests: add functionals test for UDP GRO")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Willem de Bruijn and committed by
David S. Miller
d336509c 29cd3867

+7 -4
+7 -4
tools/testing/selftests/net/udpgso_bench_rx.c
··· 293 293 294 294 static void parse_opts(int argc, char **argv) 295 295 { 296 + const char *bind_addr = NULL; 296 297 int c; 297 298 298 - /* bind to any by default */ 299 - setup_sockaddr(PF_INET6, "::", &cfg_bind_addr); 300 299 while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) { 301 300 switch (c) { 302 301 case '4': 303 302 cfg_family = PF_INET; 304 303 cfg_alen = sizeof(struct sockaddr_in); 305 - setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr); 306 304 break; 307 305 case 'b': 308 - setup_sockaddr(cfg_family, optarg, &cfg_bind_addr); 306 + bind_addr = optarg; 309 307 break; 310 308 case 'C': 311 309 cfg_connect_timeout_ms = strtoul(optarg, NULL, 0); ··· 338 340 break; 339 341 } 340 342 } 343 + 344 + if (!bind_addr) 345 + bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0"; 346 + 347 + setup_sockaddr(cfg_family, bind_addr, &cfg_bind_addr); 341 348 342 349 if (optind != argc) 343 350 usage(argv[0]);