diff options
author | Jonathan Lemon <jonathan.lemon@gmail.com> | 2019-06-06 22:59:42 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-06-11 08:31:26 +0200 |
commit | 940e7be34ab3d04b7e0b6dd57bdbda1d225c3d8c (patch) | |
tree | bd14d555613cd7c13e3e5f73f33fdfff80eabb19 /tools | |
parent | bpf/tools: sync bpf.h (diff) | |
download | linux-940e7be34ab3d04b7e0b6dd57bdbda1d225c3d8c.tar.xz linux-940e7be34ab3d04b7e0b6dd57bdbda1d225c3d8c.zip |
tools/bpf: Add bpf_map_lookup_elem selftest for xskmap
Check that bpf_map_lookup_elem lookup and structure
access operats correctly.
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/verifier/sock.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/verifier/sock.c b/tools/testing/selftests/bpf/verifier/sock.c index b31cd2cf50d0..9ed192e14f5f 100644 --- a/tools/testing/selftests/bpf/verifier/sock.c +++ b/tools/testing/selftests/bpf/verifier/sock.c @@ -498,3 +498,21 @@ .result = REJECT, .errstr = "cannot pass map_type 24 into func bpf_map_lookup_elem", }, +{ + "bpf_map_lookup_elem(xskmap, &key); xs->queue_id", + .insns = { + BPF_ST_MEM(BPF_W, BPF_REG_10, -8, 0), + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), + BPF_LD_MAP_FD(BPF_REG_1, 0), + BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), + BPF_EXIT_INSN(), + BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, offsetof(struct bpf_xdp_sock, queue_id)), + BPF_MOV64_IMM(BPF_REG_0, 0), + BPF_EXIT_INSN(), + }, + .fixup_map_xskmap = { 3 }, + .prog_type = BPF_PROG_TYPE_XDP, + .result = ACCEPT, +}, |