Skip to content

Commit 7e7ee48

Browse files
committed
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@intel.com>
1 parent 9a94d76 commit 7e7ee48

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/net/ynl/lib/ynl.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,14 @@ def _decode_enum(self, rsp, attr_spec):
407407
raw >>= 1
408408
i += 1
409409
else:
410-
value = enum.entries_by_val[raw - i].name
410+
if attr_spec.is_multi:
411+
for index in range(len(raw)):
412+
if (type(raw[index]) == int):
413+
enum_name = enum.entries_by_val[raw[index] - i].name
414+
rsp[attr_spec['name']][index] = enum_name
415+
return
416+
else:
417+
value = enum.entries_by_val[raw - i].name
411418
rsp[attr_spec['name']] = value
412419

413420
def _decode_binary(self, attr, attr_spec):

0 commit comments

Comments
 (0)