backport r19291, r19292, r19295, r19296: fix dynamic ip relay reachability

This commit is contained in:
Roger Dingledine 2009-05-31 18:18:54 -04:00 committed by Nick Mathewson
parent 74aba22040
commit 16bca35eab
4 changed files with 19 additions and 7 deletions

View File

@ -4,6 +4,13 @@ Changes in version 0.2.0.35 - 2009-??-??
Found by lark, and by automated fuzzing. Found by lark, and by automated fuzzing.
o Major bugfixes: 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 - Fix a timing-dependent, allocator-dependent, DNS-related crash bug
that would occur on some exit nodes when DNS failures and timeouts that would occur on some exit nodes when DNS failures and timeouts
occurred in certain patterns. Fix for bug 957. occurred in certain patterns. Fix for bug 957.

View File

@ -3,7 +3,7 @@
description of the patch.) description of the patch.)
Backport for 0.2.0: 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. IP address, not just the address listed in the directory currently.
Backport for 0.2.0 once better tested: Backport for 0.2.0 once better tested:

View File

@ -2458,8 +2458,12 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
end_payload, 1, NULL); end_payload, 1, NULL);
return 0; return 0;
} }
if (or_circ && or_circ->p_conn && or_circ->p_conn->_base.address) /* Make sure to get the 'real' address of the previous hop: the
address = tor_strdup(or_circ->p_conn->_base.address); * 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 else
address = tor_strdup("127.0.0.1"); address = tor_strdup("127.0.0.1");
port = 1; /* XXXX This value is never actually used anywhere, and there 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) { if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
tor_assert(or_circ); tor_assert(or_circ);
if (or_circ->p_conn && 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->_base.addr; n_stream->_base.addr = or_circ->p_conn->real_addr;
return connection_exit_connect_dir(n_stream); 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.addr = exitconn->_base.addr;
dirconn->_base.port = 0; 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.type = CONN_TYPE_DIR;
dirconn->_base.purpose = DIR_PURPOSE_SERVER; dirconn->_base.purpose = DIR_PURPOSE_SERVER;
dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT; dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;

View File

@ -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. */ return 0; /* We don't know an ORPort -- no chance. */
if (!anonymized_connection) if (!anonymized_connection)
if (!fascist_firewall_allows_address_or(addr, or_port) || 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. */ return 0; /* We're firewalled or are acting like a relay -- also no. */
if (!options->TunnelDirConns && if (!options->TunnelDirConns &&
router_purpose != ROUTER_PURPOSE_BRIDGE) router_purpose != ROUTER_PURPOSE_BRIDGE)