[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240416193215.8259-4-donald.hunter@gmail.com>
Date: Tue, 16 Apr 2024 20:32:14 +0100
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>,
Jiri Pirko <jiri@...nulli.us>,
Jacob Keller <jacob.e.keller@...el.com>,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...filter.org>,
netfilter-devel@...r.kernel.org,
coreteam@...filter.org
Cc: donald.hunter@...hat.com,
Donald Hunter <donald.hunter@...il.com>
Subject: [PATCH net-next v3 3/4] tools/net/ynl: Handle acks that use req_value
The nfnetlink family uses the directional op model but errors get
reported using the request value instead of the reply value.
Add a method get_op_by_value that falls back to returning the request op
for directional ops.
Signed-off-by: Donald Hunter <donald.hunter@...il.com>
---
tools/net/ynl/lib/nlspec.py | 12 ++++++++++++
tools/net/ynl/lib/ynl.py | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index 6d08ab9e213f..04085bc6365e 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -567,6 +567,18 @@ class SpecFamily(SpecElement):
return op
return None
+ def get_op_by_value(self, value):
+ """
+ For a given operation value, look up operation spec. Search
+ by response value first then fall back to request value. This
+ is required for handling failure cases.
+ """
+ if value in self.rsp_by_value:
+ return self.rsp_by_value[value]
+ if self.msg_id_model == 'directional' and value in self.req_by_value:
+ return self.req_by_value[value]
+ return None
+
def resolve(self):
self.resolve_up(super())
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index a45e53ab0dd9..eb6c5475fb48 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -390,7 +390,7 @@ class NetlinkProtocol:
msg = self._decode(nl_msg)
fixed_header_size = 0
if ynl:
- op = ynl.rsp_by_value[msg.cmd()]
+ op = ynl.get_op_by_value(msg.cmd())
fixed_header_size = ynl._struct_size(op.fixed_header)
msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size)
return msg
--
2.44.0
Powered by blists - more mailing lists