public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
To: Sabrina Dubroca <sd@queasysnail.net>, netdev@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
	Loic Poulain <loic.poulain@linaro.org>
Subject: Re: [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
Date: Thu, 19 Mar 2026 08:59:47 +0200	[thread overview]
Message-ID: <F93F0AB8-E659-412B-AE27-83488A711490@gmail.com> (raw)
In-Reply-To: <c8acbb1f4f3651f50fc4f5ddee234f1ea6769588.1773829376.git.sd@queasysnail.net>

On March 18, 2026 12:45:52 PM, Sabrina Dubroca <sd@queasysnail.net> wrote:
>Commit 00e77ed8e64d ("rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME")
>added those attributes to rtnl_fill_ifinfo, but forgot to extend
>if_nlmsg_size.

Nice catch! Please find an implementation question below.

>Fixes: 00e77ed8e64d ("rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME")
>Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
>---
> net/core/rtnetlink.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
>diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>index dad4b1054955..a116362f5f32 100644
>--- a/net/core/rtnetlink.c
>+++ b/net/core/rtnetlink.c
>@@ -1267,6 +1267,21 @@ static size_t rtnl_dpll_pin_size(const struct net_device *dev)
> 	return size;
> }
> 
>+static size_t rtnl_dev_parent_size(const struct net_device *dev)
>+{
>+	size_t size = 0;
>+
>+	/* IFLA_PARENT_DEV_NAME */
>+	if (dev->dev.parent)
>+		size += strlen(dev_name(dev->dev.parent)) + 1;

Shall we use nla_total_size() to account alignment?

>+	/* IFLA_PARENT_DEV_BUS_NAME */
>+	if (dev->dev.parent && dev->dev.parent->bus)
>+		size += strlen(dev->dev.parent->bus->name) + 1;
>+
>+	return size;
>+}
>+
> static noinline size_t if_nlmsg_size(const struct net_device *dev,
> 				     u32 ext_filter_mask)
> {
>@@ -1328,6 +1343,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
> 	       + nla_total_size(8)  /* IFLA_MAX_PACING_OFFLOAD_HORIZON */
> 	       + nla_total_size(2)  /* IFLA_HEADROOM */
> 	       + nla_total_size(2)  /* IFLA_TAILROOM */
>+	       + rtnl_dev_parent_size(dev)
> 	       + 0;
> 
> 	if (!(ext_filter_mask & RTEXT_FILTER_SKIP_STATS))

--
Sergey
Hi Sabrina,

  reply	other threads:[~2026-03-19  6:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 10:45 [PATCH net 0/2] rtnetlink: add missing attributes in if_nlmsg_size Sabrina Dubroca
2026-03-18 10:45 ` [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} " Sabrina Dubroca
2026-03-19  6:59   ` Sergey Ryazanov [this message]
2026-03-19  9:31     ` Sabrina Dubroca
2026-03-19  7:07   ` Sergey Ryazanov
2026-03-18 10:45 ` [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND " Sabrina Dubroca
2026-03-18 11:24   ` Jiri Pirko

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=F93F0AB8-E659-412B-AE27-83488A711490@gmail.com \
    --to=ryazanov.s.a@gmail.com \
    --cc=johannes.berg@intel.com \
    --cc=loic.poulain@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /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