mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
To: netdev@vger.kernel.org
Cc: donald.hunter@gmail.com, kuba@kernel.org, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, jiri@resnulli.us,
	jacob.e.keller@intel.com, liuhangbin@gmail.com,
	linux-kernel@vger.kernel.org,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Subject: [RFC PATCH net] tools/net/ynl: fix cli.py --subscribe feature
Date: Fri, 23 Aug 2024 10:42:20 +0200	[thread overview]
Message-ID: <20240823084220.258965-1-arkadiusz.kubalewski@intel.com> (raw)

Execution of command:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml /
	--subscribe "monitor" --sleep 10
fails with:
Traceback (most recent call last):
  File "/root/arek/linux-dpll/./tools/net/ynl/cli.py", line 114, in <module>
    main()
  File "/root/arek/linux-dpll/./tools/net/ynl/cli.py", line 109, in main
    ynl.check_ntf()
  File "/root/arek/linux-dpll/tools/net/ynl/lib/ynl.py", line 924, in check_ntf
    op = self.rsp_by_value[nl_msg.cmd()]
KeyError: 19

The key value of 19 returned from nl_msg.cmd() is a received message
header's nl_type, which is the id value of generic netlink family being
addressed in the OS on subscribing. It is wrong to use it for decoding
the notification. Expected notification message on dpll subsystem is
DPLL_CMD_PIN_CHANGE_NTF=13, seems at that point only available as first
byte of RAW message payload, use it to target correct op and allow further
parsing.

Fixes: "0a966d606c68" ("tools/net/ynl: Fix extack decoding for directional ops")
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
---
 tools/net/ynl/lib/ynl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index d42c1d605969..192d6c150303 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -921,7 +921,7 @@ class YnlFamily(SpecFamily):
                     print("Netlink done while checking for ntf!?")
                     continue
 
-                op = self.rsp_by_value[nl_msg.cmd()]
+                op = self.rsp_by_value[nl_msg.raw[0]]
                 decoded = self.nlproto.decode(self, nl_msg, op)
                 if decoded.cmd() not in self.async_msg_ids:
                     print("Unexpected msg id done while checking for ntf", decoded)
-- 
2.38.1


             reply	other threads:[~2024-08-23  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23  8:42 Arkadiusz Kubalewski [this message]
2024-08-23 10:40 ` Donald Hunter
2024-08-23 19:31   ` Kubalewski, Arkadiusz
2024-08-23 21:22     ` Donald Hunter
2024-08-23 21:39       ` Kubalewski, Arkadiusz

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=20240823084220.258965-1-arkadiusz.kubalewski@intel.com \
    --to=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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

all inboxes | Powered by JetHome®