From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 1/3] rule: adjust set expression size accordingly with intervals
Date: Wed, 24 May 2017 11:53:16 +0200 [thread overview]
Message-ID: <1495619598-22759-1-git-send-email-pablo@netfilter.org> (raw)
For implicit sets, we have to call set_to_intervals() before we add the
set so we have the net size in elements.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/rule.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index 5923bf64101e..0d9e393ab26f 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -914,10 +914,6 @@ static int do_add_chain(struct netlink_ctx *ctx, const struct handle *h,
static int __do_add_setelems(struct netlink_ctx *ctx, const struct handle *h,
struct set *set, struct expr *expr, bool excl)
{
- if (set->flags & NFT_SET_INTERVAL &&
- set_to_intervals(ctx->msgs, set, expr, true) < 0)
- return -1;
-
expr->set_flags |= set->flags;
if (netlink_add_setelems(ctx, h, expr, excl) < 0)
return -1;
@@ -934,18 +930,27 @@ static int do_add_setelems(struct netlink_ctx *ctx, const struct handle *h,
table = table_lookup(h);
set = set_lookup(table, h->set);
+ if (set->flags & NFT_SET_INTERVAL &&
+ set_to_intervals(ctx->msgs, set, init, true) < 0)
+ return -1;
+
return __do_add_setelems(ctx, h, set, init, excl);
}
static int do_add_set(struct netlink_ctx *ctx, const struct handle *h,
struct set *set, bool excl)
{
+ if (set->init != NULL) {
+ if (set->flags & NFT_SET_INTERVAL &&
+ set_to_intervals(ctx->msgs, set, set->init, true) < 0)
+ return -1;
+ }
if (netlink_add_set(ctx, h, set, excl) < 0)
return -1;
- if (set->init != NULL)
+ if (set->init != NULL) {
return __do_add_setelems(ctx, &set->handle, set, set->init,
false);
-
+ }
return 0;
}
--
2.1.4
next reply other threads:[~2017-05-24 9:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 9:53 Pablo Neira Ayuso [this message]
2017-05-24 9:53 ` [PATCH nft 2/3] segtree: reset element size counter before adding intervals to set Pablo Neira Ayuso
2017-05-24 9:53 ` [PATCH nft 3/3] netlink: add size description for constant 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=1495619598-22759-1-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).