[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzaYx9EdabuxjLsN4HKTcq+EfwRzpAYdY-D+74YOTpr4Yg@mail.gmail.com>
Date: Mon, 23 May 2022 16:22:37 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Stanislav Fomichev <sdf@...gle.com>
Cc: Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>
Subject: Re: [PATCH bpf-next v7 07/11] libbpf: implement bpf_prog_query_opts
On Wed, May 18, 2022 at 3:55 PM Stanislav Fomichev <sdf@...gle.com> wrote:
>
> Implement bpf_prog_query_opts as a more expendable version of
> bpf_prog_query. Expose new prog_attach_flags and attach_btf_func_id as
> well:
>
> * prog_attach_flags is a per-program attach_type; relevant only for
> lsm cgroup program which might have different attach_flags
> per attach_btf_id
> * attach_btf_func_id is a new field expose for prog_query which
> specifies real btf function id for lsm cgroup attachments
>
just thoughts aloud... Shouldn't bpf_prog_query() also return link_id
if the attachment was done with LINK_CREATE? And then attach flags
could actually be fetched through corresponding struct bpf_link_info.
That is, bpf_prog_query() returns a list of link_ids, and whatever
link-specific information can be fetched by querying individual links.
Seems more logical (and useful overall) to extend struct bpf_link_info
(you can get it more generically from bpftool, by querying fdinfo,
etc).
> Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> ---
> tools/include/uapi/linux/bpf.h | 5 ++++
> tools/lib/bpf/bpf.c | 42 +++++++++++++++++++++++++++-------
> tools/lib/bpf/bpf.h | 15 ++++++++++++
> tools/lib/bpf/libbpf.map | 1 +
> 4 files changed, 55 insertions(+), 8 deletions(-)
>
[...]
> ret = sys_bpf(BPF_PROG_QUERY, &attr, sizeof(attr));
>
> - if (attach_flags)
> - *attach_flags = attr.query.attach_flags;
> - *prog_cnt = attr.query.prog_cnt;
> + if (OPTS_HAS(opts, prog_cnt))
> + opts->prog_cnt = attr.query.prog_cnt;
just use OPTS_SET() instead of OPTS_HAS check
> + if (OPTS_HAS(opts, attach_flags))
> + opts->attach_flags = attr.query.attach_flags;
>
> return libbpf_err_errno(ret);
> }
>
[...]
> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index 6b36f46ab5d8..24f7a5147bf2 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -452,6 +452,7 @@ LIBBPF_0.8.0 {
> bpf_map_delete_elem_flags;
> bpf_object__destroy_subskeleton;
> bpf_object__open_subskeleton;
> + bpf_prog_query_opts;
please put it into LIBBPF_1.0.0 section, 0.8 is closed now
> bpf_program__attach_kprobe_multi_opts;
> bpf_program__attach_trace_opts;
> bpf_program__attach_usdt;
> --
> 2.36.1.124.g0e6072fb45-goog
>
Powered by blists - more mailing lists