mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 22:58:50 +01:00
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:
parent
f6a2f088fd
commit
651e49713c
4 changed files with 16 additions and 6 deletions
|
@ -1913,7 +1913,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix bug 2203: Do not count BadExit nodes as Exits for bw weights */
|
/* 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;
|
is_exit = is_exit && !is_bad_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2210,7 +2210,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
|
||||||
}
|
}
|
||||||
// Verify balancing parameters
|
// Verify balancing parameters
|
||||||
if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS && added_weights) {
|
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);
|
networkstatus_vote_free(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
/** Lowest consensus method that generates microdescriptors */
|
/** Lowest consensus method that generates microdescriptors */
|
||||||
#define MIN_METHOD_FOR_MICRODESC 8
|
#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
|
/** Lowest consensus method that ensures a majority of authorities voted
|
||||||
* for a param. */
|
* for a param. */
|
||||||
#define MIN_METHOD_FOR_MAJORITY_PARAMS 12
|
#define MIN_METHOD_FOR_MAJORITY_PARAMS 12
|
||||||
|
|
|
@ -2257,7 +2257,7 @@ networkstatus_v2_parse_from_string(const char *s)
|
||||||
|
|
||||||
/** Verify the bandwidth weights of a network status document */
|
/** Verify the bandwidth weights of a network status document */
|
||||||
int
|
int
|
||||||
networkstatus_verify_bw_weights(networkstatus_t *ns)
|
networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
|
||||||
{
|
{
|
||||||
int64_t weight_scale;
|
int64_t weight_scale;
|
||||||
int64_t G=0, M=0, E=0, D=0, T=0;
|
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
|
// Then, gather G, M, E, D, T to determine case
|
||||||
SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
|
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) {
|
if (rs->has_bandwidth) {
|
||||||
T += rs->bandwidth;
|
T += rs->bandwidth;
|
||||||
if (rs->is_exit && rs->is_possible_guard) {
|
if (is_exit && rs->is_possible_guard) {
|
||||||
D += rs->bandwidth;
|
D += rs->bandwidth;
|
||||||
Gtotal += Wgd*rs->bandwidth;
|
Gtotal += Wgd*rs->bandwidth;
|
||||||
Mtotal += Wmd*rs->bandwidth;
|
Mtotal += Wmd*rs->bandwidth;
|
||||||
Etotal += Wed*rs->bandwidth;
|
Etotal += Wed*rs->bandwidth;
|
||||||
} else if (rs->is_exit) {
|
} else if (is_exit) {
|
||||||
E += rs->bandwidth;
|
E += rs->bandwidth;
|
||||||
Mtotal += Wme*rs->bandwidth;
|
Mtotal += Wme*rs->bandwidth;
|
||||||
Etotal += Wee*rs->bandwidth;
|
Etotal += Wee*rs->bandwidth;
|
||||||
|
|
|
@ -54,7 +54,7 @@ void dump_distinct_digest_count(int severity);
|
||||||
int compare_routerstatus_entries(const void **_a, const void **_b);
|
int compare_routerstatus_entries(const void **_a, const void **_b);
|
||||||
int compare_vote_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);
|
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,
|
networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
|
||||||
const char **eos_out,
|
const char **eos_out,
|
||||||
networkstatus_type_t ns_type);
|
networkstatus_type_t ns_type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue