[or-cvs] [tor/master] read the "circwindow" parameter from the consensus

Nick Mathewson nickm at seul.org
Wed Oct 14 21:22:20 UTC 2009


Author: Roger Dingledine <arma at torproject.org>
Date: Wed, 14 Oct 2009 17:07:32 -0400
Subject: read the "circwindow" parameter from the consensus
Commit: 23943364263b8cb38e81a63715f872691269d5ed

backport of c43859c5c12361fad505
backport of 0d13e0ed145f4c1b5bd1
---
 ChangeLog              |    5 +++++
 src/or/circuitbuild.c  |    2 +-
 src/or/circuitlist.c   |   15 ++++++++++++++-
 src/or/networkstatus.c |    8 ++++++--
 src/or/or.h            |    5 +++--
 src/or/rendclient.c    |    2 +-
 src/or/rendservice.c   |    2 +-
 7 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1f33eb7..731a483 100644
--- 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.
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 983eb6d..4b5ba62 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -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;
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 252eaf9..5918bdd 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -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);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 05da73b..f4a0761 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -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;
 
diff --git a/src/or/or.h b/src/or/or.h
index 0c0d8e8..ae65127 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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,
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 13e43c8..47a8818 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -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);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 3144ef2..d2868b7 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -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);
-- 
1.5.6.5



More information about the tor-commits mailing list