Re: [PATCH net-next v2] rtnetlink: honor RTEXT_FILTER_SKIP_STATS in IFLA_STATS
From: Adrián Moreno
Date: Mon Nov 03 2025 - 10:41:34 EST
On Thu, Oct 30, 2025 at 06:20:57PM -0700, Jakub Kicinski wrote:
> 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;
Sure, I'll send V3.
> --
> pw-bot: cr
>