[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250515071042.5f668345@kernel.org>
Date: Thu, 15 May 2025 07:10:42 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Tang Longjun <lange_tang@....com>
Cc: xuanzhuo@...ux.alibaba.com, jasowang@...hat.com, mst@...hat.com,
davem@...emloft.net, edumazet@...gle.com, netdev@...r.kernel.org,
virtualization@...ts.linux.dev, Tang Longjun <tanglongjun@...inos.cn>
Subject: Re: [PATCH] virtio_net: Fix duplicated return values in
virtnet_get_hw_stats
On Wed, 14 May 2025 13:44:33 +0800 Tang Longjun wrote:
> 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()
> 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
Powered by blists - more mailing lists