Re: [PATCH bpf-next v2 3/4] bpf: sockmap, add a cork to force buffering of the scatterlist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jakub Sitnicki wrote:
> 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@xxxxxxxxx>
> > ---
> >  .../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.

Agree I'lld elete it.

> 
> > +	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);
> > +}
> 
> [...]






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux