tools/net/ynl: fix sub-message key lookup for nested attributes
Subsystems (3)
Donald Hunter
maintainerPATCH 1/1 tools/net/ynl: fix sub-message key lookup for nested attributes
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 } }
}'--- tools/net/ynl/lib/ynl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/net/ynl/lib/ynl.py +3 -3
@@ -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.
Signature · 1 line
2.47.1
Quoted 6 lines · 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_linkwhere the "kind" key and "data" sub-message are nested attributes in "linkinfo".For example:
Quoted 7 lines
./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):
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 14 lines · 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_linkwhere 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 } } }'
Quoted 1 line
[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html