Skip to content

Commit 3ed0d6a

Browse files
q2vengregkh
authored andcommitted
selftest: net: Fix weird setsockopt() in bind_bhash.c.
[ Upstream commit fd2004d ] 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: c35ecb9 ("selftests/net: Add test for timing a bind request to a port with a populated bhash entry") Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 631fc8a commit 3ed0d6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/net/bind_bhash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void *setup(void *arg)
7575
int *array = (int *)arg;
7676

7777
for (i = 0; i < MAX_CONNECTIONS; i++) {
78-
sock_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, setup_addr);
78+
sock_fd = bind_socket(SO_REUSEPORT, setup_addr);
7979
if (sock_fd < 0) {
8080
ret = sock_fd;
8181
pthread_exit(&ret);
@@ -103,7 +103,7 @@ int main(int argc, const char *argv[])
103103

104104
setup_addr = use_v6 ? setup_addr_v6 : setup_addr_v4;
105105

106-
listener_fd = bind_socket(SO_REUSEADDR | SO_REUSEPORT, setup_addr);
106+
listener_fd = bind_socket(SO_REUSEPORT, setup_addr);
107107
if (listen(listener_fd, 100) < 0) {
108108
perror("listen failed");
109109
return -1;

0 commit comments

Comments
 (0)