netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3] tools: ynl: Add missing types to encode/decode
@ 2023-03-23 17:51 Michal Michalik
  2023-03-24  4:54 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Michalik @ 2023-03-23 17:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, Michal Michalik

While testing the tool I noticed we miss the u16 type on payload create.
On the code inspection it turned out we miss also u8 and u64 - add them.

We also miss the decoding of u16 despite the fact `NlAttr` class
supports it - add it.

Fixes: e4b48ed460d3 ("tools: ynl: add a completely generic client")
Signed-off-by: Michal Michalik <michal.michalik@intel.com>
--
v3: change tree `net` -> `net-next`
v2: add a `Fixes:` tag to the commit message
---
 tools/net/ynl/lib/ynl.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 90764a8..788f130 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -334,8 +334,14 @@ class YnlFamily(SpecFamily):
                 attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
         elif attr["type"] == 'flag':
             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':
@@ -371,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: fcb3a4653bc5fb0525d957db0cc8b413252029f8

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next v3] tools: ynl: Add missing types to encode/decode
  2023-03-23 17:51 [PATCH net-next v3] tools: ynl: Add missing types to encode/decode Michal Michalik
@ 2023-03-24  4:54 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2023-03-24  4:54 UTC (permalink / raw)
  To: Michal Michalik; +Cc: netdev, davem, pabeni, edumazet

On Thu, 23 Mar 2023 18:51:29 +0100 Michal Michalik wrote:
> While testing the tool I noticed we miss the u16 type on payload create.
> On the code inspection it turned out we miss also u8 and u64 - add them.
> 
> We also miss the decoding of u16 despite the fact `NlAttr` class
> supports it - add it.
> 
> Fixes: e4b48ed460d3 ("tools: ynl: add a completely generic client")

No fixes tag, no in-tree spec needs these today, right?
Please rebase, too, Jiri sent in just the u8 addition in the meantime.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-24  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23 17:51 [PATCH net-next v3] tools: ynl: Add missing types to encode/decode Michal Michalik
2023-03-24  4:54 ` Jakub Kicinski

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).