netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: a@juaristi.eus, Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 1/4] evaluate: New internal helper __expr_evaluate_range
Date: Thu, 29 Aug 2019 16:09:01 +0200	[thread overview]
Message-ID: <20190829140904.3858-2-fw@strlen.de> (raw)
In-Reply-To: <20190829140904.3858-1-fw@strlen.de>

From: Ander Juaristi <a@juaristi.eus>

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

diff --git a/src/evaluate.c b/src/evaluate.c
index 831eb7c25c5c..a707f5e7e1fb 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.21.0


  reply	other threads:[~2019-08-29 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-29 14:09 [PATCH nft 0/4] meta: introduce time/day/hour matching Florian Westphal
2019-08-29 14:09 ` Florian Westphal [this message]
2019-08-29 14:09 ` [PATCH nft 2/4] meta: Introduce new conditions 'time', 'day' and 'hour' Florian Westphal
2019-08-29 14:09 ` [PATCH nft 3/4] tests: add meta time test cases Florian Westphal
2019-11-12 18:44   ` Phil Sutter
2019-11-12 19:35     ` Florian Westphal
2019-11-12 21:19       ` Phil Sutter
2019-11-12 21:59         ` Phil Sutter
2019-08-29 14:09 ` [PATCH nft 4/4] src: evaluate: catch invalid 'meta day' values in eval step Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190829140904.3858-2-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=a@juaristi.eus \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).