From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [RFC] [PATCH] Handle routing changes for the MASQUERADE target
Date: Mon, 3 Dec 2012 15:23:24 +0100 [thread overview]
Message-ID: <20121203142324.GA4892@1984> (raw)
In-Reply-To: <alpine.DEB.2.00.1211302115000.16257@blackhole.kfki.hu>
On Fri, Nov 30, 2012 at 09:37:15PM +0100, Jozsef Kadlecsik wrote:
> Hi Pablo,
>
> On Thu, 29 Nov 2012, Pablo Neira Ayuso wrote:
>
> > On Thu, Nov 29, 2012 at 10:12:54PM +0100, Jozsef Kadlecsik wrote:
> > > Hi,
> > >
> > > This is the second variant of the patch which addresses the route
> > > changes affecting already masqueraded connections.
> > >
> > > When the route changes (backup default route, VPNs), the packets are sent
> > > out with wrong source address. The patch addresses the issue by comparing
> > > the outgoing interface directly with the masquerade interface in the nat
> > > table. It *is* MASQUERADE specific, so probably the inserted code could be
> > > enclosed in a proper ifdef.
> > >
> > > Events are inefficient, because it'd require scanning the whole conntrack
> > > table at any route change and re-checking the route for all entry, which
> > > is simply way too expensive.
> >
> > I still have to waste the bullet of proposing to do this from
> > user-space.
>
> :-)
>
> > I think a new command for the conntrack utility to iterate over the
> > table and kill entries with wrong masq_index would be relatively
> > simple. You will have to pass the ifindex you want to compare from
> > user-space.
>
> Unfortunately the userspace suffers the same problems than my first
> attempt, the notification did:
>
> - I'm not aware of any easy way to get "route changed" events in
> userspace: as far as I know routing daemons (quagga) or openvpn don't
> generate such things.
> - The event itself not enough, the related interface is required too.
> - The event and the interface is not enough, the exact rule should be
> known otherwise the full routing table must be looked up.
> - The event, interface and exact rule is not enough, because even if
> the rule matches a conntrack entry, it might be that the route for the
> entry did not change - so we have to look up the route table anyway.
> - We are back that actually the event is enough :-).
>
> So in this case, if we can get such events (but how), we should have to
> iterate over the whole conntrack table, whatever large it is, and execute
> full route lookups for every element.
>
> In my approach the route is already computed and we just verify runtime
> that the outgoing interface corresponds to the one which was used at the
> first packet.
OK, you convinced me. The last V4 patch looks very small to handle
this case. I'll take it.
prev parent reply other threads:[~2012-12-03 14:23 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
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 [this message]
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=20121203142324.GA4892@1984 \
--to=pablo@netfilter.org \
--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).