From: kaber@trash.net
To: davem@davemloft.net
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH 5/9] netfilter: xt_connbytes: Force CT accounting to be enabled
Date: Fri, 2 Jul 2010 11:52:18 +0200 [thread overview]
Message-ID: <1278064342-19059-6-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1278064342-19059-1-git-send-email-kaber@trash.net>
From: Tim Gardner <tim.gardner@canonical.com>
Check at rule install time that CT accounting is enabled. Force it
to be enabled if not while also emitting a warning since this is not
the default state.
This is in preparation for deprecating CONFIG_NF_CT_ACCT upon which
CONFIG_NETFILTER_XT_MATCH_CONNBYTES depended being set.
Added 2 CT accounting support functions:
nf_ct_acct_enabled() - Get CT accounting state.
nf_ct_set_acct() - Enable/disable CT accountuing.
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/net/netfilter/nf_conntrack_acct.h | 12 ++++++++++++
net/netfilter/xt_connbytes.c | 10 ++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_acct.h b/include/net/netfilter/nf_conntrack_acct.h
index 03e218f..4e9c63a 100644
--- a/include/net/netfilter/nf_conntrack_acct.h
+++ b/include/net/netfilter/nf_conntrack_acct.h
@@ -45,6 +45,18 @@ struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
extern unsigned int
seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir);
+/* Check if connection tracking accounting is enabled */
+static inline bool nf_ct_acct_enabled(struct net *net)
+{
+ return net->ct.sysctl_acct != 0;
+}
+
+/* Enable/disable connection tracking accounting */
+static inline void nf_ct_set_acct(struct net *net, bool enable)
+{
+ net->ct.sysctl_acct = enable;
+}
+
extern int nf_conntrack_acct_init(struct net *net);
extern void nf_conntrack_acct_fini(struct net *net);
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index 7351783..5b13850 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -112,6 +112,16 @@ static int connbytes_mt_check(const struct xt_mtchk_param *par)
if (ret < 0)
pr_info("cannot load conntrack support for proto=%u\n",
par->family);
+
+ /*
+ * This filter cannot function correctly unless connection tracking
+ * accounting is enabled, so complain in the hope that someone notices.
+ */
+ if (!nf_ct_acct_enabled(par->net)) {
+ pr_warning("Forcing CT accounting to be enabled\n");
+ nf_ct_set_acct(par->net, true);
+ }
+
return ret;
}
--
1.7.0.4
next prev parent reply other threads:[~2010-07-02 9:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 9:52 [PATCH 0/9] netfilter: netfilter update kaber
2010-07-02 9:52 ` [PATCH 1/9] netfilter: nf_nat: support user-specified SNAT rules in LOCAL_IN kaber
2010-07-02 10:14 ` Jan Engelhardt
2010-07-02 10:17 ` Patrick McHardy
2010-07-02 12:17 ` Jan Engelhardt
2010-07-02 12:35 ` Patrick McHardy
2010-07-02 12:58 ` Jan Engelhardt
2010-07-02 14:07 ` Patrick McHardy
2010-07-02 9:52 ` [PATCH 2/9] IPVS: one-packet scheduling kaber
2010-07-02 9:52 ` [PATCH 3/9] netfilter: xt_IDLETIMER needs kdev_t.h kaber
2010-07-02 9:52 ` [PATCH 4/9] netfilter: fix simple typo in KConfig for netfiltert xt_TEE kaber
2010-07-02 9:52 ` kaber [this message]
2010-07-02 9:52 ` [PATCH 6/9] netfilter: complete the deprecation of CONFIG_NF_CT_ACCT kaber
2010-07-02 9:52 ` [PATCH 7/9] netfilter: ipt_LOG/ip6t_LOG: remove comparison within loop kaber
2010-07-02 9:52 ` [PATCH 8/9] netfilter: ipt_LOG/ip6t_LOG: add option to print decoded MAC header kaber
2010-07-02 9:52 ` [PATCH 9/9] bridge: add per bridge device controls for invoking iptables kaber
2010-07-03 5:04 ` [PATCH 0/9] netfilter: netfilter update David Miller
2010-07-03 5:44 ` David Miller
2010-07-03 9:06 ` 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=1278064342-19059-6-git-send-email-kaber@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--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).