mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
ethtool: fix ethtool msg len calculation for pause stats
[ Upstream commit1aabe578dd
] ETHTOOL_A_PAUSE_STAT_MAX is the MAX attribute id, so we need to subtract non-stats and add one to get a count (IOW -2+1 == -1). Otherwise we'll see: ethnl cmd 21: calculated reply length 40, but consumed 52 Fixes:9a27a33027
("ethtool: add standard pause stats") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
351237a76e
commit
2e746ef502
3 changed files with 7 additions and 3 deletions
|
@ -10,6 +10,9 @@
|
||||||
#define __ETHTOOL_LINK_MODE_MASK_NWORDS \
|
#define __ETHTOOL_LINK_MODE_MASK_NWORDS \
|
||||||
DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
|
DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
|
||||||
|
|
||||||
|
#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \
|
||||||
|
ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
|
||||||
|
|
||||||
enum ethtool_multicast_groups {
|
enum ethtool_multicast_groups {
|
||||||
ETHNL_MCGRP_MONITOR,
|
ETHNL_MCGRP_MONITOR,
|
||||||
};
|
};
|
||||||
|
|
|
@ -407,7 +407,9 @@ enum {
|
||||||
ETHTOOL_A_PAUSE_STAT_TX_FRAMES,
|
ETHTOOL_A_PAUSE_STAT_TX_FRAMES,
|
||||||
ETHTOOL_A_PAUSE_STAT_RX_FRAMES,
|
ETHTOOL_A_PAUSE_STAT_RX_FRAMES,
|
||||||
|
|
||||||
/* add new constants above here */
|
/* add new constants above here
|
||||||
|
* adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats!
|
||||||
|
*/
|
||||||
__ETHTOOL_A_PAUSE_STAT_CNT,
|
__ETHTOOL_A_PAUSE_STAT_CNT,
|
||||||
ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1)
|
ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1)
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,8 +56,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base,
|
||||||
|
|
||||||
if (req_base->flags & ETHTOOL_FLAG_STATS)
|
if (req_base->flags & ETHTOOL_FLAG_STATS)
|
||||||
n += nla_total_size(0) + /* _PAUSE_STATS */
|
n += nla_total_size(0) + /* _PAUSE_STATS */
|
||||||
nla_total_size_64bit(sizeof(u64)) *
|
nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT;
|
||||||
(ETHTOOL_A_PAUSE_STAT_MAX - 2);
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue