From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 3/3,v2] netlink_linearize: skip set element expression in map statement key
Date: Tue, 26 Sep 2023 18:55:35 +0200 [thread overview]
Message-ID: <ZRMNB+3/4rzYb08p@orbyte.nwl.cc> (raw)
In-Reply-To: <20230926160216.152549-1-pablo@netfilter.org>
On Tue, Sep 26, 2023 at 06:02:16PM +0200, Pablo Neira Ayuso wrote:
[...]
> diff --git a/src/parser_json.c b/src/parser_json.c
> index 16961d6013af..78895befbc6c 100644
> --- a/src/parser_json.c
> +++ b/src/parser_json.c
> @@ -2416,6 +2416,63 @@ static struct stmt *json_parse_set_stmt(struct json_ctx *ctx,
> return stmt;
> }
>
> +static struct stmt *json_parse_map_stmt(struct json_ctx *ctx,
> + const char *key, json_t *value)
> +{
> + struct expr *expr, *expr2, *expr_data;
> + json_t *elem, *data, *stmt_json;
> + const char *opstr, *set;
> + struct stmt *stmt;
> + int op;
> +
> + if (json_unpack_err(ctx, value, "{s:s, s:o, s:o, s:s}",
> + "op", &opstr, "elem", &elem, "data", &data, "map", &set))
> + return NULL;
> +
> + if (!strcmp(opstr, "add")) {
> + op = NFT_DYNSET_OP_ADD;
> + } else if (!strcmp(opstr, "update")) {
> + op = NFT_DYNSET_OP_UPDATE;
> + } else if (!strcmp(opstr, "delete")) {
> + op = NFT_DYNSET_OP_DELETE;
> + } else {
> + json_error(ctx, "Unknown set statement op '%s'.", opstr);
s/set/map/
> + return NULL;
> + }
> +
> + expr = json_parse_set_elem_expr_stmt(ctx, elem);
> + if (!expr) {
> + json_error(ctx, "Illegal set statement element.");
s/set/map/
> + return NULL;
> + }
> +
> + expr_data = json_parse_set_elem_expr_stmt(ctx, data);
> + if (!expr_data) {
> + json_error(ctx, "Illegal map expression data.");
> + expr_free(expr);
> + return NULL;
> + }
> +
> + if (set[0] != '@') {
> + json_error(ctx, "Illegal set reference in set statement.");
s/set/map/g
Cheers, Phil
next prev parent reply other threads:[~2023-09-26 16:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 16:02 [PATCH nft 3/3,v2] netlink_linearize: skip set element expression in map statement key Pablo Neira Ayuso
2023-09-26 16:55 ` Phil Sutter [this message]
2023-09-27 8:42 ` Pablo Neira Ayuso
2023-09-27 11:10 ` Phil Sutter
2023-09-27 11:19 ` Pablo Neira Ayuso
2023-09-27 13:09 ` Phil Sutter
2023-09-27 14:41 ` Phil Sutter
2023-09-27 16:52 ` Pablo Neira Ayuso
2023-09-28 14:26 ` 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=ZRMNB+3/4rzYb08p@orbyte.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 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).