[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5e642aef.66ba.196d805de6a.Coremail.lange_tang@163.com>
Date: Fri, 16 May 2025 15:36:25 +0800 (CST)
From: "Lange Tang" <lange_tang@....com>
To: "Jakub Kicinski" <kuba@...nel.org>
Cc: "xuanzhuo@...ux.alibaba.com" <xuanzhuo@...ux.alibaba.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"mst@...hat.com" <mst@...hat.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"virtualization@...ts.linux.dev" <virtualization@...ts.linux.dev>,
"Tang Longjun" <tanglongjun@...inos.cn>
Subject: Re:Re: [PATCH] virtio_net: Fix duplicated return values in
virtnet_get_hw_stats
At 2025-05-15 22:10:42, "Jakub Kicinski" <kuba@...nel.org> wrote:
>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
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/
regards,
Tang Longjun
Powered by blists - more mailing lists