From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v2 3/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries
Date: Wed, 30 Jul 2025 19:26:47 +0200 [thread overview]
Message-ID: <aIpVIcrZCy30I_sF@calendula> (raw)
In-Reply-To: <20250729161832.6450-4-phil@nwl.cc>
Hi Phil,
On Tue, Jul 29, 2025 at 06:18:32PM +0200, Phil Sutter wrote:
> @@ -2772,12 +2780,15 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
>
> pctx = eval_proto_ctx(ctx);
>
> - if (rel->right->etype == EXPR_RANGE && lhs_is_meta_hour(rel->left)) {
> - ret = __expr_evaluate_range(ctx, &rel->right);
> + if (lhs_is_meta_hour(rel->left) &&
> + rel->right->etype == EXPR_RANGE_SYMBOL) {
I just realised that we cannot just replace one expression type by
another.
For relational, this needs to handle EXPR_RANGE too, because this
generates a range expression, for instance:
define end="14:00"
table ip x {
chain y {
meta hour "13:00"-$end
}
}
this code is a bit special, it happens before the range evaluation.
For relational expressions, this is translated to EXPR_RANGE. Only
sets are using EXPR_RANGE_VALUE, relational expressions still use
EXPR_RANGE.
So this special case can see either EXPR_RANGE and EXPR_RANGE_SYMBOL.
> + range = symbol_range_expand(rel->right);
Then, this conversion above only need to happen for EXPR_RANGE_SYMBOL.
> + ret = __expr_evaluate_range(ctx, &range);
> if (ret)
> return ret;
>
> - range = rel->right;
> + expr_free(rel->right);
> + rel->right = range;
>
> /*
> * We may need to do this for proper cross-day ranges,
next prev parent reply other threads:[~2025-07-30 17:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 16:18 [nft PATCH v2 0/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-29 16:18 ` [nft PATCH v2 1/3] expression: Introduce is_symbol_value_expr() macro Phil Sutter
2025-07-29 16:18 ` [nft PATCH v2 2/3] parser_json: Parse into symbol range expression if possible Phil Sutter
2025-07-29 16:18 ` [nft PATCH v2 3/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-30 17:26 ` Pablo Neira Ayuso [this message]
2025-07-30 16:38 ` [nft PATCH v2 0/3] " Pablo Neira Ayuso
2025-07-30 17:27 ` Pablo Neira Ayuso
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=aIpVIcrZCy30I_sF@calendula \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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).