Commit 068ca522 authored by Daniel Xu's avatar Daniel Xu Committed by Andrii Nakryiko

libbpf: Add bpf_object__unpin()

For bpf_object__pin_programs() there is bpf_object__unpin_programs().
Likewise bpf_object__unpin_maps() for bpf_object__pin_maps().

But no bpf_object__unpin() for bpf_object__pin(). Adding the former adds
symmetry to the API.

It's also convenient for cleanup in application code. It's an API I
would've used if it was available for a repro I was writing earlier.
Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Reviewed-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/bpf/b2f9d41da4a350281a0b53a804d11b68327e14e5.1692832478.git.dxu@dxuuu.xyz
parent f586a770
...@@ -8376,6 +8376,21 @@ int bpf_object__pin(struct bpf_object *obj, const char *path) ...@@ -8376,6 +8376,21 @@ int bpf_object__pin(struct bpf_object *obj, const char *path)
return 0; return 0;
} }
int bpf_object__unpin(struct bpf_object *obj, const char *path)
{
int err;
err = bpf_object__unpin_programs(obj, path);
if (err)
return libbpf_err(err);
err = bpf_object__unpin_maps(obj, path);
if (err)
return libbpf_err(err);
return 0;
}
static void bpf_map__destroy(struct bpf_map *map) static void bpf_map__destroy(struct bpf_map *map)
{ {
if (map->inner_map) { if (map->inner_map) {
......
...@@ -266,6 +266,7 @@ LIBBPF_API int bpf_object__pin_programs(struct bpf_object *obj, ...@@ -266,6 +266,7 @@ LIBBPF_API int bpf_object__pin_programs(struct bpf_object *obj,
LIBBPF_API int bpf_object__unpin_programs(struct bpf_object *obj, LIBBPF_API int bpf_object__unpin_programs(struct bpf_object *obj,
const char *path); const char *path);
LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path); LIBBPF_API int bpf_object__pin(struct bpf_object *object, const char *path);
LIBBPF_API int bpf_object__unpin(struct bpf_object *object, const char *path);
LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj); LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj);
LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj); LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj);
......
...@@ -395,6 +395,7 @@ LIBBPF_1.2.0 { ...@@ -395,6 +395,7 @@ LIBBPF_1.2.0 {
LIBBPF_1.3.0 { LIBBPF_1.3.0 {
global: global:
bpf_obj_pin_opts; bpf_obj_pin_opts;
bpf_object__unpin;
bpf_prog_detach_opts; bpf_prog_detach_opts;
bpf_program__attach_netfilter; bpf_program__attach_netfilter;
bpf_program__attach_tcx; bpf_program__attach_tcx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment