From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] src: set maximum length in constant sets
Date: Sun, 5 Jan 2014 22:28:11 +0100 [thread overview]
Message-ID: <1388957291-3745-1-git-send-email-pablo@netfilter.org> (raw)
This is used to optimize the size of the set in the kernel in
case that the hash type is selected.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/netlink.c | 4 ++++
src/rule.c | 14 ++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/netlink.c b/src/netlink.c
index 59bd8e4..0ff65e1 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -785,6 +785,10 @@ int netlink_add_set(struct netlink_ctx *ctx, const struct handle *h,
nft_set_attr_set_u32(nls, NFT_SET_ATTR_DATA_LEN,
set->datalen / BITS_PER_BYTE);
}
+ if (set->flags & NFT_SET_CONSTANT) {
+ nft_set_attr_set_u32(nls, NFT_SET_ATTR_MAX_ELEMS,
+ set->init->size);
+ }
netlink_dump_set(nls);
err = mnl_nft_set_add(nf_sock, nls, NLM_F_EXCL | NLM_F_ECHO);
diff --git a/src/rule.c b/src/rule.c
index ec8b6a4..c9c8bb0 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -474,14 +474,16 @@ static int do_add_setelems(struct netlink_ctx *ctx, const struct handle *h,
static int do_add_set(struct netlink_ctx *ctx, const struct handle *h,
struct set *set)
{
+ if (set->init != NULL && set->flags & SET_F_INTERVAL)
+ set_to_intervals(set);
+
if (netlink_add_set(ctx, h, set) < 0)
return -1;
- if (set->init != NULL) {
- if (set->flags & SET_F_INTERVAL)
- set_to_intervals(set);
- if (do_add_setelems(ctx, &set->handle, set->init) < 0)
- return -1;
- }
+
+ if (set->init != NULL &&
+ do_add_setelems(ctx, &set->handle, set->init) < 0)
+ return -1;
+
return 0;
}
--
1.7.10.4
reply other threads:[~2014-01-05 21:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1388957291-3745-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).