lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <803d08dd985ff7a97cb61e3156200a0c2f27536b.1706112190.git.alessandromarcolini99@gmail.com>
Date: Wed, 24 Jan 2024 17:34:38 +0100
From: Alessandro Marcolini <alessandromarcolini99@...il.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	donald.hunter@...il.com,
	sdf@...gle.com,
	chuck.lever@...cle.com,
	lorenzo@...nel.org,
	jacob.e.keller@...el.com,
	jiri@...nulli.us
Cc: netdev@...r.kernel.org,
	Alessandro Marcolini <alessandromarcolini99@...il.com>
Subject: [PATCH net-next 3/3] tools: ynl: add support for encoding multi-attr

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@...il.com>
---
 tools/net/ynl/lib/ynl.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index dff2c042e6c3..bd01b1016fef 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -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':
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ