From: Arthur Leung <arcyleung@gmail.com>
To: dev@dpdk.org
Cc: Arthur Leung <arcyleung@gmail.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [PATCH] acl: fix trie splitting
Date: Wed, 1 Feb 2023 14:34:26 -0500 [thread overview]
Message-ID: <20230201193426.19243-1-arcyleung@gmail.com> (raw)
When using a large number of ACL rules, the trie is supposed to split when there are over 2048 nodes.
However, node_count is negative, so node_count > context->cur_node_max never actually runs, so all the nodes created from the rules end up being in one trie.
Original PR with sample files and test output can be found here:
https://github.com/DPDK/dpdk/pull/50
Fixes: dc276b5780c2 ("acl: new library")
Signed-off-by: Arthur Leung <arcyleung@gmail.com>
---
app/test-acl/test-acl.sh | 2 +-
lib/acl/acl_bld.c | 9 +++------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/app/test-acl/test-acl.sh b/app/test-acl/test-acl.sh
index 30814f3fe2..59bfa121cf 100644
--- a/app/test-acl/test-acl.sh
+++ b/app/test-acl/test-acl.sh
@@ -17,7 +17,7 @@
# <proto>'/'<mask>
# trace record format:
# <src_ip_addr><space><dst_ip_addr><space> \
-# <src_port><space<dst_port><space><proto>...<rule_id>
+# <src_port><space><dst_port><space><proto>...<rule_id>
#
# As an example:
# /bin/bash app/test-acl/test-acl.sh build/app/dpdk-test-acl \
diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c
index 2816632803..6064a8103b 100644
--- a/lib/acl/acl_bld.c
+++ b/lib/acl/acl_bld.c
@@ -946,7 +946,7 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
struct rte_acl_build_rule **last, uint32_t *count)
{
uint32_t n, m;
- int field_index, node_count;
+ int field_index;
struct rte_acl_node *trie;
struct rte_acl_build_rule *prev, *rule;
struct rte_acl_node *end, *merge, *root, *end_prev;
@@ -1048,15 +1048,13 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
}
}
- node_count = context->num_nodes;
(*count)++;
/* merge this rule into the trie */
if (acl_merge_trie(context, trie, root, 0, NULL))
return NULL;
- node_count = context->num_nodes - node_count;
- if (node_count > context->cur_node_max) {
+ if (context->num_nodes > (context->cur_node_max * context->num_tries)) {
*last = prev;
return trie;
}
@@ -1368,6 +1366,7 @@ acl_build_tries(struct acl_build_context *context,
for (n = 0;; n = num_tries) {
num_tries = n + 1;
+ context->num_tries = num_tries;
last = build_one_trie(context, rule_sets, n, context->node_max);
if (context->bld_tries[n].trie == NULL) {
@@ -1411,8 +1410,6 @@ acl_build_tries(struct acl_build_context *context,
}
}
-
- context->num_tries = num_tries;
return 0;
}
--
2.25.1
next reply other threads:[~2023-02-02 7:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 19:34 Arthur Leung [this message]
2023-02-05 16:46 ` Konstantin Ananyev
2023-02-06 3:00 ` Arthur Leung
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=20230201193426.19243-1-arcyleung@gmail.com \
--to=arcyleung@gmail.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=pablo.de.lara.guarch@intel.com \
/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).