[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.4] Bug 8419: Apply the badexit fix from #2203 to validatio too



commit 651e49713c38b8ec2bde285001e46b61c500d10c
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date:   Tue Mar 26 14:15:58 2013 -0700

    Bug 8419: Apply the badexit fix from #2203 to validatio too
    
    This was causing dirauths to emit flag weight validation warns if there
    was a sufficiently large amount of badexit bandwidth to make a difference in
    flag weight results.
---
 src/or/dirvote.c     |    4 ++--
 src/or/dirvote.h     |    3 +++
 src/or/routerparse.c |   13 ++++++++++---
 src/or/routerparse.h |    2 +-
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index bcfe2b0..7043cef 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -1913,7 +1913,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
       }
 
       /* Fix bug 2203: Do not count BadExit nodes as Exits for bw weights */
-      if (consensus_method >= 11) {
+      if (consensus_method >= MIN_METHOD_TO_CUT_BADEXIT_WEIGHT) {
         is_exit = is_exit && !is_bad_exit;
       }
 
@@ -2210,7 +2210,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
     }
     // Verify balancing parameters
     if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS && added_weights) {
-      networkstatus_verify_bw_weights(c);
+      networkstatus_verify_bw_weights(c, consensus_method);
     }
     networkstatus_vote_free(c);
   }
diff --git a/src/or/dirvote.h b/src/or/dirvote.h
index fbb61b6..8d036d6 100644
--- a/src/or/dirvote.h
+++ b/src/or/dirvote.h
@@ -34,6 +34,9 @@
 /** Lowest consensus method that generates microdescriptors */
 #define MIN_METHOD_FOR_MICRODESC 8
 
+/** Lowest consensus method that doesn't count bad exits as exits for weight */
+#define MIN_METHOD_TO_CUT_BADEXIT_WEIGHT 11
+
 /** Lowest consensus method that ensures a majority of authorities voted
   * for a param. */
 #define MIN_METHOD_FOR_MAJORITY_PARAMS 12
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index a2b4f9e..f8edb84 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -2257,7 +2257,7 @@ networkstatus_v2_parse_from_string(const char *s)
 
 /** Verify the bandwidth weights of a network status document */
 int
-networkstatus_verify_bw_weights(networkstatus_t *ns)
+networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
 {
   int64_t weight_scale;
   int64_t G=0, M=0, E=0, D=0, T=0;
@@ -2343,14 +2343,21 @@ networkstatus_verify_bw_weights(networkstatus_t *ns)
 
   // Then, gather G, M, E, D, T to determine case
   SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
+    int is_exit = 0;
+    if (consensus_method >= MIN_METHOD_TO_CUT_BADEXIT_WEIGHT) {
+      /* Bug #2203: Don't count bad exits as exits for balancing */
+      is_exit = rs->is_exit && !rs->is_bad_exit;
+    } else {
+      is_exit = rs->is_exit;
+    }
     if (rs->has_bandwidth) {
       T += rs->bandwidth;
-      if (rs->is_exit && rs->is_possible_guard) {
+      if (is_exit && rs->is_possible_guard) {
         D += rs->bandwidth;
         Gtotal += Wgd*rs->bandwidth;
         Mtotal += Wmd*rs->bandwidth;
         Etotal += Wed*rs->bandwidth;
-      } else if (rs->is_exit) {
+      } else if (is_exit) {
         E += rs->bandwidth;
         Mtotal += Wme*rs->bandwidth;
         Etotal += Wee*rs->bandwidth;
diff --git a/src/or/routerparse.h b/src/or/routerparse.h
index 859a691..7bf7d79 100644
--- a/src/or/routerparse.h
+++ b/src/or/routerparse.h
@@ -54,7 +54,7 @@ void dump_distinct_digest_count(int severity);
 int compare_routerstatus_entries(const void **_a, const void **_b);
 int compare_vote_routerstatus_entries(const void **_a, const void **_b);
 networkstatus_v2_t *networkstatus_v2_parse_from_string(const char *s);
-int networkstatus_verify_bw_weights(networkstatus_t *ns);
+int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
 networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
                                                  const char **eos_out,
                                                  networkstatus_type_t ns_type);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits