From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
netfilter-devel@vger.kernel.org
Subject: Re: [RFC] [PATCH] Handle routing changes for the MASQUERADE target
Date: Thu, 29 Nov 2012 23:33:39 +0100 [thread overview]
Message-ID: <20121129223339.GA9370@1984> (raw)
In-Reply-To: <20121129212640.GB26937@breakpoint.cc>
On Thu, Nov 29, 2012 at 10:26:40PM +0100, Florian Westphal wrote:
> Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> wrote:
>
> Hi Jozsef,
>
> this looks really good, two minor nits below.
>
> > diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c
> > index ac635a7..128885d 100644
> > --- a/net/ipv4/netfilter/iptable_nat.c
> > +++ b/net/ipv4/netfilter/iptable_nat.c
> > @@ -17,6 +17,7 @@
> > #include <net/netfilter/nf_nat.h>
> > #include <net/netfilter/nf_nat_core.h>
> > #include <net/netfilter/nf_nat_l3proto.h>
> > +#include <net/netfilter/nf_conntrack_ecache.h>
> >
> > static const struct xt_table nf_nat_ipv4_table = {
> > .name = "nat",
> > @@ -134,6 +135,24 @@ nf_nat_ipv4_fn(unsigned int hooknum,
> > /* ESTABLISHED */
> > NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
> > ctinfo == IP_CT_ESTABLISHED_REPLY);
> > + if (hooknum == NF_INET_POST_ROUTING &&
> > + CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL &&
> > + nat->masq_index && nat->masq_index != out->ifindex) {
> > + /* Outgoing interface changed, kill ct. */
>
> Would it be possible to use nf_ct_kill_acct() here instead of
>
> > + if (del_timer(&ct->timeout)) {
> > + if (nf_conntrack_event(IPCT_DESTROY, ct) < 0) {
> [..]
>
> ?
>
> > --- a/net/ipv6/netfilter/ip6table_nat.c
> > +++ b/net/ipv6/netfilter/ip6table_nat.c
> > @@ -19,6 +19,7 @@
> > #include <net/netfilter/nf_nat.h>
> > #include <net/netfilter/nf_nat_core.h>
> > #include <net/netfilter/nf_nat_l3proto.h>
> [..]
> > static const struct xt_table nf_nat_ipv6_table = {
> > + if (hooknum == NF_INET_POST_ROUTING &&
> > + CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL &&
> > + nat->masq_index && nat->masq_index != out->ifindex) {
> > + /* Outgoing interface changed, kill ct. */
> > + if (del_timer(&ct->timeout)) {
>
> perhaps this could be a helper in include/net/netfilter/nf_nat.h?
>
> It would avoid the code duplication and the needed #if IS_ENABLED() MASQ
> check.
I'd suggest a hook function that is set via rcu_pointer_assign in the
init path of the masquerade target.
next prev parent reply other threads:[~2012-11-29 22:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 21:12 [RFC] [PATCH] Handle routing changes for the MASQUERADE target Jozsef Kadlecsik
2012-11-29 21:26 ` Florian Westphal
2012-11-29 22:31 ` Jozsef Kadlecsik
2012-11-29 22:33 ` Pablo Neira Ayuso [this message]
2012-11-30 20:14 ` Jozsef Kadlecsik
2012-11-29 22:44 ` Pablo Neira Ayuso
2012-11-30 20:37 ` Jozsef Kadlecsik
2012-12-03 14:23 ` 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=20121129223339.GA9370@1984 \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=kadlec@blackhole.kfki.hu \
--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).