Herbert Xu wrote: > Patrick McHardy wrote: > >>@@ -97,6 +104,7 @@ >> err = xfrm_dst_lookup((struct xfrm_dst**)&rt, &fl_tunnel, AF_INET); >> if (err) >> goto error; >>+ rt->u.dst.flags |= DST_XFRM_TUNNEL; > > > This line doesn't look right. rt is an entry in the IPv4 routing > cache, right? If so why should its flags change when some bundle is > created? How about this one ? It keeps the DST_XFRM_TUNNEL flag and sets it on the first xfrm_dst in a bundle. I know it doesn't really belong there, but the alternatives are walking through the bundle an additional time or having xfrm_bundle_ok() return if it is a tunnel-mode bundle, but in that case we can only compare tos etc after the call to xfrm_bundle_ok(), which is rather expensive. I also moved the oif check to the checks performed only in transport mode, this reduces the number of cached bundles in tunnel mode to one per src/dst if the selector isn't narrower than that. Signed-off-by: Patrick McHardy