diff options
author | David Goulet <dgoulet@torproject.org> | 2018-01-31 15:23:45 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-01-31 16:10:48 -0500 |
commit | fb93c6fc517f8717891fa8bfb41c9381a12dc491 (patch) | |
tree | c395b724a621bff62bf26a6f52a988503c183d7c /src/or/entrynodes.c | |
parent | a846fd267edf5a457d6647b37ad7ef2ac62a1612 (diff) | |
download | tor-fb93c6fc517f8717891fa8bfb41c9381a12dc491.tar.gz tor-fb93c6fc517f8717891fa8bfb41c9381a12dc491.zip |
circ: Don't cannibalize a circuit if the guard state is unusable
Tor preemptiely builds circuits and they can be cannibalized later in their
lifetime. A Guard node can become unusable (from our guard state) but we can
still have circuits using that node opened. It is important to not pick those
circuits for any usage through the cannibalization process.
Fixes #24469
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 292a393e51..2b6ff38c9c 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -3307,6 +3307,22 @@ entry_guards_update_state(or_state_t *state) entry_guards_dirty = 0; } +/** Return true iff the circuit's guard can succeed that is can be used. */ +int +entry_guard_could_succeed(const circuit_guard_state_t *guard_state) +{ + if (!guard_state) { + return 0; + } + + entry_guard_t *guard = entry_guard_handle_get(guard_state->guard); + if (!guard || BUG(guard->in_selection == NULL)) { + return 0; + } + + return 1; +} + /** * Format a single entry guard in the format expected by the controller. * Return a newly allocated string. |