Commit 23943364 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

read the "circwindow" parameter from the consensus

backport of c43859c5
backport of 0d13e0ed
parent 83c3f118
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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;
+14 −1
Original line number Diff line number Diff line
@@ -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);
+6 −2
Original line number Diff line number Diff line
@@ -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;

+3 −2
Original line number Diff line number Diff line
@@ -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,
Loading