linux/tools/net/ynl
Arkadiusz Kubalewski 6fda63c45f tools/net/ynl: fix cli.py --subscribe feature
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: 0a966d606c ("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>
Link: https://patch.msgid.link/20240904135034.316033-1-arkadiusz.kubalewski@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-09-05 14:56:45 -07:00
..
generated tools: ynl: rename make hardclean -> distclean 2024-03-06 12:05:10 +00:00
lib tools/net/ynl: fix cli.py --subscribe feature 2024-09-05 14:56:45 -07:00
samples tools: ynl: add ynl_dump_empty() helper 2024-04-02 18:01:58 -07:00
cli.py tools: ynl: add --list-ops and --list-msgs to CLI 2024-05-03 15:13:21 -07:00
ethtool.py tools: ynl: ethtool.py: Output timestamping statistics from tsinfo-get operation 2024-04-05 22:27:57 -07:00
Makefile tools: net: package libynl for use in selftests 2024-07-02 18:59:33 -07:00
Makefile.deps tcp_metrics: add netlink protocol spec in YAML 2024-07-01 09:44:27 +01:00
requirements.txt tools: ynl: add the Python requirements.txt file 2023-03-24 19:11:02 -07:00
ynl-gen-c.py tools: ynl: use ident name for Family, too. 2024-07-03 19:13:20 -07:00
ynl-gen-rst.py doc: netlink: Fix op pre and post fields in generated .rst 2024-05-29 18:10:26 -07:00
ynl-regen.sh tools: ynl: don't skip regeneration from make targets 2023-11-29 16:07:00 -08:00