lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o7d8dv2f.fsf@cloudflare.com>
Date: Fri, 26 Jan 2024 15:19:41 +0100
From: Jakub Sitnicki <jakub@...udflare.com>
To: John Fastabend <john.fastabend@...il.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, andrii@...nel.org
Subject: Re: [PATCH bpf-next v2 3/4] bpf: sockmap, add a cork to force
 buffering of the scatterlist

On Wed, Jan 24, 2024 at 10:54 AM -08, John Fastabend wrote:
> By using cork we can force multiple sends into a single scatterlist
> and test that first the cork gives us the correct number of bytes,
> but then also test the pop over the corked data.
>
> Signed-off-by: John Fastabend <john.fastabend@...il.com>
> ---
>  .../bpf/prog_tests/sockmap_msg_helpers.c      | 81 +++++++++++++++++++
>  .../bpf/progs/test_sockmap_msg_helpers.c      |  3 +
>  2 files changed, 84 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c b/tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
> index e5e618e84950..8ced54fe1a0b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_msg_helpers.c
> @@ -21,6 +21,85 @@ struct msg_test_opts {
>  
>  #define POP_END -1
>  
> +static void cork_send(struct msg_test_opts *opts, int cork)
> +{
> +	struct test_sockmap_msg_helpers *skel = opts->skel;
> +	char buf[] = "abcdefghijklmnopqrstuvwxyz";
> +	size_t sent, total = 0, recv;
> +	char *recvbuf;
> +	int i;
> +
> +	skel->bss->pop = false;

Why reset it? Every subtest loads new program & creates new maps.

> +	skel->bss->cork = cork;
> +
> +	/* Send N bytes in 27B chunks */
> +	for (i = 0; i < cork / sizeof(buf); i++) {
> +		sent = xsend(opts->client, buf, sizeof(buf), 0);
> +		if (sent < sizeof(buf))
> +			FAIL("xsend failed");
> +		total += sent;
> +	}
> +
> +	recvbuf = malloc(total);
> +	if (!recvbuf)
> +		FAIL("cork send malloc failure\n");
> +
> +	ASSERT_OK(skel->bss->err, "cork error");
> +	ASSERT_EQ(skel->bss->size, cork, "cork did not receive all bytes");
> +
> +	recv = xrecv_nonblock(opts->server, recvbuf, total, 0);
> +	if (recv != total)
> +		FAIL("Received incorrect number of bytes");
> +
> +	free(recvbuf);
> +}

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ