diff options
author | Toke Høiland-Jørgensen <toke@redhat.com> | 2019-11-02 12:09:42 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-11-02 12:35:07 -0700 |
commit | 2f4a32cc83a584ac3669d44fa2aa1d7f115d44c1 (patch) | |
tree | 8f65a718732bf3935e040a7c745b83ca70362ca3 /tools/testing/selftests/bpf/progs/test_pinning.c | |
parent | 57a00f41644f20b11c12a27061d814655f633544 (diff) |
selftests: Add tests for automatic map pinning
This adds a new BPF selftest to exercise the new automatic map pinning
code.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/157269298209.394725.15420085139296213182.stgit@toke.dk
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_pinning.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_pinning.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_pinning.c b/tools/testing/selftests/bpf/progs/test_pinning.c new file mode 100644 index 000000000000..f69a4a50d056 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/test_pinning.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bpf.h> +#include "bpf_helpers.h" + +int _version SEC("version") = 1; + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, __u32); + __type(value, __u64); + __uint(pinning, LIBBPF_PIN_BY_NAME); +} pinmap SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 1); + __type(key, __u32); + __type(value, __u64); +} nopinmap SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, __u32); + __type(value, __u64); + __uint(pinning, LIBBPF_PIN_NONE); +} nopinmap2 SEC(".maps"); + +char _license[] SEC("license") = "GPL"; |