summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-04 11:11:54 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-04 11:11:54 -0500
commit4eff8b65305248b1e7a57d1efdf8f55039719bd7 (patch)
tree45ad7bbf37c0d5b1f583d1c072e0210786bfa080
parent61995d3e2cd7631df1fcb9fbdf9333dee24566b4 (diff)
downloadtor-4eff8b65305248b1e7a57d1efdf8f55039719bd7.tar.gz
tor-4eff8b65305248b1e7a57d1efdf8f55039719bd7.zip
When we mark a node as a sybil, mark it down and reset its uptime to 0
This prevents bug 8147, where such nodes would accrue points towards Guard, Fast, HSDir, and so on. Fixes bug 8147.
-rw-r--r--changes/bug8146_etc3
-rw-r--r--src/or/dirserv.c5
-rw-r--r--src/or/rephist.c15
-rw-r--r--src/or/rephist.h2
4 files changed, 25 insertions, 0 deletions
diff --git a/changes/bug8146_etc b/changes/bug8146_etc
index 274e2abe48..173ea3b58d 100644
--- a/changes/bug8146_etc
+++ b/changes/bug8146_etc
@@ -8,3 +8,6 @@
- Do not consider nodes with extremely low bandwidths when deciding
thresholds for various directory flags. Another fix for 8145.
+ - When marking a node as a likely sybil, reset its uptime metrics
+ to zero, so that it cannot time towards getting marked as Guard,
+ Stable, or HSDir. Fix for bug 8147.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 0c3e72f3a3..b59478e17d 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2776,6 +2776,11 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
routers_sort_by_identity(routers);
omit_as_sybil = get_possible_sybil_list(routers);
+ DIGESTMAP_FOREACH(omit_as_sybil, sybil_id, void *, ignore) {
+ (void) ignore;
+ rep_hist_make_router_pessimal(sybil_id, now);
+ } DIGESTMAP_FOREACH_END;
+
dirserv_compute_performance_thresholds(rl, omit_as_sybil);
routerstatuses = smartlist_new();
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 925ca88153..34caa4b518 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -422,6 +422,21 @@ rep_hist_note_router_unreachable(const char *id, time_t when)
}
}
+/** Mark a router with ID <b>id</b> as non-Running, and retroactively declare
+ * that it has never been running: give it no stability and no WFU. */
+void
+rep_hist_make_router_pessimal(const char *id, time_t when)
+{
+ or_history_t *hist = get_or_history(id);
+ tor_assert(hist);
+
+ rep_hist_note_router_unreachable(id, when);
+ mark_or_down(hist, when, 1);
+
+ hist->weighted_run_length = 0;
+ hist->weighted_uptime = 0;
+}
+
/** Helper: Discount all old MTBF data, if it is time to do so. Return
* the time at which we should next discount MTBF data. */
time_t
diff --git a/src/or/rephist.h b/src/or/rephist.h
index 5568330dd7..811cd8d450 100644
--- a/src/or/rephist.h
+++ b/src/or/rephist.h
@@ -24,6 +24,8 @@ void rep_hist_dump_stats(time_t now, int severity);
void rep_hist_note_bytes_read(size_t num_bytes, time_t when);
void rep_hist_note_bytes_written(size_t num_bytes, time_t when);
+void rep_hist_make_router_pessimal(const char *id, time_t when);
+
void rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when);
void rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when);