netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Daniel Borkmann <daniel@iogearbox.net>, <ast@kernel.org>
Cc: <john.fastabend@gmail.com>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next 4/6] bpf, selftests: add test for different array inner map size
Date: Thu, 8 Oct 2020 20:44:45 -0700	[thread overview]
Message-ID: <79b58368-03d5-29cf-241c-1fb0dae5ee14@fb.com> (raw)
In-Reply-To: <20201008213148.26848-5-daniel@iogearbox.net>



On 10/8/20 2:31 PM, Daniel Borkmann wrote:
> Extend the "diff_size" subtest to also include a non-inlined array map variant
> where dynamic inner #elems are possible.
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Ack with a minor comment below.

Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   .../selftests/bpf/prog_tests/btf_map_in_map.c | 39 ++++++++++++-----
>   .../selftests/bpf/progs/test_btf_map_in_map.c | 43 +++++++++++++++++++
>   2 files changed, 72 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c b/tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
> index 540fea4c91a5..e478bdec73b8 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
> @@ -55,10 +55,10 @@ static int kern_sync_rcu(void)
>   
>   static void test_lookup_update(void)
>   {
> -	int err, key = 0, val, i;
> +	int map1_fd, map2_fd, map3_fd, map4_fd, map5_fd, map1_id, map2_id;
> +	int outer_arr_fd, outer_hash_fd, outer_arr_dyn_fd;
>   	struct test_btf_map_in_map *skel;
> -	int outer_arr_fd, outer_hash_fd;
> -	int fd, map1_fd, map2_fd, map1_id, map2_id;
> +	int err, key = 0, val, i, fd;
>   
>   	skel = test_btf_map_in_map__open_and_load();
>   	if (CHECK(!skel, "skel_open", "failed to open&load skeleton\n"))
> @@ -70,32 +70,45 @@ static void test_lookup_update(void)
>   
>   	map1_fd = bpf_map__fd(skel->maps.inner_map1);
>   	map2_fd = bpf_map__fd(skel->maps.inner_map2);
> +	map3_fd = bpf_map__fd(skel->maps.inner_map3);
> +	map4_fd = bpf_map__fd(skel->maps.inner_map4);
> +	map5_fd = bpf_map__fd(skel->maps.inner_map5);
> +	outer_arr_dyn_fd = bpf_map__fd(skel->maps.outer_arr_dyn);
>   	outer_arr_fd = bpf_map__fd(skel->maps.outer_arr);
>   	outer_hash_fd = bpf_map__fd(skel->maps.outer_hash);
>   
> -	/* inner1 = input, inner2 = input + 1 */
> -	map1_fd = bpf_map__fd(skel->maps.inner_map1);
> +	/* inner1 = input, inner2 = input + 1, inner3 = input + 2 */
>   	bpf_map_update_elem(outer_arr_fd, &key, &map1_fd, 0);
> -	map2_fd = bpf_map__fd(skel->maps.inner_map2);
>   	bpf_map_update_elem(outer_hash_fd, &key, &map2_fd, 0);
> +	bpf_map_update_elem(outer_arr_dyn_fd, &key, &map3_fd, 0);
>   	skel->bss->input = 1;
>   	usleep(1);
> -
>   	bpf_map_lookup_elem(map1_fd, &key, &val);
>   	CHECK(val != 1, "inner1", "got %d != exp %d\n", val, 1);
>   	bpf_map_lookup_elem(map2_fd, &key, &val);
>   	CHECK(val != 2, "inner2", "got %d != exp %d\n", val, 2);
> +	bpf_map_lookup_elem(map3_fd, &key, &val);
> +	CHECK(val != 3, "inner3", "got %d != exp %d\n", val, 3);
>   
> -	/* inner1 = input + 1, inner2 = input */
> +	/* inner1 = input, inner2 = input + 1, inner4 = input + 2 */

The changed comments sound not right.


>   	bpf_map_update_elem(outer_arr_fd, &key, &map2_fd, 0);
>   	bpf_map_update_elem(outer_hash_fd, &key, &map1_fd, 0);
> +	bpf_map_update_elem(outer_arr_dyn_fd, &key, &map4_fd, 0);
>   	skel->bss->input = 3;
>   	usleep(1);
> -
>   	bpf_map_lookup_elem(map1_fd, &key, &val);
>   	CHECK(val != 4, "inner1", "got %d != exp %d\n", val, 4);

We have inner1 = input + 1 here.

>   	bpf_map_lookup_elem(map2_fd, &key, &val);
>   	CHECK(val != 3, "inner2", "got %d != exp %d\n", val, 3);

inner2 = input here.

> +	bpf_map_lookup_elem(map4_fd, &key, &val);
> +	CHECK(val != 5, "inner4", "got %d != exp %d\n", val, 5);
> +
[...]

  reply	other threads:[~2020-10-09  3:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 21:31 [PATCH bpf-next 0/6] Follow-up BPF helper improvements Daniel Borkmann
2020-10-08 21:31 ` [PATCH bpf-next 1/6] bpf: improve bpf_redirect_neigh helper description Daniel Borkmann
2020-10-08 22:00   ` David Ahern
2020-10-08 21:31 ` [PATCH bpf-next 2/6] bpf: add redirect_peer helper Daniel Borkmann
2020-10-08 21:31 ` [PATCH bpf-next 3/6] bpf: allow for map-in-map with dynamic inner array map entries Daniel Borkmann
2020-10-09  3:19   ` Yonghong Song
2020-10-08 21:31 ` [PATCH bpf-next 4/6] bpf, selftests: add test for different array inner map size Daniel Borkmann
2020-10-09  3:44   ` Yonghong Song [this message]
2020-10-08 21:31 ` [PATCH bpf-next 5/6] bpf, selftests: make redirect_neigh test more extensible Daniel Borkmann
2020-10-09  3:58   ` Yonghong Song
2020-10-08 21:31 ` [PATCH bpf-next 6/6] bpf, selftests: add redirect_peer selftest Daniel Borkmann

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=79b58368-03d5-29cf-241c-1fb0dae5ee14@fb.com \
    --to=yhs@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).