Skip to content

Commit 663ad74

Browse files
donaldhkuba-moo
authored andcommitted
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 } } }' Signed-off-by: Donald Hunter <[email protected]> Fixes: ab463c4 ("tools/net/ynl: Add support for encoding sub-messages") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ee76746 commit 663ad74

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/net/ynl/lib/ynl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,10 @@ def _add_attr(self, space, name, value, search_attrs):
556556
if attr["type"] == 'nest':
557557
nl_type |= Netlink.NLA_F_NESTED
558558
attr_payload = b''
559-
sub_attrs = SpaceAttrs(self.attr_sets[space], value, search_attrs)
559+
sub_space = attr['nested-attributes']
560+
sub_attrs = SpaceAttrs(self.attr_sets[sub_space], value, search_attrs)
560561
for subname, subvalue in value.items():
561-
attr_payload += self._add_attr(attr['nested-attributes'],
562-
subname, subvalue, sub_attrs)
562+
attr_payload += self._add_attr(sub_space, subname, subvalue, sub_attrs)
563563
elif attr["type"] == 'flag':
564564
if not value:
565565
# If value is absent or false then skip attribute creation.

0 commit comments

Comments
 (0)