All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Joe Perches <joe@perches.com>
Cc: netfilter-devel <netfilter-devel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>
Subject: Re: rfc: netfilter: Unhide FWINV macro arguments ?
Date: Fri, 17 Jun 2016 13:59:32 +0200	[thread overview]
Message-ID: <20160617115932.GA5482@salvia> (raw)
In-Reply-To: <1466101259.19647.51.camel@perches.com>

On Thu, Jun 16, 2016 at 11:20:59AM -0700, Joe Perches wrote:
> There are several FWINV #defines with identical form
> that hide a specific structure variable and dereference
> it with a invflags member.

Right, this macro is obscure indeed.

> $ git grep "define FWINV"
> include/linux/netfilter_bridge/ebtables.h:#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg))
> net/bridge/netfilter/ebtables.c:#define FWINV2(bool, invflg) ((bool) ^ !!(e->invflags & invflg))
> net/ipv4/netfilter/arp_tables.c:#define FWINV(bool, invflg) ((bool) ^ !!(arpinfo->invflags & (invflg)))
> net/ipv4/netfilter/ip_tables.c:#define FWINV(bool, invflg) ((bool) ^ !!(ipinfo->invflags & (invflg)))
> net/ipv6/netfilter/ip6_tables.c:#define FWINV(bool, invflg) ((bool) ^ !!(ip6info->invflags & (invflg)))
> net/netfilter/xt_tcpudp.c:#define FWINVTCP(bool, invflg) ((bool) ^ !!(tcpinfo->invflags & (invflg)))
> 
> It might make sense to use a new macro like:
> 
> #define INVFLAG(var, test, invflag)			\
> 	((test) ^ !!((var)->invflags & (invflag)))
> 
> and convert all the various FWINV style uses
> 
> $ git grep --name-only "\bFWINV"
> include/linux/netfilter_bridge/ebtables.h
> net/bridge/netfilter/ebt_802_3.c
> net/bridge/netfilter/ebt_arp.c
> net/bridge/netfilter/ebt_ip.c
> net/bridge/netfilter/ebt_ip6.c
> net/bridge/netfilter/ebt_stp.c
> net/bridge/netfilter/ebtables.c
> net/ipv4/netfilter/arp_tables.c
> net/ipv4/netfilter/ip_tables.c
> net/ipv6/netfilter/ip6_tables.c
> net/netfilter/xt_tcpudp.c
> 
> $ git grep "\bFWINV" | grep -v "#" | wc -l
> 65

I'll be taking a patch to sort out this. Thanks.

  reply	other threads:[~2016-06-17 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 18:20 rfc: netfilter: Unhide FWINV macro arguments ? Joe Perches
2016-06-17 11:59 ` Pablo Neira Ayuso [this message]
2016-06-17 15:41   ` Joe Perches

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=20160617115932.GA5482@salvia \
    --to=pablo@netfilter.org \
    --cc=joe@perches.com \
    --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.