summaryrefslogtreecommitdiff
path: root/net/ethtool
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2021-04-19 13:03:45 -0700
committerDavid S. Miller <davem@davemloft.net>2021-04-19 16:23:32 -0700
commitd1f0a5e1fb4e2f2f603bec8df79ca51768f2bdae (patch)
tree4ed8d3412ab9993fd934462287423965f612ca12 /net/ethtool
parent37434782d63f89de5b9c383a449b6a82dc3fa4fb (diff)
ethtool: stats: clarify the initialization to ETHTOOL_STAT_NOT_SET
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>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/stats.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c
index acb2b080c358..b7642dc96d50 100644
--- a/net/ethtool/stats.c
+++ b/net/ethtool/stats.c
@@ -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));