netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c.
@ 2025-09-03 22:28 Kuniyuki Iwashima
  2025-09-04  9:25 ` Simon Horman
  2025-09-04 14:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2025-09-03 22:28 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Joanne Koong, Kuniyuki Iwashima, Kuniyuki Iwashima,
	netdev

bind_bhash.c passes (SO_REUSEADDR | SO_REUSEPORT) to setsockopt().

In the asm-generic definition, the value happens to match with the
bare SO_REUSEPORT, (2 | 15) == 15, but not on some arch.

arch/alpha/include/uapi/asm/socket.h:18:#define SO_REUSEADDR	0x0004
arch/alpha/include/uapi/asm/socket.h:24:#define SO_REUSEPORT	0x0200
arch/mips/include/uapi/asm/socket.h:24:#define SO_REUSEADDR	0x0004	/* Allow reuse of local addresses.  */
arch/mips/include/uapi/asm/socket.h:33:#define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
arch/parisc/include/uapi/asm/socket.h:12:#define SO_REUSEADDR	0x0004
arch/parisc/include/uapi/asm/socket.h:18:#define SO_REUSEPORT	0x0200
arch/sparc/include/uapi/asm/socket.h:13:#define SO_REUSEADDR	0x0004
arch/sparc/include/uapi/asm/socket.h:20:#define SO_REUSEPORT	0x0200
include/uapi/asm-generic/socket.h:12:#define SO_REUSEADDR	2
include/uapi/asm-generic/socket.h:27:#define SO_REUSEPORT	15

Let's pass SO_REUSEPORT only.

Fixes: c35ecb95c448 ("selftests/net: Add test for timing a bind request to a port with a populated bhash entry")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
 tools/testing/selftests/net/bind_bhash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/bind_bhash.c b/tools/testing/selftests/net/bind_bhash.c
index 57ff67a3751e..da04b0b19b73 100644
--- a/tools/testing/selftests/net/bind_bhash.c
+++ b/tools/testing/selftests/net/bind_bhash.c
@@ -75,7 +75,7 @@ static void *setup(void *arg)
 	int *array = (int *)arg;
 
 	for (i = 0; i < MAX_CONNECTIONS; i++) {
-		sock_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, setup_addr);
+		sock_fd = bind_socket(SO_REUSEPORT, setup_addr);
 		if (sock_fd < 0) {
 			ret = sock_fd;
 			pthread_exit(&ret);
@@ -103,7 +103,7 @@ int main(int argc, const char *argv[])
 
 	setup_addr = use_v6 ? setup_addr_v6 : setup_addr_v4;
 
-	listener_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, setup_addr);
+	listener_fd = bind_socket(SO_REUSEPORT, setup_addr);
 	if (listen(listener_fd, 100) < 0) {
 		perror("listen failed");
 		return -1;
-- 
2.51.0.338.gd7d06c2dae-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c.
  2025-09-03 22:28 [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c Kuniyuki Iwashima
@ 2025-09-04  9:25 ` Simon Horman
  2025-09-04 14:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-09-04  9:25 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Joanne Koong, Kuniyuki Iwashima, netdev

On Wed, Sep 03, 2025 at 10:28:51PM +0000, Kuniyuki Iwashima wrote:
> bind_bhash.c passes (SO_REUSEADDR | SO_REUSEPORT) to setsockopt().
> 
> In the asm-generic definition, the value happens to match with the
> bare SO_REUSEPORT, (2 | 15) == 15, but not on some arch.
> 
> arch/alpha/include/uapi/asm/socket.h:18:#define SO_REUSEADDR	0x0004
> arch/alpha/include/uapi/asm/socket.h:24:#define SO_REUSEPORT	0x0200
> arch/mips/include/uapi/asm/socket.h:24:#define SO_REUSEADDR	0x0004	/* Allow reuse of local addresses.  */
> arch/mips/include/uapi/asm/socket.h:33:#define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
> arch/parisc/include/uapi/asm/socket.h:12:#define SO_REUSEADDR	0x0004
> arch/parisc/include/uapi/asm/socket.h:18:#define SO_REUSEPORT	0x0200
> arch/sparc/include/uapi/asm/socket.h:13:#define SO_REUSEADDR	0x0004
> arch/sparc/include/uapi/asm/socket.h:20:#define SO_REUSEPORT	0x0200
> include/uapi/asm-generic/socket.h:12:#define SO_REUSEADDR	2
> include/uapi/asm-generic/socket.h:27:#define SO_REUSEPORT	15
> 
> Let's pass SO_REUSEPORT only.
> 
> Fixes: c35ecb95c448 ("selftests/net: Add test for timing a bind request to a port with a populated bhash entry")
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c.
  2025-09-03 22:28 [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c Kuniyuki Iwashima
  2025-09-04  9:25 ` Simon Horman
@ 2025-09-04 14:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-04 14:40 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: davem, edumazet, kuba, pabeni, horms, joannelkoong, kuni1840,
	netdev

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  3 Sep 2025 22:28:51 +0000 you wrote:
> bind_bhash.c passes (SO_REUSEADDR | SO_REUSEPORT) to setsockopt().
> 
> In the asm-generic definition, the value happens to match with the
> bare SO_REUSEPORT, (2 | 15) == 15, but not on some arch.
> 
> arch/alpha/include/uapi/asm/socket.h:18:#define SO_REUSEADDR	0x0004
> arch/alpha/include/uapi/asm/socket.h:24:#define SO_REUSEPORT	0x0200
> arch/mips/include/uapi/asm/socket.h:24:#define SO_REUSEADDR	0x0004	/* Allow reuse of local addresses.  */
> arch/mips/include/uapi/asm/socket.h:33:#define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
> arch/parisc/include/uapi/asm/socket.h:12:#define SO_REUSEADDR	0x0004
> arch/parisc/include/uapi/asm/socket.h:18:#define SO_REUSEPORT	0x0200
> arch/sparc/include/uapi/asm/socket.h:13:#define SO_REUSEADDR	0x0004
> arch/sparc/include/uapi/asm/socket.h:20:#define SO_REUSEPORT	0x0200
> include/uapi/asm-generic/socket.h:12:#define SO_REUSEADDR	2
> include/uapi/asm-generic/socket.h:27:#define SO_REUSEPORT	15
> 
> [...]

Here is the summary with links:
  - [v1,net] selftest: net: Fix weird setsockopt() in bind_bhash.c.
    https://git.kernel.org/netdev/net/c/fd2004d82d8d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-04 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 22:28 [PATCH v1 net] selftest: net: Fix weird setsockopt() in bind_bhash.c Kuniyuki Iwashima
2025-09-04  9:25 ` Simon Horman
2025-09-04 14:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).