diff options
author | Stanislav Fomichev <sdf@google.com> | 2018-11-09 11:21:41 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-11-10 18:56:10 -0500 |
commit | 0c19a9fbc9cdba29c7effb34fd5a97226bf934e6 (patch) | |
tree | c5eb6df4d8b1e102e9e9f9a4ac1dad116b08a1a9 /tools/lib/bpf/libbpf.h | |
parent | 108d50a976db70c59e6f2fc58d3252fd38ef3fc4 (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.h | 18 |
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, | |||
71 | LIBBPF_API struct bpf_object *bpf_object__open_buffer(void *obj_buf, | 71 | LIBBPF_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); |
74 | LIBBPF_API int bpf_object__pin_maps(struct bpf_object *obj, const char *path); | ||
75 | LIBBPF_API int bpf_object__unpin_maps(struct bpf_object *obj, | ||
76 | const char *path); | ||
77 | LIBBPF_API int bpf_object__pin_programs(struct bpf_object *obj, | ||
78 | const char *path); | ||
79 | LIBBPF_API int bpf_object__unpin_programs(struct bpf_object *obj, | ||
80 | const char *path); | ||
74 | LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path); | 81 | LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path); |
75 | LIBBPF_API void bpf_object__close(struct bpf_object *object); | 82 | LIBBPF_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 | ||
122 | LIBBPF_API struct bpf_program *bpf_program__prev(struct bpf_program *prog, | ||
123 | struct bpf_object *obj); | ||
124 | |||
115 | typedef void (*bpf_program_clear_priv_t)(struct bpf_program *, | 125 | typedef 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); | |||
131 | LIBBPF_API int bpf_program__pin_instance(struct bpf_program *prog, | 141 | LIBBPF_API int bpf_program__pin_instance(struct bpf_program *prog, |
132 | const char *path, | 142 | const char *path, |
133 | int instance); | 143 | int instance); |
144 | LIBBPF_API int bpf_program__unpin_instance(struct bpf_program *prog, | ||
145 | const char *path, | ||
146 | int instance); | ||
134 | LIBBPF_API int bpf_program__pin(struct bpf_program *prog, const char *path); | 147 | LIBBPF_API int bpf_program__pin(struct bpf_program *prog, const char *path); |
148 | LIBBPF_API int bpf_program__unpin(struct bpf_program *prog, const char *path); | ||
135 | LIBBPF_API void bpf_program__unload(struct bpf_program *prog); | 149 | LIBBPF_API void bpf_program__unload(struct bpf_program *prog); |
136 | 150 | ||
137 | struct bpf_insn; | 151 | struct 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 | ||
277 | LIBBPF_API struct bpf_map * | ||
278 | bpf_map__prev(struct bpf_map *map, struct bpf_object *obj); | ||
279 | |||
263 | LIBBPF_API int bpf_map__fd(struct bpf_map *map); | 280 | LIBBPF_API int bpf_map__fd(struct bpf_map *map); |
264 | LIBBPF_API const struct bpf_map_def *bpf_map__def(struct bpf_map *map); | 281 | LIBBPF_API const struct bpf_map_def *bpf_map__def(struct bpf_map *map); |
265 | LIBBPF_API const char *bpf_map__name(struct bpf_map *map); | 282 | LIBBPF_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); | |||
274 | LIBBPF_API bool bpf_map__is_offload_neutral(struct bpf_map *map); | 291 | LIBBPF_API bool bpf_map__is_offload_neutral(struct bpf_map *map); |
275 | LIBBPF_API void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex); | 292 | LIBBPF_API void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex); |
276 | LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path); | 293 | LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path); |
294 | LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path); | ||
277 | 295 | ||
278 | LIBBPF_API long libbpf_get_error(const void *ptr); | 296 | LIBBPF_API long libbpf_get_error(const void *ptr); |
279 | 297 | ||