* rfc: netfilter: Unhide FWINV macro arguments ?
@ 2016-06-16 18:20 Joe Perches
2016-06-17 11:59 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2016-06-16 18:20 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, netdev
There are several FWINV #defines with identical form
that hide a specific structure variable and dereference
it with a invflags member.
$ 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: rfc: netfilter: Unhide FWINV macro arguments ?
2016-06-16 18:20 rfc: netfilter: Unhide FWINV macro arguments ? Joe Perches
@ 2016-06-17 11:59 ` Pablo Neira Ayuso
2016-06-17 15:41 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-17 11:59 UTC (permalink / raw)
To: Joe Perches; +Cc: netfilter-devel, netdev
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: rfc: netfilter: Unhide FWINV macro arguments ?
2016-06-17 11:59 ` Pablo Neira Ayuso
@ 2016-06-17 15:41 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-06-17 15:41 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, netdev
On Fri, 2016-06-17 at 13:59 +0200, Pablo Neira Ayuso wrote:
> 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.
[]
> I'll be taking a patch to sort out this. Thanks.
I'll wait until you pick up or reject the
ether_addr_equal_masked patch as that changes
a few FWINV uses.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-17 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16 18:20 rfc: netfilter: Unhide FWINV macro arguments ? Joe Perches
2016-06-17 11:59 ` Pablo Neira Ayuso
2016-06-17 15:41 ` Joe Perches
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.