public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netdev@vger.kernel.org, petrm@nvidia.com, horms@kernel.org,
	pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, dsahern@kernel.org, kees@kernel.org,
	Yiming Qian <yimingqian591@gmail.com>
Subject: Re: [PATCH 2/2 net v2] ipv4: nexthop: allocate skb dynamically in rtm_get_nexthop()
Date: Wed, 1 Apr 2026 16:02:57 +0300	[thread overview]
Message-ID: <20260401130257.GB1808730@shredder> (raw)
In-Reply-To: <20260401081741.4273-2-fmancera@suse.de>

On Wed, Apr 01, 2026 at 10:17:41AM +0200, Fernando Fernandez Mancera wrote:
> -static size_t nh_nlmsg_size_grp(struct nexthop *nh)
> +static size_t nh_nlmsg_size_grp(struct nexthop *nh, u32 op_flags)
>  {
>  	struct nh_group *nhg = rtnl_dereference(nh->nh_grp);
>  	size_t sz = sizeof(struct nexthop_grp) * nhg->num_nh;
> @@ -1013,6 +1013,21 @@ static size_t nh_nlmsg_size_grp(struct nexthop *nh)
>  	if (nhg->resilient)
>  		tot += nh_nlmsg_size_grp_res(nhg);
>  
> +	if (op_flags & NHA_OP_FLAG_DUMP_STATS) {
> +		tot += nla_total_size(0) +	  /* NHA_GROUP_STATS */
> +		       nla_total_size(4);	  /* NHA_HW_STATS_ENABLE */
> +		tot += nhg->num_nh *
> +		       (nla_total_size(0) +	  /* NHA_GROUP_STATS_ENTRY */
> +			nla_total_size(4) +	  /* NHA_GROUP_STATS_ENTRY_ID */
> +			nla_total_size_64bit(8)); /* NHA_GROUP_STATS_ENTRY_PACKETS */
> +
> +		if (op_flags & NHA_OP_FLAG_DUMP_HW_STATS) {
> +			tot += nhg->num_nh *
> +			       nla_total_size_64bit(8); /* NHA_GROUP_STATS_ENTRY_PACKETS_HW */
> +			tot += nla_total_size(4);	/* NHA_HW_STATS_USED */
> +		}
> +	}
> +

This looks correct

>  	return tot;
>  }
>  
> @@ -1047,14 +1062,14 @@ static size_t nh_nlmsg_size_single(struct nexthop *nh)
>  	return sz;
>  }
>  
> -static size_t nh_nlmsg_size(struct nexthop *nh)
> +static size_t nh_nlmsg_size(struct nexthop *nh, u32 op_flags)
>  {
>  	size_t sz = NLMSG_ALIGN(sizeof(struct nhmsg));
>  
>  	sz += nla_total_size(4); /* NHA_ID */
>  
>  	if (nh->is_group)
> -		sz += nh_nlmsg_size_grp(nh) +
> +		sz += nh_nlmsg_size_grp(nh, op_flags) +
>  		      nla_total_size(4) +	/* NHA_OP_FLAGS */
>  		      0;

But the AI review [1] also mentions missing accounting for NHA_FDB which
seems like a legit issue (even if we can't currently trigger it).

In the single nexthop case we have:

sz = nla_total_size(4);  /* NHA_OIF */

Which covers NHA_FDB since it's mutually exclusive with NHA_OIF.

[1] https://sashiko.dev/#/patchset/20260401081741.4273-1-fmancera%40suse.de

  parent reply	other threads:[~2026-04-01 13:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  8:17 [PATCH 1/2 net v2] ipv4: nexthop: avoid duplicate NHA_HW_STATS_ENABLE on nexthop group dump Fernando Fernandez Mancera
2026-04-01  8:17 ` [PATCH 2/2 net v2] ipv4: nexthop: allocate skb dynamically in rtm_get_nexthop() Fernando Fernandez Mancera
2026-04-01  8:59   ` Eric Dumazet
2026-04-01 13:02   ` Ido Schimmel [this message]
2026-04-01 13:24     ` Fernando Fernandez Mancera
2026-04-01 14:50   ` Fernando Fernandez Mancera
2026-04-02  0:28     ` Jakub Kicinski
2026-04-01  8:53 ` [PATCH 1/2 net v2] ipv4: nexthop: avoid duplicate NHA_HW_STATS_ENABLE on nexthop group dump Eric Dumazet
2026-04-01 12:50 ` Ido Schimmel

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=20260401130257.GB1808730@shredder \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fmancera@suse.de \
    --cc=horms@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=yimingqian591@gmail.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