[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALOAHbCikXvNEz3f8dqe8_FcNSkvhUGpJtzyvKCgnRBdXPb7Ag@mail.gmail.com>
Date: Wed, 27 Apr 2022 00:00:21 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
john fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, netdev <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next 4/4] bpftool: Generate helpers for pinning prog
through bpf object skeleton
On Mon, Apr 25, 2022 at 10:03 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> 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.)
>
Will do it, thanks.
[snip]
--
Regards
Yafang
Powered by blists - more mailing lists