summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-04-03 09:35:57 -0400
committerNick Mathewson <nickm@torproject.org>2013-04-03 09:35:57 -0400
commit5efe5067670960384f0e4a42b5073e86fe3824a7 (patch)
tree9ce7d2ba8ba0ac65346335a15b2605a352cb1ae2 /src
parent856d57531b3173ef04a9f8f69c5e6e6c16c25c00 (diff)
parent3207ace6050ea0463cfc26d6e95d737785baa5fa (diff)
downloadtor-5efe5067670960384f0e4a42b5073e86fe3824a7.tar.gz
tor-5efe5067670960384f0e4a42b5073e86fe3824a7.zip
Merge remote-tracking branch 'public/bug8235-diagnostic-rebased' into maint-0.2.4
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitbuild.c34
-rw-r--r--src/or/entrynodes.c30
2 files changed, 64 insertions, 0 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 7db2b70bf7..df56877646 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1734,6 +1734,13 @@ pathbias_count_use_success(origin_circuit_t *circ)
guard->use_successes++;
entry_guards_changed();
+ if (guard->use_attempts < guard->use_successes) {
+ log_notice(LD_BUG, "Unexpectedly high use successes counts (%f/%f) "
+ "for guard %s=%s",
+ guard->use_successes, guard->use_attempts,
+ guard->nickname, hex_str(guard->identity, DIGEST_LEN));
+ }
+
log_debug(LD_CIRC,
"Marked circuit %d (%f/%f) as used successfully for guard "
"%s ($%s).",
@@ -2481,6 +2488,9 @@ pathbias_scale_close_rates(entry_guard_t *guard)
int opened_built = pathbias_count_circs_in_states(guard,
PATH_STATE_BUILD_SUCCEEDED,
PATH_STATE_USE_FAILED);
+ /* Verify that the counts are sane before and after scaling */
+ int counts_are_sane = (guard->circ_attempts >= guard->circ_successes);
+
guard->circ_attempts -= opened_attempts;
guard->circ_successes -= opened_built;
@@ -2502,6 +2512,16 @@ pathbias_scale_close_rates(entry_guard_t *guard)
guard->circ_successes, guard->successful_circuits_closed,
guard->circ_attempts, opened_built, opened_attempts,
guard->nickname, hex_str(guard->identity, DIGEST_LEN));
+
+ /* Have the counts just become invalid by this scaling attempt? */
+ if (counts_are_sane && guard->circ_attempts < guard->circ_successes) {
+ log_notice(LD_BUG,
+ "Scaling has mangled pathbias counts to %f/%f (%d/%d open) "
+ "for guard %s ($%s)",
+ guard->circ_successes, guard->circ_attempts, opened_built,
+ opened_attempts, guard->nickname,
+ hex_str(guard->identity, DIGEST_LEN));
+ }
}
}
@@ -2524,6 +2544,9 @@ pathbias_scale_use_rates(entry_guard_t *guard)
double scale_ratio = pathbias_get_scale_ratio(options);
int opened_attempts = pathbias_count_circs_in_states(guard,
PATH_STATE_USE_ATTEMPTED, PATH_STATE_USE_SUCCEEDED);
+ /* Verify that the counts are sane before and after scaling */
+ int counts_are_sane = (guard->use_attempts >= guard->use_successes);
+
guard->use_attempts -= opened_attempts;
guard->use_attempts *= scale_ratio;
@@ -2535,6 +2558,17 @@ pathbias_scale_use_rates(entry_guard_t *guard)
"Scaled pathbias use counts to %f/%f (%d open) for guard %s ($%s)",
guard->use_successes, guard->use_attempts, opened_attempts,
guard->nickname, hex_str(guard->identity, DIGEST_LEN));
+
+ /* Have the counts just become invalid by this scaling attempt? */
+ if (counts_are_sane && guard->use_attempts < guard->use_successes) {
+ log_notice(LD_BUG,
+ "Scaling has mangled pathbias usage counts to %f/%f "
+ "(%d open) for guard %s ($%s)",
+ guard->circ_successes, guard->circ_attempts,
+ opened_attempts, guard->nickname,
+ hex_str(guard->identity, DIGEST_LEN));
+ }
+
entry_guards_changed();
}
}
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;