All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@nvidia.com>
To: "kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "mkubecek@suse.cz" <mkubecek@suse.cz>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>
Subject: Re: [PATCH net] ethtool: fix ethtool msg len calculation for pause stats
Date: Tue, 2 Nov 2021 16:08:52 +0000	[thread overview]
Message-ID: <502b2fdb44dfb579eaa00ca912b836eb8075e367.camel@nvidia.com> (raw)
In-Reply-To: <20211102042120.3595389-1-kuba@kernel.org>

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>

Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>

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

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.


  reply	other threads:[~2021-11-02 16:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  4:21 [PATCH net] ethtool: fix ethtool msg len calculation for pause stats Jakub Kicinski
2021-11-02 16:08 ` Saeed Mahameed [this message]
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=502b2fdb44dfb579eaa00ca912b836eb8075e367.camel@nvidia.com \
    --to=saeedm@nvidia.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    /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.