diff options
author | Andrii Nakryiko <andriin@fb.com> | 2019-07-05 08:50:11 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-07-05 22:52:25 +0200 |
commit | bc7430cc8bfb51577e466a8ca02ad87375a70bde (patch) | |
tree | c56b050f3bb07c491da3f0fa082e651dbfe6d993 /tools/testing/selftests/bpf/progs/test_spin_lock.c | |
parent | selftests/bpf: add __uint and __type macro for BTF-defined maps (diff) | |
download | linux-dev-bc7430cc8bfb51577e466a8ca02ad87375a70bde.tar.xz linux-dev-bc7430cc8bfb51577e466a8ca02ad87375a70bde.zip |
selftests/bpf: convert selftests using BTF-defined maps to new syntax
Convert all the existing selftests that are already using BTF-defined
maps to use new syntax (with no static data initialization).
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_spin_lock.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_spin_lock.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_spin_lock.c b/tools/testing/selftests/bpf/progs/test_spin_lock.c index 0a77ae36d981..a43b999c8da2 100644 --- a/tools/testing/selftests/bpf/progs/test_spin_lock.c +++ b/tools/testing/selftests/bpf/progs/test_spin_lock.c @@ -11,14 +11,11 @@ struct hmap_elem { }; struct { - __u32 type; - __u32 max_entries; - int *key; - struct hmap_elem *value; -} hmap SEC(".maps") = { - .type = BPF_MAP_TYPE_HASH, - .max_entries = 1, -}; + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 1); + __type(key, int); + __type(value, struct hmap_elem); +} hmap SEC(".maps"); struct cls_elem { struct bpf_spin_lock lock; @@ -26,12 +23,10 @@ struct cls_elem { }; struct { - __u32 type; - struct bpf_cgroup_storage_key *key; - struct cls_elem *value; -} cls_map SEC(".maps") = { - .type = BPF_MAP_TYPE_CGROUP_STORAGE, -}; + __uint(type, BPF_MAP_TYPE_CGROUP_STORAGE); + __type(key, struct bpf_cgroup_storage_key); + __type(value, struct cls_elem); +} cls_map SEC(".maps"); struct bpf_vqueue { struct bpf_spin_lock lock; @@ -42,14 +37,11 @@ struct bpf_vqueue { }; struct { - __u32 type; - __u32 max_entries; - int *key; - struct bpf_vqueue *value; -} vqueue SEC(".maps") = { - .type = BPF_MAP_TYPE_ARRAY, - .max_entries = 1, -}; + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 1); + __type(key, int); + __type(value, struct bpf_vqueue); +} vqueue SEC(".maps"); #define CREDIT_PER_NS(delta, rate) (((delta) * rate) >> 20) |