]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
optimize: do not merge unsupported statement expressions
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 3 Mar 2022 13:56:58 +0000 (14:56 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 3 Mar 2022 14:54:30 +0000 (15:54 +0100)
Only value, range, prefix, set and list are supported at this stage.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/optimize.c

index 6ba7e5a10cf83e725333e0bdc2ea0ec9467f8175..f8dd7f8d159fdb884e25b7af18f692bca09e9d9c 100644 (file)
@@ -91,6 +91,23 @@ static bool __expr_cmp(const struct expr *expr_a, const struct expr *expr_b)
        return true;
 }
 
+static bool stmt_expr_supported(const struct expr *expr)
+{
+       switch (expr->right->etype) {
+       case EXPR_SYMBOL:
+       case EXPR_RANGE:
+       case EXPR_PREFIX:
+       case EXPR_SET:
+       case EXPR_LIST:
+       case EXPR_VALUE:
+               return true;
+       default:
+               break;
+       }
+
+       return false;
+}
+
 static bool __stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b)
 {
        struct expr *expr_a, *expr_b;
@@ -103,6 +120,10 @@ static bool __stmt_type_eq(const struct stmt *stmt_a, const struct stmt *stmt_b)
                expr_a = stmt_a->expr;
                expr_b = stmt_b->expr;
 
+               if (!stmt_expr_supported(expr_a) ||
+                   !stmt_expr_supported(expr_b))
+                       return false;
+
                return __expr_cmp(expr_a->left, expr_b->left);
        case STMT_COUNTER:
        case STMT_NOTRACK: