Blame SOURCES/0040-evaluate-throw-distinct-error-if-map-exists-but-cont.patch

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