]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: better error notice when interval flag is not set on
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 10 Jan 2020 10:53:22 +0000 (11:53 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2020 15:08:16 +0000 (16:08 +0100)
Users get confused with the existing error notice, let's try a different one:

 # nft add element x y { 1.1.1.0/24 }
 Error: You must add 'flags interval' to your set declaration if you want to add prefix elements
 add element x y { 1.1.1.0/24 }
                   ^^^^^^^^^^

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1380
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Phil Sutter <phil@nwl.cc>
src/evaluate.c

index 34e4473e4c9a279510ea191d48189c86828a6e53..e7881543d2de63ee4d7c481acc2e4d0b568e5e00 100644 (file)
@@ -1299,13 +1299,10 @@ static int expr_evaluate_set_elem(struct eval_ctx *ctx, struct expr **expr)
            !(ctx->set->flags & (NFT_SET_ANONYMOUS | NFT_SET_INTERVAL))) {
                switch (elem->key->etype) {
                case EXPR_PREFIX:
-                       return expr_error(ctx->msgs, elem,
-                                         "Set member cannot be prefix, "
-                                         "missing interval flag on declaration");
                case EXPR_RANGE:
                        return expr_error(ctx->msgs, elem,
-                                         "Set member cannot be range, "
-                                         "missing interval flag on declaration");
+                                         "You must add 'flags interval' to your %s declaration if you want to add %s elements",
+                                         set_is_map(ctx->set->flags) ? "map" : "set", expr_name(elem->key));
                default:
                        break;
                }