Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove REUSEABLE_PORT flag from tcp_listener_bind #7

Open
jaromil opened this issue Jan 21, 2018 · 0 comments
Open

Remove REUSEABLE_PORT flag from tcp_listener_bind #7

jaromil opened this issue Jan 21, 2018 · 0 comments

Comments

@jaromil
Copy link
Member

jaromil commented Jan 21, 2018

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 79f3ad9 and is addressed already in various commits: 0a0160b and d1c1916 and 8ff4d77.

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) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant