Bug 3582

Summary: error: outgoing tcp: connect: Address already in use
Product: unbound Reporter: Florian Riehm <mail>
Component: serverAssignee: unbound team <unbound-team>
Severity: normal CC: cathya, wouter
Priority: P5    
Version: 1.6.3   
Hardware: All   
OS: OpenBSD   
Attachments: Do not log EADDRINUSE connect errors

Description Florian Riehm 2018-03-05 16:39:29 CET
Created attachment 495 [details]
Do not log EADDRINUSE connect errors

Since version 1.6.3 unbound set 'SO_REUSEADDR on outgoing tcp connections to
fix the bind before connect limited tcp connections' (commit

This is probably useful if unbound resolves recursive.

If unbound is using forwarder, it causes failures like this, especially if the
request rate is high:
error: outgoing tcp: connect: Address already in use for XXX.XXX.XXX.XXX

Due to SO_REUSEADDR the operating system (OpenBSD) can reuse same source ports
at bind(). Later if it tries to connect() errors occur if target ip and port
are the same. This happens especially if unbound sends many requests to a few
destinations (forwarder).

I propose to ignore the error and retry (see my patch).
But maybe it would be better, to avoid SO_REUSEADDR if we use forwarders?

Thanks & Regards

Comment 1 Wouter Wijngaards 2018-03-05 16:46:08 CET
Hi Florian,

Patch included!  Thank you for the report.

I guess that will help out with the logs.

Best regards, Wouter