__virtnet_get_hw_stats() returns 0 when the VIRTIO_NET_CTRL_STATS_GET command fails, so ethtool -S reports every hardware counter as 0 without the "Failed to get hw stats." warning. Return -EINVAL instead, as virtnet_probe() does for VIRTIO_NET_CTRL_STATS_QUERY. Claude Opus 5.5 was used to draft this patch. To test, the virtio-net device in QEMU was modified to offer device statistics and to fail the command. With this patch, ethtool -S triggers the warning. Reported-by: Jakub Kicinski Link: https://lore.kernel.org/all/20261110001659.1654289-2-kuba@kernel.org/ Fixes: 941168f8b40e ("virtio_net: support device stats") Signed-off-by: Lianjie Wang --- v3: - New patch. drivers/net/virtio_net.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b9b6c915b6f3..185ac95b9b1b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4980,17 +4980,14 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi, struct scatterlist sgs_in, sgs_out; void *p; u32 qid; - int ok; sg_init_one(&sgs_out, req, req_size); sg_init_one(&sgs_in, reply, res_size); - ok = virtnet_send_command_reply(vi, VIRTIO_NET_CTRL_STATS, + if (!virtnet_send_command_reply(vi, VIRTIO_NET_CTRL_STATS, VIRTIO_NET_CTRL_STATS_GET, - &sgs_out, &sgs_in); - - if (!ok) - return ok; + &sgs_out, &sgs_in)) + return -EINVAL; for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size)) { hdr = p; -- 2.56.1