diff options
author | Paul Chaignon <paul.chaignon@orange.com> | 2018-04-24 15:07:54 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-04-24 22:39:13 +0200 |
commit | d71962f3e627b5941804036755c844fabfb65ff5 (patch) | |
tree | b619bba706b401cc0c68b8aeb5f9e4ac887a5bae /tools/testing/selftests/bpf/test_verifier.c | |
parent | Merge branch 'bpf-xfrm-states' (diff) | |
download | linux-dev-d71962f3e627b5941804036755c844fabfb65ff5.tar.xz linux-dev-d71962f3e627b5941804036755c844fabfb65ff5.zip |
bpf: allow map helpers access to map values directly
Helpers that expect ARG_PTR_TO_MAP_KEY and ARG_PTR_TO_MAP_VALUE can only
access stack and packet memory. Allow these helpers to directly access
map values by passing registers of type PTR_TO_MAP_VALUE.
This change removes the need for an extra copy to the stack when using a
map value to perform a second map lookup, as in the following:
struct bpf_map_def SEC("maps") infobyreq = {
.type = BPF_MAP_TYPE_HASHMAP,
.key_size = sizeof(struct request *),
.value_size = sizeof(struct info_t),
.max_entries = 1024,
};
struct bpf_map_def SEC("maps") counts = {
.type = BPF_MAP_TYPE_HASHMAP,
.key_size = sizeof(struct info_t),
.value_size = sizeof(u64),
.max_entries = 1024,
};
SEC("kprobe/blk_account_io_start")
int bpf_blk_account_io_start(struct pt_regs *ctx)
{
struct info_t *info = bpf_map_lookup_elem(&infobyreq, &ctx->di);
u64 *count = bpf_map_lookup_elem(&counts, info);
(*count)++;
}
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_verifier.c')
0 files changed, 0 insertions, 0 deletions