public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] virtio-net: clear NETIF_F_GRO_HW if no GRO-related offloads are capable
@ 2026-03-13  1:30 Di Zhu
  2026-03-13  6:10 ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Di Zhu @ 2026-03-13  1:30 UTC (permalink / raw)
  To: mst, jasowang, xuanzhuo, eperezma, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, virtualization
  Cc: zhud, lijing, yingzhiwei

Although VIRTIO_NET_F_CTRL_GUEST_OFFLOADS is negotiated, which indicates
the device supports dynamic control of guest offloads, it does not
necessarily mean the device supports specific hardware GRO features.

If none of the features defined in GUEST_OFFLOAD_GRO_HW_MASK (such as
TSO4, TSO6, or UFO) are present in vi->guest_offloads_capable, the
device effectively lacks the hardware capability to perform GRO.

In this case, NETIF_F_GRO_HW should be cleared from dev->hw_features
to prevent the stack from attempting to enable an unsupported
hardware offload configuration.

Fixes: a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
Signed-off-by: Di Zhu <zhud@hygon.cn>
---
 drivers/net/virtio_net.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 72d6a9c6a5a2..49a60af684d5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -7058,6 +7058,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 	}
 	vi->guest_offloads_capable = vi->guest_offloads;
 
+	if (!(vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK))
+		dev->hw_features &= ~NETIF_F_GRO_HW;
+
 	rtnl_unlock();
 
 	err = virtnet_cpu_notif_add(vi);
-- 
2.34.1



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

* Re: [PATCH net] virtio-net: clear NETIF_F_GRO_HW if no GRO-related offloads are capable
  2026-03-13  1:30 [PATCH net] virtio-net: clear NETIF_F_GRO_HW if no GRO-related offloads are capable Di Zhu
@ 2026-03-13  6:10 ` Jason Wang
  2026-03-13  6:22   ` Zhud
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2026-03-13  6:10 UTC (permalink / raw)
  To: Di Zhu
  Cc: mst, xuanzhuo, eperezma, andrew+netdev, davem, edumazet, kuba,
	pabeni, netdev, virtualization, lijing, yingzhiwei

On Fri, Mar 13, 2026 at 9:37 AM Di Zhu <zhud@hygon.cn> wrote:
>
> Although VIRTIO_NET_F_CTRL_GUEST_OFFLOADS is negotiated, which indicates
> the device supports dynamic control of guest offloads, it does not
> necessarily mean the device supports specific hardware GRO features.
>
> If none of the features defined in GUEST_OFFLOAD_GRO_HW_MASK (such as
> TSO4, TSO6, or UFO) are present in vi->guest_offloads_capable, the
> device effectively lacks the hardware capability to perform GRO.
>
> In this case, NETIF_F_GRO_HW should be cleared from dev->hw_features
> to prevent the stack from attempting to enable an unsupported
> hardware offload configuration.
>
> Fixes: a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
> Signed-off-by: Di Zhu <zhud@hygon.cn>
> ---
>  drivers/net/virtio_net.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 72d6a9c6a5a2..49a60af684d5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -7058,6 +7058,9 @@ static int virtnet_probe(struct virtio_device *vdev)
>         }
>         vi->guest_offloads_capable = vi->guest_offloads;
>
> +       if (!(vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK))
> +               dev->hw_features &= ~NETIF_F_GRO_HW;
> +

It looks to me the root cause is this during probe?

        if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
                dev->hw_features |= NETIF_F_GRO_HW;

Thanks

>         rtnl_unlock();
>
>         err = virtnet_cpu_notif_add(vi);
> --
> 2.34.1
>
>


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

* RE: [PATCH net] virtio-net: clear NETIF_F_GRO_HW if no GRO-related offloads are capable
  2026-03-13  6:10 ` Jason Wang
@ 2026-03-13  6:22   ` Zhud
  0 siblings, 0 replies; 3+ messages in thread
From: Zhud @ 2026-03-13  6:22 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	virtualization@lists.linux.dev, Jing Li, Zhiwei Ying

> On Fri, Mar 13, 2026 at 9:37 AM Di Zhu <zhud@hygon.cn> wrote:
> >
> > Although VIRTIO_NET_F_CTRL_GUEST_OFFLOADS is negotiated, which
> > indicates the device supports dynamic control of guest offloads, it
> > does not necessarily mean the device supports specific hardware GRO features.
> >
> > If none of the features defined in GUEST_OFFLOAD_GRO_HW_MASK (such as
> > TSO4, TSO6, or UFO) are present in vi->guest_offloads_capable, the
> > device effectively lacks the hardware capability to perform GRO.
> >
> > In this case, NETIF_F_GRO_HW should be cleared from dev->hw_features
> > to prevent the stack from attempting to enable an unsupported hardware
> > offload configuration.
> >
> > Fixes: a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
> > Signed-off-by: Di Zhu <zhud@hygon.cn>
> > ---
> >  drivers/net/virtio_net.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index
> > 72d6a9c6a5a2..49a60af684d5 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -7058,6 +7058,9 @@ static int virtnet_probe(struct virtio_device *vdev)
> >         }
> >         vi->guest_offloads_capable = vi->guest_offloads;
> >
> > +       if (!(vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK))
> > +               dev->hw_features &= ~NETIF_F_GRO_HW;
> > +
> 
> It looks to me the root cause is this during probe?
> 
>         if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
>                 dev->hw_features |= NETIF_F_GRO_HW;
> 
> Thanks

	Exactly. It seems the code blindly enables NETIF_F_GRO_HW as long as the 
control channel is present, without verifying if the backend actually supports the
offload features.

> 
> >         rtnl_unlock();
> >
> >         err = virtnet_cpu_notif_add(vi);
> > --
> > 2.34.1
> >
> >
> 


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

end of thread, other threads:[~2026-03-13  6:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  1:30 [PATCH net] virtio-net: clear NETIF_F_GRO_HW if no GRO-related offloads are capable Di Zhu
2026-03-13  6:10 ` Jason Wang
2026-03-13  6:22   ` Zhud

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox