- 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
This commit is contained in:
Wouter Wijngaards 2014-06-27 14:11:57 +00:00
parent 0aff3e3fca
commit 6fcdb08164
5 changed files with 15 additions and 11 deletions

View file

@ -266,7 +266,7 @@ daemon_open_shared_ports(struct daemon* daemon)
daemon->ports = NULL; daemon->ports = NULL;
} }
/* see if we want to reuseport */ /* 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) if(daemon->cfg->so_reuseport && daemon->cfg->num_threads > 0)
daemon->reuseport = 1; daemon->reuseport = 1;
#endif #endif
@ -449,7 +449,7 @@ thread_start(void* arg)
tube_close_write(worker->cmd); tube_close_write(worker->cmd);
close_other_pipes(worker->daemon, worker->thread_num); close_other_pipes(worker->daemon, worker->thread_num);
#endif #endif
#if defined(__linux__) && defined(SO_REUSEPORT) #ifdef SO_REUSEPORT
if(worker->daemon->cfg->so_reuseport) if(worker->daemon->cfg->so_reuseport)
port_num = worker->thread_num; port_num = worker->thread_num;
else else

View file

@ -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 26 June 2014: Wouter
- unbound-control status reports if so-reuseport was successful. - unbound-control status reports if so-reuseport was successful.
- iana portlist updated. - iana portlist updated.

View file

@ -85,7 +85,7 @@ server:
# 0 is system default. Use 4m to handle spikes on very busy servers. # 0 is system default. Use 4m to handle spikes on very busy servers.
# so-sndbuf: 0 # 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 # so-reuseport: no
# EDNS reassembly buffer to advertise to UDP peers (the actual buffer # EDNS reassembly buffer to advertise to UDP peers (the actual buffer

View file

@ -262,8 +262,9 @@ to so\-rcvbuf.
.B so\-reuseport: \fI<yes or no> .B so\-reuseport: \fI<yes or no>
If yes, then open dedicated listening sockets for incoming queries for each 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 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 distribute incoming queries to threads more evenly. Default is no. On Linux
supported on Linux >= 3.9. You can enable it (on any platform and kernel), 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 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 at compile time, if that works it is used, if it fails, it continues
silently (unless verbosity 3) without the option. silently (unless verbosity 3) without the option.

View file

@ -153,8 +153,8 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
#endif #endif
} }
#endif /* SO_REUSEADDR */ #endif /* SO_REUSEADDR */
#if defined(__linux__) && defined(SO_REUSEPORT) #ifdef SO_REUSEPORT
/* Linux specific: try to set SO_REUSEPORT so that incoming /* try to set SO_REUSEPORT so that incoming
* queries are distributed evenly among the receiving threads. * queries are distributed evenly among the receiving threads.
* Each thread must have its own socket bound to the same port, * Each thread must have its own socket bound to the same port,
* with SO_REUSEPORT set on each socket. * with SO_REUSEPORT set on each socket.
@ -172,7 +172,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
} }
#else #else
(void)reuseport; (void)reuseport;
#endif /* defined(__linux__) && defined(SO_REUSEPORT) */ #endif /* defined(SO_REUSEPORT) */
} }
if(rcv) { if(rcv) {
#ifdef SO_RCVBUF #ifdef SO_RCVBUF
@ -491,8 +491,8 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
return -1; return -1;
} }
#endif /* SO_REUSEADDR */ #endif /* SO_REUSEADDR */
#if defined(__linux__) && defined(SO_REUSEPORT) #ifdef SO_REUSEPORT
/* Linux specific: try to set SO_REUSEPORT so that incoming /* try to set SO_REUSEPORT so that incoming
* connections are distributed evenly among the receiving threads. * connections are distributed evenly among the receiving threads.
* Each thread must have its own socket bound to the same port, * Each thread must have its own socket bound to the same port,
* with SO_REUSEPORT set on each socket. * with SO_REUSEPORT set on each socket.
@ -510,7 +510,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
} }
#else #else
(void)reuseport; (void)reuseport;
#endif /* defined(__linux__) && defined(SO_REUSEPORT) */ #endif /* defined(SO_REUSEPORT) */
#if defined(IPV6_V6ONLY) #if defined(IPV6_V6ONLY)
if(addr->ai_family == AF_INET6 && v6only) { if(addr->ai_family == AF_INET6 && v6only) {
if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,