netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: netdev@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: [PATCH nf-next 1/9] netfilter: conntrack: keep BH enabled during lookup
Date: Thu, 28 Apr 2016 19:13:40 +0200	[thread overview]
Message-ID: <1461863628-23350-2-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1461863628-23350-1-git-send-email-fw@strlen.de>

No need to disable BH here anymore:

stats are switched to _ATOMIC variant (== this_cpu_inc()), which
nowadays generates same code as the non _ATOMIC NF_STAT, at least on x86.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/netfilter/nf_conntrack_core.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 1fd0ff1..1b63359 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -472,18 +472,13 @@ ____nf_conntrack_find(struct net *net, const struct nf_conntrack_zone *zone,
 	struct hlist_nulls_node *n;
 	unsigned int bucket = hash_bucket(hash, net);
 
-	/* Disable BHs the entire time since we normally need to disable them
-	 * at least once for the stats anyway.
-	 */
-	local_bh_disable();
 begin:
 	hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[bucket], hnnode) {
 		if (nf_ct_key_equal(h, tuple, zone)) {
-			NF_CT_STAT_INC(net, found);
-			local_bh_enable();
+			NF_CT_STAT_INC_ATOMIC(net, found);
 			return h;
 		}
-		NF_CT_STAT_INC(net, searched);
+		NF_CT_STAT_INC_ATOMIC(net, searched);
 	}
 	/*
 	 * if the nulls value we got at the end of this lookup is
@@ -491,10 +486,9 @@ begin:
 	 * We probably met an item that was moved to another chain.
 	 */
 	if (get_nulls_value(n) != bucket) {
-		NF_CT_STAT_INC(net, search_restart);
+		NF_CT_STAT_INC_ATOMIC(net, search_restart);
 		goto begin;
 	}
-	local_bh_enable();
 
 	return NULL;
 }
@@ -735,22 +729,19 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
 	zone = nf_ct_zone(ignored_conntrack);
 	hash = hash_conntrack(net, tuple);
 
-	/* Disable BHs the entire time since we need to disable them at
-	 * least once for the stats anyway.
-	 */
-	rcu_read_lock_bh();
+	rcu_read_lock();
 	hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[hash], hnnode) {
 		ct = nf_ct_tuplehash_to_ctrack(h);
 		if (ct != ignored_conntrack &&
 		    nf_ct_tuple_equal(tuple, &h->tuple) &&
 		    nf_ct_zone_equal(ct, zone, NF_CT_DIRECTION(h))) {
-			NF_CT_STAT_INC(net, found);
-			rcu_read_unlock_bh();
+			NF_CT_STAT_INC_ATOMIC(net, found);
+			rcu_read_unlock();
 			return 1;
 		}
-		NF_CT_STAT_INC(net, searched);
+		NF_CT_STAT_INC_ATOMIC(net, searched);
 	}
-	rcu_read_unlock_bh();
+	rcu_read_unlock();
 
 	return 0;
 }
-- 
2.7.3

  reply	other threads:[~2016-04-28 17:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 17:13 [PATCH nf-next 0/9] netfilter: remove per-netns conntrack tables, part 1 Florian Westphal
2016-04-28 17:13 ` Florian Westphal [this message]
2016-04-28 17:13 ` [PATCH nf-next 2/9] netfilter: conntrack: fix lookup race during hash resize Florian Westphal
2016-04-28 17:13 ` [PATCH nf-next 3/9] netfilter: conntrack: don't attempt to iterate over empty table Florian Westphal
2016-05-03 17:03   ` Pablo Neira Ayuso
2016-05-03 17:17     ` Florian Westphal
2016-05-03 17:41       ` Pablo Neira Ayuso
2016-05-03 17:55         ` Florian Westphal
2016-05-03 22:27           ` Pablo Neira Ayuso
2016-04-28 17:13 ` [PATCH nf-next 4/9] netfilter: conntrack: use nf_ct_key_equal() in more places Florian Westphal
2016-04-28 17:13 ` [PATCH nf-next 5/9] netfilter: conntrack: small refactoring of conntrack seq_printf Florian Westphal
2016-05-03 18:12   ` Pablo Neira Ayuso
2016-05-03 22:27     ` Florian Westphal
2016-05-04  9:19       ` Pablo Neira Ayuso
2016-05-03 22:28     ` Pablo Neira Ayuso
2016-04-28 17:13 ` [PATCH nf-next 6/9] netfilter: conntrack: check netns when comparing conntrack objects Florian Westphal
2016-04-28 17:13 ` [PATCH nf-next 7/9] netfilter: conntrack: make netns address part of hash Florian Westphal
2016-04-28 17:13 ` [PATCH nf-next 8/9] netfilter: conntrack: use a single hashtable for all namespaces Florian Westphal
2016-04-29 15:04   ` Florian Westphal
2016-04-28 17:13 ` [PATCH nf-next 9/9] netfilter: conntrack: consider ct netns in early_drop logic Florian Westphal
2016-05-02 16:39 ` [PATCH v2 nf-next 7/9] netfilter: conntrack: make netns address part of hash Florian Westphal
2016-05-02 16:51   ` Eric Dumazet
2016-05-02 21:52     ` Florian Westphal
2016-05-02 16:39 ` [PATCH v2 nf-next 8/9] netfilter: conntrack: use a single hashtable for all namespaces Florian Westphal
2016-05-02 16:40 ` [PATCH v2 nf-next 9/9] netfilter: conntrack: consider ct netns in early_drop logic Florian Westphal
2016-05-02 22:25 ` [PATCH v3 nf-next 7/9] netfilter: conntrack: make netns address part of hash Florian Westphal
2016-05-03 22:30 ` [PATCH nf-next 0/9] netfilter: remove per-netns conntrack tables, part 1 Pablo Neira Ayuso
2016-05-05 11:54 ` Pablo Neira Ayuso
2016-05-05 20:27 ` Brian Haley
2016-05-05 20:54   ` Florian Westphal
2016-05-05 22:22     ` Brian Haley
2016-05-05 22:36       ` Florian Westphal
2016-05-05 22:55         ` Brian Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461863628-23350-2-git-send-email-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).