* [iptables PATCH] tcp_xlate: Enclose LH flag values in parentheses
@ 2016-11-29 11:47 Phil Sutter
2016-11-29 22:02 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2016-11-29 11:47 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
This fixes TCP flags matches:
| $ iptables-translate -A invalid -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
| nft add rule ip filter invalid tcp flags & fin|syn == fin|syn counter drop
Although the generated rule is syntactically correct and accepted by
nft, it will be interpreted in a different way than expected since
binary AND takes precedence over OR.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libxt_tcp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/extensions/libxt_tcp.c b/extensions/libxt_tcp.c
index 7f68b81288725..58f3c0a0c3c28 100644
--- a/extensions/libxt_tcp.c
+++ b/extensions/libxt_tcp.c
@@ -435,9 +435,9 @@ static int tcp_xlate(struct xt_xlate *xl,
return 0;
if (tcpinfo->flg_mask || (tcpinfo->invflags & XT_TCP_INV_FLAGS)) {
- xt_xlate_add(xl, "%stcp flags & ", space);
+ xt_xlate_add(xl, "%stcp flags & (", space);
print_tcp_xlate(xl, tcpinfo->flg_mask);
- xt_xlate_add(xl, " %s ",
+ xt_xlate_add(xl, ") %s ",
tcpinfo->invflags & XT_TCP_INV_FLAGS ? "!=": "==");
print_tcp_xlate(xl, tcpinfo->flg_cmp);
}
--
2.10.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [iptables PATCH] tcp_xlate: Enclose LH flag values in parentheses
2016-11-29 11:47 [iptables PATCH] tcp_xlate: Enclose LH flag values in parentheses Phil Sutter
@ 2016-11-29 22:02 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-11-29 22:02 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Tue, Nov 29, 2016 at 12:47:25PM +0100, Phil Sutter wrote:
> This fixes TCP flags matches:
>
> | $ iptables-translate -A invalid -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
> | nft add rule ip filter invalid tcp flags & fin|syn == fin|syn counter drop
>
> Although the generated rule is syntactically correct and accepted by
> nft, it will be interpreted in a different way than expected since
> binary AND takes precedence over OR.
And this one also applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-29 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 11:47 [iptables PATCH] tcp_xlate: Enclose LH flag values in parentheses Phil Sutter
2016-11-29 22:02 ` Pablo Neira Ayuso
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.