diff mbox series

[net-next] ynl: allow to encode u8 attr

Message ID 20230322154242.1739136-1-jiri@resnulli.us (mailing list archive)
State Accepted
Commit 8da3a5598f75cd0361e11b6d74697084380eb4b0
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ynl: allow to encode u8 attr | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Pirko March 22, 2023, 3:42 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

Playing with dpll netlink, I came across following issue:
$ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml --do pin-set --json '{"id": 0, "pin-idx": 1, "pin-state": 1}'
Traceback (most recent call last):
  File "tools/net/ynl/cli.py", line 52, in <module>
    main()
  File "tools/net/ynl/cli.py", line 40, in main
    reply = ynl.do(args.do, attrs)
  File "tools/net/ynl/lib/ynl.py", line 520, in do
    return self._op(method, vals)
  File "tools/net/ynl/lib/ynl.py", line 476, in _op
    msg += self._add_attr(op.attr_set.name, name, value)
  File "tools/net/ynl/lib/ynl.py", line 344, in _add_attr
    raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}')
Exception: Unknown type at dpll pin-state 1 u8

I'm not that familiar with ynl code, but from a quick peek, I suspect
that couple other types are missing for both encoding and decoding.
Ignoring those here as I'm scratching my local itch only.

Fix the issue by adding u8 attr packing.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 tools/net/ynl/lib/ynl.py | 2 ++
 1 file changed, 2 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org March 24, 2023, 4:50 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 22 Mar 2023 16:42:42 +0100 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Playing with dpll netlink, I came across following issue:
> $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml --do pin-set --json '{"id": 0, "pin-idx": 1, "pin-state": 1}'
> Traceback (most recent call last):
>   File "tools/net/ynl/cli.py", line 52, in <module>
>     main()
>   File "tools/net/ynl/cli.py", line 40, in main
>     reply = ynl.do(args.do, attrs)
>   File "tools/net/ynl/lib/ynl.py", line 520, in do
>     return self._op(method, vals)
>   File "tools/net/ynl/lib/ynl.py", line 476, in _op
>     msg += self._add_attr(op.attr_set.name, name, value)
>   File "tools/net/ynl/lib/ynl.py", line 344, in _add_attr
>     raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}')
> Exception: Unknown type at dpll pin-state 1 u8
> 
> [...]

Here is the summary with links:
  - [net-next] ynl: allow to encode u8 attr
    https://git.kernel.org/netdev/net-next/c/8da3a5598f75

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 90764a83c646..bcb798c7734d 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -334,6 +334,8 @@  class YnlFamily(SpecFamily):
                 attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
         elif attr["type"] == 'flag':
             attr_payload = b''
+        elif attr["type"] == 'u8':
+            attr_payload = struct.pack("B", int(value))
         elif attr["type"] == 'u32':
             attr_payload = struct.pack("I", int(value))
         elif attr["type"] == 'string':