netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Timo Teräs" <timo.teras@iki.fi>
To: netdev@vger.kernel.org
Subject: Re: ip xfrm policy semantics
Date: Fri, 09 Jan 2009 19:09:02 +0200	[thread overview]
Message-ID: <496784AE.6000505@iki.fi> (raw)
In-Reply-To: <49675C3E.6010109@iki.fi>

Timo Teräs wrote:
> So what I want is that locally generated / received packages should
> be protected by the ipsec policy. But forwarded GRE packets (that are
> masqueraded) should not get any xfrm treatment.
> 
> It looks like that if xfrm out policy still affects the forwarded packets.
> If I add an overriding policy for the PPTP server, things seem to work
> better. But I'd rather not do that as it's a bit hacky.
> 
> I was not able to find any authoritative place how netfilter and xfrm policies
> and routing interact. The only thing I found was [1], but that seems to be
> inaccurate. Anyone care to shed light on this part?
> 
> [1] http://www.strongswan.org/docs/netfilter.pdf

Ok, I tried to find what the code does. Apparently the ip_forward() calls 
xfrm4_route_forward() which ends up doing __xfrm_route_forward() falling
back to xfrm_lookup() which is fixed to use XFRM_POLICY_OUT. So 'out'
policy is always used; even for packets that are being forwarded.

Ok, now I tried adding:
  policy in  src pptp-server
  policy out dst pptp-server
  policy out dst internal-pptp-client

all with high priority and policy 'none'. Now it looks like the packets
from pptp-client go out to internet properly. The connection tracking
entries are recorded, but the reply packets from pptp-server do not
get back to internal-pptp-client. Apparently the 'none' policy prevents
NAT to work.

And yes, when there is no XFRM policies at all, the PPTP connection
works great.

Any ideas what would the proper way to patch XFRM to distinguish if
forwarded packets should be touched or not?

There's several things that differ:
- gre inner protocol
- gre key
- input interface
- forwarded/local

I'm thinking the easiest way out is to make XFRM GRE aware and add
an upper layer match (like icmp code; we could have gre key). But
I'm out of good ideas how to properly tie the policy to be my
local gre interface specific.

- Timo


  reply	other threads:[~2009-01-09 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09 14:16 ip xfrm policy semantics Timo Teräs
2009-01-09 17:09 ` Timo Teräs [this message]
2009-01-09 19:21   ` Timo Teräs

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=496784AE.6000505@iki.fi \
    --to=timo.teras@iki.fi \
    --cc=netdev@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).