@@ -427,10 +427,18 @@ class YnlFamily(SpecFamily):
if attr["type"] == 'nest':
nl_type |= Netlink.NLA_F_NESTED
attr_payload = b''
- subvals = ChainMap(value, vals)
- for subname, subvalue in value.items():
- attr_payload += self._add_attr(attr['nested-attributes'],
- subname, subvalue, subvals)
+ nested_attrs = self.attr_sets[attr['nested-attributes']].attrs
+ if any(a.is_multi for a in nested_attrs.values()) and isinstance(value, list):
+ for item in value:
+ subvals = ChainMap(item, vals)
+ for subname, subvalue in item.items():
+ attr_payload += self._add_attr(attr['nested-attributes'],
+ subname, subvalue, subvals)
+ else:
+ subvals = ChainMap(value, vals)
+ for subname, subvalue in value.items():
+ attr_payload += self._add_attr(attr['nested-attributes'],
+ subname, subvalue, subvals)
elif attr["type"] == 'flag':
attr_payload = b''
elif attr["type"] == 'string':
Multi-attr elements could not be encoded because of missing logic in the ynl code. Enable encoding of these attributes by checking if the nest attribute in the spec contains multi-attr attributes and if the value to be processed is a list. This has been tested both with the taprio and ets qdisc which contain this kind of attributes. Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com> --- tools/net/ynl/lib/ynl.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)