virtio_net CSUM broken with Cloud Hypervisor
Subsystems (4)
Since 56a06bd40fab ("virtio_net: enable gso over UDP tunnel support."), networking in Cloud Hypervisor is no longer working for me.
I've narrowed down the problem to here:
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2570
Quoted 7 lines
(quoted diff) +1
-2@@ -2555,14 +2567,21 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * if (dev->features & NETIF_F_RXHASH && vi->has_rss_hash_report) virtio_skb_set_hash(&hdr->hash_v1_hdr, skb); - if (flags & VIRTIO_NET_HDR_F_DATA_VALID) - skb->ip_summed = CHECKSUM_UNNECESSARY; + hdr->hdr.flags = flags;
It looks like this was added because virtio_net_handle_csum_offload() looks at the flags from the hdr it's given, rather than having it passed separately, but it appears something later on relies on the previous value of hdr->hdr.flags.
From my tracing, hdr->hdr.flags is set to either 0 or VIRTIO_NET_HDR_F_NEEDS_CSUM before this assignment, and flags is always 0, so in some cases VIRTIO_NET_HDR_F_NEEDS_CSUM now ends up being unset.
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2576
Quoted 6 lines
(quoted diff) +6
-0+ if (virtio_net_handle_csum_offload(skb, &hdr->hdr, vi->rx_tnl_csum)) { + net_warn_ratelimited("%s: bad csum: flags: %x, gso_type: %x rx_tnl_csum %d\n", + dev->name, hdr->hdr.flags, + hdr->hdr.gso_type, vi->rx_tnl_csum); + goto frame_err; + }
If I change it to save the previous value of hdr->hdr.flags, and restore it again here, everything works again.
Disabling offload_csum in Cloud Hypervisor is a usable workaround, because then hdr->hdr.flags is always 0 to begin with anyway.
#regzbot introduced: 56a06bd40fab
Quoted 19 lines · Alyssa Ross
Since
56a06bd40fab("virtio_net: enable gso over UDP tunnel support."), networking in Cloud Hypervisor is no longer working for me.I've narrowed down the problem to here:
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2570
Quoted 7 lines
(quoted diff) +1
-2@@ -2555,14 +2567,21 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * if (dev->features & NETIF_F_RXHASH && vi->has_rss_hash_report) virtio_skb_set_hash(&hdr->hash_v1_hdr, skb); - if (flags & VIRTIO_NET_HDR_F_DATA_VALID) - skb->ip_summed = CHECKSUM_UNNECESSARY; + hdr->hdr.flags = flags;It looks like this was added because
virtio_net_handle_csum_offload()looks at the flags from the hdr it's given, rather than having it passed separately, but it appears something later on relies on the previous value ofhdr->hdr.flags.
Quoted 3 lines
From my tracing,
hdr->hdr.flagsis set to either 0 orVIRTIO_NET_HDR_F_NEEDS_CSUMbefore this assignment, and flags is always 0, so in some casesVIRTIO_NET_HDR_F_NEEDS_CSUMnow ends up being unset.
Are you using XDP, if not there should be no change.
Quoted 8 lines
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2576
Quoted 7 lines
(quoted diff) +6
-0+ if (virtio_net_handle_csum_offload(skb, &hdr->hdr, vi->rx_tnl_csum)) { + net_warn_ratelimited("%s: bad csum: flags: %x, gso_type: %x rx_tnl_csum %d\n", + dev->name, hdr->hdr.flags, + hdr->hdr.gso_type, vi->rx_tnl_csum); + goto frame_err; + }
Quoted 7 lines
If I change it to save the previous value of
hdr->hdr.flags, and restore it again here, everything works again.Disabling
offload_csumin Cloud Hypervisor is a usable workaround, because thenhdr->hdr.flagsis always 0 to begin with anyway.#regzbot introduced:
56a06bd40fab
Is mergeable rx buffer enabled, if not, I wonder if this can be fixed by:
https://marc.info/?l=linux-netdev&m=176170721926346&w=2
Thanks
Quoted 37 lines · Jason Wang
Quoted 19 lines · Alyssa Ross
Since
56a06bd40fab("virtio_net: enable gso over UDP tunnel support."), networking in Cloud Hypervisor is no longer working for me.I've narrowed down the problem to here:
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2570
Quoted 7 lines
(quoted diff) +1
-2@@ -2555,14 +2567,21 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * if (dev->features & NETIF_F_RXHASH && vi->has_rss_hash_report) virtio_skb_set_hash(&hdr->hash_v1_hdr, skb); - if (flags & VIRTIO_NET_HDR_F_DATA_VALID) - skb->ip_summed = CHECKSUM_UNNECESSARY; + hdr->hdr.flags = flags;It looks like this was added because
virtio_net_handle_csum_offload()looks at the flags from the hdr it's given, rather than having it passed separately, but it appears something later on relies on the previous value ofhdr->hdr.flags.Quoted 3 lines
From my tracing,
hdr->hdr.flagsis set to either 0 orVIRTIO_NET_HDR_F_NEEDS_CSUMbefore this assignment, and flags is always 0, so in some casesVIRTIO_NET_HDR_F_NEEDS_CSUMnow ends up being unset.Are you using XDP, if not there should be no change.
Quoted 11 lines
Review static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue * · line 2576
Quoted 7 lines
(quoted diff) +6
-0+ if (virtio_net_handle_csum_offload(skb, &hdr->hdr, vi->rx_tnl_csum)) { + net_warn_ratelimited("%s: bad csum: flags: %x, gso_type: %x rx_tnl_csum %d\n", + dev->name, hdr->hdr.flags, + hdr->hdr.gso_type, vi->rx_tnl_csum); + goto frame_err; + }If I change it to save the previous value of
hdr->hdr.flags, and restore it again here, everything works again.
Quoted 8 lines
Quoted 4 lines
Disabling
offload_csumin Cloud Hypervisor is a usable workaround, because thenhdr->hdr.flagsis always 0 to begin with anyway.#regzbot introduced:
56a06bd40fabIs mergeable rx buffer enabled, if not, I wonder if this can be fixed by:
That patch does fix it, thank you!
#regzbot fix: virtio-net: fix incorrect flags recording in big mode