aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/libbpf.h
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2018-11-09 11:21:41 -0500
committerAlexei Starovoitov <ast@kernel.org>2018-11-10 18:56:10 -0500
commit0c19a9fbc9cdba29c7effb34fd5a97226bf934e6 (patch)
treec5eb6df4d8b1e102e9e9f9a4ac1dad116b08a1a9 /tools/lib/bpf/libbpf.h
parent108d50a976db70c59e6f2fc58d3252fd38ef3fc4 (diff)
libbpf: cleanup after partial failure in bpf_object__pin
bpftool will use bpf_object__pin in the next commits to pin all programs and maps from the file; in case of a partial failure, we need to get back to the clean state (undo previous program/map pins). As part of a cleanup, I've added and exported separate routines to pin all maps (bpf_object__pin_maps) and progs (bpf_object__pin_programs) of an object. Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r--tools/lib/bpf/libbpf.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 1f3468dad8b2..b1686a787102 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -71,6 +71,13 @@ struct bpf_object *__bpf_object__open_xattr(struct bpf_object_open_attr *attr,
71LIBBPF_API struct bpf_object *bpf_object__open_buffer(void *obj_buf, 71LIBBPF_API struct bpf_object *bpf_object__open_buffer(void *obj_buf,
72 size_t obj_buf_sz, 72 size_t obj_buf_sz,
73 const char *name); 73 const char *name);
74LIBBPF_API int bpf_object__pin_maps(struct bpf_object *obj, const char *path);
75LIBBPF_API int bpf_object__unpin_maps(struct bpf_object *obj,
76 const char *path);
77LIBBPF_API int bpf_object__pin_programs(struct bpf_object *obj,
78 const char *path);
79LIBBPF_API int bpf_object__unpin_programs(struct bpf_object *obj,
80 const char *path);
74LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path); 81LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path);
75LIBBPF_API void bpf_object__close(struct bpf_object *object); 82LIBBPF_API void bpf_object__close(struct bpf_object *object);
76 83
@@ -112,6 +119,9 @@ LIBBPF_API struct bpf_program *bpf_program__next(struct bpf_program *prog,
112 (pos) != NULL; \ 119 (pos) != NULL; \
113 (pos) = bpf_program__next((pos), (obj))) 120 (pos) = bpf_program__next((pos), (obj)))
114 121
122LIBBPF_API struct bpf_program *bpf_program__prev(struct bpf_program *prog,
123 struct bpf_object *obj);
124
115typedef void (*bpf_program_clear_priv_t)(struct bpf_program *, 125typedef void (*bpf_program_clear_priv_t)(struct bpf_program *,
116 void *); 126 void *);
117 127
@@ -131,7 +141,11 @@ LIBBPF_API int bpf_program__fd(struct bpf_program *prog);
131LIBBPF_API int bpf_program__pin_instance(struct bpf_program *prog, 141LIBBPF_API int bpf_program__pin_instance(struct bpf_program *prog,
132 const char *path, 142 const char *path,
133 int instance); 143 int instance);
144LIBBPF_API int bpf_program__unpin_instance(struct bpf_program *prog,
145 const char *path,
146 int instance);
134LIBBPF_API int bpf_program__pin(struct bpf_program *prog, const char *path); 147LIBBPF_API int bpf_program__pin(struct bpf_program *prog, const char *path);
148LIBBPF_API int bpf_program__unpin(struct bpf_program *prog, const char *path);
135LIBBPF_API void bpf_program__unload(struct bpf_program *prog); 149LIBBPF_API void bpf_program__unload(struct bpf_program *prog);
136 150
137struct bpf_insn; 151struct bpf_insn;
@@ -260,6 +274,9 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
260 (pos) != NULL; \ 274 (pos) != NULL; \
261 (pos) = bpf_map__next((pos), (obj))) 275 (pos) = bpf_map__next((pos), (obj)))
262 276
277LIBBPF_API struct bpf_map *
278bpf_map__prev(struct bpf_map *map, struct bpf_object *obj);
279
263LIBBPF_API int bpf_map__fd(struct bpf_map *map); 280LIBBPF_API int bpf_map__fd(struct bpf_map *map);
264LIBBPF_API const struct bpf_map_def *bpf_map__def(struct bpf_map *map); 281LIBBPF_API const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
265LIBBPF_API const char *bpf_map__name(struct bpf_map *map); 282LIBBPF_API const char *bpf_map__name(struct bpf_map *map);
@@ -274,6 +291,7 @@ LIBBPF_API int bpf_map__reuse_fd(struct bpf_map *map, int fd);
274LIBBPF_API bool bpf_map__is_offload_neutral(struct bpf_map *map); 291LIBBPF_API bool bpf_map__is_offload_neutral(struct bpf_map *map);
275LIBBPF_API void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex); 292LIBBPF_API void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex);
276LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path); 293LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path);
294LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path);
277 295
278LIBBPF_API long libbpf_get_error(const void *ptr); 296LIBBPF_API long libbpf_get_error(const void *ptr);
279 297