netdev
[Top] [All Lists]

Re: [RFC] MASQUERADE / policy routing ("Route send us somewhere else")

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: Re: [RFC] MASQUERADE / policy routing ("Route send us somewhere else")
From: Julian Anastasov <ja@xxxxxx>
Date: Tue, 31 Aug 2004 09:48:07 +0300 (EEST)
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, laforge@xxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxxxxxx, rusty@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx, kuznet@xxxxxxxxxxxxx
In-reply-to: <20040830223920.1db0d5ae.davem@xxxxxxxxxxxxx>
References: <20040830191915.04d49268.davem@xxxxxxxxxxxxx> <E1C1yRs-00086x-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20040830223920.1db0d5ae.davem@xxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
        Hello,

On Mon, 30 Aug 2004, David S. Miller wrote:

> > If you're wondering why the second lookup is returning a different
> > interface at all, it's because the routing lookup in MASQUERADE is
> > done as if the packet was generated by localhost.  This is obviously
> > going to differ from the normal routing lookup if the packet was
> > forwarded.
>
> I understand this description.
>
> Would it be enough to set 'out' to rt->u.dst.dev after the call to
> ip_route_output_key() in ipt_MASQUERADE.c?

        I think, the picture is:

Packet 1:

- input route (before NAT) => dev1

- MASQUERADE => autoselect public IP, try to use dev1 (same GW)
as already selected from input route

Packet 2..n:

- input route (before NAT) => cached dev1 (until routing/cache changes)

        So, if the input route for all packets selects dev1 before
NAT but MASQUERADE selects different device (nexthop) bad things
happen. It costs routing cache entries to provide oif key but almost
in any case the right gateway is selected (except when two nexthops
use same device).

Regards

--
Julian Anastasov <ja@xxxxxx>

<Prev in Thread] Current Thread [Next in Thread>