diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 349063d325..a724006b28 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1199,7 +1199,7 @@ pathbias_should_count(origin_circuit_t *circ) circ->base_.purpose == CIRCUIT_PURPOSE_CONTROLLER || circ->base_.purpose == CIRCUIT_PURPOSE_S_CONNECT_REND || circ->base_.purpose == CIRCUIT_PURPOSE_S_REND_JOINED || - (circ->base_.purpose >= CIRCUIT_PURPOSE_C_INTRODUCING && + (circ->base_.purpose >= CIRCUIT_PURPOSE_C_INTRODUCING && circ->base_.purpose <= CIRCUIT_PURPOSE_C_INTRODUCE_ACKED)) { return 0; } @@ -1350,7 +1350,7 @@ pathbias_count_build_success(origin_circuit_t *circ) return; } - /* Don't count cannibalized/reused circs for path bias + /* Don't count cannibalized/reused circs for path bias * build success.. They get counted under use success */ if (!circ->has_opened) { if (circ->cpath && circ->cpath->extend_info) { @@ -1456,14 +1456,14 @@ pathbias_check_close(origin_circuit_t *ocirc, int reason) } else if ((reason & ~END_CIRC_REASON_FLAG_REMOTE) == END_CIRC_REASON_CHANNEL_CLOSED && circ->n_chan && - circ->n_chan->reason_for_closing + circ->n_chan->reason_for_closing != CHANNEL_CLOSE_REQUESTED) { /* If we didn't close the channel ourselves, it could be bias */ /* FIXME: Only count bias if the network is live? * What about clock jumps/suspends? */ log_info(LD_CIRC, - "Circuit %d's channel closed without successful use for reason %d, " - "channel reason %d. Circuit purpose %d currently %s.", + "Circuit %d's channel closed without successful use for reason " + "%d, channel reason %d. Circuit purpose %d currently %s.", ocirc->global_identifier, reason, circ->n_chan->reason_for_closing, circ->purpose, circuit_state_to_string(circ->state)); @@ -1494,7 +1494,7 @@ pathbias_count_successful_close(origin_circuit_t *circ) } if (guard) { - /* In the long run: circuit_success ~= successful_circuit_close + + /* In the long run: circuit_success ~= successful_circuit_close + * circ_failure + stream_failure */ guard->successful_circuits_closed++; entry_guards_changed(); @@ -1511,7 +1511,7 @@ pathbias_count_successful_close(origin_circuit_t *circ) } /** - * Count a circuit that fails after it is built, but before it can + * Count a circuit that fails after it is built, but before it can * carry any traffic. * * This is needed because there are ways to destroy a @@ -1622,7 +1622,7 @@ pathbias_get_closed_count(entry_guard_t *guard) ocirc = TO_ORIGIN_CIRCUIT(circ); - if(!ocirc->cpath || !ocirc->cpath->extend_info) + if (!ocirc->cpath || !ocirc->cpath->extend_info) continue; if (ocirc->path_state >= PATH_STATE_BUILD_SUCCEEDED && @@ -1642,7 +1642,7 @@ pathbias_get_closed_count(entry_guard_t *guard) * if it should return guard->circ_successes or * guard->successful_circuits_closed. */ -double +double pathbias_get_success_count(entry_guard_t *guard) { if (pathbias_use_close_counts(get_options())) { @@ -1680,8 +1680,9 @@ entry_guard_inc_circ_attempt_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), - (int)pathbias_get_closed_count(guard), (int)guard->circ_attempts, - (int)guard->circ_successes, (int)guard->unusable_circuits, + (int)pathbias_get_closed_count(guard), + (int)guard->circ_attempts, (int)guard->circ_successes, + (int)guard->unusable_circuits, (int)guard->collapsed_circuits, (int)guard->timeouts, (long)circ_times.close_ms/1000); guard->path_bias_disabled = 1; @@ -1698,8 +1699,9 @@ entry_guard_inc_circ_attempt_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), - (int)pathbias_get_closed_count(guard), (int)guard->circ_attempts, - (int)guard->circ_successes, (int)guard->unusable_circuits, + (int)pathbias_get_closed_count(guard), + (int)guard->circ_attempts, (int)guard->circ_successes, + (int)guard->unusable_circuits, (int)guard->collapsed_circuits, (int)guard->timeouts, (long)circ_times.close_ms/1000); } @@ -1716,8 +1718,9 @@ entry_guard_inc_circ_attempt_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), - (int)pathbias_get_closed_count(guard), (int)guard->circ_attempts, - (int)guard->circ_successes, (int)guard->unusable_circuits, + (int)pathbias_get_closed_count(guard), + (int)guard->circ_attempts, (int)guard->circ_successes, + (int)guard->unusable_circuits, (int)guard->collapsed_circuits, (int)guard->timeouts, (long)circ_times.close_ms/1000); } @@ -1732,8 +1735,9 @@ entry_guard_inc_circ_attempt_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), - (int)pathbias_get_closed_count(guard), (int)guard->circ_attempts, - (int)guard->circ_successes, (int)guard->unusable_circuits, + (int)pathbias_get_closed_count(guard), + (int)guard->circ_attempts, (int)guard->circ_successes, + (int)guard->unusable_circuits, (int)guard->collapsed_circuits, (int)guard->timeouts, (long)circ_times.close_ms/1000); } diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h index 53c9fe5c0f..8cd61fae2d 100644 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@ -59,3 +59,4 @@ void pathbias_count_timeout(origin_circuit_t *circ); void pathbias_check_close(origin_circuit_t *circ, int reason); #endif + diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 6fab4920ae..0ee29000ed 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -1040,9 +1040,9 @@ circuit_unlink_all_from_channel(channel_t *chan, int reason) if (circ->n_chan == chan) { circuit_set_n_circid_chan(circ, 0, NULL); mark = 1; - + /* If we didn't request this closure, pass the remote - * bit to mark_for_close. */ + * bit to mark_for_close. */ if (chan->reason_for_closing != CHANNEL_CLOSE_REQUESTED) reason |= END_CIRC_REASON_FLAG_REMOTE; } @@ -1352,7 +1352,7 @@ circuit_mark_for_close_(circuit_t *circ, int reason, int line, } reason = END_CIRC_REASON_NONE; } - + if (CIRCUIT_IS_ORIGIN(circ)) { pathbias_check_close(TO_ORIGIN_CIRCUIT(circ), reason); diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 381c2b01cb..d3b480139e 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1161,7 +1161,7 @@ circuit_has_opened(origin_circuit_t *circ) control_event_circuit_status(circ, CIRC_EVENT_BUILT, 0); /* Cannibalized circuits count as used for path bias. - * (PURPOSE_GENERAL circs especially, since they are + * (PURPOSE_GENERAL circs especially, since they are * marked dirty and often go unused after preemptive * building). */ // XXX: Cannibalized now use RELAY_EARLY, which is visible @@ -1418,7 +1418,7 @@ circuit_launch_by_extend_info(uint8_t purpose, circ->path_state == PATH_STATE_BUILD_SUCCEEDED) { /* Path bias: Cannibalized rends pre-emptively count as a * successfully used circ. We don't wait until the extend, - * because the rend point could be malicious. + * because the rend point could be malicious. * * Same deal goes for client side introductions. Clients * can be manipulated to connect repeatedly to them diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index ca6060ca57..570ffe4941 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -2184,13 +2184,13 @@ connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply, endreason == END_STREAM_REASON_CONNRESET || endreason == END_STREAM_REASON_NOROUTE || endreason == END_STREAM_REASON_RESOURCELIMIT) { - if(!conn->edge_.on_circuit || + if (!conn->edge_.on_circuit || !CIRCUIT_IS_ORIGIN(conn->edge_.on_circuit)) { // DNS remaps can trigger this. So can failed hidden service // lookups. log_info(LD_BUG, - "(Harmless.) No origin circuit for successful SOCKS stream %ld. " - "Reason: %d", ENTRY_TO_CONN(conn)->global_identifier, endreason); + "No origin circuit for successful SOCKS stream %ld. Reason: " + "%d", ENTRY_TO_CONN(conn)->global_identifier, endreason); } else { TO_ORIGIN_CIRCUIT(conn->edge_.on_circuit)->path_state = PATH_STATE_USE_SUCCEEDED; diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 96b075a35c..066dbecc2a 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -1031,7 +1031,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg) } /* First try 3 params, then 2. */ - /* In the long run: circuit_success ~= successful_circuit_close + + /* In the long run: circuit_success ~= successful_circuit_close + * collapsed_circuits + * unusable_circuits */ if (tor_sscanf(line->value, "%lf %lf %lf %lf %lf %lf", @@ -1197,7 +1197,7 @@ entry_guards_update_state(or_state_t *state) 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 + + /* In the long run: circuit_success ~= successful_circuit_close + * collapsed_circuits + * unusable_circuits */ tor_asprintf(&line->value, "%lf %lf %lf %lf %lf %lf", diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h index b9d0e555f1..2686a4f34d 100644 --- a/src/or/entrynodes.h +++ b/src/or/entrynodes.h @@ -56,7 +56,7 @@ typedef struct entry_guard_t { double collapsed_circuits; /**< Number of fully built circuits that were * remotely closed before any streams were * attempted. */ - double unusable_circuits; /**< Number of circuits for which streams were + double unusable_circuits; /**< Number of circuits for which streams were * attempted, but none succeeded. */ double timeouts; /**< Number of 'right-censored' circuit timeouts for this * guard. */ diff --git a/src/or/relay.c b/src/or/relay.c index 1638dae4fd..3ee0c835b2 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -694,7 +694,7 @@ connection_ap_process_end_not_open( (void) layer_hint; /* unused */ if (rh->length > 0) { - /* Path bias: If we get a valid reason code from the exit, + /* Path bias: If we get a valid reason code from the exit, * it wasn't due to tagging */ // XXX: This relies on recognized+digest being strong enough not // to be spoofable.. Is that a valid assumption? diff --git a/src/or/rendservice.c b/src/or/rendservice.c index fbf14e9349..e70f969e8f 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -1383,7 +1383,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request, if (circuit_init_cpath_crypto(cpath,keys+DIGEST_LEN,1)<0) goto err; memcpy(cpath->handshake_digest, keys, DIGEST_LEN); - + /* For path bias: This intro circuit was used successfully */ circuit->path_state = PATH_STATE_USE_SUCCEEDED; @@ -2586,7 +2586,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit) tor_assert(circuit->rend_data); /* Declare the circuit dirty to avoid reuse, and for path-bias */ - if(!circuit->base_.timestamp_dirty) + if (!circuit->base_.timestamp_dirty) circuit->base_.timestamp_dirty = time(NULL); hop = circuit->build_state->service_pending_final_cpath_ref->cpath;