nftables/SOURCES/0040-evaluate-throw-distinct-error-if-map-exists-but-cont.patch
2021-09-09 22:49:01 +00:00

56 lines
1.8 KiB
Diff

From f50e0290b648f00fb76655b23d48d0729500c76a Mon Sep 17 00:00:00 2001
From: Florian Westphal <fw@strlen.de>
Date: Thu, 20 Sep 2018 17:21:45 +0200
Subject: [PATCH] evaluate: throw distinct error if map exists but contains no
objects
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
nft would throw misleading error in case map exists but doesn't contain
expected objects.
nft add rule filter in ct helper set tcp dport map @foo
Error: Expression is not a map
add rule filter in ct helper set tcp dport map @foo
^^^^
nft list table filter
table ip filter {
map foo {
type inet_service : ifname
}
...
clarify this.
Reported-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
(cherry picked from commit 5b35fb3132b1fa4348266139661ffa21a5a5ae0d)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
src/evaluate.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 6ab4a3309ad77..88fa44dd34ef5 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2671,10 +2671,12 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)
case EXPR_SYMBOL:
if (expr_evaluate(ctx, &map->mappings) < 0)
return -1;
- if (map->mappings->ops->type != EXPR_SET_REF ||
- !(map->mappings->set->flags & NFT_SET_OBJECT))
+ if (map->mappings->ops->type != EXPR_SET_REF)
return expr_error(ctx->msgs, map->mappings,
"Expression is not a map");
+ if (!(map->mappings->set->flags & NFT_SET_OBJECT))
+ return expr_error(ctx->msgs, map->mappings,
+ "Expression is not a map with objects");
break;
default:
BUG("invalid mapping expression %s\n",
--
2.21.0