All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yonghong Song <yhs@fb.com>
Cc: YiFei Zhu <zhuyifei1999@gmail.com>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Stanislav Fomichev <sdf@google.com>,
	Mahesh Bandewar <maheshb@google.com>,
	YiFei Zhu <zhuyifei@google.com>
Subject: Re: [PATCH bpf-next 5/5] selftests/bpf: Test bpftool loading and dumping metadata
Date: Tue, 25 Aug 2020 21:00:24 -0700	[thread overview]
Message-ID: <CAEf4BzahcdM2W8YwmWdoVwYENXmKjkgvru4Qj_uCN8BddKnoJA@mail.gmail.com> (raw)
In-Reply-To: <e0946350-9829-09b3-0a60-4b45ed918d93@fb.com>

On Thu, Aug 20, 2020 at 3:03 PM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 8/20/20 2:42 AM, YiFei Zhu wrote:
> > From: YiFei Zhu <zhuyifei@google.com>
> >
> > This is a simple test to check that loading and dumping metadata
> > works, whether or not metadata contents are used by the program.
> >
> > Signed-off-by: YiFei Zhu <zhuyifei@google.com>
> > ---
> >   tools/testing/selftests/bpf/Makefile          |  3 +-
> >   .../selftests/bpf/progs/metadata_unused.c     | 15 ++++
> >   .../selftests/bpf/progs/metadata_used.c       | 15 ++++
> >   .../selftests/bpf/test_bpftool_metadata.sh    | 82 +++++++++++++++++++
> >   4 files changed, 114 insertions(+), 1 deletion(-)
> >   create mode 100644 tools/testing/selftests/bpf/progs/metadata_unused.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/metadata_used.c
> >   create mode 100755 tools/testing/selftests/bpf/test_bpftool_metadata.sh
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index a83b5827532f..04e56c6843c6 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -68,7 +68,8 @@ TEST_PROGS := test_kmod.sh \
> >       test_tc_edt.sh \
> >       test_xdping.sh \
> >       test_bpftool_build.sh \
> > -     test_bpftool.sh
> > +     test_bpftool.sh \
> > +     test_bpftool_metadata.sh \
>
> This is mostly testing bpftool side.
> We should add testing to test_progs too as it is what most developer
> runs. If you add skeleton support for metadata, similar to bss, it will
> both make user interface easy and make testing easy.
>

I concur. It also seems that program code can use metadata variables
just like .rodata variables (e.g., for debug logging, etc), so we need
to add tests exercising that ability as well.

> >
> >   TEST_PROGS_EXTENDED := with_addr.sh \
> >       with_tunnels.sh \
> > diff --git a/tools/testing/selftests/bpf/progs/metadata_unused.c b/tools/testing/selftests/bpf/progs/metadata_unused.c
> > new file mode 100644
> > index 000000000000..523b3c332426
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/metadata_unused.c
> > @@ -0,0 +1,15 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#include <linux/bpf.h>
> > +#include <bpf/bpf_helpers.h>
> > +
> > +char metadata_a[] SEC(".metadata") = "foo";
> > +int metadata_b SEC(".metadata") = 1;
> > +
> > +SEC("cgroup_skb/egress")
> > +int prog(struct xdp_md *ctx)
> > +{
> > +     return 0;
> > +}
> > +
> > +char _license[] SEC("license") = "GPL";
> [...]

      reply	other threads:[~2020-08-26  4:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-20  9:42 [PATCH bpf-next 0/5] Allow storage of flexible metadata information for eBPF programs YiFei Zhu
2020-08-20  9:42 ` [PATCH bpf-next 1/5] bpf: Mutex protect used_maps array and count YiFei Zhu
2020-08-20 21:18   ` Yonghong Song
2020-08-20  9:42 ` [PATCH bpf-next 2/5] bpf: Add BPF_PROG_BIND_MAP syscall YiFei Zhu
2020-08-20 21:23   ` Yonghong Song
2020-08-20  9:42 ` [PATCH bpf-next 3/5] libbpf: Add BPF_PROG_BIND_MAP syscall and use it on .metadata section YiFei Zhu
2020-08-20 20:38   ` Yonghong Song
2020-08-21  7:52     ` YiFei Zhu
2020-08-21 15:14       ` Yonghong Song
2020-08-25 20:45   ` Andrey Ignatov
2020-08-26  4:02   ` Andrii Nakryiko
2020-08-20  9:42 ` [PATCH bpf-next 4/5] bpftool: support dumping metadata YiFei Zhu
2020-08-20 21:11   ` Yonghong Song
2020-08-21  8:58     ` Toke Høiland-Jørgensen
2020-08-21 20:10       ` YiFei Zhu
2020-08-23 18:36         ` Toke Høiland-Jørgensen
2020-08-28 17:00           ` sdf
2020-08-28 20:55             ` Toke Høiland-Jørgensen
2020-08-26  5:36   ` Andrii Nakryiko
2020-08-28 16:59     ` sdf
2020-09-03  5:18       ` Andrii Nakryiko
2020-08-20  9:42 ` [PATCH bpf-next 5/5] selftests/bpf: Test bpftool loading and " YiFei Zhu
2020-08-20 21:15   ` Yonghong Song
2020-08-26  4:00     ` Andrii Nakryiko [this message]

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=CAEf4BzahcdM2W8YwmWdoVwYENXmKjkgvru4Qj_uCN8BddKnoJA@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=maheshb@google.com \
    --cc=sdf@google.com \
    --cc=yhs@fb.com \
    --cc=zhuyifei1999@gmail.com \
    --cc=zhuyifei@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.