summaryrefslogtreecommitdiff
path: root/tools/net
diff options
context:
space:
mode:
authorMichal Michalik <michal.michalik@intel.com>2023-03-24 18:52:58 +0100
committerDavid S. Miller <davem@davemloft.net>2023-03-27 08:53:03 +0100
commitdd3a7d58dcc2434632bed31683ff134b7d6d1da4 (patch)
tree6133dfae2e223565dd0adb35748ac9e8449950eb /tools/net
parentfe5b9907ba995946c30c90111886b856ff86d362 (diff)
tools: ynl: Add missing types to encode/decode
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> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/net')
-rw-r--r--tools/net/ynl/lib/ynl.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 98ecfdb44a83..7eaf066b115e 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':