Remove REUSEABLE_PORT flag from tcp_listener_bind
After extensive testing we noticed the REUSABLE_PORT flag really breaks most ARM builds: for some reason Linux kernels built on ARM do not support them. This issue was introduced in 79f3ad9fb072ba569fe4ec6ac07bfbbac8ca55f3 and is addressed already in various commits: 0a0160b759fac9918fe5e1fa714c6c2e902786ec and d1c19162d6c898099c4eaec8801691e0a193a9fb and 8ff4d77f9a954aac9b588d40fe41b6f2e8d67abe.
Removing the flag alltogether solves the issue, while I'm not entirely sure the initial intention of "allowing round-robining to multiple dnscrypt-proxy daemons on a single port" is really enabled by it.
We use the following diff in Dowse as a fix and it may be worth considering mergin, unless anyone strongly relies on this RR feature:
diff --git a/src/proxy/tcp_request.c b/src/proxy/tcp_request.c
index 7ad3efc..cdb6a69 100644
--- a/src/proxy/tcp_request.c
+++ b/src/proxy/tcp_request.c
@@ -560,7 +560,7 @@ tcp_listener_bind(ProxyContext * const proxy_context)
#endif
if (proxy_context->tcp_listener_handle == -1) {
unsigned int flags = LEV_OPT_CLOSE_ON_FREE | LEV_OPT_CLOSE_ON_EXEC |
- LEV_OPT_REUSEABLE | LEV_OPT_REUSEABLE_PORT |
+ LEV_OPT_REUSEABLE |
LEV_OPT_DEFERRED_ACCEPT;
for (;;) {
proxy_context->tcp_conn_listener =
diff --git a/src/proxy/udp_request.c b/src/proxy/udp_request.c
index 455e907..a14822e 100644
--- a/src/proxy/udp_request.c
+++ b/src/proxy/udp_request.c
@@ -492,7 +492,6 @@ udp_listener_kill_oldest_request(ProxyContext * const proxy_context)
int
udp_listener_bind(ProxyContext * const proxy_context)
{
- int optval = 1;
if (proxy_context->udp_listener_handle == -1) {
if ((proxy_context->udp_listener_handle = socket
(proxy_context->local_sockaddr.ss_family,
@@ -501,9 +500,6 @@ udp_listener_bind(ProxyContext * const proxy_context)
"Unable to create a socket (UDP)");
return -1;
}
-#if defined(__linux__) && defined(SO_REUSEPORT) && !defined(NO_REUSEPORT)
- setsockopt(proxy_context->udp_listener_handle, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));
-#endif
if (bind(proxy_context->udp_listener_handle,
(struct sockaddr *) &proxy_context->local_sockaddr,
proxy_context->local_sockaddr_len) != 0) {