Merge remote-tracking branch 'public/remove_old_version_checks'

This commit is contained in:
Nick Mathewson 2015-04-01 14:02:02 -04:00
commit 05fbbfe472
6 changed files with 10 additions and 82 deletions

View File

@ -0,0 +1,5 @@
o Removed features:
- Tor no longer contains workarounds for stat files generated by
super-old versions of Tor that didn't choose guards sensibly.
- Tor no longer contains checks for ancient directory cache versions
that didn't know about microdescriptors.

View File

@ -141,8 +141,7 @@ entry_guard_set_status(entry_guard_t *e, const node_t *node,
} }
if (node) { if (node) {
int is_dir = node_is_dir(node) && node->rs && int is_dir = node_is_dir(node);
node->rs->version_supports_microdesc_cache;
if (options->UseBridges && node_is_a_configured_bridge(node)) if (options->UseBridges && node_is_a_configured_bridge(node))
is_dir = 1; is_dir = 1;
if (e->is_dir_cache != is_dir) { if (e->is_dir_cache != is_dir) {
@ -398,10 +397,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
entry->bad_since = 0; entry->bad_since = 0;
entry->can_retry = 1; entry->can_retry = 1;
} }
entry->is_dir_cache = node->rs && entry->is_dir_cache = node_is_dir(node);
node->rs->version_supports_microdesc_cache;
if (get_options()->UseBridges && node_is_a_configured_bridge(node))
entry->is_dir_cache = 1;
return NULL; return NULL;
} }
} else if (!for_directory) { } else if (!for_directory) {
@ -432,8 +428,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
node_describe(node)); node_describe(node));
strlcpy(entry->nickname, node_get_nickname(node), sizeof(entry->nickname)); strlcpy(entry->nickname, node_get_nickname(node), sizeof(entry->nickname));
memcpy(entry->identity, node->identity, DIGEST_LEN); memcpy(entry->identity, node->identity, DIGEST_LEN);
entry->is_dir_cache = node_is_dir(node) && node->rs && entry->is_dir_cache = node_is_dir(node);
node->rs->version_supports_microdesc_cache;
if (get_options()->UseBridges && node_is_a_configured_bridge(node)) if (get_options()->UseBridges && node_is_a_configured_bridge(node))
entry->is_dir_cache = 1; entry->is_dir_cache = 1;
@ -571,22 +566,6 @@ remove_obsolete_entry_guards(time_t now)
} else if (tor_version_parse(ver, &v)) { } else if (tor_version_parse(ver, &v)) {
msg = "does not seem to be from any recognized version of Tor"; msg = "does not seem to be from any recognized version of Tor";
version_is_bad = 1; version_is_bad = 1;
} else {
char *tor_ver = NULL;
tor_asprintf(&tor_ver, "Tor %s", ver);
if ((tor_version_as_new_as(tor_ver, "0.1.0.10-alpha") &&
!tor_version_as_new_as(tor_ver, "0.1.2.16-dev")) ||
(tor_version_as_new_as(tor_ver, "0.2.0.0-alpha") &&
!tor_version_as_new_as(tor_ver, "0.2.0.6-alpha")) ||
/* above are bug 440; below are bug 1217 */
(tor_version_as_new_as(tor_ver, "0.2.1.3-alpha") &&
!tor_version_as_new_as(tor_ver, "0.2.1.23")) ||
(tor_version_as_new_as(tor_ver, "0.2.2.0-alpha") &&
!tor_version_as_new_as(tor_ver, "0.2.2.7-alpha"))) {
msg = "was selected without regard for guard bandwidth";
version_is_bad = 1;
}
tor_free(tor_ver);
} }
if (!version_is_bad && entry->chosen_on_date + guard_lifetime < now) { if (!version_is_bad && entry->chosen_on_date + guard_lifetime < now) {
/* It's been too long since the date listed in our state file. */ /* It's been too long since the date listed in our state file. */
@ -989,39 +968,6 @@ entry_list_is_constrained(const or_options_t *options)
return 0; return 0;
} }
/** Return true iff this node can answer directory questions about
* microdescriptors. */
static int
node_understands_microdescriptors(const node_t *node)
{
tor_assert(node);
if (node->rs && node->rs->version_supports_microdesc_cache)
return 1;
if (node->ri && tor_version_supports_microdescriptors(node->ri->platform))
return 1;
return 0;
}
/** Return true iff <b>node</b> is able to answer directory questions
* of type <b>dirinfo</b>. Always returns true if <b>dirinfo</b> is
* NO_DIRINFO (zero). */
static int
node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
{
/* Checking dirinfo for any type other than microdescriptors isn't required
yet, since we only choose directory guards that can support microdescs,
routerinfos, and networkstatuses, AND we don't use directory guards if
we're configured to do direct downloads of anything else. The only case
where we might have a guard that doesn't know about a type of directory
information is when we're retrieving directory information from a
bridge. */
if ((dirinfo & MICRODESC_DIRINFO) &&
!node_understands_microdescriptors(node))
return 0;
return 1;
}
/** Pick a live (up and listed) entry guard from entry_guards. If /** Pick a live (up and listed) entry guard from entry_guards. If
* <b>state</b> is non-NULL, this is for a specific circuit -- * <b>state</b> is non-NULL, this is for a specific circuit --
* make sure not to pick this circuit's exit or any node in the * make sure not to pick this circuit's exit or any node in the
@ -1108,9 +1054,6 @@ populate_live_entry_guards(smartlist_t *live_entry_guards,
continue; /* don't pick the same node for entry and exit */ continue; /* don't pick the same node for entry and exit */
if (smartlist_contains(exit_family, node)) if (smartlist_contains(exit_family, node))
continue; /* avoid relays that are family members of our exit */ continue; /* avoid relays that are family members of our exit */
if (dirinfo_type != NO_DIRINFO &&
!node_can_handle_dirinfo(node, dirinfo_type))
continue; /* this node won't be able to answer our dir questions */
smartlist_add(live_entry_guards, (void*)node); smartlist_add(live_entry_guards, (void*)node);
if (!entry->made_contact) { if (!entry->made_contact) {
/* Always start with the first not-yet-contacted entry /* Always start with the first not-yet-contacted entry
@ -2484,11 +2427,9 @@ any_bridge_supports_microdescriptors(void)
SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, e) { SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, e) {
node = node_get_by_id(e->identity); node = node_get_by_id(e->identity);
if (node && node->is_running && if (node && node->is_running &&
node_is_bridge(node) && node_is_a_configured_bridge(node) && node_is_bridge(node) && node_is_a_configured_bridge(node)) {
node_understands_microdescriptors(node)) {
/* This is one of our current bridges, and we know enough about /* This is one of our current bridges, and we know enough about
* it to know that it will be able to answer our microdescriptor * it to know that it will be able to answer our questions. */
* questions. */
return 1; return 1;
} }
} SMARTLIST_FOREACH_END(e); } SMARTLIST_FOREACH_END(e);

View File

@ -2131,9 +2131,6 @@ typedef struct routerstatus_t {
* if the number of traits we care about ever becomes incredibly big. */ * if the number of traits we care about ever becomes incredibly big. */
unsigned int version_known:1; unsigned int version_known:1;
/** True iff this router is a version that, if it caches directory info,
* we can get microdescriptors from. */
unsigned int version_supports_microdesc_cache:1;
/** True iff this router has a version that allows it to accept EXTEND2 /** True iff this router has a version that allows it to accept EXTEND2
* cells */ * cells */
unsigned int version_supports_extend2_cells:1; unsigned int version_supports_extend2_cells:1;

View File

@ -1498,9 +1498,6 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags,
if ((type & EXTRAINFO_DIRINFO) && if ((type & EXTRAINFO_DIRINFO) &&
!router_supports_extrainfo(node->identity, is_trusted_extrainfo)) !router_supports_extrainfo(node->identity, is_trusted_extrainfo))
continue; continue;
if ((type & MICRODESC_DIRINFO) && !is_trusted &&
!node->rs->version_supports_microdesc_cache)
continue;
if (for_guard && node->using_as_guard) if (for_guard && node->using_as_guard)
continue; /* Don't make the same node a guard twice. */ continue; /* Don't make the same node a guard twice. */
if (try_excluding && if (try_excluding &&

View File

@ -2015,10 +2015,7 @@ routerstatus_parse_entry_from_string(memarea_t *area,
tor_assert(tok->n_args == 1); tor_assert(tok->n_args == 1);
rs->version_known = 1; rs->version_known = 1;
if (strcmpstart(tok->args[0], "Tor ")) { if (strcmpstart(tok->args[0], "Tor ")) {
rs->version_supports_microdesc_cache = 1;
} else { } else {
rs->version_supports_microdesc_cache =
tor_version_supports_microdescriptors(tok->args[0]);
rs->version_supports_extend2_cells = rs->version_supports_extend2_cells =
tor_version_as_new_as(tok->args[0], "0.2.4.8-alpha"); tor_version_as_new_as(tok->args[0], "0.2.4.8-alpha");
} }
@ -4263,14 +4260,6 @@ microdescs_parse_from_string(const char *s, const char *eos,
return result; return result;
} }
/** Return true iff this Tor version can answer directory questions
* about microdescriptors. */
int
tor_version_supports_microdescriptors(const char *platform)
{
return tor_version_as_new_as(platform, "0.2.3.1-alpha");
}
/** Parse the Tor version of the platform string <b>platform</b>, /** Parse the Tor version of the platform string <b>platform</b>,
* and compare it to the version in <b>cutoff</b>. Return 1 if * and compare it to the version in <b>cutoff</b>. Return 1 if
* the router is at least as new as the cutoff, else return 0. * the router is at least as new as the cutoff, else return 0.

View File

@ -44,7 +44,6 @@ MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
(const char *s, int assume_action)); (const char *s, int assume_action));
version_status_t tor_version_is_obsolete(const char *myversion, version_status_t tor_version_is_obsolete(const char *myversion,
const char *versionlist); const char *versionlist);
int tor_version_supports_microdescriptors(const char *platform);
int tor_version_as_new_as(const char *platform, const char *cutoff); int tor_version_as_new_as(const char *platform, const char *cutoff);
int tor_version_parse(const char *s, tor_version_t *out); int tor_version_parse(const char *s, tor_version_t *out);
int tor_version_compare(tor_version_t *a, tor_version_t *b); int tor_version_compare(tor_version_t *a, tor_version_t *b);