[Unbound-users] [PATCH] performance increase with SO_REUSEPORT on Linux 3.9+

Robert Edmonds edmonds at debian.org
Fri Jan 24 18:12:01 CET 2014

W.C.A. Wijngaards wrote:
> Hi Robert,
> On 01/07/2014 04:05 AM, Robert Edmonds wrote:
> > Hi,
> > 
> > There is a SO_REUSEPORT socket option available on Linux 3.9+,
> > described in this LWN article:
> Thank you very much for this patch.  I have applied it.
> (small changed in header comments, and documentation entry).
> The only thing I wonder if it wouldn't be better to make this the
> default setting.  It could be disabled if you then mention it in the
> config file?  This would still only apply to Linux systems (unless we
> had some way for a similar effect on other systems, and then we have
> to rename this linux-reuseport?)
> Best regards,
>    Wouter

Hi, Wouter:

You could try to enable Linux/SO_REUSEPORT support if it is available,
by detecting whether __linux__ and SO_REUSEPORT are defined at compile
time.  But it's possible for SO_REUSEPORT to be defined at compile time
but not usable at run time (e.g., new headers with old kernel, for
example during a Linux distribution upgrade where the new userland is
temporarily running with the previous kernel), in which case
setsockopt() will fail with ENOPROTOOPT.

With the current version of this patch, the daemon will fail to start if
it tries to set SO_REUSEPORT and setsockopt() fails.  So I would not
recommend making this the default just yet.

It would be possible to detect if SO_REUSEPORT is not available at run
time and fall back to only using a single listening socket.  That would
require a little more coordination between the daemon code and the code
that initializes the sockets but it's certainly possible.

Robert Edmonds
edmonds at debian.org

More information about the Unbound-users mailing list