aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-08-08 03:49:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-08-08 05:57:25 +0200
commita7c2e4bb5460119d91d428870a8ec8cb64736a8f (patch)
tree7ad37f3ee6fbd93a3902fc996f4f29dc88c3cdbf /src
parenthashtables: allow up to 2^{20} peers per interface (diff)
downloadwireguard-monolithic-historical-a7c2e4bb5460119d91d428870a8ec8cb64736a8f.tar.xz
wireguard-monolithic-historical-a7c2e4bb5460119d91d428870a8ec8cb64736a8f.zip
hashtables: if we have an index match, don't search further ever
Diffstat (limited to 'src')
-rw-r--r--src/hashtables.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/hashtables.c b/src/hashtables.c
index b3f5ca3..978997a 100644
--- a/src/hashtables.c
+++ b/src/hashtables.c
@@ -144,8 +144,9 @@ struct index_hashtable_entry *index_hashtable_lookup(struct index_hashtable *tab
struct index_hashtable_entry *iter_entry, *entry = NULL;
rcu_read_lock_bh();
hlist_for_each_entry_rcu_bh (iter_entry, index_bucket(table, index), index_hash) {
- if (iter_entry->index == index && (iter_entry->type & type_mask)) {
- entry = iter_entry;
+ if (iter_entry->index == index) {
+ if (likely(iter_entry->type & type_mask))
+ entry = iter_entry;
break;
}
}