aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-01-29 11:05:13 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-30 11:58:17 -0500
commit02c320916e025eca63d0ae23aa4f610095c7857c (patch)
treeedeec6ef2067d0db80c69c2ff28759ce9fadf9a8 /src
parent813a0f8c40d57390412ce9dc52ef503d80e1f474 (diff)
downloadtor-02c320916e025eca63d0ae23aa4f610095c7857c.tar.gz
tor-02c320916e025eca63d0ae23aa4f610095c7857c.zip
Parameterize FRAC_USABLE_NEEDED for fraction of circuits
Instead of hardcoding the minimum fraction of possible paths to 0.6, we take it from the user, and failing that from the consensus, and failing that we fall back to 0.6.
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c13
-rw-r--r--src/or/nodelist.c21
-rw-r--r--src/or/or.h3
3 files changed, 33 insertions, 4 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 4349b670b0..e503645468 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -325,6 +325,7 @@ static config_var_t option_vars_[] = {
V(PathBiasDropGuards, AUTOBOOL, "0"),
V(PathBiasUseCloseCounts, AUTOBOOL, "1"),
+ V(PathsNeededToBuildCircuits, DOUBLE, "-1"),
OBSOLETE("PathlenCoinWeight"),
V(PerConnBWBurst, MEMUNIT, "0"),
V(PerConnBWRate, MEMUNIT, "0"),
@@ -2386,6 +2387,18 @@ options_validate(or_options_t *old_options, or_options_t *options,
return -1;
}
+ if (options->PathsNeededToBuildCircuits >= 0.0) {
+ if (options->PathsNeededToBuildCircuits < 0.25) {
+ log_warn(LD_CONFIG, "PathsNeededToBuildCircuits is too low. Increasing "
+ "to 0.25");
+ options->PathsNeededToBuildCircuits = 0.25;
+ } else if (options->PathsNeededToBuildCircuits < 0.95) {
+ log_warn(LD_CONFIG, "PathsNeededToBuildCircuits is too high. Decreasing "
+ "to 0.95");
+ options->PathsNeededToBuildCircuits = 0.95;
+ }
+ }
+
if (options->MaxClientCircuitsPending <= 0 ||
options->MaxClientCircuitsPending > MAX_MAX_CLIENT_CIRCUITS_PENDING) {
tor_asprintf(msg,
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 77e4ae0fed..4d7395b047 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1387,6 +1387,22 @@ count_loading_descriptors_progress(void)
BOOTSTRAP_STATUS_LOADING_DESCRIPTORS));
}
+/** Return the fraction of paths needed before we're willing to build
+ * circuits, as configured in <b>options</b>, or in the consensus <b>ns</b>. */
+static double
+get_frac_paths_needed_for_circs(const or_options_t *options,
+ const networkstatus_t *ns)
+{
+#define DFLT_PCT_USABLE_NEEDED 60
+ if (options->PathsNeededToBuildCircuits >= 1.0) {
+ return options->PathsNeededToBuildCircuits;
+ } else {
+ return networkstatus_get_param(ns, "min_paths_for_circs_pct",
+ DFLT_PCT_USABLE_NEEDED,
+ 25, 95)/100.0;
+ }
+}
+
/** Change the value of have_min_dir_info, setting it true iff we have enough
* network and router information to build circuits. Clear the value of
* need_to_update_have_min_dir_info. */
@@ -1428,10 +1444,7 @@ update_router_have_minimum_dir_info(void)
&num_present, &num_usable,
&status);
-/* What fraction of desired paths do we need before we will build circuits? */
-#define FRAC_USABLE_NEEDED .6
-
- if (paths < FRAC_USABLE_NEEDED) {
+ if (paths < get_frac_paths_needed_for_circs(options,consensus)) {
tor_snprintf(dir_info_status, sizeof(dir_info_status),
"We need more %sdescriptors: we have %d/%d, and "
"can only build %02d%% of likely paths. (We have %s.)",
diff --git a/src/or/or.h b/src/or/or.h
index a6f3d3e88a..4c76adf98f 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3918,6 +3918,9 @@ typedef struct {
/** Autobool: should we use the ntor handshake if we can? */
int UseNTorHandshake;
+
+ /** Fraction: */
+ double PathsNeededToBuildCircuits;
} or_options_t;
/** Persistent state for an onion router, as saved to disk. */