diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2012-08-20 19:03:00 -0700 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2012-08-23 19:47:08 -0700 |
commit | 880c71304b6592fccd812315d8c27d234b694221 (patch) | |
tree | 1e7242cbecedeba47c64ca3f9072b26c5d2939d8 /src/or/circuitbuild.c | |
parent | 88859b2ff1fdd4e5f4fab8ad818131ea3c2dd1c8 (diff) | |
download | tor-880c71304b6592fccd812315d8c27d234b694221.tar tor-880c71304b6592fccd812315d8c27d234b694221.tar.gz |
Disable path bias accounting if we have no guards.
This should eliminate a lot of notices for Directory Authorities and other
situations where circuits built without using guard nodes.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 39a223b2f..35a32d864 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2638,6 +2638,14 @@ pathbias_count_first_hop(origin_circuit_t *circ) RATELIM_INIT(FIRST_HOP_NOTICE_INTERVAL); char *rate_msg = NULL; + /* We can't do path bias accounting without entry guards. + * Testing and controller circuits also have no guards. */ + if (get_options()->UseEntryGuards == 0 || + circ->_base.purpose == CIRCUIT_PURPOSE_TESTING || + circ->_base.purpose == CIRCUIT_PURPOSE_CONTROLLER) { + return 0; + } + /* Completely ignore one hop circuits */ if (circ->build_state->onehop_tunnel) { tor_assert(circ->build_state->desired_path_len == 1); @@ -2732,6 +2740,14 @@ pathbias_count_success(origin_circuit_t *circ) RATELIM_INIT(SUCCESS_NOTICE_INTERVAL); char *rate_msg = NULL; + /* We can't do path bias accounting without entry guards. + * Testing and controller circuits also have no guards. */ + if (get_options()->UseEntryGuards == 0 || + circ->_base.purpose == CIRCUIT_PURPOSE_TESTING || + circ->_base.purpose == CIRCUIT_PURPOSE_CONTROLLER) { + return; + } + /* Ignore one hop circuits */ if (circ->build_state->onehop_tunnel) { tor_assert(circ->build_state->desired_path_len == 1); @@ -2770,7 +2786,10 @@ pathbias_count_success(origin_circuit_t *circ) guard->circuit_successes, guard->first_hops, guard->nickname, hex_str(guard->identity, DIGEST_LEN)); } - } else { + /* In rare cases, CIRCUIT_PURPOSE_TESTING can get converted to + * CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT and have no guards here. + * No need to log that case. */ + } else if (circ->_base.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) { if ((rate_msg = rate_limit_log(&success_notice_limit, approx_time()))) { log_notice(LD_BUG, |