diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-11-29 12:48:32 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-12-16 11:06:19 -0500 |
commit | 80fa404625b757cbde07be76abf848efadab7c46 (patch) | |
tree | 705b08cd0eb076218fa5972b11b8eef2b8eea634 | |
parent | eac8b3f758545f02fd7db58c458de19a6442044b (diff) | |
download | tor-80fa404625b757cbde07be76abf848efadab7c46.tar.gz tor-80fa404625b757cbde07be76abf848efadab7c46.zip |
Fix for small test networks: don't refuse to have any sampled guards.
Don't restrict the sample size if the network size is less than 20
guards. Maybe we'll think of a better rule later on?
-rw-r--r-- | src/or/entrynodes.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 3ba01794da..8380dbf3d8 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -891,6 +891,23 @@ num_reachable_filtered_guards(guard_selection_t *gs) return n_reachable_filtered_guards; } +/** Return the actual maximum size for the sample in <b>gs</b>, + * given that we know about <b>n_guards</b> total. */ +static int +get_max_sample_size(guard_selection_t *gs, + int n_guards) +{ + const int using_bridges = (gs->type == GS_TYPE_BRIDGE); + + /* XXXX prop271 spec deviation with bridges, max_sample is "all of them" */ + if (using_bridges) + return n_guards; + else if (n_guards < 20) // XXXX prop271 spec deviation + return n_guards; + else + return (int)(n_guards * get_max_sample_threshold()); +} + /** * Return a smartlist of the all the guards that are not currently * members of the sample (GUARDS - SAMPLED_GUARDS). The elements of @@ -987,11 +1004,7 @@ entry_guards_expand_sample(guard_selection_t *gs) int n_guards = 0; smartlist_t *eligible_guards = get_eligible_guards(gs, &n_guards); - const int using_bridges = (gs->type == GS_TYPE_BRIDGE); - - /* XXXX prop271 spec deviation with bridges, max_sample is "all of them" */ - const int max_sample = using_bridges ? n_guards : - (int)(n_guards * get_max_sample_threshold()); + const int max_sample = get_max_sample_size(gs, n_guards); const int min_filtered_sample = get_min_filtered_sample_size(); log_info(LD_GUARD, "Expanding the sample guard set. We have %d guards " |