]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When we mark a node as a sybil, mark it down and reset its uptime to 0
authorNick Mathewson <nickm@torproject.org>
Mon, 4 Feb 2013 16:11:54 +0000 (11:11 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 4 Feb 2013 16:11:54 +0000 (11:11 -0500)
This prevents bug 8147, where such nodes would accrue points towards
Guard, Fast, HSDir, and so on.

Fixes bug 8147.

changes/bug8146_etc
src/or/dirserv.c
src/or/rephist.c
src/or/rephist.h

index 274e2abe48c646a53c9207ba25c5520a7e46cc31..173ea3b58d6ab6a9ecaec7b01e36d7e57dc774ab 100644 (file)
@@ -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.
index 0c3e72f3a32df5c6033407567974d1f116956546..b59478e17df64875c33c2e287016333a92245af7 100644 (file)
@@ -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();
index 925ca881536b60f445b40215250890203243463d..34caa4b5180c1944ace886744cf30ceeafba0262 100644 (file)
@@ -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
index 5568330dd70937de52b569e2f05bf95a90f745a0..811cd8d450341d59ee8d42a44164380b6f969509 100644 (file)
@@ -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);