aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2009-09-15 06:33:33 -0400
committerRoger Dingledine <arma@torproject.org>2009-09-15 06:33:33 -0400
commitc43859c5c12361fad50580cd76f6484dfaa6b88d (patch)
tree51b9a69d25e6c9923452aee270518de554968098 /src/or
parent40bcab1faf26dd26de48b5ea6c1846c562a11f9d (diff)
downloadtor-c43859c5c12361fad50580cd76f6484dfaa6b88d.tar.gz
tor-c43859c5c12361fad50580cd76f6484dfaa6b88d.zip
Read "circwindow=x" from the consensus and use it
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.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c2
-rw-r--r--src/or/circuitlist.c14
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/rendclient.c2
-rw-r--r--src/or/rendservice.c2
5 files changed, 19 insertions, 6 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 4432c25493..6f559d9886 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 065559620c..e1da117168 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 c93b8ed0fd..8587ea61fc 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 141efdc6a3..fc8d05b6ad 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 7a970e490d..1beebd2ed6 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);