aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2012-12-09 20:18:31 -0800
committerMike Perry <mikeperry-git@fscked.org>2012-12-09 20:24:22 -0800
commita90f165b83bc1603873308d7918e99057afdf72a (patch)
tree448a417e48f16ef608fc78a6284ad1cd90d21c22 /src/or
parent04866055e8dadc9eb5b09773b3bbdc81e3b4dbbf (diff)
downloadtor-a90f165b83bc1603873308d7918e99057afdf72a.tar
tor-a90f165b83bc1603873308d7918e99057afdf72a.tar.gz
Rename first_hop to circ_attempt.
Since we've generalized what we can count from (first or second hop), we should generalize the variable and constant naming too.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/circuitbuild.c76
-rw-r--r--src/or/entrynodes.c12
-rw-r--r--src/or/entrynodes.h2
-rw-r--r--src/or/or.h4
4 files changed, 47 insertions, 47 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index ad52a6c44..42964ebef 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -59,7 +59,7 @@ static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
static int onion_extend_cpath(origin_circuit_t *circ);
static int count_acceptable_nodes(smartlist_t *routers);
static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
-static int entry_guard_inc_first_hop_count(entry_guard_t *guard);
+static int entry_guard_inc_circ_attempt_count(entry_guard_t *guard);
static void pathbias_count_build_success(origin_circuit_t *circ);
static void pathbias_count_successful_close(origin_circuit_t *circ);
static void pathbias_count_collapse(origin_circuit_t *circ);
@@ -987,7 +987,7 @@ circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
return 0;
}
-/** The minimum number of first hop completions before we start
+/** The minimum number of circuit attempts before we start
* thinking about warning about path bias and dropping guards */
static int
pathbias_get_min_circs(const or_options_t *options)
@@ -1134,8 +1134,8 @@ pathbias_state_to_string(path_state_t state)
switch (state) {
case PATH_STATE_NEW_CIRC:
return "new";
- case PATH_STATE_DID_FIRST_HOP:
- return "first hop";
+ case PATH_STATE_BUILD_ATTEMPTED:
+ return "build attempted";
case PATH_STATE_BUILD_SUCCEEDED:
return "build succeeded";
case PATH_STATE_USE_SUCCEEDED:
@@ -1230,17 +1230,17 @@ pathbias_should_count(origin_circuit_t *circ)
}
/**
- * Check our circuit state to see if this is a successful first hop.
- * If so, record it in the current guard's path bias first_hop count.
+ * Check our circuit state to see if this is a successful circuit attempt.
+ * If so, record it in the current guard's path bias circ_attempt count.
*
* Also check for several potential error cases for bug #6475.
*/
static int
-pathbias_count_first_hop(origin_circuit_t *circ)
+pathbias_count_circ_attempt(origin_circuit_t *circ)
{
-#define FIRST_HOP_NOTICE_INTERVAL (600)
- static ratelim_t first_hop_notice_limit =
- RATELIM_INIT(FIRST_HOP_NOTICE_INTERVAL);
+#define CIRC_ATTEMPT_NOTICE_INTERVAL (600)
+ static ratelim_t circ_attempt_notice_limit =
+ RATELIM_INIT(CIRC_ATTEMPT_NOTICE_INTERVAL);
char *rate_msg = NULL;
if (!pathbias_should_count(circ)) {
@@ -1249,8 +1249,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
if (pathbias_is_new_circ_attempt(circ)) {
/* Help track down the real cause of bug #6475: */
- if (circ->has_opened && circ->path_state != PATH_STATE_DID_FIRST_HOP) {
- if ((rate_msg = rate_limit_log(&first_hop_notice_limit,
+ if (circ->has_opened && circ->path_state != PATH_STATE_BUILD_ATTEMPTED) {
+ if ((rate_msg = rate_limit_log(&circ_attempt_notice_limit,
approx_time()))) {
log_info(LD_BUG,
"Opened circuit is in strange path state %s. "
@@ -1277,14 +1277,14 @@ pathbias_count_first_hop(origin_circuit_t *circ)
if (guard) {
if (circ->path_state == PATH_STATE_NEW_CIRC) {
- circ->path_state = PATH_STATE_DID_FIRST_HOP;
+ circ->path_state = PATH_STATE_BUILD_ATTEMPTED;
- if (entry_guard_inc_first_hop_count(guard) < 0) {
+ if (entry_guard_inc_circ_attempt_count(guard) < 0) {
/* Bogus guard; we already warned. */
return -END_CIRC_REASON_TORPROTOCOL;
}
} else {
- if ((rate_msg = rate_limit_log(&first_hop_notice_limit,
+ if ((rate_msg = rate_limit_log(&circ_attempt_notice_limit,
approx_time()))) {
log_info(LD_BUG,
"Unopened circuit has strange path state %s. "
@@ -1297,7 +1297,7 @@ pathbias_count_first_hop(origin_circuit_t *circ)
}
}
} else {
- if ((rate_msg = rate_limit_log(&first_hop_notice_limit,
+ if ((rate_msg = rate_limit_log(&circ_attempt_notice_limit,
approx_time()))) {
log_info(LD_BUG,
"Unopened circuit has no known guard. "
@@ -1312,7 +1312,7 @@ pathbias_count_first_hop(origin_circuit_t *circ)
} else {
/* Help track down the real cause of bug #6475: */
if (circ->path_state == PATH_STATE_NEW_CIRC) {
- if ((rate_msg = rate_limit_log(&first_hop_notice_limit,
+ if ((rate_msg = rate_limit_log(&circ_attempt_notice_limit,
approx_time()))) {
log_info(LD_BUG,
"A %s circuit is in cpath state %d (opened: %d). "
@@ -1359,12 +1359,12 @@ pathbias_count_build_success(origin_circuit_t *circ)
}
if (guard) {
- if (circ->path_state == PATH_STATE_DID_FIRST_HOP) {
+ if (circ->path_state == PATH_STATE_BUILD_ATTEMPTED) {
circ->path_state = PATH_STATE_BUILD_SUCCEEDED;
guard->circuit_successes++;
log_info(LD_CIRC, "Got success count %u/%u for guard %s=%s",
- guard->circuit_successes, guard->first_hops,
+ guard->circuit_successes, guard->circ_attempts,
guard->nickname, hex_str(guard->identity, DIGEST_LEN));
} else {
if ((rate_msg = rate_limit_log(&success_notice_limit,
@@ -1380,10 +1380,10 @@ pathbias_count_build_success(origin_circuit_t *circ)
}
}
- if (guard->first_hops < guard->circuit_successes) {
+ if (guard->circ_attempts < guard->circuit_successes) {
log_notice(LD_BUG, "Unexpectedly high circuit_successes (%u/%u) "
"for guard %s=%s",
- guard->circuit_successes, guard->first_hops,
+ guard->circuit_successes, guard->circ_attempts,
guard->nickname, hex_str(guard->identity, DIGEST_LEN));
}
/* In rare cases, CIRCUIT_PURPOSE_TESTING can get converted to
@@ -1657,17 +1657,17 @@ pathbias_get_success_count(entry_guard_t *guard)
* eliminate the guard. Return -1 if the guard looks no good; return 0 if the
* guard looks fine. */
static int
-entry_guard_inc_first_hop_count(entry_guard_t *guard)
+entry_guard_inc_circ_attempt_count(entry_guard_t *guard)
{
const or_options_t *options = get_options();
entry_guards_changed();
- if (guard->first_hops > (unsigned)pathbias_get_min_circs(options)) {
+ if (guard->circ_attempts > (unsigned)pathbias_get_min_circs(options)) {
/* Note: We rely on the < comparison here to allow us to set a 0
* rate and disable the feature entirely. If refactoring, don't
* change to <= */
- if (pathbias_get_success_count(guard)/((double)guard->first_hops)
+ if (pathbias_get_success_count(guard)/((double)guard->circ_attempts)
< pathbias_get_extreme_rate(options)) {
/* Dropping is currently disabled by default. */
if (pathbias_get_dropguards(options)) {
@@ -1680,7 +1680,7 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
"were unusable, %d collapsed, and %d timed out. For "
"reference, your timeout cutoff is %ld seconds.",
guard->nickname, hex_str(guard->identity, DIGEST_LEN),
- pathbias_get_closed_count(guard), guard->first_hops,
+ pathbias_get_closed_count(guard), guard->circ_attempts,
guard->circuit_successes, guard->unusable_circuits,
guard->collapsed_circuits, guard->timeouts,
(long)circ_times.close_ms/1000);
@@ -1698,12 +1698,12 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
"were unusable, %d collapsed, and %d timed out. For "
"reference, your timeout cutoff is %ld seconds.",
guard->nickname, hex_str(guard->identity, DIGEST_LEN),
- pathbias_get_closed_count(guard), guard->first_hops,
+ pathbias_get_closed_count(guard), guard->circ_attempts,
guard->circuit_successes, guard->unusable_circuits,
guard->collapsed_circuits, guard->timeouts,
(long)circ_times.close_ms/1000);
}
- } else if (pathbias_get_success_count(guard)/((double)guard->first_hops)
+ } else if (pathbias_get_success_count(guard)/((double)guard->circ_attempts)
< pathbias_get_warn_rate(options)) {
if (!guard->path_bias_warned) {
guard->path_bias_warned = 1;
@@ -1716,12 +1716,12 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
"were unusable, %d collapsed, and %d timed out. For "
"reference, your timeout cutoff is %ld seconds.",
guard->nickname, hex_str(guard->identity, DIGEST_LEN),
- pathbias_get_closed_count(guard), guard->first_hops,
+ pathbias_get_closed_count(guard), guard->circ_attempts,
guard->circuit_successes, guard->unusable_circuits,
guard->collapsed_circuits, guard->timeouts,
(long)circ_times.close_ms/1000);
}
- } else if (pathbias_get_success_count(guard)/((double)guard->first_hops)
+ } else if (pathbias_get_success_count(guard)/((double)guard->circ_attempts)
< pathbias_get_notice_rate(options)) {
if (!guard->path_bias_noticed) {
guard->path_bias_noticed = 1;
@@ -1732,7 +1732,7 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
"were unusable, %d collapsed, and %d timed out. For "
"reference, your timeout cutoff is %ld seconds.",
guard->nickname, hex_str(guard->identity, DIGEST_LEN),
- pathbias_get_closed_count(guard), guard->first_hops,
+ pathbias_get_closed_count(guard), guard->circ_attempts,
guard->circuit_successes, guard->unusable_circuits,
guard->collapsed_circuits, guard->timeouts,
(long)circ_times.close_ms/1000);
@@ -1741,27 +1741,27 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
}
/* If we get a ton of circuits, just scale everything down */
- if (guard->first_hops > (unsigned)pathbias_get_scale_threshold(options)) {
+ if (guard->circ_attempts > (unsigned)pathbias_get_scale_threshold(options)) {
const int scale_factor = pathbias_get_scale_factor(options);
const int mult_factor = pathbias_get_mult_factor(options);
/* Only scale if there will be no rounding error for our scaling
* factors */
- if (((mult_factor*guard->first_hops) % scale_factor) == 0 &&
+ if (((mult_factor*guard->circ_attempts) % scale_factor) == 0 &&
((mult_factor*guard->circuit_successes) % scale_factor) == 0) {
log_info(LD_CIRC,
"Scaling pathbias counts to (%u/%u)*(%d/%d) for guard %s=%s",
- guard->circuit_successes, guard->first_hops, mult_factor,
+ guard->circuit_successes, guard->circ_attempts, mult_factor,
scale_factor, guard->nickname, hex_str(guard->identity,
DIGEST_LEN));
- guard->first_hops *= mult_factor;
+ guard->circ_attempts *= mult_factor;
guard->circuit_successes *= mult_factor;
guard->timeouts *= mult_factor;
guard->successful_circuits_closed *= mult_factor;
guard->collapsed_circuits *= mult_factor;
guard->unusable_circuits *= mult_factor;
- guard->first_hops /= scale_factor;
+ guard->circ_attempts /= scale_factor;
guard->circuit_successes /= scale_factor;
guard->timeouts /= scale_factor;
guard->successful_circuits_closed /= scale_factor;
@@ -1769,9 +1769,9 @@ entry_guard_inc_first_hop_count(entry_guard_t *guard)
guard->unusable_circuits /= scale_factor;
}
}
- guard->first_hops++;
+ guard->circ_attempts++;
log_info(LD_CIRC, "Got success count %u/%u for guard %s=%s",
- guard->circuit_successes, guard->first_hops, guard->nickname,
+ guard->circuit_successes, guard->circ_attempts, guard->nickname,
hex_str(guard->identity, DIGEST_LEN));
return 0;
}
@@ -1794,7 +1794,7 @@ circuit_finish_handshake(origin_circuit_t *circ, uint8_t reply_type,
crypt_path_t *hop;
int rv;
- if ((rv = pathbias_count_first_hop(circ)) < 0)
+ if ((rv = pathbias_count_circ_attempt(circ)) < 0)
return rv;
if (circ->cpath->state == CPATH_STATE_AWAITING_KEYS) {
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 1e64aaf98..14a1e3c7f 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1050,7 +1050,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
unusable = 0;
}
- node->first_hops = hop_cnt;
+ node->circ_attempts = hop_cnt;
node->circuit_successes = success_cnt;
node->successful_circuits_closed = successful_closed;
@@ -1059,17 +1059,17 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
node->unusable_circuits = unusable;
log_info(LD_GENERAL, "Read %u/%u path bias for node %s",
- node->circuit_successes, node->first_hops, node->nickname);
+ node->circuit_successes, node->circ_attempts, node->nickname);
/* Note: We rely on the < comparison here to allow us to set a 0
* rate and disable the feature entirely. If refactoring, don't
* change to <= */
- if ((node->circuit_successes/((double)node->first_hops)
+ if ((node->circuit_successes/((double)node->circ_attempts)
< pathbias_get_extreme_rate(options)) &&
pathbias_get_dropguards(options)) {
node->path_bias_disabled = 1;
log_info(LD_GENERAL,
"Path bias is too high (%u/%u); disabling node %s",
- node->circuit_successes, node->first_hops, node->nickname);
+ node->circuit_successes, node->circ_attempts, node->nickname);
}
} else {
@@ -1192,14 +1192,14 @@ entry_guards_update_state(or_state_t *state)
d, e->chosen_by_version, t);
next = &(line->next);
}
- if (e->first_hops) {
+ if (e->circ_attempts) {
*next = line = tor_malloc_zero(sizeof(config_line_t));
line->key = tor_strdup("EntryGuardPathBias");
/* In the long run: circuit_success ~= successful_circuit_close +
* collapsed_circuits +
* unusable_circuits */
tor_asprintf(&line->value, "%u %u %u %u %u %u",
- e->first_hops, e->circuit_successes,
+ e->circ_attempts, e->circuit_successes,
pathbias_get_closed_count(e), e->collapsed_circuits,
e->unusable_circuits, e->timeouts);
next = &(line->next);
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index c3f7b1413..b737dad5a 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -48,7 +48,7 @@ typedef struct entry_guard_t {
time_t last_attempted; /**< 0 if we can connect to this guard, or the time
* at which we last failed to connect to it. */
- unsigned first_hops; /**< Number of first hops this guard has completed */
+ unsigned circ_attempts; /**< Number of circuits this guard has "attempted" */
unsigned circuit_successes; /**< Number of successfully built circuits using
* this guard as first hop. */
unsigned successful_circuits_closed; /**< Number of circuits that carried
diff --git a/src/or/or.h b/src/or/or.h
index c8ea12f2c..aaf817d45 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2765,9 +2765,9 @@ typedef enum {
/** This circuit is "new". It has not yet completed a first hop
* or been counted by the path bias code. */
PATH_STATE_NEW_CIRC = 0,
- /** This circuit has completed a first hop, and has been counted by
+ /** This circuit has completed one/two hops, and has been counted by
* the path bias logic. */
- PATH_STATE_DID_FIRST_HOP = 1,
+ PATH_STATE_BUILD_ATTEMPTED = 1,
/** This circuit has been completely built */
PATH_STATE_BUILD_SUCCEEDED = 2,
/** Did any SOCKS streams or hidserv introductions actually succeed on