* [PATCH net 0/2] rtnetlink: add missing attributes in if_nlmsg_size
@ 2026-03-18 10:45 Sabrina Dubroca
2026-03-18 10:45 ` [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} " Sabrina Dubroca
2026-03-18 10:45 ` [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND " Sabrina Dubroca
0 siblings, 2 replies; 7+ messages in thread
From: Sabrina Dubroca @ 2026-03-18 10:45 UTC (permalink / raw)
To: netdev; +Cc: Sabrina Dubroca
Once again we have some attributes added by rtnl_fill_ifinfo() that
aren't counted in if_nlmsg_size().
Sabrina Dubroca (2):
rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
rtnetlink: count IFLA_INFO_SLAVE_KIND in if_nlmsg_size
net/core/rtnetlink.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
--
2.51.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
2026-03-18 10:45 [PATCH net 0/2] rtnetlink: add missing attributes in if_nlmsg_size Sabrina Dubroca
@ 2026-03-18 10:45 ` Sabrina Dubroca
2026-03-19 6:59 ` Sergey Ryazanov
2026-03-19 7:07 ` Sergey Ryazanov
2026-03-18 10:45 ` [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND " Sabrina Dubroca
1 sibling, 2 replies; 7+ messages in thread
From: Sabrina Dubroca @ 2026-03-18 10:45 UTC (permalink / raw)
To: netdev; +Cc: Sabrina Dubroca, Johannes Berg, Loic Poulain, Sergey Ryazanov
Commit 00e77ed8e64d ("rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME")
added those attributes to rtnl_fill_ifinfo, but forgot to extend
if_nlmsg_size.
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;
+
+ /* 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))
--
2.51.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND in if_nlmsg_size
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-18 10:45 ` Sabrina Dubroca
2026-03-18 11:24 ` Jiri Pirko
1 sibling, 1 reply; 7+ messages in thread
From: Sabrina Dubroca @ 2026-03-18 10:45 UTC (permalink / raw)
To: netdev; +Cc: Sabrina Dubroca, Jiri Pirko
rtnl_link_get_slave_info_data_size counts IFLA_INFO_SLAVE_DATA, but
rtnl_link_slave_info_fill adds both IFLA_INFO_SLAVE_DATA and
IFLA_INFO_SLAVE_KIND.
Fixes: ba7d49b1f0f8 ("rtnetlink: provide api for getting and setting slave info")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
net/core/rtnetlink.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a116362f5f32..cebc00d02fbb 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -707,11 +707,14 @@ static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev)
goto out;
ops = master_dev->rtnl_link_ops;
- if (!ops || !ops->get_slave_size)
+ if (!ops)
+ goto out;
+ size += nla_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_SLAVE_KIND */
+ if (!ops->get_slave_size)
goto out;
/* IFLA_INFO_SLAVE_DATA + nested data */
- size = nla_total_size(sizeof(struct nlattr)) +
- ops->get_slave_size(master_dev, dev);
+ size += nla_total_size(sizeof(struct nlattr)) +
+ ops->get_slave_size(master_dev, dev);
out:
rcu_read_unlock();
--
2.51.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND in if_nlmsg_size
2026-03-18 10:45 ` [PATCH net 2/2] rtnetlink: count IFLA_INFO_SLAVE_KIND " Sabrina Dubroca
@ 2026-03-18 11:24 ` Jiri Pirko
0 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2026-03-18 11:24 UTC (permalink / raw)
To: Sabrina Dubroca; +Cc: netdev
Wed, Mar 18, 2026 at 11:45:53AM +0100, sd@queasysnail.net wrote:
>rtnl_link_get_slave_info_data_size counts IFLA_INFO_SLAVE_DATA, but
>rtnl_link_slave_info_fill adds both IFLA_INFO_SLAVE_DATA and
>IFLA_INFO_SLAVE_KIND.
>
>Fixes: ba7d49b1f0f8 ("rtnetlink: provide api for getting and setting slave info")
>Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Thanks for the fix!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
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
2026-03-19 9:31 ` Sabrina Dubroca
2026-03-19 7:07 ` Sergey Ryazanov
1 sibling, 1 reply; 7+ messages in thread
From: Sergey Ryazanov @ 2026-03-19 6:59 UTC (permalink / raw)
To: Sabrina Dubroca, netdev; +Cc: Johannes Berg, Loic Poulain
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,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
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
@ 2026-03-19 7:07 ` Sergey Ryazanov
1 sibling, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2026-03-19 7:07 UTC (permalink / raw)
To: Sabrina Dubroca, netdev; +Cc: Johannes Berg, loic.poulain
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,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] rtnetlink: count IFLA_PARENT_DEV_{NAME,BUS_NAME} in if_nlmsg_size
2026-03-19 6:59 ` Sergey Ryazanov
@ 2026-03-19 9:31 ` Sabrina Dubroca
0 siblings, 0 replies; 7+ messages in thread
From: Sabrina Dubroca @ 2026-03-19 9:31 UTC (permalink / raw)
To: Sergey Ryazanov; +Cc: netdev, Johannes Berg, Loic Poulain
2026-03-19, 08:59:47 +0200, Sergey Ryazanov wrote:
> 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?
Oops, thanks for catching my brainfart (it's not alignment but the
attribute header). I'll send a v2 later today.
--
Sabrina
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-19 9:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox