diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-09-23 20:13:23 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-09-23 20:13:23 +0000 |
commit | 545b317e1ff387dcf58fbd82ccdead9afa979685 (patch) | |
tree | 53bea2743e872dd17c28bb097e139b60898e6aeb /src | |
parent | f28fc83ea57a3964457996238daf2f1697685185 (diff) | |
download | tor-545b317e1ff387dcf58fbd82ccdead9afa979685.tar.gz tor-545b317e1ff387dcf58fbd82ccdead9afa979685.zip |
Fix for bug 797 (by arma, with tweaks): always use create_fast for circuits where we do not know an onion key.
svn:r16942
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitbuild.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 163c16a907..2379be2386 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -537,19 +537,20 @@ inform_testing_reachability(void) return 1; } -/** Return true iff we should send a create_fast cell to build a circuit - * starting at <b>router</b>. (If <b>router</b> is NULL, we don't have - * information on the router, so assume true.) */ +/** Return true iff we should send a create_fast cell to start building a given + * circuit */ static INLINE int -should_use_create_fast_for_router(routerinfo_t *router, - origin_circuit_t *circ) +should_use_create_fast_for_circuit(origin_circuit_t *circ) { or_options_t *options = get_options(); - (void) router; /* ignore the router's version. */ - - if (!options->FastFirstHopPK) /* create_fast is disabled */ - return 0; - if (server_mode(options) && circ->cpath->extend_info->onion_key) { + tor_assert(circ->cpath); + tor_assert(circ->cpath->extend_info); + + if (!circ->cpath->extend_info->onion_key) + return 1; /* our hand is forced: only a create_fast will work. */ + if (!options->FastFirstHopPK) + return 0; /* we prefer to avoid create_fast */ + if (server_mode(options)) { /* We're a server, and we know an onion key. We can choose. * Prefer to blend in. */ return 0; @@ -589,14 +590,9 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) control_event_bootstrap(BOOTSTRAP_STATUS_CIRCUIT_CREATE, 0); router = router_get_by_digest(circ->_base.n_conn->identity_digest); - fast = should_use_create_fast_for_router(router, circ); - if (!fast && !circ->cpath->extend_info->onion_key) { - log_warn(LD_CIRC, - "Can't send create_fast, but have no onion key. Failing."); - return - END_CIRC_REASON_INTERNAL; - } + fast = should_use_create_fast_for_circuit(circ); if (!fast) { - /* We are an OR, or we are connecting to an old Tor: we should + /* We are an OR and we know the right onion key: we should * send an old slow create cell. */ cell_type = CELL_CREATE; |