From: Hans Schillstrom <hans.schillstrom@ericsson.com>
To: <kaber@trash.net>, <pablo@netfilter.org>, <jengelh@medozas.de>,
<netfilter-devel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <hans@schillstrom.com>, Hans Schillstrom <hans.schillstrom@ericsson.com>
Subject: [PATCH 1/1] netfilter: Add possibility to turn off netfilters defrag per netns
Date: Wed, 4 Jan 2012 09:07:23 +0100 [thread overview]
Message-ID: <1325664443-10320-1-git-send-email-hans.schillstrom@ericsson.com> (raw)
In some cases it not desirable to have auto defrag.
Ex. in a cluster where packets can arrive on different blades.
In that case it is possible to use containers (LXC) and send
all fragments to one place where defrag is enabled.
This patch makes it possible to turn off the defrag per network name space,
by setting net.netfilter.nf_conntrack_nodefrag to 1.
Both IPv4 and IPv6 is effected by this sysctl.
Default is 0 which is defrag.
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
---
include/net/netns/conntrack.h | 1 +
net/ipv4/netfilter/nf_defrag_ipv4.c | 8 ++++++++
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 6 ++++++
net/netfilter/nf_conntrack_standalone.c | 8 ++++++++
4 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index 7a911ec..059f7b5 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -26,6 +26,7 @@ struct netns_ct {
int sysctl_tstamp;
int sysctl_checksum;
unsigned int sysctl_log_invalid; /* Log invalid packets */
+ int sysctl_nodefrag;
#ifdef CONFIG_SYSCTL
struct ctl_table_header *sysctl_header;
struct ctl_table_header *acct_sysctl_header;
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index 9bb1b8a..f4908b3 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -74,6 +74,14 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
return NF_ACCEPT;
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ /* Check for no defrag options */
+ {
+ const struct net_device *dev = (hooknum == NF_INET_LOCAL_OUT ?
+ out : in);
+
+ if (dev_net(dev)->ct.sysctl_nodefrag)
+ return NF_ACCEPT;
+ }
#if !defined(CONFIG_NF_NAT) && !defined(CONFIG_NF_NAT_MODULE)
/* Previously seen (loopback)? Ignore. Do this before
fragment check. */
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index cdd6d04..4b0a05b 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -61,6 +61,12 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
struct sk_buff *reasm;
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ /* Check for no defrag options */
+ const struct net_device *dev = (hooknum == NF_INET_LOCAL_OUT ?
+ out : in);
+
+ if (dev_net(dev)->ct.sysctl_nodefrag)
+ return NF_ACCEPT;
/* Previously seen (loopback)? */
if (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))
return NF_ACCEPT;
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 885f5ab..95c489f 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -446,6 +446,13 @@ static ctl_table nf_ct_sysctl_table[] = {
.extra2 = &log_invalid_proto_max,
},
{
+ .procname = "nf_conntrack_nodefrag",
+ .data = &init_net.ct.sysctl_nodefrag,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+ {
.procname = "nf_conntrack_expect_max",
.data = &nf_ct_expect_max,
.maxlen = sizeof(int),
@@ -493,6 +500,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
table[2].data = &net->ct.htable_size;
table[3].data = &net->ct.sysctl_checksum;
table[4].data = &net->ct.sysctl_log_invalid;
+ table[5].data = &net->ct.sysctl_nodefrag;
net->ct.sysctl_header = register_net_sysctl_table(net,
nf_net_netfilter_sysctl_path, table);
--
1.7.2.3
next reply other threads:[~2012-01-04 8:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-04 8:07 Hans Schillstrom [this message]
2012-01-04 8:28 ` [PATCH 1/1] netfilter: Add possibility to turn off netfilters defrag per netns Jozsef Kadlecsik
2012-01-04 8:49 ` Hans Schillstrom
2012-01-04 9:03 ` Jozsef Kadlecsik
2012-01-04 9:32 ` Jan Engelhardt
2012-01-04 9:47 ` Hans Schillstrom
2012-01-04 17:23 ` Pablo Neira Ayuso
2012-01-04 9:49 ` Jozsef Kadlecsik
2012-01-04 10:18 ` Hans Schillstrom
2012-01-04 11:17 ` Jan Engelhardt
2012-01-04 11:48 ` Hans Schillstrom
2012-01-04 17:40 ` Pablo Neira Ayuso
2012-01-04 18:05 ` Jozsef Kadlecsik
2012-01-04 20:56 ` Hans Schillstrom
2012-01-04 21:40 ` Jozsef Kadlecsik
2012-01-05 7:19 ` Hans Schillstrom
2012-01-05 9:11 ` Jozsef Kadlecsik
2012-01-05 14:18 ` Pablo Neira Ayuso
2012-01-09 8:58 ` Hans Schillstrom
2012-01-10 3:17 ` Pablo Neira Ayuso
2012-01-04 20:45 ` Hans Schillstrom
2012-01-04 21:15 ` Hans Schillstrom
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=1325664443-10320-1-git-send-email-hans.schillstrom@ericsson.com \
--to=hans.schillstrom@ericsson.com \
--cc=hans@schillstrom.com \
--cc=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).