]> git.ipfire.org Git - thirdparty/linux.git/commit
tools: ynl: rework the string representation of NlError
authorJakub Kicinski <kuba@kernel.org>
Mon, 27 Oct 2025 19:29:58 +0000 (12:29 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 28 Oct 2025 23:35:06 +0000 (16:35 -0700)
commit34164142b5fd6878cd487f531ae074e3227031ac
treeb1e4896ceb76ba8b2981d2614af89d8bf6bd855f
parent09e2603513841c48e5422d132f57f8a4c7337721
tools: ynl: rework the string representation of NlError

In early days of YNL development dumping the NlMsg on errors
was quite useful, as the library itself could have been buggy.
These days increasingly the NlMsg is just taking up screen space
and means nothing to a typical user. Try to format the errors
more in line with how YNL C formats its errors strings.

Before:
  $ ynl --family ethtool  --do channels-set  --json '{}'
  Netlink error: Invalid argument
  nl_len = 44 (28) nl_flags = 0x300 nl_type = 2
error: -22
extack: {'miss-type': 'header'}

  $ ynl --family ethtool  --do channels-set  --json '{..., "tx-count": 999}'
  Netlink error: Invalid argument
  nl_len = 88 (72) nl_flags = 0x300 nl_type = 2
error: -22
extack: {'msg': 'requested channel count exceeds maximum', 'bad-attr': '.tx-count'}

After:
  $ ynl --family ethtool  --do channels-set  --json '{}'
  Netlink error: Invalid argument {'miss-type': 'header'}

  $ ynl --family ethtool  --do channels-set  --json '{..., "tx-count": 999}'
  Netlink error: requested channel count exceeds maximum: Invalid argument {'bad-attr': '.tx-count'}

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20251027192958.2058340-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/pyynl/lib/ynl.py