count_tree() computes the hash for searching and inserting trees based on the number of CONNCOUNT_SLOTS which is always greater than or equal to CONNCOUNT_LOCK_SLOTS. Thus tree_gc_worker() needs to use CONNCOUNT_SLOTS to find the tree and CONNCOUNT_LOCK_SLOTS to find the lock. Fixes: 5c789e131cbb9 ("netfilter: nf_conncount: Add list lock and gc worker, and RCU for init tree search") Signed-off-by: Shawn Bohrer <sbohrer@xxxxxxxxxxxxxx> --- net/netfilter/nf_conncount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c index df447877e3ac..719187ce1909 100644 --- a/net/netfilter/nf_conncount.c +++ b/net/netfilter/nf_conncount.c @@ -504,7 +504,7 @@ static void tree_gc_worker(struct work_struct *work) struct rb_node *node; unsigned int tree, next_tree, gc_count = 0; - tree = data->gc_tree % CONNCOUNT_LOCK_SLOTS; + tree = data->gc_tree % CONNCOUNT_SLOTS; root = &data->root[tree]; rcu_read_lock(); @@ -515,7 +515,7 @@ static void tree_gc_worker(struct work_struct *work) } rcu_read_unlock(); - spin_lock_bh(&nf_conncount_locks[tree]); + spin_lock_bh(&nf_conncount_locks[tree % CONNCOUNT_LOCK_SLOTS]); if (gc_count) { tree_nodes_free(root, gc_nodes, gc_count); @@ -531,7 +531,7 @@ static void tree_gc_worker(struct work_struct *work) schedule_work(work); } - spin_unlock_bh(&nf_conncount_locks[tree]); + spin_unlock_bh(&nf_conncount_locks[tree % CONNCOUNT_LOCK_SLOTS]); } /* Count and return number of conntrack entries in 'net' with particular 'key'. -- 2.19.2