From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: ebiederm@xmission.com
Subject: [PATCH -next 0/8] netfilter: don't copy init ns hooks to new namespaces
Date: Fri, 2 Oct 2015 13:49:09 +0200 [thread overview]
Message-ID: <1443786557-21315-1-git-send-email-fw@strlen.de> (raw)
Historically, a particular table or netfilter feature (defrag, iptables
filter table ...) was registered with the netfilter core hook mechanism
on module load.
When netns support was added to iptables only the ip/ip6tables ruleset
was made namespace aware, not the actual hook points.
This has changed -- after Eric Biedermans recent work we now have
per net namespace hooks.
When a new namespace is created, all the hooks registered 'globally'
(i.e. via nf_register_hook() instead of a particular namespace via
nf_register_net_hook api) get copied to the new netns.
This means f.e. that when ipt_filter table/module is loaded on a system,
then each namespace on that system has an (empty) iptables filter ruleset.
This work aims to change all major hook users to nf_register_net_hook
so that when a new netns is created it has no hooks at all, even when the
initial namespace uses conntrack, iptables and bridge netfilter.
To keep bahaviour somewhat compatible, hooks are registered once a
iptables set/getsockopt call is made within a net namespace.
This also means that e.g. conntrack behaviour is not yet optimal, we
still create all the data structures and only skip hook registration
at this time.
Note that I expect that I will need several iterations of this patch set,
I am sending this now so that reviewing can commence and to benefit from
recent addition of kbuild robot magic to patchwork (this is awesome,
thanks a lot!).
The patch set survives allmodconfig build with NAMESPACES=y and =N.
If anyone has further ideas on how to improve this, please let me know.
include/linux/netfilter.h | 29 +++------
include/linux/netfilter/x_tables.h | 10 ++-
include/linux/netfilter_ingress.h | 9 ++-
include/net/netfilter/ipv4/nf_defrag_ipv4.h | 3 -
include/net/netfilter/ipv6/nf_defrag_ipv6.h | 3 -
include/net/netfilter/nf_conntrack.h | 4 +
include/net/netfilter/nf_conntrack_l3proto.h | 4 +
net/bridge/br_netfilter_hooks.c | 68 ++++++++++++++++++++++-
net/ipv4/netfilter/arptable_filter.c | 39 ++++++++-----
net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 -
net/ipv4/netfilter/ipt_SYNPROXY.c | 4 -
net/ipv4/netfilter/iptable_filter.c | 65 ++++++++++++++++------
net/ipv4/netfilter/iptable_mangle.c | 50 +++++++++++++----
net/ipv4/netfilter/iptable_nat.c | 55 +++++++++++++-----
net/ipv4/netfilter/iptable_raw.c | 50 +++++++++++++----
net/ipv4/netfilter/iptable_security.c | 52 +++++++++++++----
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 62 +++++++++++++++++----
net/ipv4/netfilter/nf_defrag_ipv4.c | 49 +++++++++++++++-
net/ipv6/netfilter/ip6t_SYNPROXY.c | 4 -
net/ipv6/netfilter/ip6table_filter.c | 54 +++++++++++++-----
net/ipv6/netfilter/ip6table_mangle.c | 53 +++++++++++++-----
net/ipv6/netfilter/ip6table_nat.c | 55 +++++++++++++-----
net/ipv6/netfilter/ip6table_raw.c | 54 +++++++++++++-----
net/ipv6/netfilter/ip6table_security.c | 53 +++++++++++++-----
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 60 ++++++++++++++++----
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 50 +++++++++++++++--
net/netfilter/nf_conntrack_proto.c | 48 ++++++++++++++++
net/netfilter/nft_ct.c | 24 ++++----
net/netfilter/x_tables.c | 73 ++++++++++++++++++-------
net/netfilter/xt_CONNSECMARK.c | 4 -
net/netfilter/xt_CT.c | 6 +-
net/netfilter/xt_TPROXY.c | 15 +++--
net/netfilter/xt_connbytes.c | 4 -
net/netfilter/xt_connlabel.c | 6 +-
net/netfilter/xt_connlimit.c | 6 +-
net/netfilter/xt_connmark.c | 8 +-
net/netfilter/xt_conntrack.c | 2
net/netfilter/xt_helper.c | 4 -
net/netfilter/xt_socket.c | 33 +++++++++--
net/netfilter/xt_state.c | 4 -
40 files changed, 893 insertions(+), 287 deletions(-)
next reply other threads:[~2015-10-02 11:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 11:49 Florian Westphal [this message]
2015-10-02 11:49 ` [PATCH -next 1/8] netfilter: ingress: don't use nf_hook_list_active Florian Westphal
2015-10-02 11:49 ` [PATCH -next 2/8] netfilter: add and use nf_ct_netns_get/put Florian Westphal
2015-10-03 10:46 ` Jan Engelhardt
2015-10-02 11:49 ` [PATCH -next 3/8] netfilter: conntrack: register hooks in netns when needed by ruleset Florian Westphal
2015-10-02 11:49 ` [PATCH -next 4/8] netfilter: xtables: don't register table hooks in namespace at init time Florian Westphal
2015-10-04 19:58 ` Pablo Neira Ayuso
2015-10-02 11:49 ` [PATCH -next 5/8] netfilter: defrag: only register defrag functionality if needed Florian Westphal
2015-10-02 11:49 ` [PATCH -next 6/8] netfilter: nat: depend on conntrack module Florian Westphal
2015-10-02 11:49 ` [PATCH -next 7/8] netfilter: bridge: register hooks only when bridge interface is added Florian Westphal
2015-10-02 11:49 ` [PATCH -next 8/8] netfilter: don't call nf_hook_state_init/_hook_slow unless needed 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=1443786557-21315-1-git-send-email-fw@strlen.de \
--to=fw@strlen.de \
--cc=ebiederm@xmission.com \
--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).