linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Adrian Moreno <amorenoz@redhat.com>
Cc: netdev@vger.kernel.org, nicolas.dichtel@6wind.com,
	toke@redhat.com, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Xiao Liang <shaw.leon@gmail.com>,
	Cong Wang <cong.wang@bytedance.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] rtnetlink: honor RTEXT_FILTER_SKIP_STATS in IFLA_STATS
Date: Thu, 30 Oct 2025 18:20:57 -0700	[thread overview]
Message-ID: <20251030182057.59731b84@kernel.org> (raw)
In-Reply-To: <20251029080154.3794720-1-amorenoz@redhat.com>

On Wed, 29 Oct 2025 09:01:52 +0100 Adrian Moreno wrote:
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1275,8 +1275,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
>  	       + nla_total_size(IFALIASZ) /* IFLA_IFALIAS */
>  	       + nla_total_size(IFNAMSIZ) /* IFLA_QDISC */
>  	       + nla_total_size_64bit(sizeof(struct rtnl_link_ifmap))
> -	       + nla_total_size(sizeof(struct rtnl_link_stats))
> -	       + nla_total_size_64bit(sizeof(struct rtnl_link_stats64))
> +	       + ((ext_filter_mask & RTEXT_FILTER_SKIP_STATS) ? 0 :
> +		  (nla_total_size(sizeof(struct rtnl_link_stats)) +
> +		   nla_total_size_64bit(sizeof(struct rtnl_link_stats64))))
>  	       + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
>  	       + nla_total_size(MAX_ADDR_LEN) /* IFLA_BROADCAST */
>  	       + nla_total_size(4) /* IFLA_TXQLEN */

Forgive me but now I'm gonna nit pick ;)
Please break this out into a proper if condition.
It's quite hard to read.

	size_t size;

	size = NLMSG_ALIGN(sizeof(struct ifinfomsg))
		+ /* .. litany .. */

	if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS))
		size += nla_total_size(sizeof(struct rtnl_link_stats)) +
			nla_total_size_64bit(sizeof(struct rtnl_link_stats64));

	return size;
-- 
pw-bot: cr

      parent reply	other threads:[~2025-10-31  1:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29  8:01 [PATCH net-next v2] rtnetlink: honor RTEXT_FILTER_SKIP_STATS in IFLA_STATS Adrian Moreno
2025-10-29  9:01 ` Toke Høiland-Jørgensen
2025-10-29  9:10 ` Nicolas Dichtel
2025-10-31  1:20 ` Jakub Kicinski [this message]

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=20251030182057.59731b84@kernel.org \
    --to=kuba@kernel.org \
    --cc=amorenoz@redhat.com \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shaw.leon@gmail.com \
    --cc=toke@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).