Merge remote-tracking branch 'public/bug10163'

This commit is contained in:
Nick Mathewson 2014-08-26 09:44:16 -04:00
commit fdb7fc70d0
5 changed files with 56 additions and 392 deletions

16
changes/prop215 Normal file
View File

@ -0,0 +1,16 @@
o Removed features (directory authorities):
- Directory authorities no longer advertise or support consensus
methods 1 through 12 inclusive. These consensus methods were
obsolete and/or insecure: maintaining the ability to support them
served no good purpose. Implements part of proposal 215;
closes ticket 10163.
o Minor features (directory authorities)
- If a directory authority can't find a best consensus method in the
votes that it holds, it now falls back to its favorite consensus
method. Previously, it fell back to method 1. Neither of these is
likely to get enough signatures, but "fall back to favorite"
doesn't require us to maintain support an obsolete consensus
method. Implements another part of proposal 215.

View File

@ -109,7 +109,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
char *params;
authority_cert_t *cert = v3_ns->cert;
char *methods =
make_consensus_method_list(1, MAX_SUPPORTED_CONSENSUS_METHOD, " ");
make_consensus_method_list(MIN_SUPPORTED_CONSENSUS_METHOD,
MAX_SUPPORTED_CONSENSUS_METHOD, " ");
format_iso_time(published, v3_ns->published);
format_iso_time(va, v3_ns->valid_after);
format_iso_time(fu, v3_ns->fresh_until);
@ -452,8 +453,7 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
smartlist_free(alt_orports);
}
if (consensus_method >= MIN_METHOD_FOR_MICRODESC &&
microdesc_digest256_out) {
if (microdesc_digest256_out) {
smartlist_t *digests = smartlist_new();
const char *best_microdesc_digest;
SMARTLIST_FOREACH_BEGIN(votes, vote_routerstatus_t *, rs) {
@ -535,7 +535,8 @@ compute_consensus_method(smartlist_t *votes)
static int
consensus_method_is_supported(int method)
{
return (method >= 1) && (method <= MAX_SUPPORTED_CONSENSUS_METHOD);
return (method >= MIN_SUPPORTED_CONSENSUS_METHOD) &&
(method <= MAX_SUPPORTED_CONSENSUS_METHOD);
}
/** Return a newly allocated string holding the numbers between low and high
@ -599,6 +600,7 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
const int n_votes = smartlist_len(votes);
smartlist_t *output;
smartlist_t *param_list = smartlist_new();
(void) method;
/* We require that the parameter lists in the votes are well-formed: that
is, that their keywords are unique and sorted, and that their values are
@ -645,8 +647,7 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
/* We've reached the end of a series. */
/* Make sure enough authorities voted on this param, unless the
* the consensus method we use is too old for that. */
if (method < MIN_METHOD_FOR_MAJORITY_PARAMS ||
i > total_authorities/2 ||
if (i > total_authorities/2 ||
i >= MIN_VOTES_FOR_PARAM) {
int32_t median = median_int32(vals, i);
char *out_string = tor_malloc(64+cur_param_len);
@ -999,300 +1000,6 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
return 1;
}
/**
* This function computes the bandwidth weights for consensus method 9.
*
* It has been obsoleted in favor of consensus method 10.
*/
static void
networkstatus_compute_bw_weights_v9(smartlist_t *chunks, int64_t G, int64_t M,
int64_t E, int64_t D, int64_t T,
int64_t weight_scale)
{
int64_t Wgg = -1, Wgd = -1;
int64_t Wmg = -1, Wme = -1, Wmd = -1;
int64_t Wed = -1, Wee = -1;
const char *casename;
if (G <= 0 || M <= 0 || E <= 0 || D <= 0) {
log_warn(LD_DIR, "Consensus with empty bandwidth: "
"G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
" D="I64_FORMAT" T="I64_FORMAT,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
return;
}
/*
* Computed from cases in 3.4.3 of dir-spec.txt
*
* 1. Neither are scarce
* 2. Both Guard and Exit are scarce
* a. R+D <= S
* b. R+D > S
* 3. One of Guard or Exit is scarce
* a. S+D < T/3
* b. S+D >= T/3
*/
if (3*E >= T && 3*G >= T) { // E >= T/3 && G >= T/3
bw_weights_error_t berr = 0;
/* Case 1: Neither are scarce.
*
* Attempt to ensure that we have a large amount of exit bandwidth
* in the middle position.
*/
casename = "Case 1 (Wme*E = Wmd*D)";
Wgg = (weight_scale*(D+E+G+M))/(3*G);
if (D==0) Wmd = 0;
else Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D);
Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E);
Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E);
Wgd = 0;
Wmg = weight_scale - Wgg;
Wed = weight_scale - Wmd;
berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed,
weight_scale, G, M, E, D, T, 10, 1);
if (berr) {
log_warn(LD_DIR, "Bw Weights error %d for case %s. "
"G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
" D="I64_FORMAT" T="I64_FORMAT,
berr, casename,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
}
} else if (3*E < T && 3*G < T) { // E < T/3 && G < T/3
int64_t R = MIN(E, G);
int64_t S = MAX(E, G);
/*
* Case 2: Both Guards and Exits are scarce
* Balance D between E and G, depending upon
* D capacity and scarcity.
*/
if (R+D < S) { // Subcase a
Wgg = weight_scale;
Wee = weight_scale;
Wmg = 0;
Wme = 0;
Wmd = 0;
if (E < G) {
casename = "Case 2a (E scarce)";
Wed = weight_scale;
Wgd = 0;
} else { /* E >= G */
casename = "Case 2a (G scarce)";
Wed = 0;
Wgd = weight_scale;
}
} else { // Subcase b: R+D > S
bw_weights_error_t berr = 0;
casename = "Case 2b (Wme*E == Wmd*D)";
if (D != 0) {
Wgg = weight_scale;
Wgd = (weight_scale*(D + E - 2*G + M))/(3*D); // T/3 >= G (Ok)
Wmd = (weight_scale*(D + E + G - 2*M))/(6*D); // T/3 >= M
Wme = (weight_scale*(D + E + G - 2*M))/(6*E);
Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E); // 2E+M >= T/3
Wmg = 0;
Wed = weight_scale - Wgd - Wmd;
berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed,
weight_scale, G, M, E, D, T, 10, 1);
}
if (D == 0 || berr) { // Can happen if M > T/3
casename = "Case 2b (E=G)";
Wgg = weight_scale;
Wee = weight_scale;
Wmg = 0;
Wme = 0;
Wmd = 0;
if (D == 0) Wgd = 0;
else Wgd = (weight_scale*(D+E-G))/(2*D);
Wed = weight_scale - Wgd;
berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
Wed, weight_scale, G, M, E, D, T, 10, 1);
}
if (berr != BW_WEIGHTS_NO_ERROR &&
berr != BW_WEIGHTS_BALANCE_MID_ERROR) {
log_warn(LD_DIR, "Bw Weights error %d for case %s. "
"G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
" D="I64_FORMAT" T="I64_FORMAT,
berr, casename,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
}
}
} else { // if (E < T/3 || G < T/3) {
int64_t S = MIN(E, G);
// Case 3: Exactly one of Guard or Exit is scarce
if (!(3*E < T || 3*G < T) || !(3*G >= T || 3*E >= T)) {
log_warn(LD_BUG,
"Bw-Weights Case 3 but with G="I64_FORMAT" M="
I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
}
if (3*(S+D) < T) { // Subcase a: S+D < T/3
if (G < E) {
casename = "Case 3a (G scarce)";
Wgg = Wgd = weight_scale;
Wmd = Wed = Wmg = 0;
// Minor subcase, if E is more scarce than M,
// keep its bandwidth in place.
if (E < M) Wme = 0;
else Wme = (weight_scale*(E-M))/(2*E);
Wee = weight_scale-Wme;
} else { // G >= E
casename = "Case 3a (E scarce)";
Wee = Wed = weight_scale;
Wmd = Wgd = Wme = 0;
// Minor subcase, if G is more scarce than M,
// keep its bandwidth in place.
if (G < M) Wmg = 0;
else Wmg = (weight_scale*(G-M))/(2*G);
Wgg = weight_scale-Wmg;
}
} else { // Subcase b: S+D >= T/3
bw_weights_error_t berr = 0;
// D != 0 because S+D >= T/3
if (G < E) {
casename = "Case 3b (G scarce, Wme*E == Wmd*D)";
Wgd = (weight_scale*(D + E - 2*G + M))/(3*D);
Wmd = (weight_scale*(D + E + G - 2*M))/(6*D);
Wme = (weight_scale*(D + E + G - 2*M))/(6*E);
Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E);
Wgg = weight_scale;
Wmg = 0;
Wed = weight_scale - Wgd - Wmd;
berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
Wed, weight_scale, G, M, E, D, T, 10, 1);
} else { // G >= E
casename = "Case 3b (E scarce, Wme*E == Wmd*D)";
Wgg = (weight_scale*(D + E + G + M))/(3*G);
Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D);
Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E);
Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E);
Wgd = 0;
Wmg = weight_scale - Wgg;
Wed = weight_scale - Wmd;
berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
Wed, weight_scale, G, M, E, D, T, 10, 1);
}
if (berr) {
log_warn(LD_DIR, "Bw Weights error %d for case %s. "
"G="I64_FORMAT" M="I64_FORMAT
" E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT,
berr, casename,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
}
}
}
/* We cast down the weights to 32 bit ints on the assumption that
* weight_scale is ~= 10000. We need to ensure a rogue authority
* doesn't break this assumption to rig our weights */
tor_assert(0 < weight_scale && weight_scale <= INT32_MAX);
if (Wgg < 0 || Wgg > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wgg="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wgg),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wgg = MAX(MIN(Wgg, weight_scale), 0);
}
if (Wgd < 0 || Wgd > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wgd="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wgd),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wgd = MAX(MIN(Wgd, weight_scale), 0);
}
if (Wmg < 0 || Wmg > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wmg="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wmg),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wmg = MAX(MIN(Wmg, weight_scale), 0);
}
if (Wme < 0 || Wme > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wme="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wme),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wme = MAX(MIN(Wme, weight_scale), 0);
}
if (Wmd < 0 || Wmd > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wmd="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wmd),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wmd = MAX(MIN(Wmd, weight_scale), 0);
}
if (Wee < 0 || Wee > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wee="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wee),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wee = MAX(MIN(Wee, weight_scale), 0);
}
if (Wed < 0 || Wed > weight_scale) {
log_warn(LD_DIR, "Bw %s: Wed="I64_FORMAT"! G="I64_FORMAT
" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename, I64_PRINTF_ARG(Wed),
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
Wed = MAX(MIN(Wed, weight_scale), 0);
}
// Add consensus weight keywords
smartlist_add(chunks, tor_strdup("bandwidth-weights "));
/*
* Provide Wgm=Wgg, Wmm=1, Wem=Wee, Weg=Wed. May later determine
* that middle nodes need different bandwidth weights for dirport traffic,
* or that weird exit policies need special weight, or that bridges
* need special weight.
*
* NOTE: This list is sorted.
*/
smartlist_add_asprintf(chunks,
"Wbd=%d Wbe=%d Wbg=%d Wbm=%d "
"Wdb=%d "
"Web=%d Wed=%d Wee=%d Weg=%d Wem=%d "
"Wgb=%d Wgd=%d Wgg=%d Wgm=%d "
"Wmb=%d Wmd=%d Wme=%d Wmg=%d Wmm=%d\n",
(int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale,
(int)weight_scale,
(int)weight_scale, (int)Wed, (int)Wee, (int)Wed, (int)Wee,
(int)weight_scale, (int)Wgd, (int)Wgg, (int)Wgg,
(int)weight_scale, (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale);
log_notice(LD_CIRC, "Computed bandwidth weights for %s with v9: "
"G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
" T="I64_FORMAT,
casename,
I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
}
/** Given a list of vote networkstatus_t in <b>votes</b>, our public
* authority <b>identity_key</b>, our private authority <b>signing_key</b>,
@ -1344,7 +1051,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
log_warn(LD_DIR, "The other authorities will use consensus method %d, "
"which I don't support. Maybe I should upgrade!",
consensus_method);
consensus_method = 1;
consensus_method = MAX_SUPPORTED_CONSENSUS_METHOD;
}
/* Compute medians of time-related things, and figure out how many
@ -1435,10 +1142,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
flavor == FLAV_NS ? "" : " ",
flavor == FLAV_NS ? "" : flavor_name);
if (consensus_method >= 2) {
smartlist_add_asprintf(chunks, "consensus-method %d\n",
consensus_method);
}
smartlist_add_asprintf(chunks, "consensus-method %d\n",
consensus_method);
smartlist_add_asprintf(chunks,
"valid-after %s\n"
@ -1455,14 +1160,12 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(flaglist);
}
if (consensus_method >= MIN_METHOD_FOR_PARAMS) {
params = dirvote_compute_params(votes, consensus_method,
total_authorities);
if (params) {
smartlist_add(chunks, tor_strdup("params "));
smartlist_add(chunks, params);
smartlist_add(chunks, tor_strdup("\n"));
}
params = dirvote_compute_params(votes, consensus_method,
total_authorities);
if (params) {
smartlist_add(chunks, tor_strdup("params "));
smartlist_add(chunks, params);
smartlist_add(chunks, tor_strdup("\n"));
}
/* Sort the votes. */
@ -1476,8 +1179,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
e->digest = get_voter(v)->identity_digest;
e->is_legacy = 0;
smartlist_add(dir_sources, e);
if (consensus_method >= 3 &&
!tor_digest_is_zero(get_voter(v)->legacy_id_digest)) {
if (!tor_digest_is_zero(get_voter(v)->legacy_id_digest)) {
dir_src_ent_t *e_legacy = tor_malloc_zero(sizeof(dir_src_ent_t));
e_legacy->v = v;
e_legacy->digest = get_voter(v)->legacy_id_digest;
@ -1493,9 +1195,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
networkstatus_t *v = e->v;
networkstatus_voter_info_t *voter = get_voter(v);
if (e->is_legacy)
tor_assert(consensus_method >= 2);
base16_encode(fingerprint, sizeof(fingerprint), e->digest, DIGEST_LEN);
base16_encode(votedigest, sizeof(votedigest), voter->vote_digest,
DIGEST_LEN);
@ -1568,7 +1267,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
* is the same flag as votes[j]->known_flags[b]. */
int *named_flag; /* Index of the flag "Named" for votes[j] */
int *unnamed_flag; /* Index of the flag "Unnamed" for votes[j] */
int chosen_named_idx;
int n_authorities_measuring_bandwidth;
strmap_t *name_to_id_map = strmap_new();
@ -1586,7 +1284,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
unnamed_flag = tor_calloc(sizeof(int), smartlist_len(votes));
for (i = 0; i < smartlist_len(votes); ++i)
unnamed_flag[i] = named_flag[i] = -1;
chosen_named_idx = smartlist_string_pos(flags, "Named");
/* Build the flag indexes. Note that no vote can have more than 64 members
* for known_flags, so no value will be greater than 63, so it's safe to
@ -1616,7 +1313,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
} SMARTLIST_FOREACH_END(v);
/* Named and Unnamed get treated specially */
if (consensus_method >= 2) {
{
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
uint64_t nf;
if (named_flag[v_sl_idx]<0)
@ -1785,10 +1482,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
strlcpy(rs_out.nickname, rs->status.nickname, sizeof(rs_out.nickname));
}
if (consensus_method == 1) {
is_named = chosen_named_idx >= 0 &&
(!naming_conflict && flag_counts[chosen_named_idx]);
} else {
{
const char *d = strmap_get_lc(name_to_id_map, rs_out.nickname);
if (!d) {
is_named = is_unnamed = 0;
@ -1805,7 +1499,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
if (!strcmp(fl, "Named")) {
if (is_named)
smartlist_add(chosen_flags, (char*)fl);
} else if (!strcmp(fl, "Unnamed") && consensus_method >= 2) {
} else if (!strcmp(fl, "Unnamed")) {
if (is_unnamed)
smartlist_add(chosen_flags, (char*)fl);
} else {
@ -1825,7 +1519,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Starting with consensus method 4 we do not list servers
* that are not running in a consensus. See Proposal 138 */
if (consensus_method >= 4 && !is_running)
if (!is_running)
continue;
/* Pick the version. */
@ -1837,11 +1531,11 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
/* Pick a bandwidth */
if (consensus_method >= 6 && num_mbws > 2) {
if (num_mbws > 2) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 0;
rs_out.bandwidth_kb = median_uint32(measured_bws_kb, num_mbws);
} else if (consensus_method >= 5 && num_bandwidths > 0) {
} else if (num_bandwidths > 0) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 1;
rs_out.bandwidth_kb = median_uint32(bandwidths_kb, num_bandwidths);
@ -1855,11 +1549,9 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
/* Fix bug 2203: Do not count BadExit nodes as Exits for bw weights */
if (consensus_method >= MIN_METHOD_TO_CUT_BADEXIT_WEIGHT) {
is_exit = is_exit && !is_bad_exit;
}
is_exit = is_exit && !is_bad_exit;
if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS) {
{
if (rs_out.has_bandwidth) {
T += rs_out.bandwidth_kb;
if (is_exit && is_guard)
@ -1890,7 +1582,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
* the policy that was most often listed in votes, again breaking
* ties like in the previous case.
*/
if (consensus_method >= 5) {
{
/* Okay, go through all the votes for this router. We prepared
* that list previously */
const char *chosen_exitsummary = NULL;
@ -1961,7 +1653,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
if (flavor == FLAV_MICRODESC &&
consensus_method >= MIN_METHOD_FOR_MANDATORY_MICRODESC &&
tor_digest256_is_zero(microdesc_digest)) {
/* With no microdescriptor digest, we omit the entry entirely. */
continue;
@ -2027,13 +1718,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(measured_bws_kb);
}
if (consensus_method >= MIN_METHOD_FOR_FOOTER) {
/* Starting with consensus method 9, we clearly mark the directory
* footer region */
smartlist_add(chunks, tor_strdup("directory-footer\n"));
}
/* Mark the directory footer region */
smartlist_add(chunks, tor_strdup("directory-footer\n"));
if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS) {
{
int64_t weight_scale = BW_WEIGHT_SCALE;
char *bw_weight_param = NULL;
@ -2066,13 +1754,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
}
if (consensus_method < 10) {
networkstatus_compute_bw_weights_v9(chunks, G, M, E, D, T, weight_scale);
added_weights = 1;
} else {
added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
T, weight_scale);
}
added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
T, weight_scale);
}
/* Add a signature. */
@ -2113,7 +1796,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
smartlist_add(chunks, signature);
if (legacy_id_key_digest && legacy_signing_key && consensus_method >= 3) {
if (legacy_id_key_digest && legacy_signing_key) {
smartlist_add(chunks, tor_strdup("directory-signature "));
base16_encode(fingerprint, sizeof(fingerprint),
legacy_id_key_digest, DIGEST_LEN);
@ -2149,7 +1832,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
goto done;
}
// Verify balancing parameters
if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS && added_weights) {
if (added_weights) {
networkstatus_verify_bw_weights(c, consensus_method);
}
networkstatus_vote_free(c);
@ -3661,7 +3344,7 @@ static const struct consensus_method_range_t {
int low;
int high;
} microdesc_consensus_methods[] = {
{MIN_METHOD_FOR_MICRODESC, MIN_METHOD_FOR_A_LINES - 1},
{MIN_SUPPORTED_CONSENSUS_METHOD, MIN_METHOD_FOR_A_LINES - 1},
{MIN_METHOD_FOR_A_LINES, MIN_METHOD_FOR_P6_LINES - 1},
{MIN_METHOD_FOR_P6_LINES, MIN_METHOD_FOR_NTOR_KEY - 1},
{MIN_METHOD_FOR_NTOR_KEY, MIN_METHOD_FOR_ID_HASH_IN_MD - 1},

View File

@ -21,28 +21,12 @@
/** Smallest allowable voting interval. */
#define MIN_VOTE_INTERVAL 300
/** The lowest consensus method that we currently support. */
#define MIN_SUPPORTED_CONSENSUS_METHOD 13
/** The highest consensus method that we currently support. */
#define MAX_SUPPORTED_CONSENSUS_METHOD 18
/** Lowest consensus method that contains a 'directory-footer' marker */
#define MIN_METHOD_FOR_FOOTER 9
/** Lowest consensus method that contains bandwidth weights */
#define MIN_METHOD_FOR_BW_WEIGHTS 9
/** Lowest consensus method that contains consensus params */
#define MIN_METHOD_FOR_PARAMS 7
/** 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
/** Lowest consensus method where microdesc consensuses omit any entry
* with no microdesc. */
#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13

View File

@ -2047,6 +2047,7 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
double Gtotal=0, Mtotal=0, Etotal=0;
const char *casename = NULL;
int valid = 1;
(void) consensus_method;
weight_scale = networkstatus_get_weight_scale_param(ns);
Wgg = networkstatus_get_bw_weight(ns, "Wgg", -1);
@ -2126,12 +2127,8 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
// 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;
}
/* Bug #2203: Don't count bad exits as exits for balancing */
is_exit = rs->is_exit && !rs->is_bad_exit;
if (rs->has_bandwidth) {
T += rs->bandwidth_kb;
if (is_exit && rs->is_possible_guard) {

View File

@ -736,10 +736,6 @@ test_dir_param_voting(void)
/* Do the first tests without adding all the other votes, for
* networks without many dirauths. */
res = dirvote_compute_params(votes, 11, 6);
test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-99");
tor_free(res);
res = dirvote_compute_params(votes, 12, 2);
test_streq(res, "");
tor_free(res);
@ -750,10 +746,6 @@ test_dir_param_voting(void)
smartlist_add(votes, &vote2);
res = dirvote_compute_params(votes, 11, 2);
test_streq(res, "ab=27 abcd=20 cw=5 x-yz=-99");
tor_free(res);
res = dirvote_compute_params(votes, 12, 2);
test_streq(res, "ab=27 cw=5 x-yz=-99");
tor_free(res);
@ -768,10 +760,6 @@ test_dir_param_voting(void)
smartlist_add(votes, &vote3);
res = dirvote_compute_params(votes, 11, 3);
test_streq(res, "ab=27 abcd=20 c=60 cw=50 x-yz=-9 zzzzz=101");
tor_free(res);
res = dirvote_compute_params(votes, 12, 3);
test_streq(res, "ab=27 abcd=20 cw=50 x-yz=-9");
tor_free(res);
@ -786,10 +774,6 @@ test_dir_param_voting(void)
smartlist_add(votes, &vote4);
res = dirvote_compute_params(votes, 11, 4);
test_streq(res, "ab=90 abcd=20 c=1 cw=50 x-yz=-9 zzzzz=101");
tor_free(res);
res = dirvote_compute_params(votes, 12, 4);
test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-9");
tor_free(res);