mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
virtio-net: avoid unnecessary checksum calculation on guest RX
Commita2fb4bc4e2("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, but only from tun side, as 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. cc: stable@vger.kernel.org Fixes:a2fb4bc4e2("net: implement virtio helpers to handle UDP GSO tunneling.") Signed-off-by: Jon Kohler <jon@nutanix.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Link: https://patch.msgid.link/20251125222754.1737443-1-jon@nutanix.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
6d66e093e0
commit
1cd1c47234
@@ -384,7 +384,8 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
|
||||
struct virtio_net_hdr_v1_hash_tunnel *vhdr,
|
||||
bool tnl_hdr_negotiated,
|
||||
bool little_endian,
|
||||
int vlan_hlen)
|
||||
int vlan_hlen,
|
||||
bool has_data_valid)
|
||||
{
|
||||
struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)vhdr;
|
||||
unsigned int inner_nh, outer_th;
|
||||
@@ -394,8 +395,8 @@ 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,
|
||||
vlan_hlen);
|
||||
return virtio_net_hdr_from_skb(skb, hdr, little_endian,
|
||||
has_data_valid, vlan_hlen);
|
||||
|
||||
/* Tunnel support not negotiated but skb ask for it. */
|
||||
if (!tnl_hdr_negotiated)
|
||||
|
||||
Reference in New Issue
Block a user