]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
read the "circwindow" parameter from the consensus
authorRoger Dingledine <arma@torproject.org>
Wed, 14 Oct 2009 21:07:32 +0000 (17:07 -0400)
committerRoger Dingledine <arma@torproject.org>
Wed, 14 Oct 2009 21:07:32 +0000 (17:07 -0400)
backport of c43859c5c12361fad505
backport of 0d13e0ed145f4c1b5bd1

ChangeLog
src/or/circuitbuild.c
src/or/circuitlist.c
src/or/networkstatus.c
src/or/or.h
src/or/rendclient.c
src/or/rendservice.c

index 1f33eb741f27dad255aea09c1bc8b99edc57ef02..731a48388058d8f8e09bda6c38e3c4b746319728 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,11 @@ Changes in version 0.2.1.20 - 2009-??-??
       contains more than one signature from the same voter. Bugfix on
       0.2.0.3-alpha.
 
+  o Major features:
+    - Tor now reads the "circwindow" parameter out of the consensus,
+      and uses that value for its circuit package window rather than the
+      default of 1000 cells. Begins the implementation of proposal 168.
+
   o New directory authorities:
     - Set up urras (run by Jacob Appelbaum) as the seventh v3 directory
       authority.
index 983eb6dac11151251608394758aa556c930ca4b0..4b5ba62fa2564b39a1e3ff8c38cd1a65a1e7e2e3 100644 (file)
@@ -1829,7 +1829,7 @@ onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice)
 
   hop->extend_info = extend_info_dup(choice);
 
-  hop->package_window = CIRCWINDOW_START;
+  hop->package_window = circuit_initial_package_window();
   hop->deliver_window = CIRCWINDOW_START;
 
   return 0;
index 252eaf9f8eed19097a5dcbca2b397b178b48314a..5918bdd7aef1ac23950e5d092a7112dff7201344 100644 (file)
@@ -361,6 +361,19 @@ circuit_purpose_to_controller_string(uint8_t purpose)
   }
 }
 
+/** Pick a reasonable package_window to start out for our circuits.
+ * Originally this was hard-coded at 1000, but now the consensus votes
+ * on the answer. See proposal 168. */
+int32_t
+circuit_initial_package_window(void)
+{
+  int32_t num = networkstatus_get_param(NULL, "circwindow", CIRCWINDOW_START);
+  /* If the consensus tells us a negative number, we'd assert. */
+  if (num < 0)
+    num = CIRCWINDOW_START;
+  return num;
+}
+
 /** Initialize the common elements in a circuit_t, and add it to the global
  * list. */
 static void
@@ -368,7 +381,7 @@ init_circuit_base(circuit_t *circ)
 {
   circ->timestamp_created = time(NULL);
 
-  circ->package_window = CIRCWINDOW_START;
+  circ->package_window = circuit_initial_package_window();
   circ->deliver_window = CIRCWINDOW_START;
 
   circuit_add(circ);
index 05da73b5cbac4a1397a7fba32265ed2dd037548d..f4a0761f7b634aa55e06e8875d817dda95402f92 100644 (file)
@@ -1889,14 +1889,18 @@ networkstatus_dump_bridge_status_to_file(time_t now)
 }
 
 /** Return the value of a integer parameter from the networkstatus <b>ns</b>
- * whose name is <b>param_name</b>.  Return <b>default_val</b> if ns is NULL,
- * or if it has no parameter called <b>param_name</b>. */
+ * whose name is <b>param_name</b>.  If <b>ns</b> is NULL, try loading the
+ * latest consensus ourselves. Return <b>default_val</b> if no latest
+ * consensus, or if it has no parameter called <b>param_name</b>. */
 int32_t
 networkstatus_get_param(networkstatus_t *ns, const char *param_name,
                         int32_t default_val)
 {
   size_t name_len;
 
+  if (!ns) /* if they pass in null, go find it ourselves */
+    ns = networkstatus_get_latest_consensus();
+
   if (!ns || !ns->net_params)
     return default_val;
 
index 0c0d8e869e6f6e44727fdaa0ce95601ca381eb57..ae65127e368c76210beb4019e9f43151bb5a3d67 100644 (file)
@@ -1853,9 +1853,9 @@ typedef struct crypt_path_t {
   struct crypt_path_t *prev; /**< Link to previous crypt_path_t in the
                               * circuit. */
 
-  int package_window; /**< How many bytes are we allowed to originate ending
+  int package_window; /**< How many cells are we allowed to originate ending
                        * at this step? */
-  int deliver_window; /**< How many bytes are we willing to deliver originating
+  int deliver_window; /**< How many cells are we willing to deliver originating
                        * at this step? */
 } crypt_path_t;
 
@@ -2789,6 +2789,7 @@ void circuit_set_n_circid_orconn(circuit_t *circ, circid_t id,
                                  or_connection_t *conn);
 void circuit_set_state(circuit_t *circ, uint8_t state);
 void circuit_close_all_marked(void);
+int32_t circuit_initial_package_window(void);
 origin_circuit_t *origin_circuit_new(void);
 or_circuit_t *or_circuit_new(circid_t p_circ_id, or_connection_t *p_conn);
 circuit_t *circuit_get_by_circid_orconn(circid_t circ_id,
index 13e43c87b7c0592dd95fce60b7f8a068fd150958..47a8818a503d3268781ab2c9467dd31bd5c4e1f4 100644 (file)
@@ -703,7 +703,7 @@ rend_client_receive_rendezvous(origin_circuit_t *circ, const char *request,
   /* set the windows to default. these are the windows
    * that alice thinks bob has.
    */
-  hop->package_window = CIRCWINDOW_START;
+  hop->package_window = circuit_initial_package_window();
   hop->deliver_window = CIRCWINDOW_START;
 
   onion_append_to_cpath(&circ->cpath, hop);
index 3144ef2f04440dbffd1ae55af2b7c88d00ed1a98..d2868b738d65d2546efcc08941406af689545b51 100644 (file)
@@ -1556,7 +1556,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
   /* set the windows to default. these are the windows
    * that bob thinks alice has.
    */
-  hop->package_window = CIRCWINDOW_START;
+  hop->package_window = circuit_initial_package_window();
   hop->deliver_window = CIRCWINDOW_START;
 
   onion_append_to_cpath(&circuit->cpath, hop);