From cebbd9678b7ee6f74b3bd4eefc23de5b27135799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Eckl?= Date: Thu, 23 Aug 2018 12:51:07 +0200 Subject: src: Make invalid chain priority error more specific MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far if invalid priority name was specified the error message referred to the whole chain/flowtable specification: nft> add chain ip x h { type filter hook prerouting priority first; } Error: 'first' is invalid priority in this context. add chain ip x h { type filter hook prerouting priority first; } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ With this patch this reference is made specific to the priority specification: nft> add chain ip x h { type filter hook prerouting priority first; } Error: 'first' is invalid priority in this context. add chain ip x h { type filter hook prerouting priority first; } ^^^^^^^^^^^^^^ `prio_spec` is also reused to keep naming intuitive. The parser section formerly named `prio_spec` is renamed to `int_num` as it basically provides the mathematical set of integer numbers. Signed-off-by: Máté Eckl Signed-off-by: Pablo Neira Ayuso --- src/evaluate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index 647e1606..685924df 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3028,8 +3028,9 @@ static int flowtable_evaluate(struct eval_ctx *ctx, struct flowtable *ft) return chain_error(ctx, ft, "invalid hook %s", ft->hookstr); if (!evaluate_priority(&ft->priority, NFPROTO_NETDEV, ft->hooknum)) - return chain_error(ctx, ft, "'%s' is invalid priority.", - ft->priority.str); + return __stmt_binary_error(ctx, &ft->priority.loc, NULL, + "'%s' is invalid priority.", + ft->priority.str); if (!ft->dev_expr) return chain_error(ctx, ft, "Unbound flowtable not allowed (must specify devices)"); @@ -3186,9 +3187,9 @@ static int chain_evaluate(struct eval_ctx *ctx, struct chain *chain) if (!evaluate_priority(&chain->priority, chain->handle.family, chain->hooknum)) - return chain_error(ctx, chain, - "'%s' is invalid priority in this context.", - chain->priority.str); + return __stmt_binary_error(ctx, &chain->priority.loc, NULL, + "'%s' is invalid priority in this context.", + chain->priority.str); } list_for_each_entry(rule, &chain->rules, list) { -- cgit v1.2.3