* [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib
@ 2025-10-27 19:29 Jakub Kicinski
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jakub Kicinski @ 2025-10-27 19:29 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
donald.hunter, ast
Class NlError() and operation_do_attributes() are indented by 2 spaces
rather than 4 spaces used by the rest of the file.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- new patch
CC: donald.hunter@gmail.com
CC: ast@fiberby.net
---
tools/net/ynl/pyynl/lib/ynl.py | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index 62383c70ebb9..bdcc4f031d39 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -100,12 +100,12 @@ from .nlspec import SpecFamily
'bitfield32', 'sint', 'uint'])
class NlError(Exception):
- def __init__(self, nl_msg):
- self.nl_msg = nl_msg
- self.error = -nl_msg.error
+ def __init__(self, nl_msg):
+ self.nl_msg = nl_msg
+ self.error = -nl_msg.error
- def __str__(self):
- return f"Netlink error: {os.strerror(self.error)}\n{self.nl_msg}"
+ def __str__(self):
+ return f"Netlink error: {os.strerror(self.error)}\n{self.nl_msg}"
class ConfigError(Exception):
@@ -1039,15 +1039,15 @@ genl_family_name_to_id = None
self.check_ntf()
def operation_do_attributes(self, name):
- """
- For a given operation name, find and return a supported
- set of attributes (as a dict).
- """
- op = self.find_operation(name)
- if not op:
- return None
+ """
+ For a given operation name, find and return a supported
+ set of attributes (as a dict).
+ """
+ op = self.find_operation(name)
+ if not op:
+ return None
- return op['do']['request']['attributes'].copy()
+ return op['do']['request']['attributes'].copy()
def _encode_message(self, op, vals, flags, req_seq):
nl_flags = Netlink.NLM_F_REQUEST | Netlink.NLM_F_ACK
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError
2025-10-27 19:29 [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Jakub Kicinski
@ 2025-10-27 19:29 ` Jakub Kicinski
2025-10-28 10:51 ` Donald Hunter
2025-10-28 13:58 ` Andrew Lunn
2025-10-28 10:50 ` [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Donald Hunter
2025-10-28 23:50 ` patchwork-bot+netdevbpf
2 siblings, 2 replies; 7+ messages in thread
From: Jakub Kicinski @ 2025-10-27 19:29 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
donald.hunter, ast
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'}
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- remove an unnecessary condition
v1: https://lore.kernel.org/20251024215713.1250688-1-kuba@kernel.org
CC: donald.hunter@gmail.com
CC: ast@fiberby.net
---
tools/net/ynl/pyynl/lib/ynl.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index bdcc4f031d39..225baad3c8f8 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -105,7 +105,16 @@ from .nlspec import SpecFamily
self.error = -nl_msg.error
def __str__(self):
- return f"Netlink error: {os.strerror(self.error)}\n{self.nl_msg}"
+ msg = "Netlink error: "
+
+ extack = self.nl_msg.extack.copy() if self.nl_msg.extack else {}
+ if 'msg' in extack:
+ msg += extack['msg'] + ': '
+ del extack['msg']
+ msg += os.strerror(self.error)
+ if extack:
+ msg += ' ' + str(extack)
+ return msg
class ConfigError(Exception):
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib
2025-10-27 19:29 [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Jakub Kicinski
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
@ 2025-10-28 10:50 ` Donald Hunter
2025-10-28 23:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 7+ messages in thread
From: Donald Hunter @ 2025-10-28 10:50 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, ast
Jakub Kicinski <kuba@kernel.org> writes:
> Class NlError() and operation_do_attributes() are indented by 2 spaces
> rather than 4 spaces used by the rest of the file.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
@ 2025-10-28 10:51 ` Donald Hunter
2025-10-28 13:58 ` Andrew Lunn
1 sibling, 0 replies; 7+ messages in thread
From: Donald Hunter @ 2025-10-28 10:51 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, ast
Jakub Kicinski <kuba@kernel.org> writes:
> 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'}
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
2025-10-28 10:51 ` Donald Hunter
@ 2025-10-28 13:58 ` Andrew Lunn
2025-10-28 23:34 ` Jakub Kicinski
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2025-10-28 13:58 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
donald.hunter, ast
On Mon, Oct 27, 2025 at 12:29:58PM -0700, Jakub Kicinski wrote:
> 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'}
I think as a kernel programmer, i would prefer EINVAL over Invalid
argument. If i'm going to be digging into the kernel sources to find
where the error is happening, it is one less translation i need to
make.
>>> print(errno.errorcode[1])
EPERM
>>> print(errno.errorcode[2])
ENOENT
>>> print(errno.errorcode[110])
ETIMEDOUT
I suppose the question is, who is the intended user of ynl? Do we want
user friendly messages, or kernel developer friendly messages?
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError
2025-10-28 13:58 ` Andrew Lunn
@ 2025-10-28 23:34 ` Jakub Kicinski
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2025-10-28 23:34 UTC (permalink / raw)
To: Andrew Lunn
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
donald.hunter, ast
On Tue, 28 Oct 2025 14:58:59 +0100 Andrew Lunn wrote:
> I think as a kernel programmer, i would prefer EINVAL over Invalid
> argument. If i'm going to be digging into the kernel sources to find
> where the error is happening, it is one less translation i need to
> make.
>
> >>> print(errno.errorcode[1])
> EPERM
> >>> print(errno.errorcode[2])
> ENOENT
> >>> print(errno.errorcode[110])
> ETIMEDOUT
>
> I suppose the question is, who is the intended user of ynl? Do we want
> user friendly messages, or kernel developer friendly messages?
A mix of both, it is packaged in distros.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib
2025-10-27 19:29 [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Jakub Kicinski
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
2025-10-28 10:50 ` [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Donald Hunter
@ 2025-10-28 23:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-28 23:50 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
donald.hunter, ast
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 27 Oct 2025 12:29:57 -0700 you wrote:
> Class NlError() and operation_do_attributes() are indented by 2 spaces
> rather than 4 spaces used by the rest of the file.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> v2:
> - new patch
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] tools: ynl: fix indent issues in the main Python lib
https://git.kernel.org/netdev/net-next/c/09e260351384
- [net-next,v2,2/2] tools: ynl: rework the string representation of NlError
https://git.kernel.org/netdev/net-next/c/34164142b5fd
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] 7+ messages in thread
end of thread, other threads:[~2025-10-28 23:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-27 19:29 [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Jakub Kicinski
2025-10-27 19:29 ` [PATCH net-next v2 2/2] tools: ynl: rework the string representation of NlError Jakub Kicinski
2025-10-28 10:51 ` Donald Hunter
2025-10-28 13:58 ` Andrew Lunn
2025-10-28 23:34 ` Jakub Kicinski
2025-10-28 10:50 ` [PATCH net-next v2 1/2] tools: ynl: fix indent issues in the main Python lib Donald Hunter
2025-10-28 23:50 ` 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;
as well as URLs for NNTP newsgroup(s).