Bug 3582 - error: outgoing tcp: connect: Address already in use
error: outgoing tcp: connect: Address already in use
Status: RESOLVED FIXED
Product: unbound
Classification: Unclassified
Component: server
1.6.3
All OpenBSD
: P5 normal
Assigned To: unbound team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-05 16:39 CET by Florian Riehm
Modified: 2018-03-05 16:46 CET (History)
2 users (show)

See Also:


Attachments
Do not log EADDRINUSE connect errors (635 bytes, text/x-csrc)
2018-03-05 16:39 CET, Florian Riehm
Details

Note You need to log in before you can comment on or make changes to this bug.
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
4e502fd624e56922e8951acd1d71e662ffefb1e9).

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

Florian
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