From: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com,
edumazet@google.com, chuck.lever@oracle.com
Cc: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Subject: [PATCH net-next] tools: ynl-gen: fix parse multi-attr enum attribute
Date: Tue, 11 Jul 2023 11:53:23 +0200 [thread overview]
Message-ID: <20230711095323.121131-1-arkadiusz.kubalewski@intel.com> (raw)
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>
---
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
next reply other threads:[~2023-07-11 9:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 9:53 Arkadiusz Kubalewski [this message]
2023-07-12 3:59 ` Jakub Kicinski
2023-07-12 9:47 ` Kubalewski, Arkadiusz
2023-07-12 16:24 ` Jakub Kicinski
2023-07-13 9:22 ` Kubalewski, Arkadiusz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230711095323.121131-1-arkadiusz.kubalewski@intel.com \
--to=arkadiusz.kubalewski@intel.com \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®