linux-bl808/tools/testing/selftests/bpf
Daniel Borkmann f3515b5d0b bpf: provide a generic macro for percpu values for selftests
To overcome bugs as described and fixed in 89087c456f ("bpf: Fix
values type used in test_maps"), provide a generic BPF_DECLARE_PERCPU()
and bpf_percpu() accessor macro for all percpu map values used in
tests.

Declaring variables works as follows (also works for structs):

  BPF_DECLARE_PERCPU(uint32_t, my_value);

They can then be accessed normally as uint32_t type through:

  bpf_percpu(my_value, <cpu_nr>)

For example:

  bpf_percpu(my_value, 0)++;

Implicitly, we make sure that the passed type is allocated and aligned
by gcc at least on a 8-byte boundary, so that it works together with
the map lookup/update syscall for percpu maps. We use it as a usage
example in test_maps, so that others are free to adapt this into their
code when necessary.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-28 15:48:15 -04:00
..
.gitignore bpf: Add test_tag to .gitignore 2017-02-10 15:56:08 -05:00
bpf_util.h bpf: provide a generic macro for percpu values for selftests 2017-04-28 15:48:15 -04:00
config
Makefile Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-04-06 08:24:51 -07:00
test_iptunnel_common.h selftests/bpf: add a test for basic XDP functionality 2017-04-01 12:45:57 -07:00
test_kmod.sh selftests: do not require bash to run bpf tests 2017-01-05 13:19:47 -07:00
test_l4lb.c bpf: fix _htons occurences in test_progs 2017-04-28 15:48:15 -04:00
test_lpm_map.c bpf: Remove bpf_sys.h from selftests 2017-02-10 15:56:08 -05:00
test_lru_map.c bpf: lru: Lower the PERCPU_NR_SCANS from 16 to 4 2017-04-17 13:55:52 -04:00
test_maps.c bpf: provide a generic macro for percpu values for selftests 2017-04-28 15:48:15 -04:00
test_pkt_access.c bpf: fix _htons occurences in test_progs 2017-04-28 15:48:15 -04:00
test_progs.c bpf: fix _htons occurences in test_progs 2017-04-28 15:48:15 -04:00
test_tag.c bpf: Remove bpf_sys.h from selftests 2017-02-10 15:56:08 -05:00
test_verifier.c bpf: add various test cases to verifier selftests 2017-04-28 15:48:14 -04:00
test_xdp.c selftests/bpf: add a test for basic XDP functionality 2017-04-01 12:45:57 -07:00