From: Donald Hunter <donald.hunter@gmail.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Jiri Pirko <jiri@resnulli.us>,
Jacob Keller <jacob.e.keller@intel.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org
Cc: donald.hunter@redhat.com, Donald Hunter <donald.hunter@gmail.com>
Subject: [PATCH net-next v3 3/4] tools/net/ynl: Handle acks that use req_value
Date: Tue, 16 Apr 2024 20:32:14 +0100 [thread overview]
Message-ID: <20240416193215.8259-4-donald.hunter@gmail.com> (raw)
In-Reply-To: <20240416193215.8259-1-donald.hunter@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2024-04-16 19:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 19:32 [PATCH net-next v3 0/4] netlink: Add nftables spec w/ multi messages Donald Hunter
2024-04-16 19:32 ` [PATCH net-next v3 1/4] doc/netlink/specs: Add draft nftables spec Donald Hunter
2024-04-16 19:32 ` [PATCH net-next v3 2/4] tools/net/ynl: Add multi message support to ynl Donald Hunter
2024-04-16 19:32 ` Donald Hunter [this message]
2024-04-17 2:10 ` [PATCH net-next v3 3/4] tools/net/ynl: Handle acks that use req_value Jakub Kicinski
2024-04-17 12:51 ` Donald Hunter
2024-04-17 13:50 ` Jakub Kicinski
2024-04-16 19:32 ` [PATCH net-next v3 4/4] netfilter: nfnetlink: Handle ACK flags for batch messages Donald Hunter
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=20240416193215.8259-4-donald.hunter@gmail.com \
--to=donald.hunter@gmail.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=donald.hunter@redhat.com \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=jiri@resnulli.us \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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).