[or-cvs] [tor/maint-0.2.0] backport r19291, r19292, r19295, r19296: fix dynamic ip relay reachability

Nick Mathewson nickm at seul.org
Mon Jun 1 01:56:36 UTC 2009


Author: Roger Dingledine <arma at torproject.org>
Date: Sun, 31 May 2009 18:18:54 -0400
Subject: backport r19291, r19292, r19295, r19296: fix dynamic ip relay reachability
Commit: 16bca35eab81b13d6ec69acaf25e609bf663d037

---
 ChangeLog                |    7 +++++++
 doc/TODO.020             |    2 +-
 src/or/connection_edge.c |   14 +++++++++-----
 src/or/directory.c       |    3 ++-
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63e4f65..ea756f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,13 @@ Changes in version 0.2.0.35 - 2009-??-??
       Found by lark, and by automated fuzzing.
 
   o Major bugfixes:
+    - Finally fix the bug where dynamic-IP relays disappear when their
+      IP address changes: directory mirrors were mistakenly telling
+      them their old address if they asked via begin_dir, so they
+      never got an accurate answer about their new address, so they
+      just vanished after a day. For belt-and-suspenders, relays that
+      don't set Address in their config now avoid using begin_dir for
+      all direct connections. Should fix bugs 827, 883, and 900.
     - Fix a timing-dependent, allocator-dependent, DNS-related crash bug
       that would occur on some exit nodes when DNS failures and timeouts
       occurred in certain patterns.  Fix for bug 957.
diff --git a/doc/TODO.020 b/doc/TODO.020
index ebdd43c..902cce6 100644
--- a/doc/TODO.020
+++ b/doc/TODO.020
@@ -3,7 +3,7 @@
 description of the patch.)
 
 Backport for 0.2.0:
-  - r19291, r19292, r19295, r19296: Dir mirrors tell relays their actual
+  o r19291, r19292, r19295, r19296: Dir mirrors tell relays their actual
     IP address, not just the address listed in the directory currently.
 
 Backport for 0.2.0 once better tested:
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index d9f4787..0474a46 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2458,8 +2458,12 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
                                    end_payload, 1, NULL);
       return 0;
     }
-    if (or_circ && or_circ->p_conn && or_circ->p_conn->_base.address)
-      address = tor_strdup(or_circ->p_conn->_base.address);
+    /* Make sure to get the 'real' address of the previous hop: the
+     * caller might want to know whether his IP address has changed, and
+     * we might already have corrected _base.addr[ess] for the relay's
+     * canonical IP address. */
+    if (or_circ && or_circ->p_conn)
+      address = tor_dup_addr(or_circ->p_conn->real_addr);
     else
       address = tor_strdup("127.0.0.1");
     port = 1; /* XXXX This value is never actually used anywhere, and there
@@ -2533,8 +2537,8 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
 
   if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
     tor_assert(or_circ);
-    if (or_circ->p_conn && or_circ->p_conn->_base.addr)
-      n_stream->_base.addr = or_circ->p_conn->_base.addr;
+    if (or_circ->p_conn && &or_circ->p_conn->real_addr)
+      n_stream->_base.addr = or_circ->p_conn->real_addr;
     return connection_exit_connect_dir(n_stream);
   }
 
@@ -2718,7 +2722,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
 
   dirconn->_base.addr = exitconn->_base.addr;
   dirconn->_base.port = 0;
-  dirconn->_base.address = tor_strdup(circ->p_conn->_base.address);
+  dirconn->_base.address = tor_strdup(exitconn->_base.address);
   dirconn->_base.type = CONN_TYPE_DIR;
   dirconn->_base.purpose = DIR_PURPOSE_SERVER;
   dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
diff --git a/src/or/directory.c b/src/or/directory.c
index 46721e7..9362c21 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -635,7 +635,8 @@ directory_command_should_use_begindir(or_options_t *options, uint32_t addr,
     return 0; /* We don't know an ORPort -- no chance. */
   if (!anonymized_connection)
     if (!fascist_firewall_allows_address_or(addr, or_port) ||
-        directory_fetches_from_authorities(options))
+        directory_fetches_from_authorities(options) ||
+        (server_mode(options) && !options->Address))
       return 0; /* We're firewalled or are acting like a relay -- also no. */
   if (!options->TunnelDirConns &&
       router_purpose != ROUTER_PURPOSE_BRIDGE)
-- 
1.5.6.5



More information about the tor-commits mailing list