summaryrefslogtreecommitdiffstats
path: root/src/shared/bpf-dlopen.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/bpf-dlopen.h')
-rw-r--r--src/shared/bpf-dlopen.h53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/shared/bpf-dlopen.h b/src/shared/bpf-dlopen.h
index 0750abc..df12d08 100644
--- a/src/shared/bpf-dlopen.h
+++ b/src/shared/bpf-dlopen.h
@@ -7,27 +7,44 @@
#include <bpf/libbpf.h>
#include "bpf-compat.h"
+#include "dlfcn-util.h"
-extern struct bpf_link* (*sym_bpf_program__attach_cgroup)(const struct bpf_program *, int);
-extern struct bpf_link* (*sym_bpf_program__attach_lsm)(const struct bpf_program *);
-extern int (*sym_bpf_link__fd)(const struct bpf_link *);
-extern int (*sym_bpf_link__destroy)(struct bpf_link *);
-extern int (*sym_bpf_map__fd)(const struct bpf_map *);
-extern const char* (*sym_bpf_map__name)(const struct bpf_map *);
-extern int (*sym_bpf_map__set_max_entries)(struct bpf_map *, __u32);
-extern int (*sym_bpf_map_update_elem)(int, const void *, const void *, __u64);
-extern int (*sym_bpf_map_delete_elem)(int, const void *);
-extern int (*sym_bpf_map__set_inner_map_fd)(struct bpf_map *, int);
+DLSYM_PROTOTYPE(bpf_link__destroy);
+DLSYM_PROTOTYPE(bpf_link__fd);
+DLSYM_PROTOTYPE(bpf_link__open);
+DLSYM_PROTOTYPE(bpf_link__pin);
+DLSYM_PROTOTYPE(bpf_map__fd);
+DLSYM_PROTOTYPE(bpf_map__name);
+DLSYM_PROTOTYPE(bpf_map__set_inner_map_fd);
+DLSYM_PROTOTYPE(bpf_map__set_max_entries);
+DLSYM_PROTOTYPE(bpf_map__set_pin_path);
+DLSYM_PROTOTYPE(bpf_map_delete_elem);
+DLSYM_PROTOTYPE(bpf_map_get_fd_by_id);
+DLSYM_PROTOTYPE(bpf_map_lookup_elem);
+DLSYM_PROTOTYPE(bpf_map_update_elem);
/* The *_skeleton APIs are autogenerated by bpftool, the targets can be found
* in ./build/src/core/bpf/socket_bind/socket-bind.skel.h */
-extern int (*sym_bpf_object__open_skeleton)(struct bpf_object_skeleton *, const struct bpf_object_open_opts *);
-extern int (*sym_bpf_object__load_skeleton)(struct bpf_object_skeleton *);
-extern int (*sym_bpf_object__attach_skeleton)(struct bpf_object_skeleton *);
-extern void (*sym_bpf_object__detach_skeleton)(struct bpf_object_skeleton *);
-extern void (*sym_bpf_object__destroy_skeleton)(struct bpf_object_skeleton *);
-extern const char* (*sym_bpf_program__name)(const struct bpf_program *);
-extern libbpf_print_fn_t (*sym_libbpf_set_print)(libbpf_print_fn_t);
-extern long (*sym_libbpf_get_error)(const void *);
+DLSYM_PROTOTYPE(bpf_object__attach_skeleton);
+DLSYM_PROTOTYPE(bpf_object__destroy_skeleton);
+DLSYM_PROTOTYPE(bpf_object__detach_skeleton);
+DLSYM_PROTOTYPE(bpf_object__load_skeleton);
+DLSYM_PROTOTYPE(bpf_object__name);
+DLSYM_PROTOTYPE(bpf_object__open_skeleton);
+DLSYM_PROTOTYPE(bpf_object__pin_maps);
+DLSYM_PROTOTYPE(bpf_program__attach);
+DLSYM_PROTOTYPE(bpf_program__attach_cgroup);
+DLSYM_PROTOTYPE(bpf_program__attach_lsm);
+DLSYM_PROTOTYPE(bpf_program__name);
+DLSYM_PROTOTYPE(libbpf_set_print);
+DLSYM_PROTOTYPE(ring_buffer__epoll_fd);
+DLSYM_PROTOTYPE(ring_buffer__free);
+DLSYM_PROTOTYPE(ring_buffer__new);
+DLSYM_PROTOTYPE(ring_buffer__poll);
+
+/* libbpf sometimes returns error codes that make sense only in the kernel, like 524 for EOPNOTSUPP. Use
+ * this helper instead of libbpf_get_error() to ensure some of the known ones are translated into errnos
+ * we understand. */
+int bpf_get_error_translated(const void *ptr);
#endif