diff options
author | Alexander Færøy <ahf@torproject.org> | 2021-12-15 12:41:00 +0000 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2021-12-15 12:41:00 +0000 |
commit | 48d778bc3246cd7e459475f1045ad24684ddeb85 (patch) | |
tree | 74f4cb4487f8e03ec371e3e0646610454bc9ffa8 /src | |
parent | 95b82c4feede91e18ec24dafeb382208186a9791 (diff) | |
parent | dd085d42f96e39f9387aa1d7a306100c0d7df305 (diff) | |
download | tor-48d778bc3246cd7e459475f1045ad24684ddeb85.tar.gz tor-48d778bc3246cd7e459475f1045ad24684ddeb85.zip |
Merge remote-tracking branch 'tor-gitlab/mr/491' into main
Diffstat (limited to 'src')
-rw-r--r-- | src/core/or/origin_circuit_st.h | 6 | ||||
-rw-r--r-- | src/feature/client/circpathbias.c | 11 | ||||
-rw-r--r-- | src/feature/control/control_cmd.c | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/core/or/origin_circuit_st.h b/src/core/or/origin_circuit_st.h index 9264077c50..6c86a56000 100644 --- a/src/core/or/origin_circuit_st.h +++ b/src/core/or/origin_circuit_st.h @@ -180,6 +180,12 @@ struct origin_circuit_t { unsigned first_hop_from_controller : 1; /** + * If true, this circuit's path has been chosen, in full or in part, + * by the controller API, and it's okay to ignore checks that we'd + * usually do on the path as whole. */ + unsigned int any_hop_from_controller : 1; + + /** * Tristate variable to guard against pathbias miscounting * due to circuit purpose transitions changing the decision * of pathbias_should_count(). This variable is informational diff --git a/src/feature/client/circpathbias.c b/src/feature/client/circpathbias.c index 9c0ecc56ad..ff9e05a645 100644 --- a/src/feature/client/circpathbias.c +++ b/src/feature/client/circpathbias.c @@ -363,6 +363,17 @@ pathbias_should_count(origin_circuit_t *circ) return 0; } + /* Ignore circuits where the controller helped choose the path. When + * this happens, we can't be sure whether the path was chosen randomly + * or not. */ + if (circ->any_hop_from_controller) { + /* (In this case, we _don't_ check to see if shouldcount is changing, + * since it's possible that an already-created circuit later gets extended + * by the controller. */ + circ->pathbias_shouldcount = PATHBIAS_SHOULDCOUNT_IGNORED; + return 0; + } + /* Completely ignore one hop circuits */ if (circ->build_state->onehop_tunnel || circ->build_state->desired_path_len == 1) { diff --git a/src/feature/control/control_cmd.c b/src/feature/control/control_cmd.c index 2950a1c0cc..b19935e456 100644 --- a/src/feature/control/control_cmd.c +++ b/src/feature/control/control_cmd.c @@ -817,6 +817,8 @@ handle_control_extendcircuit(control_connection_t *conn, circ->first_hop_from_controller = 1; } + circ->any_hop_from_controller = 1; + /* now circ refers to something that is ready to be extended */ first_node = zero_circ; SMARTLIST_FOREACH(nodes, const node_t *, node, |