* Netlink specs, help dealing with nested array
@ 2024-06-21 14:15 Kory Maincent
2024-06-21 15:14 ` Donald Hunter
2024-06-21 15:19 ` Jakub Kicinski
0 siblings, 2 replies; 5+ messages in thread
From: Kory Maincent @ 2024-06-21 14:15 UTC (permalink / raw)
To: Jakub Kicinski, netdev, Donald Hunter
Hello Jakub, Donald or other ynl experts,
I have an issue dealing with a nested array.
Here is my current netlink spec and ethtool patches:
https://termbin.com/gbyx
https://termbin.com/b325
Here is the error I got:
https://termbin.com/c7b1
I am trying to investigate what goes wrong with ynl but I still don't know.
If someone have an idea of what is going wrong with ynl or my specs it would be
lovely!
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netlink specs, help dealing with nested array
2024-06-21 14:15 Netlink specs, help dealing with nested array Kory Maincent
@ 2024-06-21 15:14 ` Donald Hunter
2024-06-21 15:19 ` Jakub Kicinski
1 sibling, 0 replies; 5+ messages in thread
From: Donald Hunter @ 2024-06-21 15:14 UTC (permalink / raw)
To: Kory Maincent; +Cc: Jakub Kicinski, netdev
On Fri, 21 Jun 2024 at 15:15, Kory Maincent <kory.maincent@bootlin.com> wrote:
>
> Hello Jakub, Donald or other ynl experts,
>
> I have an issue dealing with a nested array.
>
> Here is my current netlink spec and ethtool patches:
> https://termbin.com/gbyx
The yaml spec looks okay to me.
> https://termbin.com/b325
Have a look at ctrl_fill_info in net/netlink/genetlink.c for an
example nested array.
https://elixir.bootlin.com/linux/latest/source/net/netlink/genetlink.c#L1247
I think what you need is to move this outside the loop:
nla_nest_start(skb, ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES);
and add nla_nest_start(skb, index) inside the loop.
> Here is the error I got:
> https://termbin.com/c7b1
>
> I am trying to investigate what goes wrong with ynl but I still don't know.
> If someone have an idea of what is going wrong with ynl or my specs it would be
> lovely!
>
> Regards,
> --
> Köry Maincent, Bootlin
> Embedded Linux and kernel engineering
> https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netlink specs, help dealing with nested array
2024-06-21 14:15 Netlink specs, help dealing with nested array Kory Maincent
2024-06-21 15:14 ` Donald Hunter
@ 2024-06-21 15:19 ` Jakub Kicinski
2024-06-21 15:27 ` Donald Hunter
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2024-06-21 15:19 UTC (permalink / raw)
To: Kory Maincent; +Cc: netdev, Donald Hunter
On Fri, 21 Jun 2024 16:15:43 +0200 Kory Maincent wrote:
> Hello Jakub, Donald or other ynl experts,
>
> I have an issue dealing with a nested array.
>
> Here is my current netlink spec and ethtool patches:
> https://termbin.com/gbyx
> https://termbin.com/b325
>
> Here is the error I got:
> https://termbin.com/c7b1
>
> I am trying to investigate what goes wrong with ynl but I still don't know.
> If someone have an idea of what is going wrong with ynl or my specs it would be
> lovely!
You're (correctly) formatting your data as a basic multi-attr.
Instead of:
+ name: c33-pse-pw-limit-ranges
+ name-prefix: ethtool-a-
+ type: indexed-array
+ sub-type: nest
+ nested-attributes: c33-pse-pw-limit
use:
+ name: c33-pse-pw-limit-ranges
+ name-prefix: ethtool-a-
+ type: nest
+ multi-attr: true
+ nested-attributes: c33-pse-pw-limit
The indexed array is described here:
https://docs.kernel.org/next/userspace-api/netlink/genetlink-legacy.html#indexed-array
it has an extra layer of nesting, which uses the index in the array
as the type of the attribute.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netlink specs, help dealing with nested array
2024-06-21 15:19 ` Jakub Kicinski
@ 2024-06-21 15:27 ` Donald Hunter
2024-06-21 15:56 ` Kory Maincent
0 siblings, 1 reply; 5+ messages in thread
From: Donald Hunter @ 2024-06-21 15:27 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Kory Maincent, netdev
On Fri, 21 Jun 2024 at 16:19, Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri, 21 Jun 2024 16:15:43 +0200 Kory Maincent wrote:
> > Hello Jakub, Donald or other ynl experts,
> >
> > I have an issue dealing with a nested array.
> >
> > Here is my current netlink spec and ethtool patches:
> > https://termbin.com/gbyx
> > https://termbin.com/b325
> >
> > Here is the error I got:
> > https://termbin.com/c7b1
> >
> > I am trying to investigate what goes wrong with ynl but I still don't know.
> > If someone have an idea of what is going wrong with ynl or my specs it would be
> > lovely!
>
> You're (correctly) formatting your data as a basic multi-attr.
> Instead of:
>
> + name: c33-pse-pw-limit-ranges
> + name-prefix: ethtool-a-
> + type: indexed-array
> + sub-type: nest
> + nested-attributes: c33-pse-pw-limit
>
> use:
>
> + name: c33-pse-pw-limit-ranges
> + name-prefix: ethtool-a-
> + type: nest
> + multi-attr: true
> + nested-attributes: c33-pse-pw-limit
Ah yes, I was "fixing" things in the wrong direction. Sorry for the confusion.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Netlink specs, help dealing with nested array
2024-06-21 15:27 ` Donald Hunter
@ 2024-06-21 15:56 ` Kory Maincent
0 siblings, 0 replies; 5+ messages in thread
From: Kory Maincent @ 2024-06-21 15:56 UTC (permalink / raw)
To: Donald Hunter; +Cc: Jakub Kicinski, netdev
On Fri, 21 Jun 2024 16:27:57 +0100
Donald Hunter <donald.hunter@gmail.com> wrote:
> On Fri, 21 Jun 2024 at 16:19, Jakub Kicinski <kuba@kernel.org> wrote:
> [...]
> [...]
> >
> > You're (correctly) formatting your data as a basic multi-attr.
> > Instead of:
> >
> > + name: c33-pse-pw-limit-ranges
> > + name-prefix: ethtool-a-
> > + type: indexed-array
> > + sub-type: nest
> > + nested-attributes: c33-pse-pw-limit
> >
> > use:
> >
> > + name: c33-pse-pw-limit-ranges
> > + name-prefix: ethtool-a-
> > + type: nest
> > + multi-attr: true
> > + nested-attributes: c33-pse-pw-limit
>
> Ah yes, I was "fixing" things in the wrong direction. Sorry for the confusion.
Thanks Donald and Jakub!
It is working better with the right netlink specs.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-21 15:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21 14:15 Netlink specs, help dealing with nested array Kory Maincent
2024-06-21 15:14 ` Donald Hunter
2024-06-21 15:19 ` Jakub Kicinski
2024-06-21 15:27 ` Donald Hunter
2024-06-21 15:56 ` Kory Maincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox