Skip to content

Commit d4872d7

Browse files
Mike Yuklassert
authored andcommitted
xfrm: fix xfrm child route lookup for packet offload
In current code, xfrm_bundle_create() always uses the matched SA's family type to look up a xfrm child route for the skb. The route returned by xfrm_dst_lookup() will eventually be used in xfrm_output_resume() (skb_dst(skb)->ops->local_out()). If packet offload is used, the above behavior can lead to calling ip_local_out() for an IPv6 packet or calling ip6_local_out() for an IPv4 packet, which is likely to fail. This change fixes the behavior by checking if the matched SA has packet offload enabled. If not, keep the same behavior; if yes, use the matched SP's family type for the lookup. Test: verified IPv6-in-IPv4 packets on Android device with IPsec packet offload enabled Signed-off-by: Mike Yu <yumike@google.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 1a807e4 commit d4872d7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net/xfrm/xfrm_policy.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,9 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
26942694
if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m)
26952695
mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);
26962696

2697-
family = xfrm[i]->props.family;
2697+
if (xfrm[i]->xso.type != XFRM_DEV_OFFLOAD_PACKET)
2698+
family = xfrm[i]->props.family;
2699+
26982700
oif = fl->flowi_oif ? : fl->flowi_l3mdev;
26992701
dst = xfrm_dst_lookup(xfrm[i], tos, oif,
27002702
&saddr, &daddr, family, mark);

0 commit comments

Comments
 (0)