Lines Matching refs:table
10 static struct hlist_head *pubkey_bucket(struct pubkey_hashtable *table, in pubkey_bucket() argument
17 const u64 hash = siphash(pubkey, NOISE_PUBLIC_KEY_LEN, &table->key); in pubkey_bucket()
19 return &table->hashtable[hash & (HASH_SIZE(table->hashtable) - 1)]; in pubkey_bucket()
24 struct pubkey_hashtable *table = kvmalloc(sizeof(*table), GFP_KERNEL); in wg_pubkey_hashtable_alloc() local
26 if (!table) in wg_pubkey_hashtable_alloc()
29 get_random_bytes(&table->key, sizeof(table->key)); in wg_pubkey_hashtable_alloc()
30 hash_init(table->hashtable); in wg_pubkey_hashtable_alloc()
31 mutex_init(&table->lock); in wg_pubkey_hashtable_alloc()
32 return table; in wg_pubkey_hashtable_alloc()
35 void wg_pubkey_hashtable_add(struct pubkey_hashtable *table, in wg_pubkey_hashtable_add() argument
38 mutex_lock(&table->lock); in wg_pubkey_hashtable_add()
40 pubkey_bucket(table, peer->handshake.remote_static)); in wg_pubkey_hashtable_add()
41 mutex_unlock(&table->lock); in wg_pubkey_hashtable_add()
44 void wg_pubkey_hashtable_remove(struct pubkey_hashtable *table, in wg_pubkey_hashtable_remove() argument
47 mutex_lock(&table->lock); in wg_pubkey_hashtable_remove()
49 mutex_unlock(&table->lock); in wg_pubkey_hashtable_remove()
54 wg_pubkey_hashtable_lookup(struct pubkey_hashtable *table, in wg_pubkey_hashtable_lookup() argument
60 hlist_for_each_entry_rcu_bh(iter_peer, pubkey_bucket(table, pubkey), in wg_pubkey_hashtable_lookup()
73 static struct hlist_head *index_bucket(struct index_hashtable *table, in index_bucket() argument
79 return &table->hashtable[(__force u32)index & in index_bucket()
80 (HASH_SIZE(table->hashtable) - 1)]; in index_bucket()
85 struct index_hashtable *table = kvmalloc(sizeof(*table), GFP_KERNEL); in wg_index_hashtable_alloc() local
87 if (!table) in wg_index_hashtable_alloc()
90 hash_init(table->hashtable); in wg_index_hashtable_alloc()
91 spin_lock_init(&table->lock); in wg_index_hashtable_alloc()
92 return table; in wg_index_hashtable_alloc()
119 __le32 wg_index_hashtable_insert(struct index_hashtable *table, in wg_index_hashtable_insert() argument
124 spin_lock_bh(&table->lock); in wg_index_hashtable_insert()
126 spin_unlock_bh(&table->lock); in wg_index_hashtable_insert()
134 index_bucket(table, entry->index), in wg_index_hashtable_insert()
144 spin_lock_bh(&table->lock); in wg_index_hashtable_insert()
146 index_bucket(table, entry->index), in wg_index_hashtable_insert()
149 spin_unlock_bh(&table->lock); in wg_index_hashtable_insert()
158 index_bucket(table, entry->index)); in wg_index_hashtable_insert()
159 spin_unlock_bh(&table->lock); in wg_index_hashtable_insert()
166 bool wg_index_hashtable_replace(struct index_hashtable *table, in wg_index_hashtable_replace() argument
172 spin_lock_bh(&table->lock); in wg_index_hashtable_replace()
188 spin_unlock_bh(&table->lock); in wg_index_hashtable_replace()
192 void wg_index_hashtable_remove(struct index_hashtable *table, in wg_index_hashtable_remove() argument
195 spin_lock_bh(&table->lock); in wg_index_hashtable_remove()
197 spin_unlock_bh(&table->lock); in wg_index_hashtable_remove()
202 wg_index_hashtable_lookup(struct index_hashtable *table, in wg_index_hashtable_lookup() argument
209 hlist_for_each_entry_rcu_bh(iter_entry, index_bucket(table, index), in wg_index_hashtable_lookup()