[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230823114202.5862-9-donald.hunter@gmail.com>
Date: Wed, 23 Aug 2023 12:41:57 +0100
From: Donald Hunter <donald.hunter@...il.com>
To: netdev@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
linux-doc@...r.kernel.org,
Stanislav Fomichev <sdf@...gle.com>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>
Cc: donald.hunter@...hat.com,
Donald Hunter <donald.hunter@...il.com>
Subject: [PATCH net-next v4 08/12] tools/net/ynl: Implement nlattr array-nest decoding in ynl
Add support for the 'array-nest' attribute type that is used by several
netlink-raw families.
Signed-off-by: Donald Hunter <donald.hunter@...il.com>
Reviewed-by: Jakub Kicinski <kuba@...nel.org>
---
tools/net/ynl/lib/ynl.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 4fa4416edd58..b44174f1fa33 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -490,6 +490,17 @@ class YnlFamily(SpecFamily):
decoded = NlAttr.formatted_string(decoded, attr_spec.display_hint)
return decoded
+ def _decode_array_nest(self, attr, attr_spec):
+ decoded = []
+ offset = 0
+ while offset < len(attr.raw):
+ item = NlAttr(attr.raw, offset)
+ offset += item.full_len
+
+ subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
+ decoded.append({ item.type: subattrs })
+ return decoded
+
def _decode(self, attrs, space):
attr_space = self.attr_sets[space]
rsp = dict()
@@ -509,6 +520,8 @@ class YnlFamily(SpecFamily):
decoded = True
elif attr_spec["type"] in NlAttr.type_formats:
decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
+ elif attr_spec["type"] == 'array-nest':
+ decoded = self._decode_array_nest(attr, attr_spec)
else:
raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}')
--
2.41.0
Powered by blists - more mailing lists