[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240129223458.52046-7-donald.hunter@gmail.com>
Date: Mon, 29 Jan 2024 22:34:51 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: netdev@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
linux-doc@...r.kernel.org,
Jacob Keller <jacob.e.keller@...el.com>,
Breno Leitao <leitao@...ian.org>,
Jiri Pirko <jiri@...nulli.us>,
Alessandro Marcolini <alessandromarcolini99@...il.com>
Cc: donald.hunter@...hat.com,
Donald Hunter <donald.hunter@...il.com>
Subject: [PATCH net-next v2 06/13] tools/net/ynl: Encode default values for binary blobs
Add support for defaulting binary byte arrays to all zeros as well as
defaulting scalar values to 0 when encoding input parameters.
Signed-off-by: Donald Hunter <donald.hunter@...il.com>
---
tools/net/ynl/lib/ynl.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index b063094e8a4b..d04435f26f89 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -742,12 +742,17 @@ class YnlFamily(SpecFamily):
members = self.consts[name].members
attr_payload = b''
for m in members:
- value = vals.pop(m.name) if m.name in vals else 0
+ value = vals.pop(m.name) if m.name in vals else None
if m.type == 'pad':
attr_payload += bytearray(m.len)
elif m.type == 'binary':
- attr_payload += bytes.fromhex(value)
+ if value is None:
+ attr_payload += bytearray(m.len)
+ else:
+ attr_payload += bytes.fromhex(value)
else:
+ if value is None:
+ value = 0
format = NlAttr.get_format(m.type, m.byte_order)
attr_payload += format.pack(value)
return attr_payload
--
2.42.0
Powered by blists - more mailing lists