From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH v3 2/3] parser_json: Parse into symbol range expression if possible
Date: Thu, 31 Jul 2025 00:25:35 +0200 [thread overview]
Message-ID: <20250730222536.786-3-phil@nwl.cc> (raw)
In-Reply-To: <20250730222536.786-1-phil@nwl.cc>
Apply the bison parser changes in commit 347039f64509e ("src: add symbol
range expression to further compact intervals") to JSON parser as well.
Fixes: 347039f64509e ("src: add symbol range expression to further compact intervals")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/parser_json.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/parser_json.c b/src/parser_json.c
index bd865de59007a..120c814bc7a9b 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1353,7 +1353,7 @@ static struct expr *json_parse_prefix_expr(struct json_ctx *ctx,
static struct expr *json_parse_range_expr(struct json_ctx *ctx,
const char *type, json_t *root)
{
- struct expr *expr_low, *expr_high;
+ struct expr *expr_low, *expr_high, *tmp;
json_t *low, *high;
if (json_unpack_err(ctx, root, "[o, o!]", &low, &high))
@@ -1370,6 +1370,16 @@ static struct expr *json_parse_range_expr(struct json_ctx *ctx,
expr_free(expr_low);
return NULL;
}
+ if (is_symbol_value_expr(expr_low) && is_symbol_value_expr(expr_high)) {
+ tmp = symbol_range_expr_alloc(int_loc,
+ SYMBOL_VALUE,
+ expr_low->scope,
+ expr_low->identifier,
+ expr_high->identifier);
+ expr_free(expr_low);
+ expr_free(expr_high);
+ return tmp;
+ }
return range_expr_alloc(int_loc, expr_low, expr_high);
}
--
2.49.0
next prev parent reply other threads:[~2025-07-30 22:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 22:25 [nft PATCH v3 0/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-30 22:25 ` [nft PATCH v3 1/3] expression: Introduce is_symbol_value_expr() macro Phil Sutter
2025-07-30 22:25 ` Phil Sutter [this message]
2025-07-30 22:25 ` [nft PATCH v3 3/3] evaluate: Fix for 'meta hour' ranges spanning date boundaries Phil Sutter
2025-07-31 11:19 ` [nft PATCH v3 0/3] " Pablo Neira Ayuso
2025-07-31 13:01 ` Phil Sutter
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=20250730222536.786-3-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 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.