[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8492bf2b-0fbc-4819-ab7a-dfe860cca412@redhat.com>
Date: Tue, 25 Nov 2025 18:59:03 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Jon Kohler <jon@...anix.com>, "Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>, Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>,
virtualization@...ts.linux.dev, linux-kernel@...r.kernel.org
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] virtio-net: avoid unnecessary checksum
calculation on guest RX
On 11/25/25 6:57 PM, Paolo Abeni wrote:
> On 11/25/25 6:51 PM, Jon Kohler wrote:
>> 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@...hat.com>
>> Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
>> Signed-off-by: Jon Kohler <jon@...anix.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. */
>
> virtio_net_hdr_tnl_from_skb() is used also by the virtio_net driver,
> which in turn must not use VIRTIO_NET_HDR_F_DATA_VALID on tx.
>
> I think you need to add another argument to
> virtio_net_hdr_tnl_from_skb(), or possibly implement a separate helper
> to take care of csum offload - the symmetric of
> virtio_net_handle_csum_offload().
>
> Also you need to CC netdev, otherwise the patch will not be processed by
> patchwork.
whoops... I almost forgot... this is 'net' material, the subj prefix
should be adjusted accordingly.
Thanks,
Paolo
Powered by blists - more mailing lists