Commit b2553bfb authored by Mike Perry's avatar Mike Perry
Browse files

Use path type hint for Vegas queue parameters.

These parameters will vary depending on path length, especially for onions.
parent 0a6cde87
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -676,6 +676,7 @@ static const config_var_t option_vars_[] = {
  V(UseMicrodescriptors,         AUTOBOOL, "auto"),
  OBSOLETE("UseNTorHandshake"),
  VAR("__AlwaysCongestionControl",  BOOL, AlwaysCongestionControl, "0"),
  VAR("__SbwsExit",  BOOL, SbwsExit, "0"),
  V_IMMUTABLE(User,              STRING,   NULL),
  OBSOLETE("UserspaceIOCPBuffers"),
  OBSOLETE("V1AuthoritativeDirectory"),
+3 −0
Original line number Diff line number Diff line
@@ -604,6 +604,9 @@ struct or_options_t {
  /** Boolean: Switch to override consensus to enable congestion control */
  int AlwaysCongestionControl;

  /** Boolean: Switch to specify this is an sbws measurement exit */
  int SbwsExit;

  int RephistTrackTime; /**< How many seconds do we keep rephist info? */
  /** Should we always fetch our dir info on the mirror schedule (which
   * means directly from the authorities) no matter our other config? */
+7 −1
Original line number Diff line number Diff line
@@ -391,7 +391,13 @@ cpuworker_onion_handshake_replyfn(void *work_)
  /* If the client asked for congestion control, if our consensus parameter
   * allowed it to negotiate as enabled, allocate a congestion control obj. */
  if (rpl.circ_params.cc_enabled) {
    TO_CIRCUIT(circ)->ccontrol = congestion_control_new(&rpl.circ_params);
    if (get_options()->SbwsExit) {
      TO_CIRCUIT(circ)->ccontrol = congestion_control_new(&rpl.circ_params,
                                                          CC_PATH_SBWS);
    } else {
      TO_CIRCUIT(circ)->ccontrol = congestion_control_new(&rpl.circ_params,
                                                          CC_PATH_EXIT);
    }
  }

  if (onionskin_answer(circ,
+15 −1
Original line number Diff line number Diff line
@@ -1275,7 +1275,21 @@ circuit_finish_handshake(origin_circuit_t *circ,
  }

  if (params.cc_enabled) {
    hop->ccontrol = congestion_control_new(&params);
    int circ_len = circuit_get_cpath_len(circ);

    if (circ_len == DEFAULT_ROUTE_LEN &&
        circuit_get_cpath_hop(circ, DEFAULT_ROUTE_LEN) == hop) {
      hop->ccontrol = congestion_control_new(&params, CC_PATH_EXIT);
    } else if (circ_len == SBWS_ROUTE_LEN &&
               circuit_get_cpath_hop(circ, SBWS_ROUTE_LEN) == hop) {
      hop->ccontrol = congestion_control_new(&params, CC_PATH_SBWS);
    } else {
      static ratelim_t cc_path_limit = RATELIM_INIT(600);
      log_fn_ratelim(&cc_path_limit, LOG_WARN, LD_CIRC,
                     "Unexpected path length %d for circuit",
                     circ_len);
      hop->ccontrol = congestion_control_new(&params, CC_PATH_EXIT);
    }
  }

  hop->state = CPATH_STATE_OPEN;
+8 −6
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ congestion_control_new_consensus_params(const networkstatus_t *ns)
 */
static void
congestion_control_init_params(congestion_control_t *cc,
                               const circuit_params_t *params)
                               const circuit_params_t *params,
                               cc_path_t path)
{
  const or_options_t *opts = get_options();
  cc->sendme_inc = params->sendme_inc_cells;
@@ -266,7 +267,7 @@ congestion_control_init_params(congestion_control_t *cc,
  if (cc->cc_alg == CC_ALG_WESTWOOD) {
    congestion_control_westwood_set_params(cc);
  } else if (cc->cc_alg == CC_ALG_VEGAS) {
    congestion_control_vegas_set_params(cc);
    congestion_control_vegas_set_params(cc, path);
  } else if (cc->cc_alg == CC_ALG_NOLA) {
    congestion_control_nola_set_params(cc);
  }
@@ -326,24 +327,25 @@ congestion_control_set_cc_enabled(void)
 */
static void
congestion_control_init(congestion_control_t *cc,
                        const circuit_params_t *params)
                        const circuit_params_t *params,
                        cc_path_t path)
{
  cc->sendme_pending_timestamps = smartlist_new();
  cc->sendme_arrival_timestamps = smartlist_new();

  cc->in_slow_start = 1;
  congestion_control_init_params(cc, params);
  congestion_control_init_params(cc, params, path);

  cc->next_cc_event = CWND_UPDATE_RATE(cc);
}

/** Allocate and initialize a new congestion control object */
congestion_control_t *
congestion_control_new(const circuit_params_t *params)
congestion_control_new(const circuit_params_t *params, cc_path_t path)
{
  congestion_control_t *cc = tor_malloc_zero(sizeof(congestion_control_t));

  congestion_control_init(cc, params);
  congestion_control_init(cc, params, path);

  return cc;
}
Loading