diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-11-25 17:19:25 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-12-17 14:51:31 -0500 |
commit | 4a07ea4a8c41c55ef4d8341ddf67601d3f09711a (patch) | |
tree | 050a2a73a7696419327a5ceadd9be9484bff4722 /src/or | |
parent | 40a9842090fbf3ecbc155e5be11e200c9aef1a08 (diff) | |
download | tor-4a07ea4a8c41c55ef4d8341ddf67601d3f09711a.tar tor-4a07ea4a8c41c55ef4d8341ddf67601d3f09711a.tar.gz |
Drop the maximum attempts to get a virtual address to 1000.
This is good enough to give P_success >= 999,999,999/1,000,000,000 so
long as the address space is less than 97.95 full. It'd be ridiculous
for that to happen for IPv6, and usome reasonable assumptions, it
would also be pretty silly for IPv4.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/addressmap.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/or/addressmap.c b/src/or/addressmap.c index e1efbf4bf..f4c31295a 100644 --- a/src/or/addressmap.c +++ b/src/or/addressmap.c @@ -863,9 +863,13 @@ addressmap_get_virtual_address(int type) const virtual_addr_conf_t *conf = ipv6 ? &virtaddr_conf_ipv6 : &virtaddr_conf_ipv4; - // This is an imperfect estimate of how many addresses are available, but - // that's ok. We also don't try every one. - uint32_t attempts = ipv6 ? UINT32_MAX : (1u << (32- conf->bits)); + /* Don't try more than 1000 times. This gives us P < 1e-9 for + * failing to get a good address so long as the address space is + * less than ~97.95% full. That's always going to be true under + * sensible circumstances for an IPv6 /10, and it's going to be + * true for an IPv4 /10 as long as we've handed out less than + * 4.08 million addresses. */ + uint32_t attempts = 1000; tor_addr_t addr; |