aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuitbuild.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2021-03-17 13:43:48 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2021-03-17 13:43:48 +0200
commit0ac03390e482a7ff1008f0051ac647114ce00c09 (patch)
tree4ae4f4611a0234034d8dfda61c8167c71007c6fc /src/core/or/circuitbuild.c
parent36b54fc6aa5f6ac0a765e9e3355ec5310a23233d (diff)
parent59bbf8cde9144ee5c8d060959e723a4bedfd6bb8 (diff)
downloadtor-0ac03390e482a7ff1008f0051ac647114ce00c09.tar.gz
tor-0ac03390e482a7ff1008f0051ac647114ce00c09.zip
Merge branch 'maint-0.4.5'
Diffstat (limited to 'src/core/or/circuitbuild.c')
-rw-r--r--src/core/or/circuitbuild.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index c99f47465f..2bcc642a97 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -880,14 +880,22 @@ circuit_pick_extend_handshake(uint8_t *cell_type_out,
}
/**
- * Return true iff <b>purpose</b> is a purpose for a circuit which is
- * allowed to have no guard configured, even if the circuit is multihop
+ * Return true iff <b>circ</b> is allowed
+ * to have no guard configured, even if the circuit is multihop
* and guards are enabled.
*/
static int
-circuit_purpose_may_omit_guard(int purpose)
+circuit_may_omit_guard(const origin_circuit_t *circ)
{
- switch (purpose) {
+ if (BUG(!circ))
+ return 0;
+
+ if (circ->first_hop_from_controller) {
+ /* The controller picked the first hop: that bypasses the guard system. */
+ return 1;
+ }
+
+ switch (circ->base_.purpose) {
case CIRCUIT_PURPOSE_TESTING:
case CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT:
/* Testing circuits may omit guards because they're measuring
@@ -1018,7 +1026,7 @@ circuit_build_no_more_hops(origin_circuit_t *circ)
guard_usable_t r;
if (! circ->guard_state) {
if (circuit_get_cpath_len(circ) != 1 &&
- ! circuit_purpose_may_omit_guard(circ->base_.purpose) &&
+ ! circuit_may_omit_guard(circ) &&
get_options()->UseEntryGuards) {
log_warn(LD_BUG, "%d-hop circuit %p with purpose %d has no "
"guard state",