From: Pablo Neira Ayuso Date: Fri, 17 Jun 2022 15:26:38 +0000 (+0200) Subject: optimize: remove comment after merging X-Git-Tag: v1.0.5~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9939f8954f800b865a0463c65f8c3e9a86aa296;p=thirdparty%2Fnftables.git optimize: remove comment after merging Remove rule comment after merging rules, let the user decide if they want to reintroduce the comment in the ruleset file. Update optimizations/merge_stmt test. Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/optimize.c b/src/optimize.c index b19a8b55..94242ee5 100644 --- a/src/optimize.c +++ b/src/optimize.c @@ -873,6 +873,11 @@ static void merge_rules(const struct optimize_ctx *ctx, assert(0); } + if (ctx->rule[from]->comment) { + xfree(ctx->rule[from]->comment); + ctx->rule[from]->comment = NULL; + } + octx->flags |= NFT_CTX_OUTPUT_STATELESS; fprintf(octx->error_fp, "Merging:\n"); diff --git a/tests/shell/testcases/optimizations/merge_stmts b/tests/shell/testcases/optimizations/merge_stmts index 0c35636e..ec7a9dd6 100755 --- a/tests/shell/testcases/optimizations/merge_stmts +++ b/tests/shell/testcases/optimizations/merge_stmts @@ -4,9 +4,9 @@ set -e RULESET="table ip x { chain y { - ip daddr 192.168.0.1 counter accept - ip daddr 192.168.0.2 counter accept - ip daddr 192.168.0.3 counter accept + ip daddr 192.168.0.1 counter accept comment "test1" + ip daddr 192.168.0.2 counter accept comment "test2" + ip daddr 192.168.0.3 counter accept comment "test3" } }"