Else we get: BUG: unknown expression type range nft: src/netlink_linearize.c:909: netlink_gen_expr: Assertion `0' failed. Signed-off-by: Florian Westphal <fw@xxxxxxxxx> --- src/evaluate.c | 19 ++++++++++++++++--- .../bogons/nft-f/exthdr_with_range_bug | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/shell/testcases/bogons/nft-f/exthdr_with_range_bug diff --git a/src/evaluate.c b/src/evaluate.c index 70d80eb48556..1c5078d67c13 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3024,14 +3024,27 @@ static bool stmt_evaluate_payload_need_csum(const struct expr *payload) static int stmt_evaluate_exthdr(struct eval_ctx *ctx, struct stmt *stmt) { struct expr *exthdr; + int ret; if (__expr_evaluate_exthdr(ctx, &stmt->exthdr.expr) < 0) return -1; exthdr = stmt->exthdr.expr; - return stmt_evaluate_arg(ctx, stmt, exthdr->dtype, exthdr->len, - BYTEORDER_BIG_ENDIAN, - &stmt->exthdr.val); + ret = stmt_evaluate_arg(ctx, stmt, exthdr->dtype, exthdr->len, + BYTEORDER_BIG_ENDIAN, + &stmt->exthdr.val); + if (ret < 0) + return ret; + + switch (stmt->exthdr.val->etype) { + case EXPR_RANGE: + return expr_error(ctx->msgs, stmt->exthdr.val, + "cannot be a range"); + default: + break; + } + + return 0; } static int stmt_evaluate_payload(struct eval_ctx *ctx, struct stmt *stmt) diff --git a/tests/shell/testcases/bogons/nft-f/exthdr_with_range_bug b/tests/shell/testcases/bogons/nft-f/exthdr_with_range_bug new file mode 100644 index 000000000000..e307e7cc5482 --- /dev/null +++ b/tests/shell/testcases/bogons/nft-f/exthdr_with_range_bug @@ -0,0 +1 @@ +add rule t c ip option ra set 0-1 -- 2.41.0