From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH 1/2] evaluate: set: Allow for set elems to be sets
Date: Mon, 20 Mar 2017 17:38:55 +0100 [thread overview]
Message-ID: <20170320163856.6064-2-phil@nwl.cc> (raw)
In-Reply-To: <20170320163856.6064-1-phil@nwl.cc>
Recursive use of sets is handled in parts by parser_bison.y, which
has a rule for inline unnamed sets in set_list_member_expr, e.g. like
this:
| add rule ip saddr { { 1.1.1.0, 2.2.2.0 }, 3.3.3.0 }
Yet there is another way to have an unnamed set inline, which is via
define:
| define myset = {
| 1.1.1.0,
| 2.2.2.0,
| }
| add rule ip saddr { $myset, 3.3.3.0 }
This didn't work because the inline set comes in as EXPR_SET_ELEM with
EXPR_SET as key. This patch handles that case by replacing the former by
a copy of the latter, so the following set list merging can take place.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/evaluate.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/evaluate.c b/src/evaluate.c
index 8fb716c062449..86ff8ebd17629 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1132,6 +1132,15 @@ static int expr_evaluate_set(struct eval_ctx *ctx, struct expr **expr)
return expr_error(ctx->msgs, i,
"Set reference cannot be part of another set");
+ if (i->ops->type == EXPR_SET_ELEM &&
+ i->key->ops->type == EXPR_SET) {
+ struct expr *new = expr_clone(i->key);
+
+ list_replace(&i->list, &new->list);
+ expr_free(i);
+ i = new;
+ }
+
if (!expr_is_constant(i))
return expr_error(ctx->msgs, i,
"Set member is not constant");
--
2.11.0
next prev parent reply other threads:[~2017-03-20 17:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 16:38 [nft PATCH 0/2] Some fixes for nested sets Phil Sutter
2017-03-20 16:38 ` Phil Sutter [this message]
2017-03-20 16:38 ` [nft PATCH 2/2] evaluate: set: Fix nested set merge size adjustment Phil Sutter
2017-03-21 13:19 ` [nft PATCH 0/2] Some fixes for nested sets Pablo Neira Ayuso
2017-03-22 0:26 ` [nft PATCH 1/3] tests: Add test cases for nested anonymous sets Phil Sutter
2017-03-22 0:26 ` [nft PATCH 2/3] tests: shell: netns/0003many_0: Fix cleanup after error Phil Sutter
2017-03-22 8:45 ` Arturo Borrero Gonzalez
2017-03-22 11:51 ` Pablo Neira Ayuso
2017-03-22 0:26 ` [nft PATCH 3/3] sets: Fix for missing space after last element Phil Sutter
2017-03-22 11:52 ` Pablo Neira Ayuso
2017-03-22 11:51 ` [nft PATCH 1/3] tests: Add test cases for nested anonymous sets 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=20170320163856.6064-2-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 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).