Skip to content

Commit b40c5f4

Browse files
Ansis Attekaklassert
authored andcommitted
udp: disable inner UDP checksum offloads in IPsec case
Otherwise, UDP checksum offloads could corrupt ESP packets by attempting to calculate UDP checksum when this inner UDP packet is already protected by IPsec. One way to reproduce this bug is to have a VM with virtio_net driver (UFO set to ON in the guest VM); and then encapsulate all guest's Ethernet frames in Geneve; and then further encrypt Geneve with IPsec. In this case following symptoms are observed: 1. If using ixgbe NIC, then it will complain with following error message: ixgbe 0000:01:00.1: partial checksum but l4 proto=32! 2. Receiving IPsec stack will drop all the corrupted ESP packets and increase XfrmInStateProtoError counter in /proc/net/xfrm_stat. 3. iperf UDP test from the VM with packet sizes above MTU will not work at all. 4. iperf TCP test from the VM will get ridiculously low performance because. Signed-off-by: Ansis Atteka <[email protected]> Co-authored-by: Steffen Klassert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4d6fa57 commit b40c5f4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/udp_offload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
2929
u16 mac_len = skb->mac_len;
3030
int udp_offset, outer_hlen;
3131
__wsum partial;
32+
bool need_ipsec;
3233

3334
if (unlikely(!pskb_may_pull(skb, tnl_hlen)))
3435
goto out;
@@ -62,8 +63,10 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
6263

6364
ufo = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP);
6465

66+
need_ipsec = skb_dst(skb) && dst_xfrm(skb_dst(skb));
6567
/* Try to offload checksum if possible */
6668
offload_csum = !!(need_csum &&
69+
!need_ipsec &&
6770
(skb->dev->features &
6871
(is_ipv6 ? (NETIF_F_HW_CSUM | NETIF_F_IPV6_CSUM) :
6972
(NETIF_F_HW_CSUM | NETIF_F_IP_CSUM))));

0 commit comments

Comments
 (0)