From 6979625686ec8d915f5ad5fdc28f24f55b6be3f7 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 16 Mar 2018 00:03:19 +0100 Subject: relational: Eliminate meta OPs With a bit of code reorganization, relational meta OPs OP_RANGE, OP_FLAGCMP and OP_LOOKUP become unused and can be removed. The only meta OP left is OP_IMPLICIT which is usually treated as alias to OP_EQ. Though it needs to stay in place for one reason: When matching against a bitmask (e.g. TCP flags or conntrack states), it has a different meaning: | nft --debug=netlink add rule ip t c tcp flags syn | ip t c | [ meta load l4proto => reg 1 ] | [ cmp eq reg 1 0x00000006 ] | [ payload load 1b @ transport header + 13 => reg 1 ] | [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ] | [ cmp neq reg 1 0x00000000 ] | nft --debug=netlink add rule ip t c tcp flags == syn | ip t c | [ meta load l4proto => reg 1 ] | [ cmp eq reg 1 0x00000006 ] | [ payload load 1b @ transport header + 13 => reg 1 ] | [ cmp eq reg 1 0x00000002 ] OP_IMPLICIT creates a match which just checks the given flag is present, while OP_EQ creates a match which ensures the given flag and no other is present. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 6fba7e59..bdf2fb49 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -3185,7 +3185,7 @@ relational_expr : expr /* implicit */ rhs_expr } | expr /* implicit */ list_rhs_expr { - $$ = relational_expr_alloc(&@$, OP_FLAGCMP, $1, $2); + $$ = relational_expr_alloc(&@$, OP_IMPLICIT, $1, $2); } | expr relational_op rhs_expr { -- cgit v1.2.3