summaryrefslogtreecommitdiff
path: root/src/test/test_entrynodes.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-06-29 15:57:48 -0400
committerNick Mathewson <nickm@torproject.org>2017-06-29 15:57:48 -0400
commit1712dc98b04ef7b84df67e02da21ea1aa70bc74c (patch)
tree8afe3757200bec46df6496e2763e6f196865359b /src/test/test_entrynodes.c
parent31a08ba26fc5eaa12de6d3c5efa3aac4d00509d0 (diff)
parent52c4440c4895cb90dd155bb094b49a97128baedf (diff)
downloadtor-1712dc98b04ef7b84df67e02da21ea1aa70bc74c.tar.gz
tor-1712dc98b04ef7b84df67e02da21ea1aa70bc74c.zip
Merge branch 'maint-0.3.0' into maint-0.3.1
Diffstat (limited to 'src/test/test_entrynodes.c')
-rw-r--r--src/test/test_entrynodes.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index 3db7e63ee3..1f008d93b3 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -121,6 +121,8 @@ big_fake_network_setup(const struct testcase_t *testcase)
n->is_running = n->is_valid = n->is_fast = n->is_stable = 1;
+ /* Note: all these guards have the same address, so you'll need to
+ * disable EnforceDistinctSubnets when a restriction is applied. */
n->rs->addr = 0x04020202;
n->rs->or_port = 1234;
n->rs->is_v2_dir = 1;
@@ -1846,14 +1848,17 @@ test_entry_guard_select_for_circuit_confirmed(void *arg)
tt_uint_op(state, OP_EQ, GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD);
tt_i64_op(g2->last_tried_to_connect, OP_EQ, approx_time());
- // If we say that the next confirmed guard in order is excluded, we get
- // The one AFTER that.
+ // If we say that the next confirmed guard in order is excluded, and
+ // we disable EnforceDistinctSubnets, we get the guard AFTER the
+ // one we excluded.
+ get_options_mutable()->EnforceDistinctSubnets = 0;
g = smartlist_get(gs->confirmed_entry_guards,
smartlist_len(gs->primary_entry_guards)+2);
entry_guard_restriction_t rst;
memset(&rst, 0, sizeof(rst));
memcpy(rst.exclude_id, g->identity, DIGEST_LEN);
g2 = select_entry_guard_for_circuit(gs, GUARD_USAGE_TRAFFIC, &rst, &state);
+ tt_ptr_op(g2, OP_NE, NULL);
tt_ptr_op(g2, OP_NE, g);
tt_int_op(g2->confirmed_idx, OP_EQ,
smartlist_len(gs->primary_entry_guards)+3);
@@ -1873,6 +1878,16 @@ test_entry_guard_select_for_circuit_confirmed(void *arg)
tt_assert(g->is_pending);
tt_int_op(g->confirmed_idx, OP_EQ, -1);
+ // If we EnforceDistinctSubnets and apply a restriction, we get
+ // nothing, since we put all of the nodes in the same /16.
+ // Regression test for bug 22753/TROVE-2017-006.
+ get_options_mutable()->EnforceDistinctSubnets = 1;
+ g = smartlist_get(gs->confirmed_entry_guards, 0);
+ memset(&rst, 0, sizeof(rst));
+ memcpy(rst.exclude_id, g->identity, DIGEST_LEN);
+ g2 = select_entry_guard_for_circuit(gs, GUARD_USAGE_TRAFFIC, &rst, &state);
+ tt_ptr_op(g2, OP_EQ, NULL);
+
done:
guard_selection_free(gs);
}