netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nftables] evaluate: allow == and != in the new shortcut syntax to match for flags
@ 2021-05-24 20:08 Pablo Neira Ayuso
  2021-05-24 20:08 ` [PATCH nftables] expression: display an error on unknown datatype Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo Neira Ayuso @ 2021-05-24 20:08 UTC (permalink / raw)
  To: netfilter-devel

The flags / mask syntax only allows for ==, !=  and the implicit
operation (which is == in this case).

 # nft add rule x y tcp flags ! syn / syn,ack
 Error: either == or != is allowed
 add rule x y tcp flags ! syn / syn,ack
              ^^^^^^^^^^^^^^^^^^^^^^^^^

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/evaluate.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/evaluate.c b/src/evaluate.c
index 006b04affbd7..384e2fa786e0 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2139,6 +2139,10 @@ static int expr_evaluate_flagcmp(struct eval_ctx *ctx, struct expr **exprp)
 {
 	struct expr *expr = *exprp, *binop, *rel;
 
+	if (expr->op != OP_EQ &&
+	    expr->op != OP_NEQ)
+		return expr_error(ctx->msgs, expr, "either == or != is allowed");
+
 	binop = binop_expr_alloc(&expr->location, OP_AND,
 				 expr_get(expr->flagcmp.expr),
 				 expr_get(expr->flagcmp.mask));
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-24 20:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-24 20:08 [PATCH nftables] evaluate: allow == and != in the new shortcut syntax to match for flags Pablo Neira Ayuso
2021-05-24 20:08 ` [PATCH nftables] expression: display an error on unknown datatype Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).