virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] virtio-net: avoid unnecessary checksum calculation on guest RX
@ 2025-11-25 17:51 Jon Kohler
  2025-11-25 17:57 ` Paolo Abeni
  0 siblings, 1 reply; 9+ messages in thread
From: Jon Kohler @ 2025-11-25 17:51 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, Eugenio Pérez,
	Paolo Abeni, virtualization, linux-kernel
  Cc: Jon Kohler

Commit a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP
GSO tunneling.") inadvertently altered checksum offload behavior
for guests not using UDP GSO tunneling.

Before, tun_put_user called tun_vnet_hdr_from_skb, which passed
has_data_valid = true to virtio_net_hdr_from_skb.

After, tun_put_user began calling tun_vnet_hdr_tnl_from_skb instead,
which passes has_data_valid = false into both call sites.

This caused virtio hdr flags to not include VIRTIO_NET_HDR_F_DATA_VALID
for SKBs where skb->ip_summed == CHECKSUM_UNNECESSARY. As a result,
guests are forced to recalculate checksums unnecessarily.

Restore the previous behavior by ensuring has_data_valid = true is
passed in the !tnl_gso_type case.

Cc: Paolo Abeni <pabeni@redhat.com>
Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 include/linux/virtio_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index b673c31569f3..570c6dd1666d 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -394,7 +394,7 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
 	tnl_gso_type = skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL |
 						    SKB_GSO_UDP_TUNNEL_CSUM);
 	if (!tnl_gso_type)
-		return virtio_net_hdr_from_skb(skb, hdr, little_endian, false,
+		return virtio_net_hdr_from_skb(skb, hdr, little_endian, true,
 					       vlan_hlen);
 
 	/* Tunnel support not negotiated but skb ask for it. */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-11-26 19:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 17:51 [PATCH net-next] virtio-net: avoid unnecessary checksum calculation on guest RX Jon Kohler
2025-11-25 17:57 ` Paolo Abeni
2025-11-25 17:59   ` Paolo Abeni
2025-11-25 20:00   ` Jon Kohler
2025-11-26  0:03     ` Michael S. Tsirkin
2025-11-26 11:16     ` Paolo Abeni
2025-11-26 12:30       ` Michael S. Tsirkin
2025-11-26 19:00         ` Jon Kohler
2025-11-26 18:58       ` Jon Kohler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).