All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft v8 1/2] evaluate: New internal helper __expr_evaluate_range
@ 2019-08-21 15:18 Ander Juaristi
  2019-08-21 15:18 ` [PATCH nft v8 2/2] meta: Introduce new conditions 'time', 'day' and 'hour' Ander Juaristi
  0 siblings, 1 reply; 8+ messages in thread
From: Ander Juaristi @ 2019-08-21 15:18 UTC (permalink / raw)
  To: netfilter-devel

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>
---
 src/evaluate.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 831eb7c..a707f5e 100755
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-08-24 14:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-21 15:18 [PATCH nft v8 1/2] evaluate: New internal helper __expr_evaluate_range Ander Juaristi
2019-08-21 15:18 ` [PATCH nft v8 2/2] meta: Introduce new conditions 'time', 'day' and 'hour' Ander Juaristi
2019-08-21 16:23   ` Florian Westphal
2019-08-21 20:50     ` Pablo Neira Ayuso
2019-08-21 21:04       ` Florian Westphal
2019-08-23  7:08         ` Ander Juaristi
2019-08-23 12:39           ` Pablo Neira Ayuso
2019-08-24 14:07             ` Ander Juaristi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.