aboutsummaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2013-03-25 16:04:30 -0700
committerNick Mathewson <nickm@torproject.org>2013-04-03 09:32:15 -0400
commit2b05a8c6716f1c7e07e658719c093723809e19a6 (patch)
tree0e037a4452a23852a7e166f8b083594eb5c69d2a /src/or/entrynodes.c
parent856d57531b3173ef04a9f8f69c5e6e6c16c25c00 (diff)
downloadtor-2b05a8c6716f1c7e07e658719c093723809e19a6.tar.gz
tor-2b05a8c6716f1c7e07e658719c093723809e19a6.zip
Clip invalid path bias counts at startup.
There was a bug in Tor prior to 0.2.4.10-alpha that allowed counts to become invalid. Clipping the counts at startup allows us to rule out log messages due to corruption from these prior Tor versions.
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 6b21d1092b..3234f4f3c7 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1211,6 +1211,21 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
continue;
}
+ if (use_cnt < success_cnt) {
+ int severity = LOG_INFO;
+ /* If this state file was written by a Tor that would have
+ * already fixed it, then the overcounting bug is still there.. */
+ if (tor_version_as_new_as(state_version, "0.2.4.12-alpha")) {
+ severity = LOG_NOTICE;
+ }
+ log_fn(severity, LD_BUG,
+ "State file contains unexpectedly high usage success "
+ "counts %lf/%lf for Guard %s ($%s)",
+ success_cnt, use_cnt,
+ node->nickname, hex_str(node->identity, DIGEST_LEN));
+ success_cnt = use_cnt;
+ }
+
node->use_attempts = use_cnt;
node->use_successes = success_cnt;
@@ -1261,6 +1276,21 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
unusable = 0;
}
+ if (hop_cnt < success_cnt) {
+ int severity = LOG_INFO;
+ /* If this state file was written by a Tor that would have
+ * already fixed it, then the overcounting bug is still there.. */
+ if (tor_version_as_new_as(state_version, "0.2.4.12-alpha")) {
+ severity = LOG_NOTICE;
+ }
+ log_fn(severity, LD_BUG,
+ "State file contains unexpectedly high success counts "
+ "%lf/%lf for Guard %s ($%s)",
+ success_cnt, hop_cnt,
+ node->nickname, hex_str(node->identity, DIGEST_LEN));
+ success_cnt = hop_cnt;
+ }
+
node->circ_attempts = hop_cnt;
node->circ_successes = success_cnt;