Subject: Re: ip xfrm policy semantics

From: Timo Teräs <[email-masked]>
Date: Fri, 09 Jan 2009 21:21:42 +0200

Timo Teräs wrote:
> 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.

Forget the above. I had a typo in my policy config.

Having:
  policy out dst pptp-server
  policy out dst internal-pptp-client

set to high priority and no transforms works great too.

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

So basically, I would like to have separate policy for 'out' and
'fwd_out'. But adding new policy type is kinda bad. I wonder why
in the first place 'in' and 'fwd' were split, but 'out' was left
all alone without any information about if it's forwarded or local
packet?

So, I'm back to thinking how to fix this without adding IP
addresses to my security policies.

The options I could think of are:
1. A way to test input interface on policy selector
2. GRE upper layer awareness. gre key being the likely key.
(3. Splitting 'out' policy to 'out' and 'outfwd')

Any comment on which would the preferred way to go?

- Timo