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.
This commit is contained in:
Mike Perry 2013-03-26 14:15:58 -07:00 committed by Nick Mathewson
parent f6a2f088fd
commit 651e49713c
4 changed files with 16 additions and 6 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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);