Skip to content

Commit d1f0a5e

Browse files
kuba-moodavem330
authored andcommitted
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>
1 parent 3743478 commit d1f0a5e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ethtool/stats.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,
114114
if (ret < 0)
115115
return ret;
116116

117+
/* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them
118+
* from being reported to user space in case driver did not set them.
119+
*/
117120
memset(&data->phy_stats, 0xff, sizeof(data->phy_stats));
118121
memset(&data->mac_stats, 0xff, sizeof(data->mac_stats));
119122
memset(&data->ctrl_stats, 0xff, sizeof(data->mac_stats));

0 commit comments

Comments
 (0)