[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8736f6mtq8.fsf@toke.dk>
Date: Sat, 02 Nov 2019 11:57:03 +0100
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.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
Andrii Nakryiko <andrii.nakryiko@...il.com> writes:
> 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.
Can do :)
Powered by blists - more mailing lists