summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2009-10-14 17:07:32 -0400
committerRoger Dingledine <arma@torproject.org>2009-10-14 17:07:32 -0400
commit23943364263b8cb38e81a63715f872691269d5ed (patch)
tree263f2411ed01a8f25307a33b00197141657f0f3e
parent83c3f118db0ae3911ea72403856df9fb08b2d0e5 (diff)
downloadtor-23943364263b8cb38e81a63715f872691269d5ed.tar.gz
tor-23943364263b8cb38e81a63715f872691269d5ed.zip
read the "circwindow" parameter from the consensus
backport of c43859c5c12361fad505 backport of 0d13e0ed145f4c1b5bd1
-rw-r--r--ChangeLog5
-rw-r--r--src/or/circuitbuild.c2
-rw-r--r--src/or/circuitlist.c15
-rw-r--r--src/or/networkstatus.c8
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/rendclient.c2
-rw-r--r--src/or/rendservice.c2
7 files changed, 31 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f33eb741f..731a483880 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 983eb6dac1..4b5ba62fa2 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 252eaf9f8e..5918bdd7ae 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 05da73b5cb..f4a0761f7b 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 0c0d8e869e..ae65127e36 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 13e43c87b7..47a8818a50 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 3144ef2f04..d2868b738d 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);