diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2017-05-02 14:32:01 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-03 09:30:24 -0400 |
commit | 6979bcc731f9680824a85a9efc43f36d01cec1b2 (patch) | |
tree | 930220b0624efcd0c0b94e4c3dbaabf85202fc72 /samples/bpf/map_perf_test_user.c | |
parent | 156450d9d964447adfb44a231c634d2f5609d110 (diff) | |
download | talos-obmc-linux-6979bcc731f9680824a85a9efc43f36d01cec1b2.tar.gz talos-obmc-linux-6979bcc731f9680824a85a9efc43f36d01cec1b2.zip |
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 <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/map_perf_test_user.c')
-rw-r--r-- | samples/bpf/map_perf_test_user.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/samples/bpf/map_perf_test_user.c b/samples/bpf/map_perf_test_user.c index 6ac778153315..1a8894b5ac51 100644 --- a/samples/bpf/map_perf_test_user.c +++ b/samples/bpf/map_perf_test_user.c @@ -320,21 +320,21 @@ static void fill_lpm_trie(void) assert(!r); } -static void fixup_map(struct bpf_map_def *map, const char *name, int idx) +static void fixup_map(struct bpf_map_data *map, int idx) { int i; - if (!strcmp("inner_lru_hash_map", name)) { + if (!strcmp("inner_lru_hash_map", map->name)) { inner_lru_hash_idx = idx; - inner_lru_hash_size = map->max_entries; + inner_lru_hash_size = map->def.max_entries; } - if (!strcmp("array_of_lru_hashs", name)) { + if (!strcmp("array_of_lru_hashs", map->name)) { if (inner_lru_hash_idx == -1) { printf("inner_lru_hash_map must be defined before array_of_lru_hashs\n"); exit(1); } - map->inner_map_idx = inner_lru_hash_idx; + map->def.inner_map_idx = inner_lru_hash_idx; array_of_lru_hashs_idx = idx; } @@ -345,9 +345,9 @@ static void fixup_map(struct bpf_map_def *map, const char *name, int idx) /* Only change the max_entries for the enabled test(s) */ for (i = 0; i < NR_TESTS; i++) { - if (!strcmp(test_map_names[i], name) && + if (!strcmp(test_map_names[i], map->name) && (check_test_flags(i))) { - map->max_entries = num_map_entries; + map->def.max_entries = num_map_entries; } } } |