All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Dmitrii Dolgov <9erthalion6@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, Yonghong Song <yhs@fb.com>,
	Song Liu <songliubraving@fb.com>
Subject: Re: [RFC PATCH bpf-next 1/2] bpf: Add bpf_link iterator
Date: Wed, 27 Apr 2022 12:03:47 -0700	[thread overview]
Message-ID: <CAEf4BzZxq3koNMRAXw-o=vdkqqiwfyPhbjgZZ9H+0Dx8UnGo5A@mail.gmail.com> (raw)
In-Reply-To: <20220422182254.13693-2-9erthalion6@gmail.com>

On Fri, Apr 22, 2022 at 11:23 AM Dmitrii Dolgov <9erthalion6@gmail.com> wrote:
>
> Implement bpf_link iterator to traverse links via bpf_seq_file
> operations. The changeset is mostly shamelessly copied from
> commit a228a64fc1e4 ("bpf: Add bpf_prog iterator")
>
> Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com>
> ---
>  include/linux/bpf.h    |   1 +
>  kernel/bpf/Makefile    |   2 +-
>  kernel/bpf/link_iter.c | 107 +++++++++++++++++++++++++++++++++++++++++
>  kernel/bpf/syscall.c   |  19 ++++++++
>  4 files changed, 128 insertions(+), 1 deletion(-)
>  create mode 100644 kernel/bpf/link_iter.c
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 7bf441563ffc..330e88fcc50e 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1489,6 +1489,7 @@ void bpf_link_put(struct bpf_link *link);
>  int bpf_link_new_fd(struct bpf_link *link);
>  struct file *bpf_link_new_file(struct bpf_link *link, int *reserved_fd);
>  struct bpf_link *bpf_link_get_from_fd(u32 ufd);
> +struct bpf_link *bpf_link_get_curr_or_next(u32 *id);
>
>  int bpf_obj_pin_user(u32 ufd, const char __user *pathname);
>  int bpf_obj_get_user(const char __user *pathname, int flags);
> diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
> index c1a9be6a4b9f..057ba8e01e70 100644
> --- a/kernel/bpf/Makefile
> +++ b/kernel/bpf/Makefile
> @@ -6,7 +6,7 @@ cflags-nogcse-$(CONFIG_X86)$(CONFIG_CC_IS_GCC) := -fno-gcse
>  endif
>  CFLAGS_core.o += $(call cc-disable-warning, override-init) $(cflags-nogcse-yy)
>
> -obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o bpf_iter.o map_iter.o task_iter.o prog_iter.o
> +obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o
>  obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o
>  obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o
>  obj-$(CONFIG_BPF_SYSCALL) += bpf_local_storage.o bpf_task_storage.o
> diff --git a/kernel/bpf/link_iter.c b/kernel/bpf/link_iter.c
> new file mode 100644
> index 000000000000..fde41d09f26b
> --- /dev/null
> +++ b/kernel/bpf/link_iter.c
> @@ -0,0 +1,107 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (c) 2020 Facebook */

this probably needs a bit of update?

> +#include <linux/bpf.h>
> +#include <linux/fs.h>
> +#include <linux/filter.h>
> +#include <linux/kernel.h>
> +#include <linux/btf_ids.h>
> +
> +struct bpf_iter_seq_link_info {
> +       u32 link_id;
> +};
> +

[...]

  reply	other threads:[~2022-04-27 19:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 18:22 [RFC PATCH bpf-next 0/2] bpf: bpf link iterator Dmitrii Dolgov
2022-04-22 18:22 ` [RFC PATCH bpf-next 1/2] bpf: Add bpf_link iterator Dmitrii Dolgov
2022-04-27 19:03   ` Andrii Nakryiko [this message]
2022-04-28 16:14   ` Yonghong Song
     [not found]     ` <CA+q6zcXkSBrmnUt3jS+zggqJjUFJQ2J_qUmA4HXtcFmYzYppMg@mail.gmail.com>
2022-04-28 21:02       ` Yonghong Song
2022-04-22 18:22 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Add bpf link iter test Dmitrii Dolgov
2022-04-27 19:03   ` Andrii Nakryiko
2022-04-28 16:42   ` Yonghong Song
2022-04-27 19:04 ` [RFC PATCH bpf-next 0/2] bpf: bpf link iterator Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzZxq3koNMRAXw-o=vdkqqiwfyPhbjgZZ9H+0Dx8UnGo5A@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=9erthalion6@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.