aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/hashtables.h
diff options
context:
space:
mode:
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-21 03:34:46 +0200
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>2018-07-21 03:34:46 +0200
commit9d0d777b2bbe4358e1b64b4d09683371ed0ccca9 (patch)
treec1f4af8acf1a135705abbd2b6bbc22618d17bb3c /src/hashtables.h
parentreceive: check against proper return value type (diff)
downloadwireguard-monolithic-historical-jn/rhashtable.tar.xz
wireguard-monolithic-historical-jn/rhashtable.zip
hashtables: switch to rhashtablejn/rhashtable
NOTE: Due to a limitation in the rhashtable API, the siphash key (or "seed") is reduced to 32 bits of random, rather than 128 bits that were used before. Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Diffstat (limited to 'src/hashtables.h')
-rw-r--r--src/hashtables.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/hashtables.h b/src/hashtables.h
index a2ef6f0..432e32e 100644
--- a/src/hashtables.h
+++ b/src/hashtables.h
@@ -15,20 +15,17 @@
struct wireguard_peer;
struct pubkey_hashtable {
- /* TODO: move to rhashtable */
- DECLARE_HASHTABLE(hashtable, 11);
- siphash_key_t key;
- struct mutex lock;
+ struct rhashtable hashtable;
};
-void pubkey_hashtable_init(struct pubkey_hashtable *table);
+int pubkey_hashtable_init(struct pubkey_hashtable *table);
+void pubkey_hashtable_cleanup(struct pubkey_hashtable *table);
void pubkey_hashtable_add(struct pubkey_hashtable *table, struct wireguard_peer *peer);
void pubkey_hashtable_remove(struct pubkey_hashtable *table, struct wireguard_peer *peer);
struct wireguard_peer *pubkey_hashtable_lookup(struct pubkey_hashtable *table, const u8 pubkey[NOISE_PUBLIC_KEY_LEN]);
struct index_hashtable {
- /* TODO: move to rhashtable */
- DECLARE_HASHTABLE(hashtable, 13);
+ struct rhashtable hashtable;
spinlock_t lock;
};
@@ -39,11 +36,12 @@ enum index_hashtable_type {
struct index_hashtable_entry {
struct wireguard_peer *peer;
- struct hlist_node index_hash;
+ struct rhash_head index_hash;
enum index_hashtable_type type;
__le32 index;
};
-void index_hashtable_init(struct index_hashtable *table);
+int index_hashtable_init(struct index_hashtable *table);
+void index_hashtable_cleanup(struct index_hashtable *table);
__le32 index_hashtable_insert(struct index_hashtable *table, struct index_hashtable_entry *entry);
bool index_hashtable_replace(struct index_hashtable *table, struct index_hashtable_entry *old, struct index_hashtable_entry *new);
void index_hashtable_remove(struct index_hashtable *table, struct index_hashtable_entry *entry);