All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, saeedm@nvidia.com, mkubecek@suse.cz,
	andrew@lunn.ch, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net] ethtool: fix ethtool msg len calculation for pause stats
Date: Mon,  1 Nov 2021 21:21:20 -0700	[thread overview]
Message-ID: <20211102042120.3595389-1-kuba@kernel.org> (raw)

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(-)

diff --git a/net/ethtool/pause.c b/net/ethtool/pause.c
index 9009f412151e..c9171234130b 100644
--- a/net/ethtool/pause.c
+++ b/net/ethtool/pause.c
@@ -57,7 +57,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base,
 	if (req_base->flags & ETHTOOL_FLAG_STATS)
 		n += nla_total_size(0) +	/* _PAUSE_STATS */
 			nla_total_size_64bit(sizeof(u64)) *
-				(ETHTOOL_A_PAUSE_STAT_MAX - 2);
+				(ETHTOOL_A_PAUSE_STAT_MAX - 1);
 	return n;
 }
 
-- 
2.31.1


             reply	other threads:[~2021-11-02  4:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  4:21 Jakub Kicinski [this message]
2021-11-02 16:08 ` [PATCH net] ethtool: fix ethtool msg len calculation for pause stats Saeed Mahameed
2021-11-02 18:10   ` Jakub Kicinski
2021-11-02 20:41     ` Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211102042120.3595389-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.