From: Joe Perches <joe@perches.com>
To: Jiri Kosina <jikos@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
Florian Westphal <fw@strlen.de>,
NetFilter <netfilter-devel@vger.kernel.org>,
coreteam@netfilter.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
info@jablonka.cz, eric@regit.org
Subject: Re: [PATCH v2] netfilter: nf_ct_helper: warn when not applying default helper assignment
Date: Wed, 25 Jan 2017 21:40:49 -0800 [thread overview]
Message-ID: <1485409249.12563.96.camel@perches.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1701252136460.25515@cbobk.fhfr.pm>
On Wed, 2017-01-25 at 21:43 +0100, Jiri Kosina wrote:
> Rewrite the code a little bit as suggested by Linus, so that we avoid
> spaghettiing the code even more -- namely the whole decision making
> process regarding helper selection (either automatic or not) is being
> separated, so that the whole logic can be simplified and code (condition)
> duplication reduced.
[]
> diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
[]
> @@ -188,6 +188,39 @@ struct nf_conn_help *
> }
> EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add);
>
> +static struct nf_conntrack_helper *find_auto_helper(struct nf_conn *ct)
> +{
> + return __nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
> +}
> +
> +static struct nf_conntrack_helper *ct_lookup_helper(struct nf_conn *ct, struct net *net)
> +{
> + struct nf_conntrack_helper *ret;
> +
> + if (!net->ct.sysctl_auto_assign_helper) {
> + if (net->ct.auto_assign_helper_warned)
> + return NULL;
> + if (!find_auto_helper(ct))
> + return NULL;
> + pr_info("nf_conntrack: default automatic helper assignment "
> + "has been turned off for security reasons and CT-based "
> + " firewall rule not found. Use the iptables CT target "
> + "to attach helpers instead.\n");
> + net->ct.auto_assign_helper_warned = 1;
> + return NULL;
> + }
> +
> + ret = find_auto_helper(ct);
> + if (!ret || net->ct.auto_assign_helper_warned)
> + return ret;
> + pr_info("nf_conntrack: automatic helper assignment is deprecated and it will "
> + "be removed soon. Use the iptables CT target to attach helpers "
> + " instead.\n");
> + net->ct.auto_assign_helper_warned = 1;
> + return ret;
> +}
There are whitespece defects concatenating these multi-line strings.
How about an exit block that emits the message like
{
[...]
const char *msg;
[...]
if (!net->ct.sysctl_auto_assign_helper) {
if (net->ct.auto_assign_helper_warned)
return NULL;
if (!find_auto_helper(ct))
return NULL;
msg = "default automatic helper assignment has been turned off for security reasons and CT-based firewall rule not found";
ret = NULL;
} else {
ret = find_auto_helper(ct);
if (!ret || net->ct.auto_assign_helper_warned)
return ret;
msg = "automatic helper assignment is deprecated and it will be removed soon";
net->ct.auto_assign_helper_warned = 1;
}
pr_info("nf_conntrack: %s. Use the iptables CT target to attach helpers instead.\n", msg);
return ret;
}
next prev parent reply other threads:[~2017-01-26 5:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 0:06 [RFC PATCH 0/2] restore original default of nf_conntrack_helper sysctl Jiri Kosina
2017-01-24 1:09 ` Linus Torvalds
2017-01-24 1:28 ` Pablo Neira Ayuso
2017-01-24 7:40 ` [PATCH] netfilter: nf_ct_helper: warn when not applying default helper assignment (was Re: [RFC PATCH 0/2] restore original default of nf_conntrack_helper sysctl) Jiri Kosina
2017-01-24 10:17 ` [PATCH v2] netfilter: nf_ct_helper: warn when not applying default helper assignment Jiri Kosina
2017-01-25 19:13 ` Linus Torvalds
2017-01-25 20:43 ` Jiri Kosina
2017-01-26 5:40 ` Joe Perches [this message]
2017-02-01 16:27 ` Pablo Neira Ayuso
2017-02-01 19:43 ` Jiri Kosina
2017-02-01 20:01 ` [PATCH v3] " Jiri Kosina
2017-02-02 13:26 ` 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=1485409249.12563.96.camel@perches.com \
--to=joe@perches.com \
--cc=coreteam@netfilter.org \
--cc=eric@regit.org \
--cc=fw@strlen.de \
--cc=info@jablonka.cz \
--cc=jikos@kernel.org \
--cc=kadlec@blackhole.kfki.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=torvalds@linux-foundation.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
Powered by JetHome