diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 938703088306..872c76065f1b 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -261,6 +261,9 @@ properties:
struct:
description: Name of the struct type used for the attribute.
type: string
+ nest-depth:
+ description: Depth of nesting for an array-nest, defaults to 1.
+ type: integer
# End genetlink-legacy
# Make sure name-prefix does not appear in subsets (subsets inherit naming)diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index fbce52395b3b..50e8447f089a 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -161,6 +161,7 @@ class SpecAttr(SpecElement):
sub_message string, name of sub message type
selector string, name of attribute used to select
sub-message type
+ nest_depth integer, depth of array nesting
is_auto_scalar bool, attr is a variable-size scalar
"""@@ -178,6 +179,7 @@ class SpecAttr(SpecElement):
self.display_hint = yaml.get('display-hint')
self.sub_message = yaml.get('sub-message')
self.selector = yaml.get('selector')
+ self.nest_depth = yaml.get('nest-depth', 1)
self.is_auto_scalar = self.type == "sint" or self.type == "uint"
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 29262505a3f2..efceea9433f2 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -556,14 +556,17 @@ class YnlFamily(SpecFamily):
decoded = self._formatted_string(decoded, attr_spec.display_hint)
return decoded
- def _decode_array_nest(self, attr, attr_spec):
+ def _decode_array_nest(self, attr, attr_spec, depth):
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'])
+ if depth > 1:
+ subattrs = self._decode_array_nest(item, attr_spec, depth - 1)
+ else:
+ subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
decoded.append({ item.type: subattrs })
return decoded
@@ -649,7 +652,7 @@ class YnlFamily(SpecFamily):
if 'enum' in attr_spec:
decoded = self._decode_enum(decoded, attr_spec)
elif attr_spec["type"] == 'array-nest':
- decoded = self._decode_array_nest(attr, attr_spec)
+ decoded = self._decode_array_nest(attr, attr_spec, attr_spec.nest_depth)
elif attr_spec["type"] == 'bitfield32':
value, selector = struct.unpack("II", attr.raw)
if 'enum' in attr_spec:--
2.42.0