From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft] evaluate: error out when existing set has incompatible key
Date: Wed, 13 Dec 2023 17:29:50 +0100 [thread overview]
Message-ID: <20231213162954.10145-1-fw@strlen.de> (raw)
Before:
BUG: invalid range expression type symbol
nft: expression.c:1494: range_expr_value_high: Assertion `0' failed.
After:
range_expr_value_high_assert:5:20-27: Error: Could not resolve protocol name
elements = { 100-11.0.0.0, }
^^^^^^^^
range_expr_value_high_assert:7:6-7: Error: set definition has conflicting key (ipv4_addr vs inet_proto)
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/evaluate.c | 3 +++
.../bogons/nft-f/range_expr_value_high_assert | 12 ++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 tests/shell/testcases/bogons/nft-f/range_expr_value_high_assert
diff --git a/src/evaluate.c b/src/evaluate.c
index dd1c0b44c278..27adbf7f51ee 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -4769,6 +4769,9 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
existing_set = set_cache_find(table, set->handle.set.name);
if (!existing_set)
set_cache_add(set_get(set), table);
+ else if (!datatype_equal(existing_set->key->dtype, set->key->dtype))
+ return set_error(ctx, set, "%s definition has conflicting key (%s vs %s)\n",
+ type, set->key->dtype->name, existing_set->key->dtype->name);
if (existing_set && existing_set->flags & NFT_SET_EVAL) {
uint32_t existing_flags = existing_set->flags & ~NFT_SET_EVAL;
diff --git a/tests/shell/testcases/bogons/nft-f/range_expr_value_high_assert b/tests/shell/testcases/bogons/nft-f/range_expr_value_high_assert
new file mode 100644
index 000000000000..a25ac028bb9b
--- /dev/null
+++ b/tests/shell/testcases/bogons/nft-f/range_expr_value_high_assert
@@ -0,0 +1,12 @@
+table inet t {
+ set s3 {
+ type inet_proto
+ flags interval
+ elements = { 100-11.0.0.0, }
+ }
+ set s3 {
+ type ipv4_addr
+ flags interval
+ elements = { 100-11.0.0.0, }
+ }
+}
--
2.41.0
reply other threads:[~2023-12-13 16:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20231213162954.10145-1-fw@strlen.de \
--to=fw@strlen.de \
--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