diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-18 12:50:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-18 12:58:58 -0400 |
commit | 0d75344b0e0eafc89db89a974e87b16564cd8f0a (patch) | |
tree | c5dbe44f5b4ddbfa0855ce8cb3066c1095384d3a /src/or/channel.c | |
parent | bb9b4c37f8e7f5cf78918f382e90d8b11ff42551 (diff) | |
download | tor-0d75344b0e0eafc89db89a974e87b16564cd8f0a.tar.gz tor-0d75344b0e0eafc89db89a974e87b16564cd8f0a.zip |
Switch to random allocation on circuitIDs.
Fixes a possible root cause of 11553 by only making 64 attempts at
most to pick a circuitID. Previously, we would test every possible
circuit ID until we found one or ran out.
This algorithm succeeds probabilistically. As the comment says:
This potentially causes us to give up early if our circuit ID
space is nearly full. If we have N circuit IDs in use, then we
will reject a new circuit with probability (N / max_range) ^
MAX_CIRCID_ATTEMPTS. This means that in practice, a few percent
of our circuit ID capacity will go unused.
The alternative here, though, is to do a linear search over the
whole circuit ID space every time we extend a circuit, which is
not so great either.
This makes new vs old clients distinguishable, so we should try to
batch it with other patches that do that, like 11438.
Diffstat (limited to 'src/or/channel.c')
-rw-r--r-- | src/or/channel.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/or/channel.c b/src/or/channel.c index 1270eace7d..dfef703b1b 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -731,9 +731,6 @@ channel_init(channel_t *chan) /* Init timestamp */ chan->timestamp_last_added_nonpadding = time(NULL); - /* Init next_circ_id */ - chan->next_circ_id = crypto_rand_int(1 << 15); - /* Initialize queues. */ TOR_SIMPLEQ_INIT(&chan->incoming_queue); TOR_SIMPLEQ_INIT(&chan->outgoing_queue); |