From a31a5581eecc900c9e3d7be78ea06a3ea7fe32a3 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 18 Jan 2017 15:33:26 -0500 Subject: [PATCH] Remove UseDeprecatedGuardAlgorithm. --- src/or/bridges.c | 11 ++--------- src/or/circuitbuild.c | 5 +---- src/or/config.c | 4 ---- src/or/entrynodes.c | 26 +++----------------------- src/or/or.h | 8 -------- src/test/test_entrynodes.c | 19 ------------------- 6 files changed, 6 insertions(+), 67 deletions(-) diff --git a/src/or/bridges.c b/src/or/bridges.c index d9a8873c96..8b37f412ea 100644 --- a/src/or/bridges.c +++ b/src/or/bridges.c @@ -761,20 +761,13 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache) fmt_and_decorate_addr(&bridge->addr), (int) bridge->port); } - if (get_options()->UseDeprecatedGuardAlgorithm) { - tor_assert_nonfatal_unreached(); - } else { - entry_guard_learned_bridge_identity(&bridge->addrport_configured, - (const uint8_t*)ri->cache_info.identity_digest); - } + entry_guard_learned_bridge_identity(&bridge->addrport_configured, + (const uint8_t*)ri->cache_info.identity_digest); log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname, from_cache ? "cached" : "fresh", router_describe(ri)); /* set entry->made_contact so if it goes down we don't drop it from * our entry node list */ - if (get_options()->UseDeprecatedGuardAlgorithm) { - tor_assert_nonfatal_unreached(); - } if (first) { routerlist_retry_directory_downloads(now); } diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 91bd823451..f11c865ad0 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -967,10 +967,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) if (!hop) { /* done building the circuit. whew. */ guard_usable_t r; - if (get_options()->UseDeprecatedGuardAlgorithm) { - // The circuit is usable; we already marked the guard as okay. - r = GUARD_USABLE_NOW; - } else if (! circ->guard_state) { + if (! circ->guard_state) { if (circuit_get_cpath_len(circ) != 1 && circ->base_.purpose != CIRCUIT_PURPOSE_TESTING && get_options()->UseEntryGuards) { diff --git a/src/or/config.c b/src/or/config.c index 7240308c2f..7a1623ff5d 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -308,9 +308,6 @@ static config_var_t option_vars_[] = { V(ExtraInfoStatistics, BOOL, "1"), V(ExtendByEd25519ID, AUTOBOOL, "auto"), V(FallbackDir, LINELIST, NULL), - /* XXXX prop271 -- this has an ugly name to remind us to remove it. */ - VAR("UseDeprecatedGuardAlgorithm_", BOOL, - UseDeprecatedGuardAlgorithm, "0"), V(UseDefaultFallbackDirs, BOOL, "1"), @@ -1578,7 +1575,6 @@ options_transition_affects_guards(const or_options_t *old, return (old->UseEntryGuards != new->UseEntryGuards || - old->UseDeprecatedGuardAlgorithm != new->UseDeprecatedGuardAlgorithm || old->UseBridges != new->UseBridges || old->UseEntryGuards != new->UseEntryGuards || old->ClientUseIPv4 != new->ClientUseIPv4 || diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 195c6b98ad..3e3dff3f00 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -546,10 +546,6 @@ choose_guard_selection(const or_options_t *options, { tor_assert(options); tor_assert(type_out); - if (options->UseDeprecatedGuardAlgorithm) { - *type_out = GS_TYPE_LEGACY; - return "legacy"; - } if (options->UseBridges) { *type_out = GS_TYPE_BRIDGE; @@ -2113,9 +2109,6 @@ entry_guard_pick_for_circuit(guard_selection_t *gs, guard_usable_t entry_guard_succeeded(circuit_guard_state_t **guard_state_p) { - if (get_options()->UseDeprecatedGuardAlgorithm) - return GUARD_USABLE_NOW; - if (BUG(*guard_state_p == NULL)) return GUARD_USABLE_NEVER; @@ -2143,8 +2136,6 @@ entry_guard_succeeded(circuit_guard_state_t **guard_state_p) void entry_guard_cancel(circuit_guard_state_t **guard_state_p) { - if (get_options()->UseDeprecatedGuardAlgorithm) - return; if (BUG(*guard_state_p == NULL)) return; entry_guard_t *guard = entry_guard_handle_get((*guard_state_p)->guard); @@ -2166,9 +2157,6 @@ entry_guard_cancel(circuit_guard_state_t **guard_state_p) void entry_guard_failed(circuit_guard_state_t **guard_state_p) { - if (get_options()->UseDeprecatedGuardAlgorithm) - return; - if (BUG(*guard_state_p == NULL)) return; @@ -2191,8 +2179,6 @@ entry_guard_chan_failed(channel_t *chan) { if (!chan) return; - if (get_options()->UseDeprecatedGuardAlgorithm) - return; smartlist_t *pending = smartlist_new(); circuit_get_all_pending_on_channel(pending, chan); @@ -3278,10 +3264,7 @@ const node_t * guards_choose_guard(cpath_build_state_t *state, circuit_guard_state_t **guard_state_out) { - if (get_options()->UseDeprecatedGuardAlgorithm) { - tor_assert_nonfatal_unreached(); - return NULL; - } else { + if (1) { const node_t *r = NULL; const uint8_t *exit_id = NULL; entry_guard_restriction_t *rst = NULL; @@ -3308,11 +3291,7 @@ const node_t * guards_choose_dirguard(dirinfo_type_t info, circuit_guard_state_t **guard_state_out) { - if (get_options()->UseDeprecatedGuardAlgorithm) { - (void)info; - tor_assert_nonfatal_unreached(); - return NULL; - } else { + if (1) { /* XXXX prop271 We don't need to look at the dirinfo_type_t here, * apparently. If you look at the old implementation, and you follow info * downwards through choose_random_dirguard(), into @@ -3320,6 +3299,7 @@ guards_choose_dirguard(dirinfo_type_t info, * find out that it isn't even used, and hasn't been since 0.2.7.1-alpha, * when we realized that every Tor on the network would support * microdescriptors. -NM */ + (void) info; const node_t *r = NULL; if (entry_guard_pick_for_circuit(get_guard_selection_info(), GUARD_USAGE_DIRGUARD, diff --git a/src/or/or.h b/src/or/or.h index 6292c499df..81fcf61a15 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -4574,14 +4574,6 @@ typedef struct { * do we enforce Ed25519 identity match? */ /* NOTE: remove this option someday. */ int AuthDirTestEd25519LinkKeys; - - /** If 1, we use the old (pre-prop271) guard selection algorithm. - * - * XXXX prop271 This option is only here as a stopgap while we're - * XXXX tuning and debugging the new (post-prop271) algorithm. Eventually - * we should remove it entirely. - */ - int UseDeprecatedGuardAlgorithm; } or_options_t; /** Persistent state for an onion router, as saved to disk. */ diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index 2e7abd1e00..772ecaa275 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -789,17 +789,6 @@ test_entry_guard_get_guard_selection_by_name(void *arg) tt_assert(gs3 != gs1); tt_assert(gs3 == get_guard_selection_info()); - or_options_t *options = get_options_mutable(); - options->UseDeprecatedGuardAlgorithm = 1; - update_guard_selection_choice(options); - guard_selection_t *gs4 = get_guard_selection_info(); - tt_assert(gs4 != gs3); - tt_assert(gs4 == get_guard_selection_by_name("legacy", GS_TYPE_LEGACY, 1)); - - options->UseDeprecatedGuardAlgorithm = 0; - update_guard_selection_choice(options); - tt_assert(gs3 == get_guard_selection_info()); - done: entry_guards_free_all(); } @@ -824,14 +813,6 @@ test_entry_guard_choose_selection_initial(void *arg) tt_int_op(type, OP_EQ, GS_TYPE_BRIDGE); get_options_mutable()->UseBridges = 0; - /* If we're using legacy guards, we get the legacy selection */ - get_options_mutable()->UseDeprecatedGuardAlgorithm = 1; - name = choose_guard_selection(get_options(), - dummy_consensus, NULL, &type); - tt_str_op(name, OP_EQ, "legacy"); - tt_int_op(type, OP_EQ, GS_TYPE_LEGACY); - get_options_mutable()->UseDeprecatedGuardAlgorithm = 0; - /* If we discard >99% of our guards, though, we should be in the restricted * set. */ tt_assert(get_options_mutable()->EntryNodes == NULL);