Re: [PATCH bpf-next] libbpf: auto-attach skeletons struct_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 5, 2024 at 10:51 AM Mykyta Yatsenko
<mykyta.yatsenko5@xxxxxxxxx> wrote:
>
> From: Mykyta Yatsenko <yatsenko@xxxxxxxx>
>
> Similarly to `bpf_program`, support `bpf_map` automatic attachment in
> `bpf_object__attach_skeleton`. Currently only struct_ops maps could be
> attached.
>
> Bpftool
> Code-generate links in skeleton struct for struct_ops maps.
> Similarly to `bpf_program_skeleton`, set links in `bpf_map_skeleton`.
>
> Libbpf
> Extending `bpf_map` with new `autoattach` field to support enabling or
> disabling autoattach functionality, introducing getter/setter for this
> field.
> Extending `bpf_object__(attach|detach)_skeleton` with
> attaching/detaching struct_ops maps.
>
> Signed-off-by: Mykyta Yatsenko <yatsenko@xxxxxxxx>
> ---
>  tools/bpf/bpftool/gen.c  | 36 +++++++++++++++++++---
>  tools/lib/bpf/libbpf.c   | 65 ++++++++++++++++++++++++++++++++++++++--
>  tools/lib/bpf/libbpf.h   | 20 +++++++++++++
>  tools/lib/bpf/libbpf.map |  2 ++
>  4 files changed, 116 insertions(+), 7 deletions(-)
>

This looks great and finished (see minor nit below which I fixed up
while applying). I know you had a selftest ready, why didn't you
submit it? Please follow up with a selftest so we have this
functionality executed in our selftests. Thanks!

[...]

> +               /* only struct_ops maps can be attached */
> +               if (!bpf_map__is_struct_ops(map))
> +                       continue;
> +               *link = bpf_map__attach_struct_ops(map);
> +
> +               if (!*link) {
> +                       const int errcode = errno;
> +
> +                       pr_warn("struct_ops %s: failed to auto-attach: %d\n", bpf_map__name(map),
> +                               errcode);
> +                       return libbpf_err(-errcode);

there is err variable already in this function, I switched to using it here

> +               }
> +       }
> +
>         return 0;
>  }
>

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux