From abbe85b3fdc101b23acdbb874d26d10686cf8a95 Mon Sep 17 00:00:00 2001 From: Sabrina Dubroca Date: Fri, 25 May 2018 15:23:16 +0200 Subject: 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 Signed-off-by: Florian Westphal --- tests/py/inet/tcp.t.payload | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/py/inet/tcp.t.payload') diff --git a/tests/py/inet/tcp.t.payload b/tests/py/inet/tcp.t.payload index 512b42e9..09538aed 100644 --- a/tests/py/inet/tcp.t.payload +++ b/tests/py/inet/tcp.t.payload @@ -421,6 +421,13 @@ inet test-inet input [ payload load 1b @ transport header + 13 => reg 1 ] [ cmp neq reg 1 0x00000080 ] +# tcp flags == syn +inet test-inet input + [ meta load l4proto => reg 1 ] + [ cmp eq reg 1 0x00000006 ] + [ payload load 1b @ transport header + 13 => reg 1 ] + [ cmp eq reg 1 0x00000002 ] + # tcp flags & (syn|fin) == (syn|fin) inet test-inet input [ meta load l4proto => reg 1 ] -- cgit v1.2.3