netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Christoph Paasch <cpaasch@apple.com>
Cc: <netdev@vger.kernel.org>, David Miller <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
	Petr Machata <petrm@nvidia.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net] netlink: Correct offload_xstats size
Date: Fri, 13 Oct 2023 14:43:05 +0200	[thread overview]
Message-ID: <87zg0mofiv.fsf@nvidia.com> (raw)
In-Reply-To: <20231013041448.8229-1-cpaasch@apple.com>


Christoph Paasch <cpaasch@apple.com> writes:

> rtnl_offload_xstats_get_size_hw_s_info_one() conditionalizes the
> size-computation for IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED based on whether
> or not the device has offload_xstats enabled.
>
> However, rtnl_offload_xstats_fill_hw_s_info_one() is adding the u8 for
> that field uncondtionally.

> Which didn't happen prior to commit bf9f1baa279f ("net: add dedicated
> kmem_cache for typical/small skb->head") as the skb always was large
> enough.
>
> Cc: Petr Machata <petrm@nvidia.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Fixes: 0e7788fd7622 ("net: rtnetlink: Add UAPI for obtaining L3 offload xstats")
> Signed-off-by: Christoph Paasch <cpaasch@apple.com>
> ---
>
> Notes:
>     Another fix would be to make rtnl_offload_xstats_fill_hw_s_info_one()
>     check whether the device has offload_xstats enabled. Let me know if that
>     is a preferred route.

I think I decided that it's going to be useful to get the info always,
but then neglected to update the size computation. So this fix looks
good to me. Also, it maintains the same behavior as before, minus the
size computation bug.

Reviewed-by: Petr Machata <petrm@nvidia.com>

>
>  net/core/rtnetlink.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 4a2ec33bfb51..53c377d054f0 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -5503,13 +5503,11 @@ static unsigned int
>  rtnl_offload_xstats_get_size_hw_s_info_one(const struct net_device *dev,
>  					   enum netdev_offload_xstats_type type)
>  {
> -	bool enabled = netdev_offload_xstats_enabled(dev, type);
> -
>  	return nla_total_size(0) +
>  		/* IFLA_OFFLOAD_XSTATS_HW_S_INFO_REQUEST */
>  		nla_total_size(sizeof(u8)) +
>  		/* IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED */
> -		(enabled ? nla_total_size(sizeof(u8)) : 0) +
> +		nla_total_size(sizeof(u8)) +
>  		0;
>  }


  reply	other threads:[~2023-10-13 12:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  4:14 [PATCH net] netlink: Correct offload_xstats size Christoph Paasch
2023-10-13 12:43 ` Petr Machata [this message]
2023-10-17  0:40 ` patchwork-bot+netdevbpf

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=87zg0mofiv.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=cpaasch@apple.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).