summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-06-22 10:56:08 -0400
committerNick Mathewson <nickm@torproject.org>2017-06-22 10:56:08 -0400
commite23084bc6a9343013988d7c14c7a70b8244825ce (patch)
treeeb3977734064e589b82a25c592742b2aaf42f29e
parent1bf534c8b37d0f1608395e9362384afb1f4f7187 (diff)
parentbdd267e74d97cf2672fa2e1e9deb2a33fd755f2c (diff)
downloadtor-e23084bc6a9343013988d7c14c7a70b8244825ce.tar.gz
tor-e23084bc6a9343013988d7c14c7a70b8244825ce.zip
Merge branch 'maint-0.3.0' into release-0.3.0
-rw-r--r--changes/bug22400_014
-rw-r--r--src/or/entrynodes.c36
2 files changed, 29 insertions, 11 deletions
diff --git a/changes/bug22400_01 b/changes/bug22400_01
new file mode 100644
index 0000000000..454c5f746f
--- /dev/null
+++ b/changes/bug22400_01
@@ -0,0 +1,4 @@
+ o Major bugfixes (entry guards):
+ - When starting with an old consensus, do not add new entry guards
+ unless the consensus is "reasonably live" (under 1 day old). Fixes
+ one root cause of bug 22400; bugfix on 0.3.0.1-alpha.
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 5b5e13bced..aba35e69f7 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1093,6 +1093,18 @@ select_and_add_guard_item_for_sample(guard_selection_t *gs,
return added_guard;
}
+/** Return true iff we need a consensus to maintain our */
+static int
+live_consensus_is_missing(const guard_selection_t *gs)
+{
+ tor_assert(gs);
+ if (gs->type == GS_TYPE_BRIDGE) {
+ /* We don't update bridges from the consensus; they aren't there. */
+ return 0;
+ }
+ return networkstatus_get_live_consensus(approx_time()) == NULL;
+}
+
/**
* Add new guards to the sampled guards in <b>gs</b> until there are
* enough usable filtered guards, but never grow the sample beyond its
@@ -1104,6 +1116,13 @@ entry_guards_expand_sample(guard_selection_t *gs)
{
tor_assert(gs);
const or_options_t *options = get_options();
+
+ if (live_consensus_is_missing(gs)) {
+ log_info(LD_GUARD, "Not expanding the sample guard set; we have "
+ "no live consensus.");
+ return NULL;
+ }
+
int n_sampled = smartlist_len(gs->sampled_entry_guards);
entry_guard_t *added_guard = NULL;
int n_usable_filtered_guards = num_reachable_filtered_guards(gs, NULL);
@@ -1212,18 +1231,13 @@ sampled_guards_update_from_consensus(guard_selection_t *gs)
// It's important to use only a live consensus here; we don't want to
// make changes based on anything expired or old.
- if (gs->type != GS_TYPE_BRIDGE) {
- networkstatus_t *ns = networkstatus_get_live_consensus(approx_time());
-
- if (! ns) {
- log_info(LD_GUARD, "No live consensus; can't update "
- "sampled entry guards.");
- return;
- } else {
- log_info(LD_GUARD, "Updating sampled guard status based on received "
- "consensus.");
- }
+ if (live_consensus_is_missing(gs)) {
+ log_info(LD_GUARD, "Not updating the sample guard set; we have "
+ "no live consensus.");
+ return;
}
+ log_info(LD_GUARD, "Updating sampled guard status based on received "
+ "consensus.");
int n_changes = 0;