]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: remove zero shift expressions at eval stage master
authorFlorian Westphal <fw@strlen.de>
Wed, 22 Apr 2026 17:18:59 +0000 (19:18 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 23 Apr 2026 16:18:48 +0000 (18:18 +0200)
There is a kernel patch (under review) that rejects 0-shifts from
control plane.  Remove zero-shifts at eval stage: they are
a no-op in any case.

Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
src/evaluate.c

index 482708ae61914a5fdc4275a7ac3dcd5a012113c2..8bb7b6095309cf2512569b9891278231fd501aae 100644 (file)
@@ -1454,6 +1454,12 @@ static int expr_evaluate_shift(struct eval_ctx *ctx, struct expr **expr)
                                         "shifts exceeding %u bits are not supported", UINT_MAX);
 
        shift = mpz_get_uint32(right->value);
+       if (shift == 0) {
+               *expr = expr_get(left);
+               expr_free(op);
+               return 0;
+       }
+
        if (ctx->stmt_len > left->len)
                max_shift_len = ctx->stmt_len;
        else