netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes
@ 2024-12-13 13:07 Donald Hunter
  2024-12-14  1:47 ` Jakub Kicinski
  2024-12-15 21:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Donald Hunter @ 2024-12-13 13:07 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman
  Cc: donald.hunter, Donald Hunter

Use the correct attribute space for sub-message key lookup in nested
attributes when adding attributes. This fixes rt_link where the "kind"
key and "data" sub-message are nested attributes in "linkinfo".

For example:

./tools/net/ynl/cli.py \
    --create \
    --spec Documentation/netlink/specs/rt_link.yaml \
    --do newlink \
    --json '{"link": 99,
             "linkinfo": { "kind": "vlan", "data": {"id": 4 } }
             }'

Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
 tools/net/ynl/lib/ynl.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 01ec01a90e76..eea29359a899 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -556,10 +556,10 @@ class YnlFamily(SpecFamily):
         if attr["type"] == 'nest':
             nl_type |= Netlink.NLA_F_NESTED
             attr_payload = b''
-            sub_attrs = SpaceAttrs(self.attr_sets[space], value, search_attrs)
+            sub_space = attr['nested-attributes']
+            sub_attrs = SpaceAttrs(self.attr_sets[sub_space], value, search_attrs)
             for subname, subvalue in value.items():
-                attr_payload += self._add_attr(attr['nested-attributes'],
-                                               subname, subvalue, sub_attrs)
+                attr_payload += self._add_attr(sub_space, subname, subvalue, sub_attrs)
         elif attr["type"] == 'flag':
             if not value:
                 # If value is absent or false then skip attribute creation.
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes
  2024-12-13 13:07 [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes Donald Hunter
@ 2024-12-14  1:47 ` Jakub Kicinski
  2024-12-15 21:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-12-14  1:47 UTC (permalink / raw)
  To: Donald Hunter
  Cc: netdev, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
	donald.hunter

On Fri, 13 Dec 2024 13:07:11 +0000 Donald Hunter wrote:
> Use the correct attribute space for sub-message key lookup in nested
> attributes when adding attributes. This fixes rt_link where the "kind"
> key and "data" sub-message are nested attributes in "linkinfo".
> 
> For example:
> 
> ./tools/net/ynl/cli.py \
>     --create \
>     --spec Documentation/netlink/specs/rt_link.yaml \
>     --do newlink \
>     --json '{"link": 99,
>              "linkinfo": { "kind": "vlan", "data": {"id": 4 } }
>              }'

Let's take it as a fix into net (no need to repost):

Fixes: ab463c4342d1 ("tools/net/ynl: Add support for encoding sub-messages")
Reviewed-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes
  2024-12-13 13:07 [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes Donald Hunter
  2024-12-14  1:47 ` Jakub Kicinski
@ 2024-12-15 21:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-15 21:40 UTC (permalink / raw)
  To: Donald Hunter; +Cc: netdev, kuba, davem, edumazet, pabeni, horms, donald.hunter

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 Dec 2024 13:07:11 +0000 you wrote:
> Use the correct attribute space for sub-message key lookup in nested
> attributes when adding attributes. This fixes rt_link where the "kind"
> key and "data" sub-message are nested attributes in "linkinfo".
> 
> For example:
> 
> ./tools/net/ynl/cli.py \
>     --create \
>     --spec Documentation/netlink/specs/rt_link.yaml \
>     --do newlink \
>     --json '{"link": 99,
>              "linkinfo": { "kind": "vlan", "data": {"id": 4 } }
>              }'
> 
> [...]

Here is the summary with links:
  - [net-next,v1] tools/net/ynl: fix sub-message key lookup for nested attributes
    https://git.kernel.org/netdev/net/c/663ad7481f06

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-15 21:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 13:07 [PATCH net-next v1] tools/net/ynl: fix sub-message key lookup for nested attributes Donald Hunter
2024-12-14  1:47 ` Jakub Kicinski
2024-12-15 21:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).