From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 7/7] evaluate: bail out on prefix or range to non-interval set
Date: Mon, 18 Apr 2016 20:14:35 +0200 [thread overview]
Message-ID: <1461003275-2330-8-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1461003275-2330-1-git-send-email-pablo@netfilter.org>
If you declare a set with no interval flag, you get this bug message:
# nft add element filter myset { 192.168.1.100/24 }
BUG: invalid data expression type prefix
nft: netlink.c:323: netlink_gen_data: Assertion `0' failed.
Aborted
After this patch, we provide a clue to the user:
# nft add element filter myset { 192.168.1.100/24 }
<cmdline>:1:23-38: Error: Set member cannot be prefix, missing interval flag on declaration
add element filter myset { 192.168.1.100/24 }
^^^^^^^^^^^^^^^^
# nft add element filter myset { 192.168.1.100-192.168.1.200 }
<cmdline>:1:23-49: Error: Set member cannot be range, missing interval flag on declaration
add element filter myset { 192.168.1.100-192.168.1.200 }
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/evaluate.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/evaluate.c b/src/evaluate.c
index 346e34f..be4dac7 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -957,6 +957,21 @@ static int expr_evaluate_set_elem(struct eval_ctx *ctx, struct expr **expr)
if (expr_evaluate(ctx, &elem->key) < 0)
return -1;
+ if (ctx->set && !(ctx->set->flags & SET_F_INTERVAL)) {
+ switch (elem->key->ops->type) {
+ case EXPR_PREFIX:
+ return expr_error(ctx->msgs, elem,
+ "Set member cannot be prefix, "
+ "missing interval flag on declaration");
+ case EXPR_RANGE:
+ return expr_error(ctx->msgs, elem,
+ "Set member cannot be range, "
+ "missing interval flag on declaration");
+ default:
+ break;
+ }
+ }
+
elem->dtype = elem->key->dtype;
elem->len = elem->key->len;
elem->flags = elem->key->flags;
--
2.1.4
prev parent reply other threads:[~2016-04-18 18:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 18:14 [PATCH nft 0/7] named sets with intervals Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 1/7] segtree: perform stricter expression type validation from expr_value() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 2/7] segtree: clone full expression from interval_map_decompose() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 3/7] segtree: handle adjacent interval nodes from expr_value_cmp() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 4/7] segtree: explicit initialization via set_to_intervals() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 5/7] rule: support for incremental set interval element updates Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 6/7] segtree: special handling for the first non-matching segment Pablo Neira Ayuso
2016-04-18 18:14 ` Pablo Neira Ayuso [this message]
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=1461003275-2330-8-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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).