Skip to contentSkip to conversation

evaluate: better error notice when interval flag is not set on

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Jan 10, 2020 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 evaluate: better error notice when interval flag is not set on

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 }
                   ^^^^^^^^^^
---
 src/evaluate.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
src/evaluate.c +2 -5
index 34e4473e4c9a..e7881543d2de 100644
@@ -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;
 		}
Signature · 1 line
2.11.0
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Pablo Neira Ayuso

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 }
                   ^^^^^^^^^^

Not sure why "missing inverval flag on declaration" is more confusing than "you must add 'flags interval' to ...", but maybe I'm just too much into the topic to notice the difference. :)

Quoted 1 line

Unrelated? Did you pick the wrong ticket ID?

Quoted 1 line

Except for nfbz link: