summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2018-05-25 15:23:16 +0200
committerFlorian Westphal <fw@strlen.de>2018-05-25 17:48:55 +0200
commitabbe85b3fdc101b23acdbb874d26d10686cf8a95 (patch)
tree44f6e835975cb08516bde94ca6b26201a795fa7a /src
parentbe90e03dd1fa374aeaebb4de3174b97c3bd224f8 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/expression.c5
-rw-r--r--src/netlink_delinearize.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/expression.c b/src/expression.c
index 53fb1811..bea0f4c8 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -565,6 +565,11 @@ static void binop_arg_print(const struct expr *op, const struct expr *arg,
bool must_print_eq_op(const struct expr *expr)
{
+ if (expr->right->dtype->basetype != NULL &&
+ expr->right->dtype->basetype->type == TYPE_BITMASK &&
+ expr->right->ops->type == EXPR_VALUE)
+ return true;
+
return expr->left->ops->type == EXPR_BINOP;
}
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 8f4035a2..7d882eba 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -1733,7 +1733,7 @@ static void relational_binop_postprocess(struct rule_pp_ctx *ctx, struct expr *e
expr->left = expr_get(binop->left);
expr->right = binop_tree_to_list(NULL, binop->right);
- expr->op = OP_EQ;
+ expr->op = OP_IMPLICIT;
expr_free(binop);
} else if (binop->left->dtype->flags & DTYPE_F_PREFIX &&