• Home
  • Raw
  • Download

Lines Matching refs:bits

13 static void swap_endian(u8 *dst, const u8 *src, u8 bits)  in swap_endian()  argument
15 if (bits == 32) { in swap_endian()
17 } else if (bits == 128) { in swap_endian()
24 u8 cidr, u8 bits) in copy_and_assign_cidr() argument
29 node->bit_at_a ^= (bits / 8U - 1U) % 8U; in copy_and_assign_cidr()
32 node->bitlen = bits; in copy_and_assign_cidr()
33 memcpy(node->bits, src, bits / 8U); in copy_and_assign_cidr()
88 u8 bits) in common_bits() argument
90 if (bits == 32) in common_bits()
91 return 32U - fls(*(const u32 *)node->bits ^ *(const u32 *)key); in common_bits()
92 else if (bits == 128) 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()
100 u8 bits) in prefix_matches() argument
108 return common_bits(node, key, bits) >= node->cidr; in prefix_matches()
111 static struct allowedips_node *find_node(struct allowedips_node *trie, u8 bits, in find_node() argument
116 while (node && prefix_matches(node, key, bits)) { in find_node()
119 if (node->cidr == bits) in find_node()
127 static struct wg_peer *lookup(struct allowedips_node __rcu *root, u8 bits, in lookup() argument
135 swap_endian(ip, be_ip, bits); in lookup()
139 node = find_node(rcu_dereference_bh(root), bits, ip); in lookup()
150 u8 cidr, u8 bits, struct allowedips_node **rnode, in node_placement() argument
157 while (node && node->cidr <= cidr && prefix_matches(node, key, bits)) { in node_placement()
177 u8 bit = choose(parent, node->bits); in choose_and_connect_node()
181 static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key, in add() argument
186 if (unlikely(cidr > bits || !peer)) in add()
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()
222 cidr = min(cidr, common_bits(down, key, bits)); in add()
241 copy_and_assign_cidr(node, newnode->bits, cidr, bits); in add()
346 swap_endian(ip, node->bits, node->bitlen); in wg_allowedips_read_node()