From: Wouter Wijngaards Date: Fri, 27 Jun 2014 14:11:57 +0000 (+0000) Subject: - so-reuseport is available on BSDs(such as FreeBSD 10) and OS/X. X-Git-Tag: release-1.5.0rc1~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fcdb08164456a31d524010a01807eb148bef53a;p=thirdparty%2Funbound.git - so-reuseport is available on BSDs(such as FreeBSD 10) and OS/X. git-svn-id: file:///svn/unbound/trunk@3153 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/daemon.c b/daemon/daemon.c index 3406d7940..fd9d670e0 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -266,7 +266,7 @@ daemon_open_shared_ports(struct daemon* daemon) daemon->ports = NULL; } /* see if we want to reuseport */ -#if defined(__linux__) && defined(SO_REUSEPORT) +#ifdef SO_REUSEPORT if(daemon->cfg->so_reuseport && daemon->cfg->num_threads > 0) daemon->reuseport = 1; #endif @@ -449,7 +449,7 @@ thread_start(void* arg) tube_close_write(worker->cmd); close_other_pipes(worker->daemon, worker->thread_num); #endif -#if defined(__linux__) && defined(SO_REUSEPORT) +#ifdef SO_REUSEPORT if(worker->daemon->cfg->so_reuseport) port_num = worker->thread_num; else diff --git a/doc/Changelog b/doc/Changelog index 14b03df8b..673365f67 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +27 June 2014: Wouter + - so-reuseport is available on BSDs(such as FreeBSD 10) and OS/X. + 26 June 2014: Wouter - unbound-control status reports if so-reuseport was successful. - iana portlist updated. diff --git a/doc/example.conf.in b/doc/example.conf.in index d3249824a..9cc7e0200 100644 --- a/doc/example.conf.in +++ b/doc/example.conf.in @@ -85,7 +85,7 @@ server: # 0 is system default. Use 4m to handle spikes on very busy servers. # so-sndbuf: 0 - # on Linux(3.9+) use SO_REUSEPORT to distribute queries over threads. + # use SO_REUSEPORT to distribute queries over threads. # so-reuseport: no # EDNS reassembly buffer to advertise to UDP peers (the actual buffer diff --git a/doc/unbound.conf.5.in b/doc/unbound.conf.5.in index d175b4a0b..d98492ca3 100644 --- a/doc/unbound.conf.5.in +++ b/doc/unbound.conf.5.in @@ -262,8 +262,9 @@ to so\-rcvbuf. .B so\-reuseport: \fI If yes, then open dedicated listening sockets for incoming queries for each thread and try to set the SO_REUSEPORT socket option on each socket. May -distribute incoming queries to threads more evenly. Default is no. Only -supported on Linux >= 3.9. You can enable it (on any platform and kernel), +distribute incoming queries to threads more evenly. Default is no. On Linux +it is supported in kernels >= 3.9. On other systems, FreeBSD, OSX it may +also work. You can enable it (on any platform and kernel), it then attempts to open the port and passes the option if it was available at compile time, if that works it is used, if it fails, it continues silently (unless verbosity 3) without the option. diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index badd303d9..e1d5f8b6f 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -153,8 +153,8 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, #endif } #endif /* SO_REUSEADDR */ -#if defined(__linux__) && defined(SO_REUSEPORT) - /* Linux specific: try to set SO_REUSEPORT so that incoming +#ifdef SO_REUSEPORT + /* try to set SO_REUSEPORT so that incoming * queries are distributed evenly among the receiving threads. * Each thread must have its own socket bound to the same port, * with SO_REUSEPORT set on each socket. @@ -172,7 +172,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, } #else (void)reuseport; -#endif /* defined(__linux__) && defined(SO_REUSEPORT) */ +#endif /* defined(SO_REUSEPORT) */ } if(rcv) { #ifdef SO_RCVBUF @@ -491,8 +491,8 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto, return -1; } #endif /* SO_REUSEADDR */ -#if defined(__linux__) && defined(SO_REUSEPORT) - /* Linux specific: try to set SO_REUSEPORT so that incoming +#ifdef SO_REUSEPORT + /* try to set SO_REUSEPORT so that incoming * connections are distributed evenly among the receiving threads. * Each thread must have its own socket bound to the same port, * with SO_REUSEPORT set on each socket. @@ -510,7 +510,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto, } #else (void)reuseport; -#endif /* defined(__linux__) && defined(SO_REUSEPORT) */ +#endif /* defined(SO_REUSEPORT) */ #if defined(IPV6_V6ONLY) if(addr->ai_family == AF_INET6 && v6only) { if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,