The branch, master has been updated via 6ba8b15 Fix setsockopt(s, SOL_SOCKET, SO_REUSEPORT, ...) with glibc 2.40 via 6404c8f tests: Add test for test_sockopt_reuseport() from d7c4bb5 Bump version to 1.4.3
https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 6ba8b15f79aa466f1226b0e4aa8e2bb4c2b2cad5 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 20 13:33:21 2025 +0100 Fix setsockopt(s, SOL_SOCKET, SO_REUSEPORT, ...) with glibc 2.40 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 6404c8f9fd1b1795af65f459cefd6ac454becd9b Author: Andreas Schneider <a...@cryptomilk.org> Date: Mon Jan 20 13:32:35 2025 +0100 tests: Add test for test_sockopt_reuseport() Signed-off-by: Andreas Schneider <a...@cryptomilk.org> Reviewed-by: Volker Lendecke <v...@samba.org> ----------------------------------------------------------------------- Summary of changes: src/socket_wrapper.c | 7 +++++++ tests/test_echo_tcp_socket_options.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) Changeset truncated at 500 lines: diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 37799c8..db20eac 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5110,6 +5110,13 @@ static int swrap_setsockopt(int s, int level, int optname, } if (level == SOL_SOCKET) { + /* + * SO_REUSEPORT is not supported on a unix socket. glibc 2.40 + * returns ENOTSUPP now. + */ + if (optname == SO_REUSEPORT) { + return 0; + } return libc_setsockopt(s, level, optname, diff --git a/tests/test_echo_tcp_socket_options.c b/tests/test_echo_tcp_socket_options.c index 5e5661d..5d6ac2e 100644 --- a/tests/test_echo_tcp_socket_options.c +++ b/tests/test_echo_tcp_socket_options.c @@ -389,6 +389,22 @@ static void test_sockopt_tcp(void **state) close(s); } +static void test_sockopt_reuseport(void **state) +{ + socklen_t optlen = sizeof(int); + int opt = 1; + int rc; + int s; + + (void) state; /* unused */ + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + assert_return_code(s, errno); + + rc = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &opt, optlen); + assert_return_code(rc, errno); +} + int main(void) { int rc; @@ -410,6 +426,9 @@ int main(void) { cmocka_unit_test_setup_teardown(test_sockopt_tcp, setup_echo_srv_tcp_ipv4, teardown), + cmocka_unit_test_setup_teardown(test_sockopt_reuseport, + setup_echo_srv_tcp_ipv4, + teardown), }; rc = cmocka_run_group_tests(sockopt_tests, NULL, NULL); -- Socket Wrapper Repository