diff mbox series

[net-next,v1] tools/net/ynl: fix sub-message key lookup for nested attributes

Message ID 20241213130711.40267-1-donald.hunter@gmail.com (mailing list archive)
State Accepted
Commit 663ad7481f068057f6f692c5368c47150e855370
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1] tools/net/ynl: fix sub-message key lookup for nested attributes | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 0 (+23) this patch: 0 (+23)
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-15--09-00 (tests: 795)

Commit Message

Donald Hunter Dec. 13, 2024, 1:07 p.m. UTC
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(-)

Comments

Jakub Kicinski Dec. 14, 2024, 1:47 a.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org Dec. 15, 2024, 9:40 p.m. UTC | #2
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!
diff mbox series

Patch

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.