]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ethtool: stats: clarify the initialization to ETHTOOL_STAT_NOT_SET
authorJakub Kicinski <kuba@kernel.org>
Mon, 19 Apr 2021 20:03:45 +0000 (13:03 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Apr 2021 23:23:32 +0000 (16:23 -0700)
Ido suggests we add a comment about the init of stats to -1.
This is unlikely to be clear to first time readers.

Suggested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethtool/stats.c

index acb2b080c35832e5cffba62c1a40383d91d9a260..b7642dc96d5072d66efb43b63516f258551ac70b 100644 (file)
@@ -114,6 +114,9 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,
        if (ret < 0)
                return ret;
 
+       /* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them
+        * from being reported to user space in case driver did not set them.
+        */
        memset(&data->phy_stats, 0xff, sizeof(data->phy_stats));
        memset(&data->mac_stats, 0xff, sizeof(data->mac_stats));
        memset(&data->ctrl_stats, 0xff, sizeof(data->mac_stats));