[tor-bugs] #17873 [Tor]: replacing 0.0.0.0 listeners at runtime fails

Tor Bug Tracker & Wiki blackhole at torproject.org
Sun Jan 10 01:08:33 UTC 2016


#17873: replacing 0.0.0.0 listeners at runtime fails
-------------------------+------------------------------------
 Reporter:  cypherpunks  |          Owner:
     Type:  defect       |         Status:  needs_review
 Priority:  Medium       |      Milestone:  Tor: 0.2.8.x-final
Component:  Tor          |        Version:
 Severity:  Normal       |     Resolution:
 Keywords:  easy         |  Actual Points:
Parent ID:               |         Points:
  Sponsor:               |
-------------------------+------------------------------------

Comment (by teor):

 Replying to [comment:9 rl1987]:
 > https://github.com/rl1987/tor/compare/bug17873
 >
 > Some experimentation with changing DNSPort over control interface and
 launching DNS queries with dig(1) indicates that this branch is switching
 between listener addresses and ports properly.

 This patch switches the order of close and launch for all connections, but
 we want to keep "launch then close" as much as possible:

 Replying to [comment:4 nickm]:
 > Actually, I don't think switching the order of the bind and the close is
 a good idea.  The important observation about the current behavior is that
 (except in the cases noted on this ticket), it is reversible: we can't get
 stuck in a state where we closed the old ports but can't open the new
 ones.

 Can we only switch the order to "close then launch" if either the old or
 new connection is 0.0.0.0 or [::], and the bind() in
 connection_listener_new() fails with ERRNO_IS_EADDRINUSE(s)?

 (I apologise for tagging this task "easy".)

 As far as I can tell, this should only happen on Linux and Windows[0], and
 only for:
 * 0.0.0.0, which conflicts with any IPv4 address
 * [::], which conflicts with any IPv6 address

 Let's make this fix very specific:
  * only on Linux and Windows,
     * (We use SO_REUSEADDR, which avoids this issue on every unix-based
 system except for Linux.)
  * only if the first bind() fails with ERRNO_IS_EADDRINUSE(s),
  * and only for:
    * 0.0.0.0 replacing IPv4, or IPv4 replacing 0.0.0.0, or
    * [::] replacing IPv6, or IPv6 replacing [::].

 [0]: https://stackoverflow.com/questions/14388706/socket-options-so-
 reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/17873#comment:10>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list