diff options
author | YiFei Zhu <zhuyifei@google.com> | 2020-09-16 02:45:43 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-09-16 04:28:27 +0300 |
commit | d42d1cc44d702123d6ff12ce54a0e854036d29cb (patch) | |
tree | d4cb7f11dd9c6d75bd829770ffdf9dcc68203f67 /tools/testing/selftests/bpf/progs/metadata_used.c | |
parent | aff52e685eb39984f3a613e8a5c570d97e5d2414 (diff) | |
download | linux-d42d1cc44d702123d6ff12ce54a0e854036d29cb.tar.xz |
selftests/bpf: Test load and dump metadata with btftool and skel
This is a simple test to check that loading and dumping metadata
in btftool works, whether or not metadata contents are used by the
program.
A C test is also added to make sure the skeleton code can read the
metadata values.
Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Cc: YiFei Zhu <zhuyifei1999@gmail.com>
Link: https://lore.kernel.org/bpf/20200915234543.3220146-6-sdf@google.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/metadata_used.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/metadata_used.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/metadata_used.c b/tools/testing/selftests/bpf/progs/metadata_used.c new file mode 100644 index 000000000000..b7198e65383d --- /dev/null +++ b/tools/testing/selftests/bpf/progs/metadata_used.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +volatile const char bpf_metadata_a[] SEC(".rodata") = "bar"; +volatile const int bpf_metadata_b SEC(".rodata") = 2; + +SEC("cgroup_skb/egress") +int prog(struct xdp_md *ctx) +{ + return bpf_metadata_b ? 1 : 0; +} + +char _license[] SEC("license") = "GPL"; |