]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
optimize: remove comment after merging
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 17 Jun 2022 15:26:38 +0000 (17:26 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jun 2022 17:00:02 +0000 (19:00 +0200)
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 <pablo@netfilter.org>
src/optimize.c
tests/shell/testcases/optimizations/merge_stmts

index b19a8b553555900fdc9141054576df3adf7d2568..94242ee5f490d9aee5801f997a65dfe098b8a550 100644 (file)
@@ -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");
index 0c35636efaa9885439f10873a4f421a65d2d1041..ec7a9dd6b5546b9eed245f8b135cae2dc95f490d 100755 (executable)
@@ -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"
        }
 }"