[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZMO7j1LsESEetTJCRpw4HDZ994C5RigFU+uQ1tgQa_PQ@mail.gmail.com>
Date: Fri, 1 Nov 2019 22:10:22 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Toke Høiland-Jørgensen <toke@...hat.com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
David Miller <davem@...emloft.net>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v5 2/5] libbpf: Store map pin path and status in
struct bpf_map
On Fri, Nov 1, 2019 at 2:53 AM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>
> From: Toke Høiland-Jørgensen <toke@...hat.com>
>
> Support storing and setting a pin path in struct bpf_map, which can be used
> for automatic pinning. Also store the pin status so we can avoid attempts
> to re-pin a map that has already been pinned (or reused from a previous
> pinning).
>
> The behaviour of bpf_object__{un,}pin_maps() is changed so that if it is
> called with a NULL path argument (which was previously illegal), it will
> (un)pin only those maps that have a pin_path set.
>
> Acked-by: Andrii Nakryiko <andriin@...com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
> ---
> tools/lib/bpf/libbpf.c | 164 +++++++++++++++++++++++++++++++++++-----------
> tools/lib/bpf/libbpf.h | 8 ++
> tools/lib/bpf/libbpf.map | 3 +
> 3 files changed, 134 insertions(+), 41 deletions(-)
>
[...]
> LIBBPF_API int bpf_object__pin_maps(struct bpf_object *obj, const char *path);
> LIBBPF_API int bpf_object__unpin_maps(struct bpf_object *obj,
> const char *path);
> @@ -385,6 +390,9 @@ LIBBPF_API int bpf_map__resize(struct bpf_map *map, __u32 max_entries);
> LIBBPF_API bool bpf_map__is_offload_neutral(const struct bpf_map *map);
> LIBBPF_API bool bpf_map__is_internal(const struct bpf_map *map);
> LIBBPF_API void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex);
> +LIBBPF_API int bpf_map__set_pin_path(struct bpf_map *map, const char *path);
> +LIBBPF_API const char *bpf_map__get_pin_path(struct bpf_map *map);
> +LIBBPF_API bool bpf_map__is_pinned(struct bpf_map *map);
Didn't notice this before and wasn't going to force another version
just for this, but given you'll be fixing last patch anyways...
bpf_map__is_pinned and bpf_map__get_pin_path are read-only "getters",
so it would be appropriate for them to accept "const struct bpf_map *"
instead.
> LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path);
> LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path);
>
> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index d1473ea4d7a5..1681a9ce109f 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -193,6 +193,9 @@ LIBBPF_0.0.5 {
>
> LIBBPF_0.0.6 {
> global:
> + bpf_map__get_pin_path;
> + bpf_map__is_pinned;
> + bpf_map__set_pin_path;
> bpf_object__open_file;
> bpf_object__open_mem;
> bpf_program__get_expected_attach_type;
>
Powered by blists - more mailing lists