All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Aaron Conole <aconole@bytheb.org>
Cc: netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH RFC netfilter-next 1/3] netfilter: introduce accessor functions for hook entries
Date: Thu, 3 Nov 2016 17:15:59 +0100	[thread overview]
Message-ID: <20161103161559.GA3362@salvia> (raw)
In-Reply-To: <1477592873-4468-2-git-send-email-aconole@bytheb.org>

On Thu, Oct 27, 2016 at 02:27:51PM -0400, Aaron Conole wrote:
> This allows easier future refactoring.
> 
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---
>  include/linux/netfilter.h       | 35 ++++++++++++++++++++++++++++++++++-
>  net/bridge/br_netfilter_hooks.c |  2 +-
>  net/netfilter/core.c            |  8 +++-----
>  net/netfilter/nf_queue.c        |  8 ++++----
>  4 files changed, 42 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
> index d0beb607..b25386b 100644
> --- a/include/linux/netfilter.h
> +++ b/include/linux/netfilter.h
> @@ -80,6 +80,38 @@ struct nf_hook_entry {
>  	const struct nf_hook_ops	*orig_ops;
>  };
>  
> +static inline void
> +nf_hook_entry_init(struct nf_hook_entry *entry,	const struct nf_hook_ops *ops)
> +{
> +	entry->next = NULL;
> +	entry->ops = *ops;
> +	entry->orig_ops = ops;
> +}
> +
> +static inline int
> +nf_hook_entry_priority(const struct nf_hook_entry *entry)
> +{
> +	return entry->ops.priority;
> +}
> +
> +static inline nf_hookfn *
> +nf_hook_entry_hookfn(const struct nf_hook_entry *entry)
> +{
> +	return entry->ops.hook;
> +}

I'd suggest something like:

static inline int
nf_entry_hookfn(const struct nf_hook_entry *entry,
                struct sk_buff *skb, struct nf_hook_state *state)
{
        return entry->ops.hook(entry, nf_hook_entry_priv(entry), skb, state);
}

So you can avoid this:

		verdict = nf_hook_entry_hookfn(*entryp)
			(nf_hook_entry_priv(*entryp), skb, state);

  reply	other threads:[~2016-11-03 16:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 18:27 [PATCH RFC netfilter-next 0/3] Additional refactoring enhancements for nf_hook_entry Aaron Conole
2016-10-27 18:27 ` [PATCH RFC netfilter-next 1/3] netfilter: introduce accessor functions for hook entries Aaron Conole
2016-11-03 16:15   ` Pablo Neira Ayuso [this message]
2016-11-03 16:32     ` Aaron Conole
2016-10-27 18:27 ` [PATCH RFC netfilter-next 2/3] netfilter: decouple nf_hook_entry and nf_hook_ops Aaron Conole
2016-10-27 18:27 ` [PATCH RFC netfilter-next 3/3] netfilter: convert while loops to for loops Aaron Conole

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=20161103161559.GA3362@salvia \
    --to=pablo@netfilter.org \
    --cc=aconole@bytheb.org \
    --cc=fw@strlen.de \
    --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.