From: Jan Engelhardt <jengelh@medozas.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH] netfilter: the "none" conntrack helper module
Date: Thu, 19 May 2011 00:21:05 +0200 [thread overview]
Message-ID: <1305757266-8730-2-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1305757266-8730-1-git-send-email-jengelh@medozas.de>
To cope with some crappy, easily DOS-able network equipment, a
customer put Linux on each side of the shabby shaper in question.
Since NFCT supports zones since recently, these two system images can
be collapsed without causing tracking problems. The layout thus is
something like:
graph {
subgraph cluster_1 {
label="linux";
subgraph cluster_2 { label="ctzone0"; eth0; eth1; };
subgraph cluster_3 { label="ctzone1"; eth2; eth3; };
};
subgraph cluster_4 {
label="shaper";
"FE/0"; "FE/1";
};
netA -- eth0 -- eth1 -- "FE/0" -- "FE/1" --
eth2 -- eth3 -- netB;
};
With this setup however, nf_conntrack_ftp seems to discard packets
when they re-enter nfct_ftp for the second time. To work around this,
I devised this "none" helper module, which can be used in the raw
table with `-j CT --helper none` in one zone to avoid automatically
running nfct_ftp - or any other helper for that matter. `-j CT
--notrack` was out of the option, as both zones needed tracking
support for xt_connlimit.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
net/netfilter/Kconfig | 8 +++
net/netfilter/Makefile | 1 +
net/netfilter/nf_conntrack_none.c | 111 +++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 0 deletions(-)
create mode 100644 net/netfilter/nf_conntrack_none.c
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 32bff6d..9300b11 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -132,6 +132,14 @@ config NF_CT_PROTO_UDPLITE
To compile it as a module, choose M here. If unsure, say N.
+config NF_CONNTRACK_NONE
+ tristate '"none" helper'
+ depends on NETFILTER_ADVANCED
+ ---help---
+ This helper does nothing, and is a workaround for
+ nf_conntrack_* breaking down on expectations when traffic
+ is fed back into the system.
+
config NF_CONNTRACK_AMANDA
tristate "Amanda backup protocol support"
depends on NETFILTER_ADVANCED
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 1a02853..d710ec5 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o
# connection tracking helpers
nf_conntrack_h323-objs := nf_conntrack_h323_main.o nf_conntrack_h323_asn1.o
+obj-$(CONFIG_NF_CONNTRACK_NONE) += nf_conntrack_none.o
obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_conntrack_amanda.o
obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o
obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o
diff --git a/net/netfilter/nf_conntrack_none.c b/net/netfilter/nf_conntrack_none.c
new file mode 100644
index 0000000..5ae618f
--- /dev/null
+++ b/net/netfilter/nf_conntrack_none.c
@@ -0,0 +1,111 @@
+#include <linux/module.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_helper.h>
+
+static int nohelp_helper(struct sk_buff *skb, unsigned int protoff,
+ struct nf_conn *ct, enum ip_conntrack_info ctinfo)
+{
+ return NF_ACCEPT;
+}
+
+static const struct nf_conntrack_expect_policy noexp_policy = {
+ .max_expected = 1,
+ .timeout = 5 * 60,
+};
+
+static struct nf_conntrack_helper nohelp_reg[] __read_mostly = {
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV6,
+ .tuple.dst.protonum = IPPROTO_TCP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV6,
+ .tuple.dst.protonum = IPPROTO_SCTP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV6,
+ .tuple.dst.protonum = IPPROTO_UDP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV6,
+ .tuple.dst.protonum = IPPROTO_DCCP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV4,
+ .tuple.dst.protonum = IPPROTO_TCP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV4,
+ .tuple.dst.protonum = IPPROTO_SCTP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV4,
+ .tuple.dst.protonum = IPPROTO_UDP,
+ },
+ {
+ .name = "none",
+ .me = THIS_MODULE,
+ .help = nohelp_helper,
+ .expect_policy = &noexp_policy,
+ .tuple.src.l3num = NFPROTO_IPV4,
+ .tuple.dst.protonum = IPPROTO_DCCP,
+ },
+};
+
+static int __init nfct_none_init(void)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < ARRAY_SIZE(nohelp_reg); ++i) {
+ ret = nf_conntrack_helper_register(&nohelp_reg[i]);
+ if (ret < 0)
+ goto out;
+ }
+ return 0;
+out:
+ while (i-- > 0)
+ nf_conntrack_helper_unregister(&nohelp_reg[i]);
+ return ret;
+}
+
+static void __exit nfct_none_exit(void)
+{
+ unsigned int i = ARRAY_SIZE(nohelp_reg);
+
+ while (i-- > 0)
+ nf_conntrack_helper_unregister(&nohelp_reg[i]);
+}
+
+module_init(nfct_none_init);
+module_exit(nfct_none_exit);
+MODULE_LICENSE("GPL");
--
1.7.3.4
next prev parent reply other threads:[~2011-05-18 22:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 22:21 The glorious NFCT "none" helper Jan Engelhardt
2011-05-18 22:21 ` Jan Engelhardt [this message]
2011-05-23 14:29 ` Patrick McHardy
2011-05-23 15:47 ` Pablo Neira Ayuso
2011-05-23 15:59 ` Jan Engelhardt
2011-05-23 16:13 ` Pablo Neira Ayuso
2011-05-24 7:06 ` Patrick McHardy
2011-05-24 19:03 ` Pablo Neira Ayuso
2011-06-07 10:23 ` Patrick McHardy
2011-06-07 11:09 ` Patrick McHardy
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=1305757266-8730-2-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--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).