RFC: consistent disable_xfrm behaviour
Subsystems (3)
Currently the behaviour of disable_xfrm is inconsistent between locally generated and forwarded packets. For locally generated packets disable_xfrm disables the policy lookup if it is set on the output device, for forwarded traffic however it looks at the input device. This makes it impossible to disable xfrm on all devices but a dummy device and use normal routing to direct traffic to that device.
The Documentation is not exactly clear about whether the input or output device is meant, but the way I read it talks about the output device as well (since encryption is only done at output):
disable_xfrm - BOOLEAN
Disable IPSEC encryption on this interface, whatever the policy
Opinions?
net/ipv4/route.c +1 -1
@@ -1780,7 +1780,7 @@ #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED#endif if (in_dev->cnf.no_policy) rth->u.dst.flags |=DST_NOPOLICY ; -if (in_dev->cnf.no_xfrm) +if (out_dev->cnf.no_xfrm) rth->u.dst.flags |=DST_NOXFRM ; rth->fl.fl4_dst = daddr; rth->rt_dst = daddr;
Quoted 5 lines · Patrick McHardy
disable_xfrm- BOOLEANDisable IPSEC encryption on this interface, whatever the policy
Opinions?
Looks good to me, wonder what the original rationale was, though.
Signature · 2 lines
James Morris <[email protected]>
Quoted 11 lines · James Morris
Quoted 5 lines · Patrick McHardy
disable_xfrm- BOOLEANDisable IPSEC encryption on this interface, whatever the policy
Opinions?
Looks good to me, wonder what the original rationale was, though.
Me too. It was introduced by this patch:
which only mentions the loopback device, in which case it doesn't matter.
Alexey, do you remember what the original intent of this was?
Hello!
Quoted 1 line
Alexey, do you remember what the original intent of this was?
disable_policy was supposed to skip policy checks on input. It makes sense only on input device.
disable_xfrm was supposed to skip transformations on output. It makes sense only on output device.
If it does not work, it was done wrong. :-)
As I see it, root of the problem is that DST_NOXFRM flag is calculated using wrong device. out_dev should be used in __mkroute_input(). It looks as a cut-n-paste error, the code was taken from output path, where it is correct.
Quoted 12 lines · Alexey Kuznetsov
Hello!
Quoted 1 line
Alexey, do you remember what the original intent of this was?
disable_policywas supposed to skip policy checks on input. It makes sense only on input device.
disable_xfrmwas supposed to skip transformations on output. It makes sense only on output device.
Quoted 6 lines
If it does not work, it was done wrong. :-)
As I see it, root of the problem is that
DST_NOXFRMflag is calculated using wrong device.out_devshould be used in__mkroute_input(). It looks as a cut-n-paste error, the code was taken from output path, where it is correct.
Thanks, thats exactly what I suspected :)
Here's the patch again properly signed off.
[XFRM]: Use output device disable_xfrm for forwarded packets
Currently the behaviour of disable_xfrm is inconsistent between locally generated and forwarded packets. For locally generated packets disable_xfrm disables the policy lookup if it is set on the output device, for forwarded traffic however it looks at the input device. This makes it impossible to disable xfrm on all devices but a dummy device and use normal routing to direct traffic to that device.
Always use the output device when checking disable_xfrm.
net/ipv4/route.c +1 -1
@@ -1780,7 +1780,7 @@ #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED#endif if (in_dev->cnf.no_policy) rth->u.dst.flags |=DST_NOPOLICY ; -if (in_dev->cnf.no_xfrm) +if (out_dev->cnf.no_xfrm) rth->u.dst.flags |=DST_NOXFRM ; rth->fl.fl4_dst = daddr; rth->rt_dst = daddr;
Hello!
Quoted 1 line
Here's the patch again properly signed off.
I think it is correct.
Alexey
David Miller
maintainerFrom: Alexey Kuznetsov <[email protected]>
Date: Mon, 4 Dec 2006 20:20:01 +0300
Quoted 3 lines
Quoted 1 line
Here's the patch again properly signed off.
I think it is correct.
Patch applied, thanks everyone.
I'll push this one to -stable too.