From: Stanislav Fomichev <stfomichev@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: Stanislav Fomichev <sdf@fomichev.me>,
netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net-next 02/13] selftests: ncdevmem: Remove validation
Date: Thu, 12 Sep 2024 14:57:35 -0700 [thread overview]
Message-ID: <ZuNjz7HvlD4z6dR8@mini-arch> (raw)
In-Reply-To: <CAHS8izNOZMeNi4WNWL9jmLd-rJeGA=M3zBKDSzMNHZ3sZOxUuA@mail.gmail.com>
On 09/12, Mina Almasry wrote:
> On Thu, Sep 12, 2024 at 10:12 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > ncdevmem should (see next patches) print the payload on the stdout.
> > The validation can and should be done by the callers:
> >
> > $ ncdevmem -l ... > file
> > $ sha256sum file
> >
> > Cc: Mina Almasry <almasrymina@google.com>
> > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> > ---
> > tools/testing/selftests/net/ncdevmem.c | 56 +++-----------------------
> > 1 file changed, 6 insertions(+), 50 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> > index 352dba211fb0..3712296d997b 100644
> > --- a/tools/testing/selftests/net/ncdevmem.c
> > +++ b/tools/testing/selftests/net/ncdevmem.c
> > @@ -64,24 +64,13 @@
> > static char *server_ip = "192.168.1.4";
> > static char *client_ip = "192.168.1.2";
> > static char *port = "5201";
> > -static size_t do_validation;
> > static int start_queue = 8;
> > static int num_queues = 8;
> > static char *ifname = "eth1";
> > static unsigned int ifindex;
> > static unsigned int dmabuf_id;
> >
> > -void print_bytes(void *ptr, size_t size)
> > -{
> > - unsigned char *p = ptr;
> > - int i;
> > -
> > - for (i = 0; i < size; i++)
> > - printf("%02hhX ", p[i]);
> > - printf("\n");
> > -}
> > -
> > -void print_nonzero_bytes(void *ptr, size_t size)
> > +static void print_nonzero_bytes(void *ptr, size_t size)
> > {
> > unsigned char *p = ptr;
> > unsigned int i;
> > @@ -91,30 +80,6 @@ void print_nonzero_bytes(void *ptr, size_t size)
> > printf("\n");
> > }
> >
> > -void validate_buffer(void *line, size_t size)
> > -{
> > - static unsigned char seed = 1;
> > - unsigned char *ptr = line;
> > - int errors = 0;
> > - size_t i;
> > -
> > - for (i = 0; i < size; i++) {
> > - if (ptr[i] != seed) {
> > - fprintf(stderr,
> > - "Failed validation: expected=%u, actual=%u, index=%lu\n",
> > - seed, ptr[i], i);
> > - errors++;
>
> FWIW the index at where the validation started to fail often gives
> critical clues about where the bug is, along with this line, which I'm
> glad is not removed:
>
> printf("received frag_page=%llu, in_page_offset=%llu,
> frag_offset=%llu, frag_size=%u, token=%u, total_received=%lu,
> dmabuf_id=%u\n",
>
> I think we can ensure that what is doing the validation above ncdevmem
> prints enough context about the error. Although, just to understand
> your thinking a bit, why not have this binary do the validation
> itself?
Right, the debugging stuff will still be there to track the offending
part. And the caller can print out the idx of data where the validation
failed.
The reason I removed it from the tool is to be able to do the validation
with regular nc on the other side. I just do:
- echo "expected payload" | nc ..
- ncdevmem -s .. > expected_payload.txt
- [ "expected payload" != $(cat expected_payload.txt) ] && fail
If I were to use the validation on the ncdevmem side, I'd need to bother
with generating the payload that it expects which seems like
an unnecessary complication? For the (to be posted) txrx test I basically
do the following (sha256sum to validate a bunch of random bytes):
def check_txrx(cfg) -> None:
cfg.require_v6()
require_devmem(cfg)
cmd(f"cat /dev/urandom | tr -dc '[:print:]' | head -c 1M > random_file.txt", host=cfg.remote, shell=True)
want_sha = cmd(f"sha256sum random_file.txt", host=cfg.remote, shell=True).stdout.strip()
port = rand_port()
listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.v6} -p {port} | tee random_file.txt | sha256sum -"
pwd = cmd(f"pwd").stdout.strip()
with bkg(listen_cmd, exit_wait=True) as nc:
wait_port_listen(port)
cmd(f"cat random_file.txt | {pwd}/ncdevmem -f {cfg.ifname} -s {cfg.v6} -p {port}", host=cfg.remote, shell=True)
ksft_eq(nc.stdout.strip().split(" ")[0], want_sha.split(" ")[0])
next prev parent reply other threads:[~2024-09-12 21:57 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 17:12 [PATCH net-next 00/13] selftests: ncdevmem: Add ncdevmem to ksft Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 01/13] selftests: ncdevmem: Add a flag for the selftest Stanislav Fomichev
2024-09-12 20:36 ` Mina Almasry
2024-09-12 21:59 ` Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 02/13] selftests: ncdevmem: Remove validation Stanislav Fomichev
2024-09-12 20:36 ` Mina Almasry
2024-09-12 21:57 ` Stanislav Fomichev [this message]
2024-09-13 15:30 ` Mina Almasry
2024-09-13 17:15 ` Stanislav Fomichev
2024-09-13 23:42 ` Mina Almasry
2024-09-12 17:12 ` [PATCH net-next 03/13] selftests: ncdevmem: Redirect all non-payload output to stderr Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 04/13] selftests: ncdevmem: Separate out dmabuf provider Stanislav Fomichev
2024-09-12 20:36 ` Mina Almasry
2024-09-12 17:12 ` [PATCH net-next 05/13] selftests: ncdevmem: Unify error handling Stanislav Fomichev
2024-09-12 20:35 ` Mina Almasry
2024-09-12 21:49 ` Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 06/13] selftests: ncdevmem: Remove client_ip Stanislav Fomichev
2024-09-12 20:35 ` Mina Almasry
2024-09-12 21:48 ` Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 07/13] selftests: ncdevmem: Remove default arguments Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 08/13] selftests: ncdevmem: Switch to AF_INET6 Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 09/13] selftests: ncdevmem: Properly reset flow steering Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 10/13] selftests: ncdevmem: Use YNL to enable TCP header split Stanislav Fomichev
2024-09-14 13:14 ` kernel test robot
2024-09-12 17:12 ` [PATCH net-next 11/13] selftests: ncdevmem: Remove hard-coded queue numbers Stanislav Fomichev
2024-09-12 20:34 ` Mina Almasry
2024-09-12 21:47 ` Stanislav Fomichev
2024-09-26 16:26 ` Mina Almasry
2024-09-27 1:20 ` Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 12/13] selftests: ncdevmem: Move ncdevmem under drivers/net Stanislav Fomichev
2024-09-13 15:38 ` Mina Almasry
2024-09-13 17:19 ` Stanislav Fomichev
2024-09-12 17:12 ` [PATCH net-next 13/13] selftests: ncdevmem: Add automated test Stanislav Fomichev
2024-09-12 20:34 ` Mina Almasry
2024-09-12 19:48 ` [PATCH net-next 00/13] selftests: ncdevmem: Add ncdevmem to ksft Stanislav Fomichev
2024-09-12 21:07 ` Mina Almasry
2024-09-12 21:43 ` Stanislav Fomichev
2024-12-13 1:18 ` Stanislav Fomichev
2024-12-13 17:47 ` Mina Almasry
2024-12-13 18:53 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZuNjz7HvlD4z6dR8@mini-arch \
--to=stfomichev@gmail.com \
--cc=almasrymina@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox