* [PATCH nft] optimize: do not merge unsupported statement expressions
@ 2022-03-03 13:59 Pablo Neira Ayuso
0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2022-03-03 13:59 UTC (permalink / raw)
To: netfilter-devel
Only value, range, prefix, set and list are supported at this stage.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/optimize.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/optimize.c b/src/optimize.c
index c8bdccf7b610..b4035d0a96fc 100644
--- a/src/optimize.c
+++ b/src/optimize.c
@@ -91,6 +91,22 @@ 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_VALUE:
+ case EXPR_RANGE:
+ case EXPR_PREFIX:
+ case EXPR_SET:
+ case EXPR_LIST:
+ 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 +119,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:
--
2.30.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-03 13:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03 13:59 [PATCH nft] optimize: do not merge unsupported statement expressions 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).