netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 04/18] optimize: remove comment after merging
Date: Mon, 20 Jun 2022 10:32:01 +0200	[thread overview]
Message-ID: <20220620083215.1021238-5-pablo@netfilter.org> (raw)
In-Reply-To: <20220620083215.1021238-1-pablo@netfilter.org>

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                                  | 5 +++++
 tests/shell/testcases/optimizations/merge_stmts | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/optimize.c b/src/optimize.c
index b19a8b553555..94242ee5f490 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 0c35636efaa9..ec7a9dd6b554 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"
 	}
 }"
 
-- 
2.30.2


  parent reply	other threads:[~2022-06-20  8:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  8:31 [PATCH nft 00/18] fixes and improvements for -o/--optimize Pablo Neira Ayuso
2022-06-20  8:31 ` [PATCH nft 01/18] optimize: do not compare relational expression rhs when collecting statements Pablo Neira Ayuso
2022-06-20  8:31 ` [PATCH nft 02/18] optimize: do not merge rules with set reference in rhs Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 03/18] optimize: do not print stateful information Pablo Neira Ayuso
2022-06-20  8:32 ` Pablo Neira Ayuso [this message]
2022-06-20  8:32 ` [PATCH nft 05/18] optimize: fix reject statement Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 06/18] optimize: fix verdict map merging Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 07/18] optimize: add osf expression support Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 08/18] optimize: add xfrm " Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 09/18] optimize: add fib " Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 10/18] optimize: add binop " Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 11/18] optimize: add numgen " Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 12/18] optimize: add hash " Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 13/18] optimize: add unsupported statement Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 14/18] tests: shell: run -c -o on ruleset Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 15/18] optimize: only merge OP_IMPLICIT and OP_EQ relational Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 16/18] optimize: assume verdict is same when rules have no verdict Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 17/18] optimize: limit statement is not supported yet Pablo Neira Ayuso
2022-06-20  8:32 ` [PATCH nft 18/18] libnftables: release top level scope Pablo Neira Ayuso
2022-06-23 17:17 ` [PATCH nft 00/18] fixes and improvements for -o/--optimize Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220620083215.1021238-5-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).