optimize: expand expression list when merging into concatenation
Pablo Neira Ayuso
maintainerPATCH 1/1 optimize: expand expression list when merging into concatenation
The following rules:
udp dport 137 ct state new,untracked accept
udp dport 138 ct state new,untracked accept
results in:
nft: src/optimize.c:670: __merge_concat: Assertion `0' failed.
The logic to expand to the new,untracked list in the concatenation is missing.
Fixes 187c6d01d357 ("optimize: expand implicit set element when merging into concatenation")
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/optimize.c | 10 +++ .../dumps/merge_stmts_concat.json-nft | 61 +++++++++++++++++++ .../dumps/merge_stmts_concat.nft | 1 + .../optimizations/merge_stmts_concat | 2 + 4 files changed, 74 insertions(+)
src/optimize.c +10 -0
@@ -666,6 +666,16 @@ static void __merge_concat(const struct optimize_ctx *ctx, uint32_t i, clone =expr_clone (stmt_a->expr->right);compound_expr_add (concat, clone);break ; +case EXPR_LIST : +list_for_each_entry (expr, &stmt_a->expr->right->expressions, list) { + concat_clone =expr_clone (concat); + clone =expr_clone (expr); +compound_expr_add (concat_clone, clone); +list_add_tail (&concat_clone->list, &pending_list); + } +list_del (&concat->list); +expr_free (concat); +break ;default :assert (0 );break ;
tests/shell/testcases/optimizations/dumps/merge_stmts_concat.json-nft +61 -0
67 lines not on this page · raw message
tests/shell/testcases/optimizations/dumps/merge_stmts_concat.nft +1 -0
@@ -2,6 +2,7 @@ table ip x { chain y { iifname . ip saddr . ip daddr { "eth1" . 1.1.1.1 . 2.2.2.3, "eth1" . 1.1.1.2 . 2.2.2.4, "eth1" . 1.1.1.2 . 2.2.3.0/24, "eth1" . 1.1.1.2 . 2.2.4.0-2.2.4.10, "eth2" . 1.1.1.3 . 2.2.2.5 } accept ip protocol . th dport { tcp . 22, udp . 67 } + udp dport . ct state { 137 . new, 138 . new, 137 . untracked, 138 . untracked } accept } chain c1 {
tests/shell/testcases/optimizations/merge_stmts_concat +2 -0
@@ -12,6 +12,8 @@ RULESET="table ip x { meta iifname eth1 ip saddr 1.1.1.2 ip daddr 2.2.4.0-2.2.4.10 accept meta iifname eth2 ip saddr 1.1.1.3 ip daddr 2.2.2.5 accept ip protocol . th dport { tcp . 22, udp . 67 } + udp dport 137 ct state new,untracked accept + udp dport 138 ct state new,untracked accept } }"
Signature · 1 line
2.30.2