]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expr: do not suppress OP_EQ when RHS is bitmask type
authorFlorian Westphal <fw@strlen.de>
Mon, 17 Mar 2014 22:03:43 +0000 (23:03 +0100)
committerFlorian Westphal <fw@strlen.de>
Fri, 4 Apr 2014 15:32:46 +0000 (17:32 +0200)
bitmask types default to flagcmp now, thus do not suppress OP_EQ.  Else,

rule filter output tcp flags syn
rule filter output tcp flags == syn

are both displayed as 'flags syn'.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/expression.c

index 131392566716bafb3eabafa4b4261e3a1e4b45e6..fa14d99c4692b46035dca6a75d4b3b0035719505 100644 (file)
@@ -514,13 +514,21 @@ static void binop_arg_print(const struct expr *op, const struct expr *arg)
                printf(")");
 }
 
+static bool must_print_eq_op(const struct expr *expr)
+{
+       if (expr->right->dtype->basetype != NULL &&
+           expr->right->dtype->basetype->type == TYPE_BITMASK)
+               return true;
+
+       return expr->left->ops->type == EXPR_BINOP;
+}
+
 static void binop_expr_print(const struct expr *expr)
 {
        binop_arg_print(expr, expr->left);
 
        if (expr_op_symbols[expr->op] &&
-           (expr->op != OP_EQ ||
-            expr->left->ops->type == EXPR_BINOP))
+           (expr->op != OP_EQ || must_print_eq_op(expr)))
                printf(" %s ", expr_op_symbols[expr->op]);
        else
                printf(" ");