Re: [PATCH bpf-next v6 05/10] bpf: implement BPF_PROG_QUERY for BPF_LSM_CGROUP
From: Stanislav Fomichev <hidden>
Date: 2022-05-09 23:43:51
Also in:
bpf
On Mon, May 9, 2022 at 2:49 PM Andrii Nakryiko [off-list ref] wrote:
On Fri, Apr 29, 2022 at 2:15 PM Stanislav Fomichev [off-list ref] wrote:quoted
We have two options: 1. Treat all BPF_LSM_CGROUP as the same, regardless of attach_btf_id 2. Treat BPF_LSM_CGROUP+attach_btf_id as a separate hook point I'm doing (2) here and adding attach_btf_id as a new BPF_PROG_QUERY argument. The downside is that it requires iterating over all possible bpf_lsm_ hook points in the userspace which might take some time. Signed-off-by: Stanislav Fomichev <redacted> --- include/uapi/linux/bpf.h | 1 + kernel/bpf/cgroup.c | 43 ++++++++++++++++++++++++---------- kernel/bpf/syscall.c | 3 ++- tools/include/uapi/linux/bpf.h | 1 + tools/lib/bpf/bpf.c | 42 ++++++++++++++++++++++++++------- tools/lib/bpf/bpf.h | 15 ++++++++++++ tools/lib/bpf/libbpf.map | 1 +please split kernel and libbpf changes into separate patches and mark libbpf's with "libbpf: " prefix
Ack, thanks, will do this and will address the rest.
quoted
7 files changed, 85 insertions(+), 21 deletions(-)[...]quoted
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index a9d292c106c2..f62823451b99 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c@@ -946,28 +946,54 @@ int bpf_iter_create(int link_fd) return libbpf_err_errno(fd); } -int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, - __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt) +int bpf_prog_query2(int target_fd,this would have to be named bpf_prog_query_opts()quoted
+ enum bpf_attach_type type, + struct bpf_prog_query_opts *opts) { union bpf_attr attr; int ret; memset(&attr, 0, sizeof(attr)); +[...]quoted
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map index b5bc84039407..5e5bb3e437cc 100644 --- a/tools/lib/bpf/libbpf.map +++ b/tools/lib/bpf/libbpf.map@@ -450,4 +450,5 @@ LIBBPF_0.8.0 { bpf_program__attach_usdt; libbpf_register_prog_handler; libbpf_unregister_prog_handler; + bpf_prog_query2;this list is alphabetically orderedquoted
} LIBBPF_0.7.0; -- 2.36.0.464.gb9c8b46e94-goog