From 6979bcc731f9680824a85a9efc43f36d01cec1b2 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Tue, 2 May 2017 14:32:01 +0200 Subject: samples/bpf: load_bpf.c make callback fixup more flexible Do this change before others start to use this callback. Change map_perf_test_user.c which seems to be the only user. This patch extends capabilities of commit 9fd63d05f3e8 ("bpf: Allow bpf sample programs (*_user.c) to change bpf_map_def"). Give fixup callback access to struct bpf_map_data, instead of only stuct bpf_map_def. This add flexibility to allow userspace to reassign the map file descriptor. This is very useful when wanting to share maps between several bpf programs. Signed-off-by: Jesper Dangaard Brouer Signed-off-by: David S. Miller --- samples/bpf/bpf_load.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'samples/bpf/bpf_load.h') diff --git a/samples/bpf/bpf_load.h b/samples/bpf/bpf_load.h index 05822f83173a..4d4fd4678a64 100644 --- a/samples/bpf/bpf_load.h +++ b/samples/bpf/bpf_load.h @@ -15,8 +15,14 @@ struct bpf_map_def { unsigned int inner_map_idx; }; -typedef void (*fixup_map_cb)(struct bpf_map_def *map, const char *map_name, - int idx); +struct bpf_map_data { + int fd; + char *name; + size_t elf_offset; + struct bpf_map_def def; +}; + +typedef void (*fixup_map_cb)(struct bpf_map_data *map, int idx); extern int map_fd[MAX_MAPS]; extern int prog_fd[MAX_PROGS]; -- cgit v1.2.3