[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33e5314f-8546-3945-c73b-25ee13d1b368@iogearbox.net>
Date: Mon, 25 Apr 2022 16:03:38 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Yafang Shao <laoar.shao@...il.com>, ast@...nel.org,
andrii@...nel.org, kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next 4/4] bpftool: Generate helpers for pinning prog
through bpf object skeleton
On 4/23/22 4:00 PM, Yafang Shao wrote:
> After this change, with command 'bpftool gen skeleton XXX.bpf.o', the
> helpers for pinning BPF prog will be generated in BPF object skeleton. It
> could simplify userspace code which wants to pin bpf progs in bpffs.
>
> The new helpers are named with __{pin, unpin}_prog, because it only pins
> bpf progs. If the user also wants to pin bpf maps in bpffs, he can use
> LIBBPF_PIN_BY_NAME.
>
> Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> ---
> tools/bpf/bpftool/gen.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 8f76d8d9996c..1d06ebde723b 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -1087,6 +1087,8 @@ static int do_skeleton(int argc, char **argv)
> static inline int load(struct %1$s *skel); \n\
> static inline int attach(struct %1$s *skel); \n\
> static inline void detach(struct %1$s *skel); \n\
> + static inline int pin_prog(struct %1$s *skel, const char *path);\n\
> + static inline void unpin_prog(struct %1$s *skel); \n\
> static inline void destroy(struct %1$s *skel); \n\
> static inline const void *elf_bytes(size_t *sz); \n\
> #endif /* __cplusplus */ \n\
> @@ -1172,6 +1174,18 @@ static int do_skeleton(int argc, char **argv)
> %1$s__detach(struct %1$s *obj) \n\
> { \n\
> bpf_object__detach_skeleton(obj->skeleton); \n\
> + } \n\
> + \n\
> + static inline int \n\
> + %1$s__pin_prog(struct %1$s *obj, const char *path) \n\
> + { \n\
> + return bpf_object__pin_skeleton_prog(obj->skeleton, path);\n\
> + } \n\
> + \n\
> + static inline void \n\
> + %1$s__unpin_prog(struct %1$s *obj) \n\
> + { \n\
> + bpf_object__unpin_skeleton_prog(obj->skeleton); \n\
> } \n\
(This should also have BPF selftest code as in-tree user.)
> ",
> obj_name
> @@ -1237,6 +1251,8 @@ static int do_skeleton(int argc, char **argv)
> int %1$s::load(struct %1$s *skel) { return %1$s__load(skel); } \n\
> int %1$s::attach(struct %1$s *skel) { return %1$s__attach(skel); } \n\
> void %1$s::detach(struct %1$s *skel) { %1$s__detach(skel); } \n\
> + int %1$s::pin_prog(struct %1$s *skel, const char *path) { return %1$s__pin_prog(skel, path); }\n\
> + void %1$s::unpin_prog(struct %1$s *skel) { %1$s__unpin_prog(skel); } \n\
> void %1$s::destroy(struct %1$s *skel) { %1$s__destroy(skel); } \n\
> const void *%1$s::elf_bytes(size_t *sz) { return %1$s__elf_bytes(sz); } \n\
> #endif /* __cplusplus */ \n\
>
Powered by blists - more mailing lists