• Mike Yu's avatar
    xfrm: fix xfrm child route lookup for packet offload · d4872d70
    Mike Yu authored
    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: default avatarMike Yu <yumike@google.com>
    Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
    d4872d70
xfrm_policy.c 108 KB