diff options
author | Donald Hunter <donald.hunter@gmail.com> | 2024-03-06 23:10:44 +0000 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-03-07 20:28:32 -0800 |
commit | b6e6a76dec330dc0c3ed3149acc2669f3ebfb3cb (patch) | |
tree | 4954b5a2510463759dd80d0ec0614685f58b3cfb /tools/net | |
parent | 6fe7de5e9c08dd6838149a50e468bc8f94e4fdbe (diff) | |
download | linux-b6e6a76dec330dc0c3ed3149acc2669f3ebfb3cb.tar.gz linux-b6e6a76dec330dc0c3ed3149acc2669f3ebfb3cb.tar.bz2 linux-b6e6a76dec330dc0c3ed3149acc2669f3ebfb3cb.zip |
tools/net/ynl: Add nest-type-value decoding
The nlctrl genetlink-legacy family uses nest-type-value encoding as
described in Documentation/userspace-api/netlink/genetlink-legacy.rst
Add nest-type-value decoding to ynl.
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20240306231046.97158-5-donald.hunter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rw-r--r-- | tools/net/ynl/lib/ynl.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index b810a478a304..2d7fdd903d9e 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -595,6 +595,16 @@ class YnlFamily(SpecFamily): decoded.append({ item.type: subattrs }) return decoded + def _decode_nest_type_value(self, attr, attr_spec): + decoded = {} + value = attr + for name in attr_spec['type-value']: + value = NlAttr(value.raw, 0) + decoded[name] = value.type + subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes']) + decoded.update(subattrs) + return decoded + def _decode_unknown(self, attr): if attr.is_nest: return self._decode(NlAttrs(attr.raw), None) @@ -686,6 +696,8 @@ class YnlFamily(SpecFamily): decoded = {"value": value, "selector": selector} elif attr_spec["type"] == 'sub-message': decoded = self._decode_sub_msg(attr, attr_spec, search_attrs) + elif attr_spec["type"] == 'nest-type-value': + decoded = self._decode_nest_type_value(attr, attr_spec) else: if not self.process_unknown: raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}') |