From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 1/2] optimize: wrap code to build concatenation in helper function
Date: Thu, 2 Feb 2023 22:04:31 +0100 [thread overview]
Message-ID: <20230202210432.106465-1-pablo@netfilter.org> (raw)
Move code to build concatenations into helper function, this routine
includes support for expansion of implicit sets containing singleton
values. This is preparation work to reuse existing code in a follow up
patch.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/optimize.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/optimize.c b/src/optimize.c
index 289c442dc915..8cec04c02c4f 100644
--- a/src/optimize.c
+++ b/src/optimize.c
@@ -552,20 +552,19 @@ static void merge_stmts(const struct optimize_ctx *ctx,
}
}
-static void __merge_concat_stmts(const struct optimize_ctx *ctx, uint32_t i,
- const struct merge *merge, struct expr *set)
+static void __merge_concat(const struct optimize_ctx *ctx, uint32_t i,
+ const struct merge *merge, struct list_head *concat_list)
{
- struct expr *concat, *next, *expr, *concat_clone, *clone, *elem;
+ struct expr *concat, *next, *expr, *concat_clone, *clone;
LIST_HEAD(pending_list);
- LIST_HEAD(concat_list);
struct stmt *stmt_a;
uint32_t k;
concat = concat_expr_alloc(&internal_location);
- list_add(&concat->list, &concat_list);
+ list_add(&concat->list, concat_list);
for (k = 0; k < merge->num_stmts; k++) {
- list_for_each_entry_safe(concat, next, &concat_list, list) {
+ list_for_each_entry_safe(concat, next, concat_list, list) {
stmt_a = ctx->stmt_matrix[i][merge->stmt[k]];
switch (stmt_a->expr->right->etype) {
case EXPR_SET:
@@ -590,8 +589,17 @@ static void __merge_concat_stmts(const struct optimize_ctx *ctx, uint32_t i,
break;
}
}
- list_splice_init(&pending_list, &concat_list);
+ list_splice_init(&pending_list, concat_list);
}
+}
+
+static void __merge_concat_stmts(const struct optimize_ctx *ctx, uint32_t i,
+ const struct merge *merge, struct expr *set)
+{
+ struct expr *concat, *next, *elem;
+ LIST_HEAD(concat_list);
+
+ __merge_concat(ctx, i, merge, &concat_list);
list_for_each_entry_safe(concat, next, &concat_list, list) {
list_del(&concat->list);
--
2.30.2
next reply other threads:[~2023-02-02 21:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 21:04 Pablo Neira Ayuso [this message]
2023-02-02 21:04 ` [PATCH nft 2/2] optimize: fix incorrect expansion into concatenation with verdict map 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=20230202210432.106465-1-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).