[PATCH nft] expr: do not suppress OP_EQ when RHS is bitmask type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 src/expression.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/expression.c b/src/expression.c
index 1313925..fa14d99 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -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(" ");
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux