From: Jakub Kicinski <kuba@kernel.org> Date: 2021-11-02 04:21:26
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: 9a27a33027f2 ("ethtool: add standard pause stats")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/ethtool/pause.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
On Mon, 2021-11-01 at 21:21 -0700, Jakub Kicinski wrote:
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: 9a27a33027f2 ("ethtool: add standard pause stats")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Maybe for net-next we can improve readability here.
Just by staring at these lines, you'd think that this should've been
(ETHTOOL_A_PAUSE_STAT_MAX + 1), or even better, just
(ETHTOOL_A_PAUSE_STAT_CNT) /* Count of only stats */
maybe we need to separate stats from non-stats, or define
ETHTOOL_A_PAUSE_STAT_CNT where it needs to be defined.
Maybe for net-next we can improve readability here.
Just by staring at these lines, you'd think that this should've been
(ETHTOOL_A_PAUSE_STAT_MAX + 1), or even better, just
(ETHTOOL_A_PAUSE_STAT_CNT) /* Count of only stats */
maybe we need to separate stats from non-stats, or define
ETHTOOL_A_PAUSE_STAT_CNT where it needs to be defined.
Fair point, something like this?
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -411,10 +411,14 @@ enum {ETHTOOL_A_PAUSE_STAT_TX_FRAMES,ETHTOOL_A_PAUSE_STAT_RX_FRAMES,-/* add new constants above here */+/* add new constants above here+*adjustETHTOOL_PAUSE_STAT_CNTifaddingnon-stats!+*/__ETHTOOL_A_PAUSE_STAT_CNT,ETHTOOL_A_PAUSE_STAT_MAX=(__ETHTOOL_A_PAUSE_STAT_CNT-1)};+#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \+ETHTOOL_A_PAUSE_STAT_TX_FRAMES)/* EEE */