diff mbox series

[net-next,v2,4/4] tools: ynl: add --dbg-small-recv for easier kernel testing

Message ID 20240305053310.815877-5-kuba@kernel.org (mailing list archive)
State Accepted
Commit c0111878d45e3bb8779886fbf956b574bac8a3aa
Delegated to: Netdev Maintainers
Headers show
Series tools: ynl: add --dbg-small-recv for easier kernel testing | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-05--21-00 (tests: 892)

Commit Message

Jakub Kicinski March 5, 2024, 5:33 a.m. UTC
Most "production" netlink clients use large buffers to
make dump efficient, which means that handling of dump
continuation in the kernel is not very well tested.

Add an option for debugging / testing handling of dumps.
It enables printing of extra netlink-level debug and
lowers the recv() buffer size in one go. When used
without any argument (--dbg-small-recv) it picks
a very small default (4000), explicit size can be set,
too (--dbg-small-recv 5000).

Example:

$ ./cli.py [...] --dbg-small-recv
Recv: read 3712 bytes, 29 messages
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
 [...]
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
Recv: read 3968 bytes, 31 messages
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
 [...]
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
Recv: read 532 bytes, 5 messages
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
 [...]
   nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
   nl_len = 20 (4) nl_flags = 0x2 nl_type = 3

(the [...] are edits to shorten the commit message).

Note that the first message of the dump is sized conservatively
by the kernel.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/cli.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Donald Hunter March 5, 2024, 11:05 a.m. UTC | #1
Jakub Kicinski <kuba@kernel.org> writes:

> Most "production" netlink clients use large buffers to
> make dump efficient, which means that handling of dump
> continuation in the kernel is not very well tested.
>
> Add an option for debugging / testing handling of dumps.
> It enables printing of extra netlink-level debug and
> lowers the recv() buffer size in one go. When used
> without any argument (--dbg-small-recv) it picks
> a very small default (4000), explicit size can be set,
> too (--dbg-small-recv 5000).
>
> Example:
>
> $ ./cli.py [...] --dbg-small-recv
> Recv: read 3712 bytes, 29 messages
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
>  [...]
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
> Recv: read 3968 bytes, 31 messages
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
>  [...]
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
> Recv: read 532 bytes, 5 messages
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
>  [...]
>    nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
>    nl_len = 20 (4) nl_flags = 0x2 nl_type = 3
>
> (the [...] are edits to shorten the commit message).
>
> Note that the first message of the dump is sized conservatively
> by the kernel.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
diff mbox series

Patch

diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/cli.py
index 0f8239979670..e8a65fbc3698 100755
--- a/tools/net/ynl/cli.py
+++ b/tools/net/ynl/cli.py
@@ -38,6 +38,8 @@  from lib import YnlFamily, Netlink
                         const=Netlink.NLM_F_APPEND)
     parser.add_argument('--process-unknown', action=argparse.BooleanOptionalAction)
     parser.add_argument('--output-json', action='store_true')
+    parser.add_argument('--dbg-small-recv', default=0, const=4000,
+                        action='store', nargs='?', type=int)
     args = parser.parse_args()
 
     def output(msg):
@@ -53,7 +55,10 @@  from lib import YnlFamily, Netlink
     if args.json_text:
         attrs = json.loads(args.json_text)
 
-    ynl = YnlFamily(args.spec, args.schema, args.process_unknown)
+    ynl = YnlFamily(args.spec, args.schema, args.process_unknown,
+                    recv_size=args.dbg_small_recv)
+    if args.dbg_small_recv:
+        ynl.set_recv_dbg(True)
 
     if args.ntf:
         ynl.ntf_subscribe(args.ntf)