* [PATCH nft] evaluate: exthdr: statement arg must be not be a range
@ 2023-12-14 16:56 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2023-12-14 16:56 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
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@strlen.de>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-14 16:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 16:56 [PATCH nft] evaluate: exthdr: statement arg must be not be a range Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox