From: Florian Westphal <fw@strlen.de>
To: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: [RFC] conntrack event framework speedup
Date: Tue, 15 Mar 2022 13:05:38 +0100 [thread overview]
Message-ID: <20220315120538.GB16569@breakpoint.cc> (raw)
Hello,
Due to net.netfilter.nf_conntrack_events=1 we eat some uncessesary
overhead:
1. allocation of new conntrack entries needs to alloc ct->ext
2. inverse for deletion/free.
3. Because the ctnetlink module is typically active, each packet will
end up calling __nf_conntrack_eventmask_report via nf_confirm() and
then in ctnetlink only to find that we have no listeners
(and we can't call nfnetlink_has_listeners() from conntrack because
that would yield a dependency of conntrack to nfnetlink).
I would propose to add minimal conntrack specific code
to nfnetlink, namely, to add bind()(/unbind() calls that inc/dec a
counter for each ctnetlink event listener/socket.
If counter becomes nonzero, flip a bit in struct net.
This would allow us to do the following:
add new net.netfilter.nf_conntrack_events default mode: 2, autodetect.
in nfnetlink bind, inc pernet counter when event group is bound.
in nfnetlink unbind, dec pernet counter when event group is unbound.
in init_conntrack() allocate the event cache extension only if
a) nf_conntrack_events == 1, or
b) nf_conntrack_events == 2 and pernet counter is nonzero.
Extend nf_confirm() to check of the pernet counter before
call to __nf_conntrack_eventmask_report().
If nobody spots a problem with this idea I'd start to work on
a prototype.
Thanks.
next reply other threads:[~2022-03-15 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 12:05 Florian Westphal [this message]
2022-03-15 21:30 ` [RFC] conntrack event framework speedup Pablo Neira Ayuso
2022-03-15 21:41 ` Florian Westphal
2022-03-15 21:53 ` Pablo Neira Ayuso
2022-03-15 22:07 ` Florian Westphal
2022-03-16 9:12 ` Pablo Neira Ayuso
2022-03-16 12:18 ` Florian Westphal
2022-03-17 9:13 ` 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=20220315120538.GB16569@breakpoint.cc \
--to=fw@strlen.de \
--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).