From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick McHardy Subject: Re: [PATCH 3/3] nfnetlink_queue: use hash table to speed up entry finding. Date: Thu, 15 Apr 2010 17:35:02 +0200 Message-ID: <4BC73226.2030007@trash.net> References: <4BBEA97A.5020303@gmail.com> <1271164991.16881.346.camel@edumazet-laptop> <4BC470B3.4030007@trash.net> <4BC6EC15.4070205@trash.net> <4BC72572.1050507@trash.net> <4BC726B4.1030003@trash.net> <4BC72B2B.9010104@trash.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Eric Dumazet , netfilter-devel@vger.kernel.org To: Changli Gao Return-path: Received: from stinky.trash.net ([213.144.137.162]:33955 "EHLO stinky.trash.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752581Ab0DOPfH (ORCPT ); Thu, 15 Apr 2010 11:35:07 -0400 In-Reply-To: Sender: netfilter-devel-owner@vger.kernel.org List-ID: Changli Gao wrote: > static int > nfqnl_rcv_nl_event(struct notifier_block *this, > unsigned long event, void *ptr) > { > struct netlink_notify *n = ptr; > > if (event == NETLINK_URELEASE && n->protocol == NETLINK_NETFILTER) { > int i; > > /* destroy all instances for this pid */ > spin_lock(&instances_lock); > for (i = 0; i < INSTANCE_BUCKETS; i++) { > struct hlist_node *tmp, *t2; > struct nfqnl_instance *inst; > struct hlist_head *head = &instance_table[i]; > > hlist_for_each_entry_safe(inst, tmp, t2, head, hlist) { > if ((n->net == &init_net) && > (n->pid == inst->peer_pid)) > __instance_destroy(inst); > } > } > spin_unlock(&instances_lock); > } > return NOTIFY_DONE; > } > > static struct notifier_block nfqnl_rtnl_notifier = { > .notifier_call = nfqnl_rcv_nl_event, > }; > Ah, right. So call nfnl_lock() or convert the spinlock to a mutex.