evaluate: error reporting for missing statements in set/map declaration
Pablo Neira Ayuso
maintainerPATCH 1/1 evaluate: error reporting for missing statements in set/map declaration
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 <[email protected]>
--- src/evaluate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
src/evaluate.c +5 -3
@@ -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 ; }
Signature · 1 line
2.20.1