From 2a9623d61c44b1ac47a1cdb8f1c5059a8efcc6d1 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 26 Oct 2023 19:45:01 +0200 Subject: [PATCH] SO_REUSEADDR per default on TCP LISTEN; so-reuseaddr= --- CHANGES | 4 + doc/socat.yo | 29 +- test.sh | 808 +++++++++++++++++++++++++++++++++++++-------------- xio-listen.c | 3 + xio-socket.c | 36 ++- xio-socket.h | 1 + xio-udp.c | 14 +- xioopts.c | 57 +++- xioopts.h | 4 +- 9 files changed, 714 insertions(+), 242 deletions(-) diff --git a/CHANGES b/CHANGES index 879bf7a..e5d5480 100644 --- a/CHANGES +++ b/CHANGES @@ -66,6 +66,10 @@ Features: With this option Socat restores the VLAN tag. Feature inspired by Zhao Dong. + Socket option SO_REUSEADDR is now automatically applied to TCP LISTEN + addresses. reuseaddr= restores the old behaviour. + Tests: TCP4_REUSEADDR OPENSSL_6_REUSEADDR REUSEADDR_NULL + Corrections: When a sub process (EXEC, SYSTEM) terminated with exit code other than 0, its last sent data might have been lost depending on timing of read/ diff --git a/doc/socat.yo b/doc/socat.yo index 7ec9b5a..6ca5159 100644 --- a/doc/socat.yo +++ b/doc/socat.yo @@ -586,7 +586,7 @@ label(ADDRESS_OPENSSL_LISTEN)dit(bf(tt(OPENSSL-LISTEN:))) link(range)(OPTION_RANGE), link(tcpwrap)(OPTION_TCPWRAPPERS), link(su)(OPTION_SUBSTUSER), - link(reuseaddr)(OPTION_REUSEADDR), + link(reuseaddr)(OPTION_SO_REUSEADDR), link(retry)(OPTION_RETRY)nl() See also: link(OPENSSL)(ADDRESS_OPENSSL_CONNECT), @@ -652,7 +652,7 @@ label(ADDRESS_OPENSSL_DTLS_SERVER)dit(bf(tt(OPENSSL-DTLS-SERVER:))) link(range)(OPTION_RANGE), link(tcpwrap)(OPTION_TCPWRAPPERS), link(su)(OPTION_SUBSTUSER), - link(reuseaddr)(OPTION_REUSEADDR), + link(reuseaddr)(OPTION_SO_REUSEADDR), link(retry)(OPTION_RETRY)nl() link(rcvtimeo)(OPTION_SO_RCVTIMOE)nl() See also: @@ -788,7 +788,7 @@ label(ADDRESS_SCTP_LISTEN)dit(bf(tt(SCTP-LISTEN:))) link(sctp-maxseg)(OPTION_SCTP_MAXSEG), link(sctp-nodelay)(OPTION_SCTP_NODELAY), link(su)(OPTION_SUBSTUSER), - link(reuseaddr)(OPTION_REUSEADDR), + link(reuseaddr)(OPTION_SO_REUSEADDR), link(retry)(OPTION_RETRY)nl() See also: link(SCTP4-LISTEN)(ADDRESS_SCTP4_LISTEN), @@ -1053,7 +1053,7 @@ label(ADDRESS_TCP_LISTEN)dit(bf(tt(TCP-LISTEN:))) link(accept-timeout)(OPTION_ACCEPT_TIMEOUT), link(mss)(OPTION_MSS), link(su)(OPTION_SUBSTUSER), - link(reuseaddr)(OPTION_REUSEADDR), + link(reuseaddr)(OPTION_SO_REUSEADDR), link(retry)(OPTION_RETRY), link(cool-write)(OPTION_COOL_WRITE)nl() See also: @@ -1413,7 +1413,7 @@ label(ADDRESS_VSOCK_LISTEN)dit(bf(tt(VSOCK-LISTEN:))) link(max-children)(OPTION_MAX_CHILDREN), link(backlog)(OPTION_BACKLOG), link(su)(OPTION_SUBSTUSER), - link(reuseaddr)(OPTION_REUSEADDR), + link(reuseaddr)(OPTION_SO_REUSEADDR), link(retry)(OPTION_RETRY)nl() See also: link(VSOCK-CONNECT)(ADDRESS_VSOCK_CONNECT) @@ -2004,9 +2004,16 @@ label(OPTION_SO_RCVTIMOE)dit(bf(tt(so-rcvtimeo=