[bind10-dev] SO_REUSADDR question... was Socket creator and low-level code
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Wed Oct 27 12:46:15 UTC 2010
At Wed, 27 Oct 2010 13:27:23 +0200,
Shane Kerr <shane at isc.org> wrote:
> Off-topic, but is there ever a situation where you would want a
> listening socket to not have SO_REUSEADDR set?
There was with BIND 9.
With the port randomization patch we also adopted connected UDP
sockets. To benefit from these as much as possible, we basically
wanted to specify SO_REUSEADDR for UDP sockets of outgoing queries.
However, if we naively did that, we could share the same local port
with a different application, and, depending on the timing we could
intercept packets that were originally destined to that application.
(such troubles really happened, even though rare)
So we ended up opening the first socket of a particular local port
without SO_REUSEADDR (so that we could identify and avoid any
conflicting ports), and specify SO_REUSADDR for any subsequent sockets
using the same local port (so that we could bind the socket to the
same port with a different destination).
I'd not necessarily insist that we need to do the same thing for BIND
10, but in this context the point is that in the real operational
world we'll encounter many strange cases that would require tricky
corner cases.
> As far as I can tell, if you don't set SO_REUSEADDR you basically
> require a couple minutes for various timers to expire before you can
> re-bind to a port, making a quick restart impossible. It is difficult to
> imagine a circumstance where this a good idea.
For TCP, you're right.
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list