Lines Matching refs:key

36 static inline u8 choose(struct allowedips_node *node, const u8 *key)  in choose()  argument
38 return (key[node->bit_at_a] >> node->bit_at_b) & 1; in choose()
87 static u8 common_bits(const struct allowedips_node *node, const u8 *key, in common_bits() argument
91 return 32U - fls(*(const u32 *)node->bits ^ *(const u32 *)key); in common_bits()
94 *(const u64 *)&node->bits[0] ^ *(const u64 *)&key[0], in common_bits()
95 *(const u64 *)&node->bits[8] ^ *(const u64 *)&key[8]); in common_bits()
99 static bool prefix_matches(const struct allowedips_node *node, const u8 *key, in prefix_matches() argument
108 return common_bits(node, key, bits) >= node->cidr; in prefix_matches()
112 const u8 *key) in find_node() argument
116 while (node && prefix_matches(node, key, bits)) { in find_node()
121 node = rcu_dereference_bh(node->bit[choose(node, key)]); in find_node()
149 static bool node_placement(struct allowedips_node __rcu *trie, const u8 *key, in node_placement() argument
157 while (node && node->cidr <= cidr && prefix_matches(node, key, bits)) { in node_placement()
163 node = rcu_dereference_protected(parent->bit[choose(parent, key)], lockdep_is_held(lock)); in node_placement()
181 static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, in add() argument
195 copy_and_assign_cidr(node, key, cidr, bits); in add()
199 if (node_placement(*trie, key, cidr, bits, &node, lock)) { in add()
210 copy_and_assign_cidr(newnode, key, cidr, bits); in add()
215 const u8 bit = choose(node, key); in add()
222 cidr = min(cidr, common_bits(down, key, bits)); in add()
285 u8 key[4] __aligned(__alignof(u32)); in wg_allowedips_insert_v4() local
288 swap_endian(key, (const u8 *)ip, 32); in wg_allowedips_insert_v4()
289 return add(&table->root4, 32, key, cidr, peer, lock); in wg_allowedips_insert_v4()
296 u8 key[16] __aligned(__alignof(u64)); in wg_allowedips_insert_v6() local
299 swap_endian(key, (const u8 *)ip, 128); in wg_allowedips_insert_v6()
300 return add(&table->root6, 128, key, cidr, peer, lock); in wg_allowedips_insert_v6()