Clients replace entry guards that were chosen more than a few months

ago. This change should significantly improve client performance,
especially once more people upgrade, since relays that have been
a guard for a long time are currently overloaded.


svn:r19287
This commit is contained in:
Roger Dingledine 2009-04-11 12:00:18 +00:00
parent ebadf2b068
commit 48118b228e
2 changed files with 21 additions and 11 deletions

View File

@ -3,12 +3,18 @@ Changes in version 0.2.1.14-rc - 2009-04-11
- Avoid crashing in the presence of certain malformed descriptors. - Avoid crashing in the presence of certain malformed descriptors.
Found by lark, and by automated fuzzing. Found by lark, and by automated fuzzing.
o Major features:
- Clients replace entry guards that were chosen more than a few months
ago. This change should significantly improve client performance,
especially once more people upgrade, since relays that have been
a guard for a long time are currently overloaded.
o Major bugfixes: o Major bugfixes:
- Relays were falling out of the networkstatus consensus for - Relays were falling out of the networkstatus consensus for
half a day if they changed their local config but the authorities part of a day if they changed their local config but the
discarded their new descriptor as "not sufficiently different". Now authorities discarded their new descriptor as "not sufficiently
directory authorities accept a descriptor as changed if different". Now directory authorities accept a descriptor as changed
bandwidthrate or bandwidthburst changed. Partial fix for bug 962; if bandwidthrate or bandwidthburst changed. Partial fix for bug 962;
patch by Sebastian. patch by Sebastian.
o Minor features: o Minor features:

View File

@ -2135,28 +2135,30 @@ static int
remove_obsolete_entry_guards(void) remove_obsolete_entry_guards(void)
{ {
int changed = 0, i; int changed = 0, i;
time_t this_month = start_of_month(time(NULL));
for (i = 0; i < smartlist_len(entry_guards); ++i) { for (i = 0; i < smartlist_len(entry_guards); ++i) {
entry_guard_t *entry = smartlist_get(entry_guards, i); entry_guard_t *entry = smartlist_get(entry_guards, i);
const char *ver = entry->chosen_by_version; const char *ver = entry->chosen_by_version;
const char *msg = NULL; const char *msg = NULL;
tor_version_t v; tor_version_t v;
int version_is_bad = 0;
if (!ver) { if (!ver) {
msg = "does not say what version of Tor it was selected by"; msg = "does not say what version of Tor it was selected by";
version_is_bad = 1;
} 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;
} else if ((tor_version_as_new_as(ver, "0.1.0.10-alpha") && } else if ((tor_version_as_new_as(ver, "0.1.0.10-alpha") &&
!tor_version_as_new_as(ver, "0.1.2.16-dev")) || !tor_version_as_new_as(ver, "0.1.2.16-dev")) ||
(tor_version_as_new_as(ver, "0.2.0.0-alpha") && (tor_version_as_new_as(ver, "0.2.0.0-alpha") &&
!tor_version_as_new_as(ver, "0.2.0.6-alpha"))) { !tor_version_as_new_as(ver, "0.2.0.6-alpha"))) {
msg = "was selected without regard for guard bandwidth"; msg = "was selected without regard for guard bandwidth";
version_is_bad = 1; } else if (entry->chosen_on_date + 3600*24*35 < this_month) {
/* It's been more than a month, and probably more like two since
* chosen_on_date is clipped to the beginning of its month. */
msg = "was selected several months ago";
} }
if (version_is_bad) {
if (msg) { /* we need to drop it */
char dbuf[HEX_DIGEST_LEN+1]; char dbuf[HEX_DIGEST_LEN+1];
tor_assert(msg);
base16_encode(dbuf, sizeof(dbuf), entry->identity, DIGEST_LEN); base16_encode(dbuf, sizeof(dbuf), entry->identity, DIGEST_LEN);
log_notice(LD_CIRC, "Entry guard '%s' (%s) %s. (Version=%s.) " log_notice(LD_CIRC, "Entry guard '%s' (%s) %s. (Version=%s.) "
"Replacing it.", "Replacing it.",
@ -2730,7 +2732,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
SMARTLIST_FOREACH(new_entry_guards, entry_guard_t *, e, SMARTLIST_FOREACH(new_entry_guards, entry_guard_t *, e,
entry_guard_free(e)); entry_guard_free(e));
smartlist_free(new_entry_guards); smartlist_free(new_entry_guards);
} else { /* !*err && set */ } else { /* !err && set */
if (entry_guards) { if (entry_guards) {
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e, SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e,
entry_guard_free(e)); entry_guard_free(e));
@ -2738,6 +2740,8 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
} }
entry_guards = new_entry_guards; entry_guards = new_entry_guards;
entry_guards_dirty = 0; entry_guards_dirty = 0;
/* XXX022 hand new_entry_guards to this func, and move it up a
* few lines, so we don't have to re-dirty it */
if (remove_obsolete_entry_guards()) if (remove_obsolete_entry_guards())
entry_guards_dirty = 1; entry_guards_dirty = 1;
} }