diff mbox series

[net] selftests/net: udpgso_bench_rx: fix port argument

Message ID 20211111115717.1925230-1-willemdebruijn.kernel@gmail.com (mailing list archive)
State Accepted
Commit d336509cb9d03970911878bb77f0497f64fda061
Delegated to: Netdev Maintainers
Headers show
Series [net] selftests/net: udpgso_bench_rx: fix port argument | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Willem de Bruijn Nov. 11, 2021, 11:57 a.m. UTC
From: Willem de Bruijn <willemb@google.com>

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>
---
 tools/testing/selftests/net/udpgso_bench_rx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 11, 2021, 12:30 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 11 Nov 2021 06:57:17 -0500 you wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net] selftests/net: udpgso_bench_rx: fix port argument
    https://git.kernel.org/netdev/net/c/d336509cb9d0

You are awesome, thank you!
Paolo Abeni Nov. 11, 2021, 12:42 p.m. UTC | #2
On Thu, 2021-11-11 at 06:57 -0500, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> 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>
> ---
>  tools/testing/selftests/net/udpgso_bench_rx.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
> index 76a24052f4b4..6a193425c367 100644
> --- a/tools/testing/selftests/net/udpgso_bench_rx.c
> +++ b/tools/testing/selftests/net/udpgso_bench_rx.c
> @@ -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);
> @@ -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]);
>  
LGTM, thanks Willem,

Acked-by: Paolo Abeni <pabeni@redhat.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
index 76a24052f4b4..6a193425c367 100644
--- a/tools/testing/selftests/net/udpgso_bench_rx.c
+++ b/tools/testing/selftests/net/udpgso_bench_rx.c
@@ -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);
@@ -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]);