]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: New internal helper __expr_evaluate_range
authorAnder Juaristi <a@juaristi.eus>
Thu, 29 Aug 2019 14:09:01 +0000 (16:09 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 6 Sep 2019 14:25:57 +0000 (16:25 +0200)
This is used by the followup patch to evaluate a range without emitting
an error when the left value is larger than the right one.

This is done to handle time-matching such as
23:00-01:00 -- expr_evaluate_range() will reject this, but
we want to be able to evaluate and then handle this as a request
to match from 23:00 to 1am.

Signed-off-by: Ander Juaristi <a@juaristi.eus>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/evaluate.c

index 831eb7c25c5cf2e6b400935e1ada81cd8039574c..a707f5e7e1fb1de7f2c72c6516d3dbcbd2b00c78 100755 (executable)
@@ -941,16 +941,28 @@ static int expr_evaluate_range_expr(struct eval_ctx *ctx,
        return 0;
 }
 
-static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **expr)
+static int __expr_evaluate_range(struct eval_ctx *ctx, struct expr **expr)
 {
-       struct expr *range = *expr, *left, *right;
+       struct expr *range = *expr;
 
        if (expr_evaluate_range_expr(ctx, range, &range->left) < 0)
                return -1;
-       left = range->left;
-
        if (expr_evaluate_range_expr(ctx, range, &range->right) < 0)
                return -1;
+
+       return 0;
+}
+
+static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **expr)
+{
+       struct expr *range = *expr, *left, *right;
+       int rc;
+
+       rc = __expr_evaluate_range(ctx, expr);
+       if (rc)
+               return rc;
+
+       left = range->left;
        right = range->right;
 
        if (mpz_cmp(left->value, right->value) >= 0)