Re:Re: [PATCH] virtio_net: Fix duplicated return values in virtnet_get_hw_stats
From: Lange Tang <hidden>
Date: 2025-05-16 07:37:16
Also in:
virtualization
At 2025-05-15 22:10:42, "Jakub Kicinski" [off-list ref] wrote:
On Wed, 14 May 2025 13:44:33 +0800 Tang Longjun wrote:quoted
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index e53ba600605a..c9a86f325619 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c@@ -4897,7 +4897,7 @@ static int __virtnet_get_hw_stats(struct virtnet_info *vi, &sgs_out, &sgs_in); if (!ok) - return ok; + return 1;This makes sense, looks like a typo in the original code. But we are now returning the reverse polarity of "ok", so we should probably rename the variable in virtnet_get_hw_stats() ok -> failed Or invert the polarity here and in virtnet_get_hw_stats()quoted
for (p = reply; p - reply < res_size; p += le16_to_cpu(hdr->size)) { hdr = p;@@ -4937,7 +4937,7 @@ static int virtnet_get_hw_stats(struct virtnet_info *vi, int ok; if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_DEVICE_STATS)) - return 0; + return -EOPNOTSUPP;IDK about this part. We should not spam the logs if the device does not support a feature. We should instead skip reporting the relevant stats. User can tell that those stats are not supported from the fact they are not present. --
pw-bot: cr
I found that Dan Carpenter had discovered the same issue before, and he had already submitted a patch, so I'm backing out. https://lore.kernel.org/netdev/20240515110626-mutt-send-email-mst@kernel.org/ (local) regards, Tang Longjun