... this will cause an assertion in netlink linearization, catch this at eval stage instead. before: BUG: unknown expression type range nft: netlink_linearize.c:908: netlink_gen_expr: Assertion `0' failed. after: /unknown_expr_type_range_assert:3:31-40: Error: Meta expression cannot be a range meta mark set 0x001-3434 ^^^^^^^^^^ Signed-off-by: Florian Westphal <fw@xxxxxxxxx> --- src/evaluate.c | 13 +++++++++++++ .../bogons/nft-f/unknown_expr_type_range_assert | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 tests/shell/testcases/bogons/nft-f/unknown_expr_type_range_assert diff --git a/src/evaluate.c b/src/evaluate.c index 51ae276aac6a..131b0a0eaa66 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3169,6 +3169,19 @@ static int stmt_evaluate_meta(struct eval_ctx *ctx, struct stmt *stmt) &stmt->meta.expr); ctx->stmt_len = 0; + if (ret < 0) + return ret; + + switch (stmt->meta.expr->etype) { + case EXPR_RANGE: + ret = expr_error(ctx->msgs, stmt->meta.expr, + "Meta expression cannot be a range"); + break; + default: + break; + + } + return ret; } diff --git a/tests/shell/testcases/bogons/nft-f/unknown_expr_type_range_assert b/tests/shell/testcases/bogons/nft-f/unknown_expr_type_range_assert new file mode 100644 index 000000000000..234dd623167d --- /dev/null +++ b/tests/shell/testcases/bogons/nft-f/unknown_expr_type_range_assert @@ -0,0 +1,5 @@ +table ip x { + chain k { + meta mark set 0x001-3434 + } +} -- 2.41.0