]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: throw distinct error if map exists but contains no objects
authorFlorian Westphal <fw@strlen.de>
Thu, 20 Sep 2018 15:21:45 +0000 (17:21 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 20 Sep 2018 15:21:45 +0000 (17:21 +0200)
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>
src/evaluate.c

index 195508236e1e6a2a5b458f431f03ac11497443da..c8010852eecb2f349f739e0465e31c9e47d9fef5 100644 (file)
@@ -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",