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-next>] [day] [month] [year] [list]
Message-Id: <20230711095323.121131-1-arkadiusz.kubalewski@intel.com>
Date:   Tue, 11 Jul 2023 11:53:23 +0200
From:   Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>
To:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        kuba@...nel.org, davem@...emloft.net, pabeni@...hat.com,
        edumazet@...gle.com, chuck.lever@...cle.com
Cc:     Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>
Subject: [PATCH net-next] tools: ynl-gen: fix parse multi-attr enum attribute

When attribute is enum type and marked as multi-attr, the netlink respond
is not parsed, fails with stack trace:
File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 600, in dump
  return self._op(method, vals, dump=True)
File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 586, in _op
  rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name)
File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 453, in _decode
  self._decode_enum(rsp, attr_spec)
File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 410, in _decode_enum
  value = enum.entries_by_val[raw - i].name
TypeError: unsupported operand type(s) for -: 'list' and 'int'
error: 1

Allow succesfull parse of multi-attr enums by decoding and assigning their
names into response in the _decode_enum(..) function.

Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>
---
 tools/net/ynl/lib/ynl.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 3b343d6cbbc0..553d82dd6382 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -407,7 +407,14 @@ class YnlFamily(SpecFamily):
                 raw >>= 1
                 i += 1
         else:
-            value = enum.entries_by_val[raw - i].name
+            if attr_spec.is_multi:
+                for index in range(len(raw)):
+                    if (type(raw[index]) == int):
+                        enum_name = enum.entries_by_val[raw[index] - i].name
+                        rsp[attr_spec['name']][index] = enum_name
+                return
+            else:
+                value = enum.entries_by_val[raw - i].name
         rsp[attr_spec['name']] = value
 
     def _decode_binary(self, attr, attr_spec):
-- 
2.37.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ