From: Li RongQing Date: Tue, 26 Feb 2019 09:20:52 +0000 (+0800) Subject: netfilter: nf_conntrack: ensure that CONNTRACK_LOCKS is power of 2 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=2e7b162c5e911050be84c86c6226a5e21bba5771;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Li RongQing Signed-off-by: Pablo Neira Ayuso --- diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index ff9313c579b4..82bfbeef46af 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -2480,6 +2480,7 @@ int nf_conntrack_init_net(struct net *net) int cpu; BUILD_BUG_ON(IP_CT_UNTRACKED == IP_CT_NUMBER); + BUILD_BUG_ON_NOT_POWER_OF_2(CONNTRACK_LOCKS); atomic_set(&net->ct.count, 0); net->ct.pcpu_lists = alloc_percpu(struct ct_pcpu);