summaryrefslogtreecommitdiffstats
path: root/src/peer_hashtable.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-01-20 22:51:40 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-01-20 22:51:40 +0100
commitb5d83e3988d346af26b479b7c1be96185de040aa (patch)
treeac1de596302c14d46a576f788b3fca31bb11a80c /src/peer_hashtable.c
parent9f1a5ab5614976e10c4cfaeb055b6c0058b8ba20 (diff)
downloadfastd-b5d83e3988d346af26b479b7c1be96185de040aa.tar
fastd-b5d83e3988d346af26b479b7c1be96185de040aa.zip
Implement new hash table to keep track of unknown peers handshakes have been sent to
This should significantly reduce the number of handshakes sent after restarting fastd with many active connections.
Diffstat (limited to 'src/peer_hashtable.c')
-rw-r--r--src/peer_hashtable.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/peer_hashtable.c b/src/peer_hashtable.c
index 4b606b0..d499be7 100644
--- a/src/peer_hashtable.c
+++ b/src/peer_hashtable.c
@@ -31,9 +31,6 @@
#include "peer_hashtable.h"
-#include "fastd.h"
-#include "hash.h"
-#include "peer.h"
/** Initializes the hashtable */
@@ -75,24 +72,7 @@ static void resize_hashtable(void) {
/** Gets the hash bucket used for an address */
static size_t peer_address_bucket(const fastd_peer_address_t *addr) {
uint32_t hash = ctx.peer_addr_ht_seed;
-
- switch(addr->sa.sa_family) {
- case AF_INET:
- fastd_hash(&hash, &addr->in.sin_addr.s_addr, sizeof(addr->in.sin_addr.s_addr));
- fastd_hash(&hash, &addr->in.sin_port, sizeof(addr->in.sin_port));
- break;
-
- case AF_INET6:
- fastd_hash(&hash, &addr->in6.sin6_addr, sizeof(addr->in6.sin6_addr));
- fastd_hash(&hash, &addr->in6.sin6_port, sizeof(addr->in6.sin6_port));
- if (IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr))
- fastd_hash(&hash, &addr->in6.sin6_scope_id, sizeof(addr->in6.sin6_scope_id));
- break;
-
- default:
- exit_bug("peer_address_bucket: unknown address family");
- }
-
+ fastd_peer_address_hash(&hash, addr);
fastd_hash_final(&hash);
return hash % ctx.peer_addr_ht_size;