From: Florian Westphal <fw@strlen.de>
To: Phil Sutter <phil@nwl.cc>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [iptables PATCH] nft: Increase BATCH_PAGE_SIZE to support huge rulesets
Date: Fri, 2 Apr 2021 07:38:10 +0200 [thread overview]
Message-ID: <20210402053810.GI13699@breakpoint.cc> (raw)
In-Reply-To: <20210401145307.29927-1-phil@nwl.cc>
Phil Sutter <phil@nwl.cc> wrote:
> In order to support the same ruleset sizes as legacy iptables, the
> kernel's limit of 1024 iovecs has to be overcome. Therefore increase
> each iovec's size from 256KB to 4MB.
>
> While being at it, add a log message for failing sendmsg() call. This is
> not supposed to happen, even if the transaction fails. Yet if it does,
> users are left with only a "line XXX failed" message (with line number
> being the COMMIT line).
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> iptables/nft.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/iptables/nft.c b/iptables/nft.c
> index bd840e75f83f4..e19c88ece6c2a 100644
> --- a/iptables/nft.c
> +++ b/iptables/nft.c
> @@ -88,11 +88,11 @@ int mnl_talk(struct nft_handle *h, struct nlmsghdr *nlh,
>
> #define NFT_NLMSG_MAXSIZE (UINT16_MAX + getpagesize())
>
> -/* selected batch page is 256 Kbytes long to load ruleset of
> - * half a million rules without hitting -EMSGSIZE due to large
> - * iovec.
> +/* Selected batch page is 4 Mbytes long to support loading a ruleset of 3.5M
> + * rules matching on source and destination address as well as input and output
> + * interfaces. This is what legacy iptables supports.
> */
> -#define BATCH_PAGE_SIZE getpagesize() * 32
> +#define BATCH_PAGE_SIZE getpagesize() * 512
Why not remove getpagesize() altogether?
The comment assumes getpagesize returns 4096 so might as well just use
"#define BATCH_PAGE_SIZE (4 * 1024 * 1024)" or similar?
On my system getpagesize() * 512 yields 2097152 ...
> static struct nftnl_batch *mnl_batch_init(void)
> {
> @@ -220,8 +220,10 @@ static int mnl_batch_talk(struct nft_handle *h, int numcmds)
> int err = 0;
>
> ret = mnl_nft_socket_sendmsg(h, numcmds);
> - if (ret == -1)
> + if (ret == -1) {
> + fprintf(stderr, "sendmsg() failed: %s\n", strerror(errno));
> return -1;
> + }
Isn't that library code? At the very least this should use
nft_print().
next prev parent reply other threads:[~2021-04-02 5:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 14:53 [iptables PATCH] nft: Increase BATCH_PAGE_SIZE to support huge rulesets Phil Sutter
2021-04-02 5:38 ` Florian Westphal [this message]
2021-04-02 6:47 ` Pablo Neira Ayuso
2021-04-03 8:49 ` Phil Sutter
2021-04-03 10:23 ` Pablo Neira Ayuso
2021-04-03 11:31 ` Florian Westphal
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=20210402053810.GI13699@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.