summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2019-04-17 06:09:06 +0000
committerNick Mathewson <nickm@torproject.org>2019-05-13 14:30:35 -0400
commit621ea2315b3f53a9ef4ace9f3f6cb2f03a241042 (patch)
tree5262598079ea1e36fb4c3845beebf98bb0ff5ce8 /src/core
parentf4064d6ce214b4b79017280a6c9db9b3f945ece1 (diff)
downloadtor-621ea2315b3f53a9ef4ace9f3f6cb2f03a241042.tar.gz
tor-621ea2315b3f53a9ef4ace9f3f6cb2f03a241042.zip
Bug 29203: Provide ReducedCircuitPadding torrc and consensus params
Diffstat (limited to 'src/core')
-rw-r--r--src/core/or/circuitpadding.c13
-rw-r--r--src/core/or/circuitpadding.h11
2 files changed, 24 insertions, 0 deletions
diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c
index dcd8f645c4..8d2749906b 100644
--- a/src/core/or/circuitpadding.c
+++ b/src/core/or/circuitpadding.c
@@ -82,6 +82,7 @@ static double circpad_distribution_sample(circpad_distribution_t dist);
/** Cached consensus params */
static uint8_t circpad_padding_disabled;
+static uint8_t circpad_padding_reduced;
static uint8_t circpad_global_max_padding_percent;
static uint16_t circpad_global_allowed_cells;
static uint16_t circpad_max_circ_queued_cells;
@@ -1086,6 +1087,10 @@ circpad_new_consensus_params(const networkstatus_t *ns)
networkstatus_get_param(ns, "circpad_padding_disabled",
0, 0, 1);
+ circpad_padding_reduced =
+ networkstatus_get_param(ns, "circpad_padding_reduced",
+ 0, 0, 1);
+
circpad_global_allowed_cells =
networkstatus_get_param(ns, "circpad_global_allowed_cells",
0, 0, UINT16_MAX-1);
@@ -1662,6 +1667,14 @@ circpad_machine_conditions_met(origin_circuit_t *circ,
if (circpad_padding_disabled || !get_options()->CircuitPadding)
return 0;
+ /* If the consensus or our torrc has selected reduced connection padding,
+ * then only allow this machine if it is flagged as acceptable under
+ * reduced padding conditions */
+ if (circpad_padding_reduced || get_options()->ReducedCircuitPadding) {
+ if (!machine->conditions.reduced_padding_ok)
+ return 0;
+ }
+
if (!(circpad_circ_purpose_to_mask(TO_CIRCUIT(circ)->purpose)
& machine->conditions.purpose_mask))
return 0;
diff --git a/src/core/or/circuitpadding.h b/src/core/or/circuitpadding.h
index bc2522c210..f00369eb0a 100644
--- a/src/core/or/circuitpadding.h
+++ b/src/core/or/circuitpadding.h
@@ -152,6 +152,17 @@ typedef struct circpad_machine_conditions_t {
/** Only apply the machine *if* vanguards are enabled */
unsigned requires_vanguards : 1;
+ /**
+ * This machine is ok to use if reduced padding is set in consensus
+ * or torrc. This machine will still be applied even if reduced padding
+ * is not set; this flag only acts to exclude machines that don't have
+ * it set when reduced padding is requested. Therefore, reduced padding
+ * machines should appear at the lowest priority in the padding machine
+ * lists (aka first in the list), so that non-reduced padding machines
+ * for the same purpose are given a chance to apply when reduced padding
+ * is not requested. */
+ unsigned reduced_padding_ok : 1;
+
/** Only apply the machine *if* the circuit's state matches any of
* the bits set in this bitmask. */
circpad_circuit_state_t state_mask;