All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 01/10] netfilter: ingress: don't use nf_hook_list_active
Date: Wed, 11 Nov 2015 18:33:34 +0100	[thread overview]
Message-ID: <1447263223-22662-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1447263223-22662-1-git-send-email-pablo@netfilter.org>

From: Florian Westphal <fw@strlen.de>

nf_hook_list_active() always returns true once at least one device has
NF_INGRESS hook enabled.

Thus, don't use this function. Instead, inverse the test and use the static
key to elide list_empty test if no NF_INGRESS hooks are active.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/linux/netfilter_ingress.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/linux/netfilter_ingress.h b/include/linux/netfilter_ingress.h
index 187feab..ba7ce88 100644
--- a/include/linux/netfilter_ingress.h
+++ b/include/linux/netfilter_ingress.h
@@ -5,10 +5,13 @@
 #include <linux/netdevice.h>
 
 #ifdef CONFIG_NETFILTER_INGRESS
-static inline int nf_hook_ingress_active(struct sk_buff *skb)
+static inline bool nf_hook_ingress_active(const struct sk_buff *skb)
 {
-	return nf_hook_list_active(&skb->dev->nf_hooks_ingress,
-				   NFPROTO_NETDEV, NF_NETDEV_INGRESS);
+#ifdef HAVE_JUMP_LABEL
+	if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS]))
+		return false;
+#endif
+	return !list_empty(&skb->dev->nf_hooks_ingress);
 }
 
 static inline int nf_hook_ingress(struct sk_buff *skb)
-- 
2.1.4

  reply	other threads:[~2015-11-11 17:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 17:33 [PATCH 00/10] Netfilter fixes for net Pablo Neira Ayuso
2015-11-11 17:33 ` Pablo Neira Ayuso [this message]
2015-11-11 17:33 ` [PATCH 02/10] netfilter: ingress: fix wrong input interface on hook Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 03/10] netfilter: ipset: Fix extension alignment Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 04/10] netfilter: ipset: Fix hash:* type expiration Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 05/10] netfilter: ipset: Fix hash type expire: release empty hash bucket block Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 06/10] netfilter: Fix removal of GRE expectation entries created by PPTP Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 07/10] netfilter: nfnetlink_log: work around uninitialized variable warning Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 08/10] netfilter: fix xt_TEE and xt_TPROXY dependencies Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 09/10] net: add __netdev_alloc_pcpu_stats() to indicate gfp flags Pablo Neira Ayuso
2015-11-11 17:33 ` [PATCH 10/10] netfilter: nf_tables: add clone interface to expression operations Pablo Neira Ayuso
2015-11-12 19:20 ` [PATCH 00/10] Netfilter fixes for net David Miller
2015-11-13 17:58 ` Josh Boyer
2015-11-13 18:52   ` Jozsef Kadlecsik

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=1447263223-22662-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.