From b8163155e3095d17852a6a59c86e4257d06b80d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 13 Jan 2021 16:09:17 -0800 Subject: [PATCH] slightly more type safety for bpf_map_{lookup,update,delete}_elem_unsafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: builds Signed-off-by: Maciej Żenczykowski Change-Id: I808400e624fa96ed72d9a3b1b153b0ce5a84d6f8 --- progs/include/bpf_helpers.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/progs/include/bpf_helpers.h b/progs/include/bpf_helpers.h index 9d22584..d23e275 100644 --- a/progs/include/bpf_helpers.h +++ b/progs/include/bpf_helpers.h @@ -47,18 +47,18 @@ * This will make sure that if you change the type of a map you'll get compile * errors at any spots you forget to update with the new type. * - * Note: these all take 'const void* map' because from the C/eBPF point of view + * Note: these all take pointers to const map because from the C/eBPF point of view * the map struct is really just a readonly map definition of the in kernel object. * Runtime modification of the map defining struct is meaningless, since * the contents is only ever used during bpf program loading & map creation * by the bpf loader, and not by the eBPF program itself. */ -static void* (*bpf_map_lookup_elem_unsafe)(const void* map, +static void* (*bpf_map_lookup_elem_unsafe)(const struct bpf_map_def* map, const void* key) = (void*)BPF_FUNC_map_lookup_elem; -static int (*bpf_map_update_elem_unsafe)(const void* map, const void* key, const void* value, - unsigned long long flags) = (void*) +static int (*bpf_map_update_elem_unsafe)(const struct bpf_map_def* map, const void* key, + const void* value, unsigned long long flags) = (void*) BPF_FUNC_map_update_elem; -static int (*bpf_map_delete_elem_unsafe)(const void* map, +static int (*bpf_map_delete_elem_unsafe)(const struct bpf_map_def* map, const void* key) = (void*)BPF_FUNC_map_delete_elem; /* type safe macro to declare a map and related accessor functions */