From: Florian Westphal Date: Thu, 20 Sep 2018 15:21:45 +0000 (+0200) Subject: evaluate: throw distinct error if map exists but contains no objects X-Git-Tag: v0.9.1~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b35fb3132b1fa4348266139661ffa21a5a5ae0d;p=thirdparty%2Fnftables.git evaluate: throw distinct error if map exists but contains no objects 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 Signed-off-by: Florian Westphal --- diff --git a/src/evaluate.c b/src/evaluate.c index 19550823..c8010852 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -2806,10 +2806,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",