From c36973d6d86a8644095eefa163330b114c2f7e4f Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Mon, 22 Nov 2021 20:43:11 -0800 Subject: [PATCH 1/2] In guard filtering code, warn if the filter is too small according to guard params --- crates/tor-guardmgr/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/tor-guardmgr/src/lib.rs b/crates/tor-guardmgr/src/lib.rs index d73a555b7..fcddbbf02 100644 --- a/crates/tor-guardmgr/src/lib.rs +++ b/crates/tor-guardmgr/src/lib.rs @@ -347,7 +347,14 @@ impl GuardMgr { // TODO: Once we support nontrivial filters, we might have to // swap out "active_guards" depending on which set it is. - // TODO: Warn if the filter is waaaay to small according to guard params. + + if n_permitted < inner.params.min_filtered_sample_size { + warn!( + "The number of guards permitted is smaller than the guard param minimum of {}", + inner.params.min_filtered_sample_size, + ); + } + info!( ?filter, restrictive = restrictive_filter, From 22f2a696367a056d7ccbb69e632eb3a3e83f92b2 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Tue, 23 Nov 2021 09:26:24 -0800 Subject: [PATCH 2/2] Use guard-extreme-restriction-percent --- crates/tor-guardmgr/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/tor-guardmgr/src/lib.rs b/crates/tor-guardmgr/src/lib.rs index fcddbbf02..f550cac13 100644 --- a/crates/tor-guardmgr/src/lib.rs +++ b/crates/tor-guardmgr/src/lib.rs @@ -348,10 +348,10 @@ impl GuardMgr { // TODO: Once we support nontrivial filters, we might have to // swap out "active_guards" depending on which set it is. - if n_permitted < inner.params.min_filtered_sample_size { + if frac_permitted < inner.params.extreme_threshold { warn!( - "The number of guards permitted is smaller than the guard param minimum of {}", - inner.params.min_filtered_sample_size, + "The number of guards permitted is smaller than the guard param minimum of {}%.", + inner.params.extreme_threshold * 100.0, ); } @@ -741,6 +741,9 @@ struct GuardParams { /// /// (Not fully implemented yet.) filter_threshold: f64, + /// What fraction of the guards determine that our filter is "very + /// restrictive"? + extreme_threshold: f64, } impl Default for GuardParams { @@ -760,6 +763,7 @@ impl Default for GuardParams { np_idle_timeout: Duration::from_secs(600), internet_down_timeout: Duration::from_secs(600), filter_threshold: 0.2, + extreme_threshold: 0.01, } } } @@ -781,6 +785,7 @@ impl TryFrom<&NetParameters> for GuardParams { np_idle_timeout: p.guard_nonprimary_idle_timeout.try_into()?, internet_down_timeout: p.guard_internet_likely_down.try_into()?, filter_threshold: p.guard_meaningful_restriction.as_fraction(), + extreme_threshold: p.guard_extreme_restriction.as_fraction(), }) } }