Skip to content

Commit 2e7b162

Browse files
lrq-maxummakynes
authored andcommitted
netfilter: nf_conntrack: ensure that CONNTRACK_LOCKS is power of 2
CONNTRACK_LOCKS is divisor when computer array index, if it is power of 2, compiler will optimize modulo operation as bitwise AND, or else modulo will lower performance. Suggested-by: Florian Westphal <[email protected]> Signed-off-by: Li RongQing <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent a9f5e78 commit 2e7b162

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/netfilter/nf_conntrack_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,7 @@ int nf_conntrack_init_net(struct net *net)
24802480
int cpu;
24812481

24822482
BUILD_BUG_ON(IP_CT_UNTRACKED == IP_CT_NUMBER);
2483+
BUILD_BUG_ON_NOT_POWER_OF_2(CONNTRACK_LOCKS);
24832484
atomic_set(&net->ct.count, 0);
24842485

24852486
net->ct.pcpu_lists = alloc_percpu(struct ct_pcpu);

0 commit comments

Comments
 (0)