* [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature
@ 2024-09-04 13:50 Arkadiusz Kubalewski
2024-09-04 17:21 ` Donald Hunter
2024-09-05 22:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Arkadiusz Kubalewski @ 2024-09-04 13:50 UTC (permalink / raw)
To: netdev
Cc: donald.hunter, kuba, davem, edumazet, pabeni, jiri,
jacob.e.keller, liuhangbin, linux-kernel, Arkadiusz Kubalewski
Execution of command:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml /
--subscribe "monitor" --sleep 10
fails with:
File "/repo/./tools/net/ynl/cli.py", line 109, in main
ynl.check_ntf()
File "/repo/tools/net/ynl/lib/ynl.py", line 924, in check_ntf
op = self.rsp_by_value[nl_msg.cmd()]
KeyError: 19
Parsing Generic Netlink notification messages performs lookup for op in
the message. The message was not yet decoded, and is not yet considered
GenlMsg, thus msg.cmd() returns Generic Netlink family id (19) instead of
proper notification command id (i.e.: DPLL_CMD_PIN_CHANGE_NTF=13).
Allow the op to be obtained within NetlinkProtocol.decode(..) itself if the
op was not passed to the decode function, thus allow parsing of Generic
Netlink notifications without causing the failure.
Suggested-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/netdev/m2le0n5xpn.fsf@gmail.com/
Fixes: 0a966d606c68 ("tools/net/ynl: Fix extack decoding for directional ops")
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
---
v2:
- use ynl.rsp_by_value[] within decode(..) instead of passing additional
argument from the caller function
---
tools/net/ynl/lib/ynl.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index d42c1d605969..c22c22bf2cb7 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -388,6 +388,8 @@ class NetlinkProtocol:
def decode(self, ynl, nl_msg, op):
msg = self._decode(nl_msg)
+ if op is None:
+ op = ynl.rsp_by_value[msg.cmd()]
fixed_header_size = ynl._struct_size(op.fixed_header)
msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size)
return msg
@@ -921,8 +923,7 @@ class YnlFamily(SpecFamily):
print("Netlink done while checking for ntf!?")
continue
- op = self.rsp_by_value[nl_msg.cmd()]
- decoded = self.nlproto.decode(self, nl_msg, op)
+ decoded = self.nlproto.decode(self, nl_msg, None)
if decoded.cmd() not in self.async_msg_ids:
print("Unexpected msg id done while checking for ntf", decoded)
continue
@@ -980,7 +981,7 @@ class YnlFamily(SpecFamily):
if nl_msg.extack:
self._decode_extack(req_msg, op, nl_msg.extack)
else:
- op = self.rsp_by_value[nl_msg.cmd()]
+ op = None
req_flags = []
if nl_msg.error:
--
2.38.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature
2024-09-04 13:50 [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature Arkadiusz Kubalewski
@ 2024-09-04 17:21 ` Donald Hunter
2024-09-05 22:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Donald Hunter @ 2024-09-04 17:21 UTC (permalink / raw)
To: Arkadiusz Kubalewski
Cc: netdev, kuba, davem, edumazet, pabeni, jiri, jacob.e.keller,
liuhangbin, linux-kernel
On Wed, 4 Sept 2024 at 14:55, Arkadiusz Kubalewski
<arkadiusz.kubalewski@intel.com> wrote:
>
> Execution of command:
> ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml /
> --subscribe "monitor" --sleep 10
> fails with:
> File "/repo/./tools/net/ynl/cli.py", line 109, in main
> ynl.check_ntf()
> File "/repo/tools/net/ynl/lib/ynl.py", line 924, in check_ntf
> op = self.rsp_by_value[nl_msg.cmd()]
> KeyError: 19
>
> Parsing Generic Netlink notification messages performs lookup for op in
> the message. The message was not yet decoded, and is not yet considered
> GenlMsg, thus msg.cmd() returns Generic Netlink family id (19) instead of
> proper notification command id (i.e.: DPLL_CMD_PIN_CHANGE_NTF=13).
>
> Allow the op to be obtained within NetlinkProtocol.decode(..) itself if the
> op was not passed to the decode function, thus allow parsing of Generic
> Netlink notifications without causing the failure.
>
> Suggested-by: Donald Hunter <donald.hunter@gmail.com>
> Link: https://lore.kernel.org/netdev/m2le0n5xpn.fsf@gmail.com/
> Fixes: 0a966d606c68 ("tools/net/ynl: Fix extack decoding for directional ops")
> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature
2024-09-04 13:50 [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature Arkadiusz Kubalewski
2024-09-04 17:21 ` Donald Hunter
@ 2024-09-05 22:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-05 22:10 UTC (permalink / raw)
To: Kubalewski, Arkadiusz
Cc: netdev, donald.hunter, kuba, davem, edumazet, pabeni, jiri,
jacob.e.keller, liuhangbin, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 4 Sep 2024 15:50:34 +0200 you wrote:
> Execution of command:
> ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml /
> --subscribe "monitor" --sleep 10
> fails with:
> File "/repo/./tools/net/ynl/cli.py", line 109, in main
> ynl.check_ntf()
> File "/repo/tools/net/ynl/lib/ynl.py", line 924, in check_ntf
> op = self.rsp_by_value[nl_msg.cmd()]
> KeyError: 19
>
> [...]
Here is the summary with links:
- [net,v2] tools/net/ynl: fix cli.py --subscribe feature
https://git.kernel.org/netdev/net/c/6fda63c45fe8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-05 22:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-04 13:50 [PATCH net v2] tools/net/ynl: fix cli.py --subscribe feature Arkadiusz Kubalewski
2024-09-04 17:21 ` Donald Hunter
2024-09-05 22:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®