* [PATCH nft] evaluate: error reporting for missing statements in set/map declaration
@ 2021-07-26 16:38 Pablo Neira Ayuso
0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2021-07-26 16:38 UTC (permalink / raw)
To: netfilter-devel
Assuming this map:
map y {
type ipv4_addr : verdict
}
This patch slightly improves error reporting to refer to the missing
'counter' statement in the map declaration.
# nft 'add element x y { 1.2.3.4 counter packets 1 bytes 1 : accept, * counter : drop }'
Error: missing statement in map declaration
add element x y { 1.2.3.4 counter packets 10 bytes 640 : accept, * counter : drop }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/evaluate.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 98309ea83ac0..4609576b2a61 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1351,10 +1351,12 @@ static int __expr_evaluate_set_elem(struct eval_ctx *ctx, struct expr *elem)
"but element has %d", num_set_exprs,
num_elem_exprs);
} else if (num_set_exprs == 0) {
- if (!(set->flags & NFT_SET_EVAL))
- return expr_error(ctx->msgs, elem,
- "missing statements in %s definition",
+ if (!(set->flags & NFT_SET_EVAL)) {
+ elem_stmt = list_first_entry(&elem->stmt_list, struct stmt, list);
+ return stmt_error(ctx, elem_stmt,
+ "missing statement in %s declaration",
set_is_map(set->flags) ? "map" : "set");
+ }
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-26 16:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-26 16:38 [PATCH nft] evaluate: error reporting for missing statements in set/map declaration Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).