aboutsummaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-07 17:38:16 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 11:32:10 -0500
commit0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2 (patch)
treea9d0e1914c9bf8e136486ca02658029273e86be5 /src/or/geoip.c
parentf05820531a1e4bc5935609900f0067b2643f0529 (diff)
downloadtor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.tar
tor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.tar.gz
Siphash-2-4 is now our hash in nearly all cases.
I've made an exception for cases where I'm sure that users can't influence the inputs. This is likely to cause a slowdown somewhere, but it's safer to siphash everything and *then* look for cases to optimize. This patch doesn't actually get us any _benefit_ from siphash yet, since we don't really randomize the key at any point.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index dc4730c81..6088f5d19 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -486,10 +486,12 @@ static HT_HEAD(clientmap, clientmap_entry_t) client_history =
static INLINE unsigned
clientmap_entry_hash(const clientmap_entry_t *a)
{
- unsigned h = tor_addr_hash(&a->addr);
+ unsigned h = (unsigned) tor_addr_hash(&a->addr);
+
if (a->transport_name)
- h += ht_string_hash(a->transport_name);
- return ht_improve_hash(h);
+ h += (unsigned) siphash24g(a->transport_name, strlen(a->transport_name));
+
+ return h;
}
/** Hashtable helper: compare two clientmap_entry_t values for equality. */
static INLINE int