]> git.ipfire.org Git - thirdparty/nftables.git/commit
fix printing of "tcp flags syn" and "tcp flags == syn" expressions
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 25 May 2018 13:23:16 +0000 (15:23 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 25 May 2018 15:48:55 +0000 (17:48 +0200)
commitabbe85b3fdc101b23acdbb874d26d10686cf8a95
tree44f6e835975cb08516bde94ca6b26201a795fa7a
parentbe90e03dd1fa374aeaebb4de3174b97c3bd224f8
fix printing of "tcp flags syn" and "tcp flags == syn" expressions

Commit 6979625686ec ("relational: Eliminate meta OPs") introduced some
bugs when printing bitmask types.

First, during the post-processing phase of delinearization, the
expression for "tcp flags syn" (PAYLOAD & flag != 0) gets converted to
PAYLOAD == flag, which is not equivalent. This should be
PAYLOAD (IMPL) flag.

Then, during output, the "==" sign from "tcp flags == syn" is dropped,
because the bitmask condition in must_print_eq_op() was removed. Let's
restore it, so that "tcp flags == syn" doesn't get printed as
"tcp flags syn". An extra check for value types is added, so that we
don't start printing "==" for sets such as "tcp flags {syn,ack}"

Finally, add a regression test for this particular case.

Fixes: 6979625686ec ("relational: Eliminate meta OPs")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/expression.c
src/netlink_delinearize.c
tests/py/inet/tcp.t
tests/py/inet/tcp.t.payload