mbox series

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

Message ID 20240305053310.815877-1-kuba@kernel.org (mailing list archive)
Headers show
Series tools: ynl: add --dbg-small-recv for easier kernel testing | expand

Message

Jakub Kicinski March 5, 2024, 5:33 a.m. UTC
When testing netlink dumps I usually hack some user space up
to constrain its user space buffer size (iproute2, ethtool or ynl).
Netlink will try to fill the messages up, so since these apps use
large buffers by default, the dumps are rarely fragmented.

I was hoping to figure out a way to create a selftest for dump
testing, but so far I have no idea how to do that in a useful
and generic way.

Until someone does that, make manual dump testing easier with YNL.
Create a special option for limiting the buffer size, so I don't
have to make the same edits each time, and maybe others will benefit,
too :)

Example:

  $ ./cli.py [...] --dbg-small-recv >/dev/null
  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

Now let's make the DONE not fit in the last message:

  $ ./cli.py [...] --dbg-small-recv 4499 >/dev/null
  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 4480 bytes, 35 messages
     nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
    [...]
     nl_len = 128 (112) nl_flags = 0x0 nl_type = 19
  Recv: read 20 bytes, 1 messages
     nl_len = 20 (4) nl_flags = 0x2 nl_type = 3


A real test would also have to check the messages are complete
and not duplicated. That part has to be done manually right now.

Note that the first message is always conservatively sized by the kernel.
Still, I think this is good enough to be useful.

v2:
 - patch 2:
   - move the recv_size setting up
   - change the default to 0 so that cli.py doesn't have to worry
     what the "unset" value is
v1: https://lore.kernel.org/all/20240301230542.116823-1-kuba@kernel.org/

Jakub Kicinski (4):
  tools: ynl: move the new line in NlMsg __repr__
  tools: ynl: allow setting recv() size
  tools: ynl: support debug printing messages
  tools: ynl: add --dbg-small-recv for easier kernel testing

 tools/net/ynl/cli.py     |  7 ++++++-
 tools/net/ynl/lib/ynl.py | 42 ++++++++++++++++++++++++++++++++++------
 2 files changed, 42 insertions(+), 7 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 6, 2024, 12:10 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon,  4 Mar 2024 21:33:06 -0800 you wrote:
> When testing netlink dumps I usually hack some user space up
> to constrain its user space buffer size (iproute2, ethtool or ynl).
> Netlink will try to fill the messages up, so since these apps use
> large buffers by default, the dumps are rarely fragmented.
> 
> I was hoping to figure out a way to create a selftest for dump
> testing, but so far I have no idea how to do that in a useful
> and generic way.
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/4] tools: ynl: move the new line in NlMsg __repr__
    https://git.kernel.org/netdev/net-next/c/7df7231d6a6b
  - [net-next,v2,2/4] tools: ynl: allow setting recv() size
    https://git.kernel.org/netdev/net-next/c/7c93a88785da
  - [net-next,v2,3/4] tools: ynl: support debug printing messages
    https://git.kernel.org/netdev/net-next/c/a6a41521f95e
  - [net-next,v2,4/4] tools: ynl: add --dbg-small-recv for easier kernel testing
    https://git.kernel.org/netdev/net-next/c/c0111878d45e

You are awesome, thank you!