[or-cvs] [tor/master] Read "circwindow=x" from the consensus and use it

arma at seul.org arma at seul.org
Tue Sep 15 10:35:41 UTC 2009


Author: Roger Dingledine <arma at torproject.org>
Date: Tue, 15 Sep 2009 06:33:33 -0400
Subject: Read "circwindow=x" from the consensus and use it
Commit: c43859c5c12361fad50580cd76f6484dfaa6b88d

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.
---
 ChangeLog             |    5 ++++-
 src/or/circuitbuild.c |    2 +-
 src/or/circuitlist.c  |   14 +++++++++++++-
 src/or/or.h           |    5 +++--
 src/or/rendclient.c   |    2 +-
 src/or/rendservice.c  |    2 +-
 6 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b1cb770..b6863ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,11 @@
 Changes in version 0.2.2.2-alpha - 2009-09-??
   o Major features:
     - Authorities can now vote on arbitary integer values as part of the
-      consensus process.  This is designed to help set network parameters.
+      consensus process. This is designed to help set network parameters.
       Implements proposal 167.
+    - 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 Minor bugfixes:
     - Fix an extremely rare infinite recursion bug that could occur if
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 4432c25..6f559d9 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1833,7 +1833,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 0655596..e1da117 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -361,6 +361,18 @@ 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)
+{
+  networkstatus_t *consensus = networkstatus_get_latest_consensus();
+  if (consensus)
+    return networkstatus_get_param(consensus, "circwindow", CIRCWINDOW_START);
+  return CIRCWINDOW_START;
+}
+
 /** Initialize the common elements in a circuit_t, and add it to the global
  * list. */
 static void
@@ -368,7 +380,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/or.h b/src/or/or.h
index c93b8ed..8587ea6 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1870,9 +1870,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;
 
@@ -2864,6 +2864,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 141efdc..fc8d05b 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -644,7 +644,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 7a970e4..1beebd2 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1477,7 +1477,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