]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expression: Set range expression 'len' field
authorPhil Sutter <phil@nwl.cc>
Thu, 16 Oct 2025 16:57:20 +0000 (18:57 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 27 Jan 2026 22:01:54 +0000 (23:01 +0100)
The length value is needed for netlink debug output of concatenated
ranges. Set it to one of the inner elements' lengths (which should be
identical).

Since the inner element length may not be set initially, set it in
eval phase again. This covers at least all cases in tests/py.

Without this, netlink_gen_concat_key() et al. would have to inspect
element types and extract lengths accordingly, this is much easier.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/evaluate.c
src/expression.c

index b42b5a6fba631210dae5b89dddaa1b186de48b5b..7e6ef3c724c1932d8466b3446f1be4f93c949392 100644 (file)
@@ -1347,6 +1347,7 @@ static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **exprp)
 
        datatype_set(range, left->dtype);
        range->flags |= EXPR_F_CONSTANT;
+       range->len = left->len;
        return 0;
 }
 
index 4d68967f112e41d55fd2e77baf04d6b2d9cea156..e036c4bb699655f191fd9038457453851b5aa35e 100644 (file)
@@ -1018,6 +1018,7 @@ struct expr *range_expr_alloc(const struct location *loc,
                          BYTEORDER_INVALID, 0);
        expr->left  = left;
        expr->right = right;
+       expr->len = left->len;
        return expr;
 }