netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] tools: ynl: add --dbg-small-recv for easier kernel testing
@ 2024-03-05  5:33 Jakub Kicinski
  2024-03-05  5:33 ` [PATCH net-next v2 1/4] tools: ynl: move the new line in NlMsg __repr__ Jakub Kicinski
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Jakub Kicinski @ 2024-03-05  5:33 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, pabeni, jiri, donald.hunter, Jakub Kicinski

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(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-06 12:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05  5:33 [PATCH net-next v2 0/4] tools: ynl: add --dbg-small-recv for easier kernel testing Jakub Kicinski
2024-03-05  5:33 ` [PATCH net-next v2 1/4] tools: ynl: move the new line in NlMsg __repr__ Jakub Kicinski
2024-03-05  5:33 ` [PATCH net-next v2 2/4] tools: ynl: allow setting recv() size Jakub Kicinski
2024-03-05 11:04   ` Donald Hunter
2024-03-05  5:33 ` [PATCH net-next v2 3/4] tools: ynl: support debug printing messages Jakub Kicinski
2024-03-05  5:33 ` [PATCH net-next v2 4/4] tools: ynl: add --dbg-small-recv for easier kernel testing Jakub Kicinski
2024-03-05 11:05   ` Donald Hunter
2024-03-06 12:10 ` [PATCH net-next v2 0/4] " 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).