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  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]
Date:   Thu, 20 Aug 2020 16:28:40 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Andrii Nakryiko <andriin@...com>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 12/16] selftests/bpf: add selftest for multi-prog
 sections and bpf-to-bpf calls

On Thu, Aug 20, 2020 at 4:13 PM Andrii Nakryiko <andriin@...com> wrote:
>
> Add a selftest excercising bpf-to-bpf subprogram calls, as well as multiple
> entry-point BPF programs per section. Also make sure that BPF CO-RE works for
> such set ups both for sub-programs and for multi-entry sections.
>
> Signed-off-by: Andrii Nakryiko <andriin@...com>
> ---
>  .../selftests/bpf/prog_tests/subprogs.c       | 31 +++++++
>  .../selftests/bpf/progs/test_subprogs.c       | 92 +++++++++++++++++++
>  2 files changed, 123 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/subprogs.c
>  create mode 100644 tools/testing/selftests/bpf/progs/test_subprogs.c
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/subprogs.c b/tools/testing/selftests/bpf/prog_tests/subprogs.c
> new file mode 100644
> index 000000000000..a00abf58c037
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/subprogs.c
> @@ -0,0 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2020 Facebook */
> +#include <test_progs.h>
> +#include <time.h>
> +#include "test_subprogs.skel.h"
> +
> +static int duration;
> +
> +void test_subprogs(void)
> +{
> +       struct test_subprogs *skel;
> +       int err;
> +
> +       skel = test_subprogs__open_and_load();
> +       if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
> +               return;
> +
> +       err = test_subprogs__attach(skel);
> +       if (CHECK(err, "skel_attach", "failed to attach skeleton: %d\n", err))
> +               goto cleanup;
> +
> +       usleep(1);
> +
> +       CHECK(skel->bss->res1 != 12, "res1", "got %d, exp %d\n", skel->bss->res1, 12);
> +       CHECK(skel->bss->res2 != 17, "res2", "got %d, exp %d\n", skel->bss->res2, 17);
> +       CHECK(skel->bss->res3 != 19, "res3", "got %d, exp %d\n", skel->bss->res3, 19);
> +       CHECK(skel->bss->res4 != 36, "res4", "got %d, exp %d\n", skel->bss->res4, 36);
> +

res4 was a late addition, and apparently I missed test_progs build
failure among other local warnings. I'll add res4 in BPF code in the
next version.

> +cleanup:
> +       test_subprogs__destroy(skel);
> +}

[...]

Powered by blists - more mailing lists