Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

virtio-net: enable NETIF_F_GRO_HW only if GRO-related offloads are supported

Negotiating VIRTIO_NET_F_CTRL_GUEST_OFFLOADS indicates the device
allows control over offload support, but the offloads that can be
controlled may have nothing to do with GRO (e.g., if neither GUEST_TSO4
nor GUEST_TSO6 is supported).

In such a setup, reporting NETIF_F_GRO_HW as available for the device
is too optimistic and misleading to the user.

Improve the situation by masking off NETIF_F_GRO_HW unless the device
possesses actual GRO-related offload capabilities. Out of an abundance
of caution, this does not change the current behaviour for hardware with
just v6 or just v4 GRO: current interfaces do not allow distinguishing
between v6/v4 GRO, so we can't expose them to userspace precisely.

Signed-off-by: Di Zhu <zhud@hygon.cn>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://patch.msgid.link/20260323041730.986351-1-zhud@hygon.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Di Zhu and committed by
Jakub Kicinski
f8844dfe 6a539eee

+13 -11
+13 -11
drivers/net/virtio_net.c
··· 6800 6800 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || 6801 6801 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)) 6802 6802 dev->features |= NETIF_F_GRO_HW; 6803 - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) 6804 - dev->hw_features |= NETIF_F_GRO_HW; 6805 6803 6806 6804 dev->vlan_features = dev->features; 6807 6805 dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | ··· 6992 6994 6993 6995 enable_rx_mode_work(vi); 6994 6996 6997 + for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) { 6998 + unsigned int fbit; 6999 + 7000 + fbit = virtio_offload_to_feature(guest_offloads[i]); 7001 + if (virtio_has_feature(vi->vdev, fbit)) 7002 + set_bit(guest_offloads[i], &vi->guest_offloads); 7003 + } 7004 + vi->guest_offloads_capable = vi->guest_offloads; 7005 + 7006 + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) && 7007 + (vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK)) 7008 + dev->hw_features |= NETIF_F_GRO_HW; 7009 + 6995 7010 /* serialize netdev register + virtio_device_ready() with ndo_open() */ 6996 7011 rtnl_lock(); 6997 7012 ··· 7086 7075 virtnet_update_settings(vi); 7087 7076 netif_carrier_on(dev); 7088 7077 } 7089 - 7090 - for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) { 7091 - unsigned int fbit; 7092 - 7093 - fbit = virtio_offload_to_feature(guest_offloads[i]); 7094 - if (virtio_has_feature(vi->vdev, fbit)) 7095 - set_bit(guest_offloads[i], &vi->guest_offloads); 7096 - } 7097 - vi->guest_offloads_capable = vi->guest_offloads; 7098 7078 7099 7079 rtnl_unlock(); 7100 7080