]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Parameterize FRAC_USABLE_NEEDED for fraction of circuits
authorNick Mathewson <nickm@torproject.org>
Tue, 29 Jan 2013 16:05:13 +0000 (11:05 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 30 Jan 2013 16:58:17 +0000 (11:58 -0500)
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.

changes/feature5956
doc/tor.1.txt
src/or/config.c
src/or/nodelist.c
src/or/or.h

index dbc6a1ef80f269dd4874058c0b39b554971e48eb..2e188105886318227d53d85fb61b4051e5d410ce 100644 (file)
@@ -3,4 +3,6 @@
       instead of looking at raw circuit counts, look at which fraction of
       (bandwidth-weighted) paths we're able to build. This approach keeps
       clients from building circuits if their paths are likely to stand out
-      statistically. Fixes issue 5956.
+      statistically. The default fraction of paths needed is taken from the
+      consensus directory; you can override it with the new
+      PathsNeededToBuildCircuits option.  Fixes issue 5956.
index 40cf66dbc454049614723b455a6420a66c42be6e..2b616bd26cac6cae1bb8773953b9eb122ea1250a 100644 (file)
@@ -1282,6 +1282,18 @@ The following options are useful only for clients (that is, if
     things may influence the choice. This option breaks a tie to the
     favor of IPv6. (Default: 0)
 
+**PathsNeededToBuildCircuits** __NUM__::
+    Tor clients don't build circuits for user traffic until they know
+    about enough of the network so that they could potentially construct
+    enough of the possible paths through the network. If this option
+    is set to a fraction between 0.25 and 0.95, Tor won't build circuits
+    until it has enough descriptors or microdescriptors to construct
+    that fraction of possible paths. Note that setting this option too low
+    can make your Tor client less anonymous, and setting it too high can
+    prevent your Tor client from bootstrapping.  If this option is negative,
+    Tor will use a default value chosen by the directory
+    authorities. (Default: -1.)
+
 
 SERVER OPTIONS
 --------------
index 4349b670b06f55f02918be7ccaf17395130f9467..e503645468f39e4ce4f260ca36a7c70540ebdf55 100644 (file)
@@ -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,
index 77e4ae0fed9c219801741ef29761c6e01dd8fb63..4d7395b047776f8b2302f089b532588b13982a18 100644 (file)
@@ -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.)",
index a6f3d3e88ab4ae041ac70b076887de045072718f..4c76adf98faa086a903945a324857a6c6d459324 100644 (file)
@@ -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. */