From: Michal Michalik <michal.michalik@intel.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, Michal Michalik <michal.michalik@intel.com>
Subject: [PATCH net-next v4] tools: ynl: Add missing types to encode/decode
Date: Fri, 24 Mar 2023 18:52:58 +0100 [thread overview]
Message-ID: <20230324175258.25145-1-michal.michalik@intel.com> (raw)
While testing the tool I noticed we miss the u16 type on payload create.
On the code inspection it turned out we miss also u64 - add them.
We also miss the decoding of u16 despite the fact `NlAttr` class
supports it - add it.
Signed-off-by: Michal Michalik <michal.michalik@intel.com>
--
v4:
- remove `Fixes:` tag since no code is using that now
- rebased to latest tree
v3: change tree `net` -> `net-next`
v2: add a `Fixes:` tag to the commit message
---
tools/net/ynl/lib/ynl.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index bcb798c..788f130 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -336,8 +336,12 @@ class YnlFamily(SpecFamily):
attr_payload = b''
elif attr["type"] == 'u8':
attr_payload = struct.pack("B", int(value))
+ elif attr["type"] == 'u16':
+ attr_payload = struct.pack("H", int(value))
elif attr["type"] == 'u32':
attr_payload = struct.pack("I", int(value))
+ elif attr["type"] == 'u64':
+ attr_payload = struct.pack("Q", int(value))
elif attr["type"] == 'string':
attr_payload = str(value).encode('ascii') + b'\x00'
elif attr["type"] == 'binary':
@@ -373,6 +377,8 @@ class YnlFamily(SpecFamily):
decoded = subdict
elif attr_spec['type'] == 'u8':
decoded = attr.as_u8()
+ elif attr_spec['type'] == 'u16':
+ decoded = attr.as_u16()
elif attr_spec['type'] == 'u32':
decoded = attr.as_u32()
elif attr_spec['type'] == 'u64':
--
2.9.5
base-commit: 323fe43cf9aef79159ba8937218a3f076bf505af
next reply other threads:[~2023-03-24 17:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 17:52 Michal Michalik [this message]
2023-03-24 22:31 ` [PATCH net-next v4] tools: ynl: Add missing types to encode/decode Jakub Kicinski
2023-03-27 8:00 ` patchwork-bot+netdevbpf
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=20230324175258.25145-1-michal.michalik@intel.com \
--to=michal.michalik@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@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;
as well as URLs for NNTP newsgroup(s).