netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, me@ubique.spb.ru,
	Florian Westphal <fw@strlen.de>
Subject: [PATCH RFC nf-next 3/9] netfilter: remove hook index from nf_hook_slow arguments
Date: Thu, 14 Oct 2021 14:10:40 +0200	[thread overview]
Message-ID: <20211014121046.29329-5-fw@strlen.de> (raw)
In-Reply-To: <20211014121046.29329-1-fw@strlen.de>

Previous patch added hook_entry member to nf_hook_state struct, so
use that for passing the index.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 include/linux/netfilter.h         | 5 +++--
 include/linux/netfilter_ingress.h | 2 +-
 net/bridge/br_netfilter_hooks.c   | 3 ++-
 net/netfilter/core.c              | 6 +++---
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 1d8b87abd54c..61a8c8ded57b 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -154,6 +154,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
 {
 	p->hook = hook;
 	p->pf = pf;
+	p->hook_index = 0;
 	p->in = indev;
 	p->out = outdev;
 	p->sk = sk;
@@ -198,7 +199,7 @@ extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
 #endif
 
 int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
-		 const struct nf_hook_entries *e, unsigned int i);
+		 const struct nf_hook_entries *e);
 
 void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
 		       const struct nf_hook_entries *e);
@@ -260,7 +261,7 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
 		nf_hook_state_init(&state, hook, pf, indev, outdev,
 				   sk, net, okfn);
 
-		ret = nf_hook_slow(skb, &state, hook_head, 0);
+		ret = nf_hook_slow(skb, &state, hook_head);
 	}
 	rcu_read_unlock();
 
diff --git a/include/linux/netfilter_ingress.h b/include/linux/netfilter_ingress.h
index a13774be2eb5..c95f84a5badc 100644
--- a/include/linux/netfilter_ingress.h
+++ b/include/linux/netfilter_ingress.h
@@ -31,7 +31,7 @@ static inline int nf_hook_ingress(struct sk_buff *skb)
 	nf_hook_state_init(&state, NF_NETDEV_INGRESS,
 			   NFPROTO_NETDEV, skb->dev, NULL, NULL,
 			   dev_net(skb->dev), NULL);
-	ret = nf_hook_slow(skb, &state, e, 0);
+	ret = nf_hook_slow(skb, &state, e);
 	if (ret == 0)
 		return -1;
 
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 8edfb98ae1d5..5ed8b698ce11 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -1020,7 +1020,8 @@ int br_nf_hook_thresh(unsigned int hook, struct net *net,
 	nf_hook_state_init(&state, hook, NFPROTO_BRIDGE, indev, outdev,
 			   sk, net, okfn);
 
-	ret = nf_hook_slow(skb, &state, e, i);
+	state.hook_index = i;
+	ret = nf_hook_slow(skb, &state, e);
 	if (ret == 1)
 		ret = okfn(net, sk, skb);
 
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 57685334d32b..129d48304821 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -580,9 +580,9 @@ EXPORT_SYMBOL(nf_unregister_net_hooks);
 /* Returns 1 if okfn() needs to be executed by the caller,
  * -EPERM for NF_DROP, 0 otherwise.  Caller must hold rcu_read_lock. */
 int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
-		 const struct nf_hook_entries *e, unsigned int s)
+		 const struct nf_hook_entries *e)
 {
-	unsigned int verdict;
+	unsigned int verdict, s = state->hook_index;
 	int ret;
 
 	for (; s < e->num_hook_entries; s++) {
@@ -625,7 +625,7 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
 
 	list_for_each_entry_safe(skb, next, head, list) {
 		skb_list_del_init(skb);
-		ret = nf_hook_slow(skb, state, e, 0);
+		ret = nf_hook_slow(skb, state, e);
 		if (ret == 1)
 			list_add_tail(&skb->list, &sublist);
 	}
-- 
2.32.0


  parent reply	other threads:[~2021-10-14 12:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 12:10 [PATCH RFC nf-next 0/9] netfilter: bpf base hook program generator Florian Westphal
2021-10-14 12:10 ` [PATCH 1/1] netfilter: add " Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 1/9] netfilter: nf_queue: carry index in hook state Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 2/9] netfilter: nat: split nat hook iteration into a helper Florian Westphal
2021-10-14 12:10 ` Florian Westphal [this message]
2021-10-14 12:10 ` [PATCH RFC nf-next 4/9] netfilter: make hook functions accept only one argument Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 5/9] netfilter: reduce allowed hook count to 32 Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 6/9] netfilter: add bpf base hook program generator Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 7/9] netfilter: core: do not rebuild bpf program on dying netns Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 8/9] netfilter: ingress: switch to invocation via bpf Florian Westphal
2021-10-14 12:10 ` [PATCH RFC nf-next 9/9] netfilter: hook_jit: add prog cache Florian Westphal

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=20211014121046.29329-5-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=bpf@vger.kernel.org \
    --cc=me@ubique.spb.ru \
    --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).