Merge branch 'remove_old_consensus_methods_2018_squashed'

This commit is contained in:
Nick Mathewson 2018-04-22 20:01:09 -04:00
commit 0e8ae82a87
8 changed files with 50 additions and 214 deletions

8
changes/24378 Normal file
View File

@ -0,0 +1,8 @@
o Removed features:
- Directory authorities will no longer support voting according to any
consensus method before consensus method 25. This keeps authorities
compatible with all authorities running 0.2.9.8 and later, and does
not break any clients or relays. Implements ticket 24378 and
proposal 290.

View File

@ -25,7 +25,6 @@
#include "dircollate.h" #include "dircollate.h"
#include "dirvote.h" #include "dirvote.h"
static void dircollator_collate_by_rsa(dircollator_t *dc);
static void dircollator_collate_by_ed25519(dircollator_t *dc); static void dircollator_collate_by_ed25519(dircollator_t *dc);
/** Hashtable entry mapping a pair of digests (actually an ed25519 key and an /** Hashtable entry mapping a pair of digests (actually an ed25519 key and an
@ -208,48 +207,17 @@ dircollator_add_vote(dircollator_t *dc, networkstatus_t *v)
void void
dircollator_collate(dircollator_t *dc, int consensus_method) dircollator_collate(dircollator_t *dc, int consensus_method)
{ {
(void) consensus_method;
tor_assert(!dc->is_collated); tor_assert(!dc->is_collated);
dc->all_rsa_sha1_lst = smartlist_new(); dc->all_rsa_sha1_lst = smartlist_new();
if (consensus_method < MIN_METHOD_FOR_ED25519_ID_VOTING) dircollator_collate_by_ed25519(dc);
dircollator_collate_by_rsa(dc);
else
dircollator_collate_by_ed25519(dc);
smartlist_sort_digests(dc->all_rsa_sha1_lst); smartlist_sort_digests(dc->all_rsa_sha1_lst);
dc->is_collated = 1; dc->is_collated = 1;
} }
/**
* Collation function for RSA-only consensuses: collate the votes for each
* entry in <b>dc</b> by their RSA keys.
*
* The rule is:
* If an RSA identity key is listed by more than half of the authorities,
* include that identity, and treat all descriptors with that RSA identity
* as describing the same router.
*/
static void
dircollator_collate_by_rsa(dircollator_t *dc)
{
const int total_authorities = dc->n_authorities;
DIGESTMAP_FOREACH(dc->by_rsa_sha1, k, vote_routerstatus_t **, vrs_lst) {
int n = 0, i;
for (i = 0; i < dc->n_votes; ++i) {
if (vrs_lst[i] != NULL)
++n;
}
if (n <= total_authorities / 2)
continue;
smartlist_add(dc->all_rsa_sha1_lst, (char *)k);
} DIGESTMAP_FOREACH_END;
dc->by_collated_rsa_sha1 = dc->by_rsa_sha1;
}
/** /**
* Collation function for ed25519 consensuses: collate the votes for each * Collation function for ed25519 consensuses: collate the votes for each
* entry in <b>dc</b> by ed25519 key and by RSA key. * entry in <b>dc</b> by ed25519 key and by RSA key.

View File

@ -549,12 +549,12 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
tor_assert(most); tor_assert(most);
/* If we're producing "a" lines, vote on potential alternative (sets /* Vote on potential alternative (sets of) OR port(s) in the winning
* of) OR port(s) in the winning routerstatuses. * routerstatuses.
* *
* XXX prop186 There's at most one alternative OR port (_the_ IPv6 * XXX prop186 There's at most one alternative OR port (_the_ IPv6
* port) for now. */ * port) for now. */
if (consensus_method >= MIN_METHOD_FOR_A_LINES && best_alt_orport_out) { if (best_alt_orport_out) {
smartlist_t *alt_orports = smartlist_new(); smartlist_t *alt_orports = smartlist_new();
const tor_addr_port_t *most_alt_orport = NULL; const tor_addr_port_t *most_alt_orport = NULL;
@ -664,13 +664,6 @@ compute_consensus_method(smartlist_t *votes)
static int static int
consensus_method_is_supported(int method) consensus_method_is_supported(int method)
{ {
if (method == MIN_METHOD_FOR_ED25519_ID_IN_MD) {
/* This method was broken due to buggy code accidentally left in
* dircollate.c; do not actually use it.
*/
return 0;
}
return (method >= MIN_SUPPORTED_CONSENSUS_METHOD) && return (method >= MIN_SUPPORTED_CONSENSUS_METHOD) &&
(method <= MAX_SUPPORTED_CONSENSUS_METHOD); (method <= MAX_SUPPORTED_CONSENSUS_METHOD);
} }
@ -1455,19 +1448,14 @@ networkstatus_compute_consensus(smartlist_t *votes,
n_versioning_servers); n_versioning_servers);
client_versions = compute_consensus_versions_list(combined_client_versions, client_versions = compute_consensus_versions_list(combined_client_versions,
n_versioning_clients); n_versioning_clients);
if (consensus_method >= MIN_METHOD_FOR_PACKAGE_LINES) { packages = compute_consensus_package_lines(votes);
packages = compute_consensus_package_lines(votes);
} else {
packages = tor_strdup("");
}
SMARTLIST_FOREACH(combined_server_versions, char *, cp, tor_free(cp)); SMARTLIST_FOREACH(combined_server_versions, char *, cp, tor_free(cp));
SMARTLIST_FOREACH(combined_client_versions, char *, cp, tor_free(cp)); SMARTLIST_FOREACH(combined_client_versions, char *, cp, tor_free(cp));
smartlist_free(combined_server_versions); smartlist_free(combined_server_versions);
smartlist_free(combined_client_versions); smartlist_free(combined_client_versions);
if (consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING) smartlist_add_strdup(flags, "NoEdConsensus");
smartlist_add_strdup(flags, "NoEdConsensus");
smartlist_sort_strings(flags); smartlist_sort_strings(flags);
smartlist_uniq_strings(flags); smartlist_uniq_strings(flags);
@ -1516,7 +1504,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(flaglist); tor_free(flaglist);
} }
if (consensus_method >= MIN_METHOD_FOR_RECOMMENDED_PROTOCOLS) { {
int num_dirauth = get_n_authorities(V3_DIRINFO); int num_dirauth = get_n_authorities(V3_DIRINFO);
int idx; int idx;
for (idx = 0; idx < 4; ++idx) { for (idx = 0; idx < 4; ++idx) {
@ -1536,7 +1524,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_add_strdup(chunks, "\n"); smartlist_add_strdup(chunks, "\n");
} }
if (consensus_method >= MIN_METHOD_FOR_SHARED_RANDOM) { {
int num_dirauth = get_n_authorities(V3_DIRINFO); int num_dirauth = get_n_authorities(V3_DIRINFO);
/* Default value of this is 2/3 of the total number of authorities. For /* Default value of this is 2/3 of the total number of authorities. For
* instance, if we have 9 dirauth, the default value is 6. The following * instance, if we have 9 dirauth, the default value is 6. The following
@ -1601,7 +1589,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_free(dir_sources); smartlist_free(dir_sources);
} }
if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW) { {
char *max_unmeasured_param = NULL; char *max_unmeasured_param = NULL;
/* XXXX Extract this code into a common function. Or don't! see #19011 */ /* XXXX Extract this code into a common function. Or don't! see #19011 */
if (params) { if (params) {
@ -1863,7 +1851,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
continue; continue;
if (ed_consensus > 0) { if (ed_consensus > 0) {
tor_assert(consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING);
if (ed_consensus <= total_authorities / 2) { if (ed_consensus <= total_authorities / 2) {
log_warn(LD_BUG, "Not enough entries had ed_consensus set; how " log_warn(LD_BUG, "Not enough entries had ed_consensus set; how "
"can we have a consensus of %d?", ed_consensus); "can we have a consensus of %d?", ed_consensus);
@ -1890,10 +1877,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
rs_out.published_on = rs->status.published_on; rs_out.published_on = rs->status.published_on;
rs_out.dir_port = rs->status.dir_port; rs_out.dir_port = rs->status.dir_port;
rs_out.or_port = rs->status.or_port; rs_out.or_port = rs->status.or_port;
if (consensus_method >= MIN_METHOD_FOR_A_LINES) { tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr);
tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr); rs_out.ipv6_orport = alt_orport.port;
rs_out.ipv6_orport = alt_orport.port;
}
rs_out.has_bandwidth = 0; rs_out.has_bandwidth = 0;
rs_out.has_exitsummary = 0; rs_out.has_exitsummary = 0;
@ -1923,8 +1908,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
} else if (!strcmp(fl, "Unnamed")) { } else if (!strcmp(fl, "Unnamed")) {
if (is_unnamed) if (is_unnamed)
smartlist_add(chosen_flags, (char*)fl); smartlist_add(chosen_flags, (char*)fl);
} else if (!strcmp(fl, "NoEdConsensus") && } else if (!strcmp(fl, "NoEdConsensus")) {
consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING) {
if (ed_consensus <= total_authorities/2) if (ed_consensus <= total_authorities/2)
smartlist_add(chosen_flags, (char*)fl); smartlist_add(chosen_flags, (char*)fl);
} else { } else {
@ -1951,8 +1935,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Starting with consensus method 24, we don't list servers /* Starting with consensus method 24, we don't list servers
* that are not valid in a consensus. See Proposal 272 */ * that are not valid in a consensus. See Proposal 272 */
if (!is_valid && if (!is_valid)
consensus_method >= MIN_METHOD_FOR_EXCLUDING_INVALID_NODES)
continue; continue;
/* Pick the version. */ /* Pick the version. */
@ -1973,8 +1956,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* If it's a guard and we have enough guardfraction votes, /* If it's a guard and we have enough guardfraction votes,
calculate its consensus guardfraction value. */ calculate its consensus guardfraction value. */
if (is_guard && num_guardfraction_inputs > 2 && if (is_guard && num_guardfraction_inputs > 2) {
consensus_method >= MIN_METHOD_FOR_GUARDFRACTION) {
rs_out.has_guardfraction = 1; rs_out.has_guardfraction = 1;
rs_out.guardfraction_percentage = median_uint32(measured_guardfraction, rs_out.guardfraction_percentage = median_uint32(measured_guardfraction,
num_guardfraction_inputs); num_guardfraction_inputs);
@ -1991,8 +1973,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
rs_out.has_bandwidth = 1; rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 1; rs_out.bw_is_unmeasured = 1;
rs_out.bandwidth_kb = median_uint32(bandwidths_kb, num_bandwidths); rs_out.bandwidth_kb = median_uint32(bandwidths_kb, num_bandwidths);
if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW && if (n_authorities_measuring_bandwidth > 2) {
n_authorities_measuring_bandwidth > 2) {
/* Cap non-measured bandwidths. */ /* Cap non-measured bandwidths. */
if (rs_out.bandwidth_kb > max_unmeasured_bw_kb) { if (rs_out.bandwidth_kb > max_unmeasured_bw_kb) {
rs_out.bandwidth_kb = max_unmeasured_bw_kb; rs_out.bandwidth_kb = max_unmeasured_bw_kb;
@ -2132,8 +2113,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Now the weight line. */ /* Now the weight line. */
if (rs_out.has_bandwidth) { if (rs_out.has_bandwidth) {
char *guardfraction_str = NULL; char *guardfraction_str = NULL;
int unmeasured = rs_out.bw_is_unmeasured && int unmeasured = rs_out.bw_is_unmeasured;
consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW;
/* If we have guardfraction info, include it in the 'w' line. */ /* If we have guardfraction info, include it in the 'w' line. */
if (rs_out.has_guardfraction) { if (rs_out.has_guardfraction) {
@ -3835,8 +3815,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
smartlist_add_asprintf(chunks, "onion-key\n%s", key); smartlist_add_asprintf(chunks, "onion-key\n%s", key);
if (consensus_method >= MIN_METHOD_FOR_NTOR_KEY && if (ri->onion_curve25519_pkey) {
ri->onion_curve25519_pkey) {
char kbuf[128]; char kbuf[128];
base64_encode(kbuf, sizeof(kbuf), base64_encode(kbuf, sizeof(kbuf),
(const char*)ri->onion_curve25519_pkey->public_key, (const char*)ri->onion_curve25519_pkey->public_key,
@ -3846,8 +3825,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
/* We originally put a lines in the micrdescriptors, but then we worked out /* We originally put a lines in the micrdescriptors, but then we worked out
* that we needed them in the microdesc consensus. See #20916. */ * that we needed them in the microdesc consensus. See #20916. */
if (consensus_method >= MIN_METHOD_FOR_A_LINES && if (consensus_method < MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC &&
consensus_method < MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC &&
!tor_addr_is_null(&ri->ipv6_addr) && ri->ipv6_orport) !tor_addr_is_null(&ri->ipv6_addr) && ri->ipv6_orport)
smartlist_add_asprintf(chunks, "a %s\n", smartlist_add_asprintf(chunks, "a %s\n",
fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport)); fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport));
@ -3858,8 +3836,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
if (summary && strcmp(summary, "reject 1-65535")) if (summary && strcmp(summary, "reject 1-65535"))
smartlist_add_asprintf(chunks, "p %s\n", summary); smartlist_add_asprintf(chunks, "p %s\n", summary);
if (consensus_method >= MIN_METHOD_FOR_P6_LINES && if (ri->ipv6_exit_policy) {
ri->ipv6_exit_policy) {
/* XXXX+++ This doesn't match proposal 208, which says these should /* XXXX+++ This doesn't match proposal 208, which says these should
* be taken unchanged from the routerinfo. That's bogosity, IMO: * be taken unchanged from the routerinfo. That's bogosity, IMO:
* the proposal should have said to do this instead.*/ * the proposal should have said to do this instead.*/
@ -3869,11 +3846,10 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
tor_free(p6); tor_free(p6);
} }
if (consensus_method >= MIN_METHOD_FOR_ID_HASH_IN_MD) { {
char idbuf[ED25519_BASE64_LEN+1]; char idbuf[ED25519_BASE64_LEN+1];
const char *keytype; const char *keytype;
if (consensus_method >= MIN_METHOD_FOR_ED25519_ID_IN_MD && if (ri->cache_info.signing_key_cert &&
ri->cache_info.signing_key_cert &&
ri->cache_info.signing_key_cert->signing_key_included) { ri->cache_info.signing_key_cert->signing_key_included) {
keytype = "ed25519"; keytype = "ed25519";
ed25519_public_to_base64(idbuf, ed25519_public_to_base64(idbuf,
@ -3951,13 +3927,7 @@ static const struct consensus_method_range_t {
int low; int low;
int high; int high;
} microdesc_consensus_methods[] = { } microdesc_consensus_methods[] = {
{MIN_SUPPORTED_CONSENSUS_METHOD, MIN_METHOD_FOR_A_LINES - 1}, {MIN_SUPPORTED_CONSENSUS_METHOD, MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC - 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},
{MIN_METHOD_FOR_ID_HASH_IN_MD, MIN_METHOD_FOR_ED25519_ID_IN_MD - 1},
{MIN_METHOD_FOR_ED25519_ID_IN_MD,
MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC - 1},
{MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC, MAX_SUPPORTED_CONSENSUS_METHOD}, {MIN_METHOD_FOR_NO_A_LINES_IN_MICRODESC, MAX_SUPPORTED_CONSENSUS_METHOD},
{-1, -1} {-1, -1}
}; };

View File

@ -56,57 +56,11 @@
#define ROUTERSTATUS_FORMAT_NO_CONSENSUS_METHOD 0 #define ROUTERSTATUS_FORMAT_NO_CONSENSUS_METHOD 0
/** The lowest consensus method that we currently support. */ /** The lowest consensus method that we currently support. */
#define MIN_SUPPORTED_CONSENSUS_METHOD 13 #define MIN_SUPPORTED_CONSENSUS_METHOD 25
/** The highest consensus method that we currently support. */ /** The highest consensus method that we currently support. */
#define MAX_SUPPORTED_CONSENSUS_METHOD 28 #define MAX_SUPPORTED_CONSENSUS_METHOD 28
/** Lowest consensus method where microdesc consensuses omit any entry
* with no microdesc. */
#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
/** Lowest consensus method that contains "a" lines. */
#define MIN_METHOD_FOR_A_LINES 14
/** Lowest consensus method where microdescs may include a "p6" line. */
#define MIN_METHOD_FOR_P6_LINES 15
/** Lowest consensus method where microdescs may include an onion-key-ntor
* line */
#define MIN_METHOD_FOR_NTOR_KEY 16
/** Lowest consensus method that ensures that authorities output an
* Unmeasured=1 flag for unmeasured bandwidths */
#define MIN_METHOD_TO_CLIP_UNMEASURED_BW 17
/** Lowest consensus method where authorities may include an "id" line in
* microdescriptors. */
#define MIN_METHOD_FOR_ID_HASH_IN_MD 18
/** Lowest consensus method where we include "package" lines*/
#define MIN_METHOD_FOR_PACKAGE_LINES 19
/** Lowest consensus method where authorities may include
* GuardFraction information in microdescriptors. */
#define MIN_METHOD_FOR_GUARDFRACTION 20
/** Lowest consensus method where authorities may include an "id" line for
* ed25519 identities in microdescriptors. (Broken; see
* consensus_method_is_supported() for more info.) */
#define MIN_METHOD_FOR_ED25519_ID_IN_MD 21
/** Lowest consensus method where authorities vote on ed25519 ids and ensure
* ed25519 id consistency. */
#define MIN_METHOD_FOR_ED25519_ID_VOTING 22
/** Lowest consensus method where authorities may include a shared random
* value(s). */
#define MIN_METHOD_FOR_SHARED_RANDOM 23
/** Lowest consensus method where authorities drop all nodes that don't get
* the Valid flag. */
#define MIN_METHOD_FOR_EXCLUDING_INVALID_NODES 24
/** Lowest consensus method where authorities vote on required/recommended /** Lowest consensus method where authorities vote on required/recommended
* protocols. */ * protocols. */
#define MIN_METHOD_FOR_RECOMMENDED_PROTOCOLS 25 #define MIN_METHOD_FOR_RECOMMENDED_PROTOCOLS 25

View File

@ -1528,7 +1528,7 @@ networkstatus_consensus_has_ipv6(const or_options_t* options)
return return
cons->consensus_method >= MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS; cons->consensus_method >= MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS;
} else { } else {
return cons->consensus_method >= MIN_METHOD_FOR_A_LINES; return 1;
} }
} }

View File

@ -2743,8 +2743,7 @@ routerstatus_parse_entry_from_string(memarea_t *area,
/* These are implied true by having been included in a consensus made /* These are implied true by having been included in a consensus made
* with a given method */ * with a given method */
rs->is_flagged_running = 1; /* Starting with consensus method 4. */ rs->is_flagged_running = 1; /* Starting with consensus method 4. */
if (consensus_method >= MIN_METHOD_FOR_EXCLUDING_INVALID_NODES) rs->is_valid = 1; /* Starting with consensus method 24. */
rs->is_valid = 1;
} }
{ {
const char *protocols = NULL, *version = NULL; const char *protocols = NULL, *version = NULL;

View File

@ -2917,8 +2917,9 @@ gen_routerstatus_for_umbw(int idx, time_t now)
rs->addr = 0x99008801; rs->addr = 0x99008801;
rs->or_port = 443; rs->or_port = 443;
rs->dir_port = 8000; rs->dir_port = 8000;
/* all flags but running cleared */ /* all flags but running and valid cleared */
rs->is_flagged_running = 1; rs->is_flagged_running = 1;
rs->is_valid = 1;
/* /*
* This one has measured bandwidth below the clip cutoff, and * This one has measured bandwidth below the clip cutoff, and
* so shouldn't be clipped; we'll have to test that it isn't * so shouldn't be clipped; we'll have to test that it isn't
@ -2991,8 +2992,9 @@ gen_routerstatus_for_umbw(int idx, time_t now)
rs->addr = 0xC0000203; rs->addr = 0xC0000203;
rs->or_port = 500; rs->or_port = 500;
rs->dir_port = 1999; rs->dir_port = 1999;
/* all flags but running cleared */ /* all flags but running and valid cleared */
rs->is_flagged_running = 1; rs->is_flagged_running = 1;
rs->is_valid = 1;
/* /*
* This one has unmeasured bandwidth below the clip cutoff, and * This one has unmeasured bandwidth below the clip cutoff, and
* so shouldn't be clipped; we'll have to test that it isn't * so shouldn't be clipped; we'll have to test that it isn't
@ -3014,7 +3016,7 @@ gen_routerstatus_for_umbw(int idx, time_t now)
if (vrs) { if (vrs) {
vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t)); vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
tor_asprintf(&vrs->microdesc->microdesc_hash_line, tor_asprintf(&vrs->microdesc->microdesc_hash_line,
"m 9,10,11,12,13,14,15,16,17 " "m 25,26,27,28 "
"sha256=xyzajkldsdsajdadlsdjaslsdksdjlsdjsdaskdaaa%d\n", "sha256=xyzajkldsdsajdadlsdjaslsdksdjlsdjsdaskdaaa%d\n",
idx); idx);
} }
@ -3040,7 +3042,7 @@ vote_tweaks_for_umbw(networkstatus_t *v, int voter, time_t now)
smartlist_clear(v->supported_methods); smartlist_clear(v->supported_methods);
/* Method 17 is MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB */ /* Method 17 is MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB */
smartlist_split_string(v->supported_methods, smartlist_split_string(v->supported_methods,
"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17", "25 26 27 28",
NULL, 0, -1); NULL, 0, -1);
/* If we're using a non-default clip bandwidth, add it to net_params */ /* If we're using a non-default clip bandwidth, add it to net_params */
if (alternate_clip_bw > 0) { if (alternate_clip_bw > 0) {
@ -3202,9 +3204,9 @@ test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
tt_assert(!rs->is_fast); tt_assert(!rs->is_fast);
tt_assert(!rs->is_possible_guard); tt_assert(!rs->is_possible_guard);
tt_assert(!rs->is_stable); tt_assert(!rs->is_stable);
/* (If it wasn't running it wouldn't be here) */ /* (If it wasn't running and valid it wouldn't be here) */
tt_assert(rs->is_flagged_running); tt_assert(rs->is_flagged_running);
tt_assert(!rs->is_valid); tt_assert(rs->is_valid);
tt_assert(!rs->is_named); tt_assert(!rs->is_named);
/* This one should have measured bandwidth below the clip cutoff */ /* This one should have measured bandwidth below the clip cutoff */
tt_assert(rs->has_bandwidth); tt_assert(rs->has_bandwidth);
@ -5615,9 +5617,8 @@ test_dir_assumed_flags(void *arg)
memarea_t *area = memarea_new(); memarea_t *area = memarea_new();
routerstatus_t *rs = NULL; routerstatus_t *rs = NULL;
/* First, we should always assume that the Running flag is set, even /* We can assume that consensus method is higher than 24, so Running and
* when it isn't listed, since the consensus method is always * Valid are always implicitly set */
* higher than 4. */
const char *str1 = const char *str1 =
"r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 " "r example hereiswhereyouridentitygoes 2015-08-30 12:00:00 "
"192.168.0.1 9001 0\n" "192.168.0.1 9001 0\n"
@ -5625,17 +5626,6 @@ test_dir_assumed_flags(void *arg)
"s Fast Guard Stable\n"; "s Fast Guard Stable\n";
const char *cp = str1; const char *cp = str1;
rs = routerstatus_parse_entry_from_string(area, &cp, tokens, NULL, NULL,
23, FLAV_MICRODESC);
tt_assert(rs);
tt_assert(rs->is_flagged_running);
tt_assert(! rs->is_valid);
tt_assert(! rs->is_exit);
tt_assert(rs->is_fast);
routerstatus_free(rs);
/* With method 24 or later, we can assume "valid" is set. */
cp = str1;
rs = routerstatus_parse_entry_from_string(area, &cp, tokens, NULL, NULL, rs = routerstatus_parse_entry_from_string(area, &cp, tokens, NULL, NULL,
24, FLAV_MICRODESC); 24, FLAV_MICRODESC);
tt_assert(rs); tt_assert(rs);
@ -5769,22 +5759,10 @@ test_dir_networkstatus_consensus_has_ipv6(void *arg)
/* Test the bounds for A lines in the NS consensus */ /* Test the bounds for A lines in the NS consensus */
mock_options->UseMicrodescriptors = 0; mock_options->UseMicrodescriptors = 0;
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES; mock_networkstatus->consensus_method = MIN_SUPPORTED_CONSENSUS_METHOD;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options()); has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6); tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES + 1;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES + 20;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MIN_METHOD_FOR_A_LINES - 1;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(!has_ipv6);
/* Test the bounds for A lines in the microdesc consensus */ /* Test the bounds for A lines in the microdesc consensus */
mock_options->UseMicrodescriptors = 1; mock_options->UseMicrodescriptors = 1;
@ -5793,6 +5771,10 @@ test_dir_networkstatus_consensus_has_ipv6(void *arg)
has_ipv6 = networkstatus_consensus_has_ipv6(get_options()); has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6); tt_assert(has_ipv6);
mock_networkstatus->consensus_method = MAX_SUPPORTED_CONSENSUS_METHOD + 20;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options());
tt_assert(has_ipv6);
mock_networkstatus->consensus_method = mock_networkstatus->consensus_method =
MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 1; MIN_METHOD_FOR_A_LINES_IN_MICRODESC_CONSENSUS + 1;
has_ipv6 = networkstatus_consensus_has_ipv6(get_options()); has_ipv6 = networkstatus_consensus_has_ipv6(get_options());

View File

@ -385,25 +385,6 @@ static const char test_ri2[] =
"cf34GXHv61XReJF3AlzNHFpbrPOYmowmhrTULKyMqow=\n" "cf34GXHv61XReJF3AlzNHFpbrPOYmowmhrTULKyMqow=\n"
"-----END SIGNATURE-----\n"; "-----END SIGNATURE-----\n";
static const char test_md_8[] =
"onion-key\n"
"-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBANBJz8Vldl12aFeSMPLiA4nOetLDN0oxU8bB1SDhO7Uu2zdWYVYAF5J0\n"
"st7WvrVy/jA9v/fsezNAPskBanecHRSkdMTpkcgRPMHE7CTGEwIy1Yp1X4bPgDlC\n"
"VCnbs5Pcts5HnWEYNK7qHDAUn+IlmjOO+pTUY8uyq+GQVz6H9wFlAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n"
"p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n";
static const char test_md_16[] =
"onion-key\n"
"-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBANBJz8Vldl12aFeSMPLiA4nOetLDN0oxU8bB1SDhO7Uu2zdWYVYAF5J0\n"
"st7WvrVy/jA9v/fsezNAPskBanecHRSkdMTpkcgRPMHE7CTGEwIy1Yp1X4bPgDlC\n"
"VCnbs5Pcts5HnWEYNK7qHDAUn+IlmjOO+pTUY8uyq+GQVz6H9wFlAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n"
"ntor-onion-key Gg73xH7+kTfT6bi1uNVx9gwQdQas9pROIfmc4NpAdC4=\n"
"p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n";
static const char test_md_18[] = static const char test_md_18[] =
"onion-key\n" "onion-key\n"
"-----BEGIN RSA PUBLIC KEY-----\n" "-----BEGIN RSA PUBLIC KEY-----\n"
@ -415,16 +396,6 @@ static const char test_md_18[] =
"p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n" "p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n"
"id rsa1024 Cd47okjCHD83YGzThGBDptXs9Z4\n"; "id rsa1024 Cd47okjCHD83YGzThGBDptXs9Z4\n";
static const char test_md2_18[] =
"onion-key\n"
"-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBAL2R8EfubUcahxha4u02P4VAR0llQIMwFAmrHPjzcK7apcQgDOf2ovOA\n"
"+YQnJFxlpBmCoCZC6ssCi+9G0mqo650lFuTMP5I90BdtjotfzESfTykHLiChyvhd\n"
"l0dlqclb2SU/GKem/fLRXH16aNi72CdSUu/1slKs/70ILi34QixRAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n"
"ntor-onion-key hbxdRnfVUJJY7+KcT4E3Rs7/zuClbN3hJrjSBiEGMgI=\n"
"id rsa1024 t+J/EEITw28T5+mCkYKEXklZl6A\n";
static const char test_md2_21[] = static const char test_md2_21[] =
"onion-key\n" "onion-key\n"
"-----BEGIN RSA PUBLIC KEY-----\n" "-----BEGIN RSA PUBLIC KEY-----\n"
@ -444,17 +415,6 @@ test_md_generate(void *arg)
ri = router_parse_entry_from_string(test_ri, NULL, 0, 0, NULL, NULL); ri = router_parse_entry_from_string(test_ri, NULL, 0, 0, NULL, NULL);
tt_assert(ri); tt_assert(ri);
md = dirvote_create_microdescriptor(ri, 8);
tt_str_op(md->body, OP_EQ, test_md_8);
/* XXXX test family lines. */
/* XXXX test method 14 for A lines. */
/* XXXX test method 15 for P6 lines. */
microdesc_free(md);
md = NULL;
md = dirvote_create_microdescriptor(ri, 16);
tt_str_op(md->body, OP_EQ, test_md_16);
microdesc_free(md); microdesc_free(md);
md = NULL; md = NULL;
@ -469,11 +429,6 @@ test_md_generate(void *arg)
routerinfo_free(ri); routerinfo_free(ri);
ri = router_parse_entry_from_string(test_ri2, NULL, 0, 0, NULL, NULL); ri = router_parse_entry_from_string(test_ri2, NULL, 0, 0, NULL, NULL);
microdesc_free(md);
md = NULL;
md = dirvote_create_microdescriptor(ri, 18);
tt_str_op(md->body, OP_EQ, test_md2_18);
microdesc_free(md); microdesc_free(md);
md = NULL; md = NULL;
md = dirvote_create_microdescriptor(ri, 21); md = dirvote_create_microdescriptor(ri, 21);