summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2022-03-03 13:06:59 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2022-03-03 15:54:27 +0100
commit3de1dbd2da8a76ddd2d1d9fcd7e469eb848f0d00 (patch)
treee16709ed82e5875694cbbbd7f69debdeba7a254d /src
parent99eb46969f3d7ccd37899f2755055fe7511c46b0 (diff)
optimize: more robust statement merge with vmap
Check expressions that are expected on the rhs rather than using a catch-all default case. Actually, lists and sets need to be their own routine, because this needs the set element key expression to be merged. This is a follow up to 99eb46969f3d ("optimize: fix vmap with anonymous sets"). Fixes: 1542082e259b ("optimize: merge same selector with different verdict into verdict map") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/optimize.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/optimize.c b/src/optimize.c
index 64c0a4db..af075da4 100644
--- a/src/optimize.c
+++ b/src/optimize.c
@@ -437,7 +437,6 @@ static void build_verdict_map(struct expr *expr, struct stmt *verdict, struct ex
switch (expr->etype) {
case EXPR_LIST:
- case EXPR_SET:
list_for_each_entry(item, &expr->expressions, list) {
elem = set_elem_expr_alloc(&internal_location, expr_get(item));
mapping = mapping_expr_alloc(&internal_location, elem,
@@ -445,12 +444,27 @@ static void build_verdict_map(struct expr *expr, struct stmt *verdict, struct ex
compound_expr_add(set, mapping);
}
break;
- default:
+ case EXPR_SET:
+ list_for_each_entry(item, &expr->expressions, list) {
+ elem = set_elem_expr_alloc(&internal_location, expr_get(item->key));
+ mapping = mapping_expr_alloc(&internal_location, elem,
+ expr_get(verdict->expr));
+ compound_expr_add(set, mapping);
+ }
+ break;
+ case EXPR_PREFIX:
+ case EXPR_RANGE:
+ case EXPR_VALUE:
+ case EXPR_SYMBOL:
+ case EXPR_CONCAT:
elem = set_elem_expr_alloc(&internal_location, expr_get(expr));
mapping = mapping_expr_alloc(&internal_location, elem,
expr_get(verdict->expr));
compound_expr_add(set, mapping);
break;
+ default:
+ assert(0);
+ break;
}
}