Re: [PATCH bpf-next v2 1/2] bpf: enable the "open" operator on a pinned path of a struct_osp link.

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

 



On Thu, Apr 18, 2024 at 9:35 AM Kui-Feng Lee <thinker.li@xxxxxxxxx> wrote:
>
> Add the "open" operator for the inodes of BPF links to allow applications
> to obtain a file descriptor of a struct_ops link from a pinned path.
>
> Applications have the ability to update a struct_ops link with another
> struct_ops map. However, they were unable to open pinned paths of the links
> with this patch. This implies that updating a link through its pinned paths
> was not feasible.
>
> This patch adds the "open" operator to bpf_link_ops and uses bpf_link_ops
> as the i_fop for inodes of struct_ops links. "open" will be called to open
> the pinned path represented by an inode. Additionally, bpf_link_ops will be
> used as the f->f_ops of the opened "file" to provide operators for the
> "file".
>
> Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
> ---
>  include/linux/bpf.h         |  6 ++++++
>  kernel/bpf/bpf_struct_ops.c | 10 ++++++++++
>  kernel/bpf/inode.c          | 11 ++++++++---
>  kernel/bpf/syscall.c        | 16 +++++++++++++++-
>  4 files changed, 39 insertions(+), 4 deletions(-)
>

This is already supported, but you don't do it with open() syscall.
bpf() syscall provides BPF_OBJ_GET as a counterpart to BPF_OBJ_PIN. So
what you/your users want to do should be already supported through
libbpf's bpf_obj_get()/bpf_obj_get_ops() APIs. Have you tried that?

> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 5034c1b4ded7..a0c0234d754b 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -2160,6 +2160,12 @@ extern const struct super_operations bpf_super_ops;
>  extern const struct file_operations bpf_map_fops;
>  extern const struct file_operations bpf_prog_fops;
>  extern const struct file_operations bpf_iter_fops;
> +extern const struct file_operations bpf_link_fops;
> +

[...]





[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