From b73413e5114e7aabacd2adfc9dc1e796b3677c2f Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sat, 2 Sep 2023 00:29:03 +0200 Subject: sys/linux: support multi-progs for BPF_PROG_QUERY Commit [1] upstream, and subsequent patches, extended the BPF_PROG_QUERY command to support a new multi-prog object in the BPF subsystem. In particular the command can now dump the link IDs and the link attach flags. It is also the only way currently to retrieve the revision number of a BPF program (for use in BPF_PROG_{ATTACH,DETACH} commands). 1 - 053c8e1f235dc ("bpf: Add generic attach/detach/query API for multi-progs") Signed-off-by: Paul Chaignon --- sys/linux/bpf.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt index 56f33c204..d6ad7a0b2 100644 --- a/sys/linux/bpf.txt +++ b/sys/linux/bpf.txt @@ -17,6 +17,7 @@ resource bpf_map_id[int32]: 0, -1 resource bpf_btf_id[int32]: 0, -1 resource bpf_link_id[int32]: 0, -1 resource fd_bpf_link[fd] +resource bpf_revision[int64] # NEED: this is a random index in btf_header:types. We can't express this, so we just use a small index. type btf_type_id int32[1:5] @@ -51,7 +52,7 @@ bpf$BPF_MAP_GET_FD_BY_ID(cmd const[BPF_MAP_GET_FD_BY_ID], arg ptr[in, bpf_map_ge bpf$BPF_GET_PROG_INFO(cmd const[BPF_OBJ_GET_INFO_BY_FD], arg ptr[in, bpf_get_prog_info_arg], size len[arg]) bpf$BPF_GET_MAP_INFO(cmd const[BPF_OBJ_GET_INFO_BY_FD], arg ptr[in, bpf_get_map_info_arg], size len[arg]) bpf$BPF_GET_BTF_INFO(cmd const[BPF_OBJ_GET_INFO_BY_FD], arg ptr[in, bpf_get_btf_info_arg], size len[arg]) -bpf$BPF_PROG_QUERY(cmd const[BPF_PROG_QUERY], arg ptr[in, bpf_prog_query], size len[arg]) +bpf$BPF_PROG_QUERY(cmd const[BPF_PROG_QUERY], arg ptr[inout, bpf_prog_query], size len[arg]) bpf$BPF_BTF_LOAD(cmd const[BPF_BTF_LOAD], arg ptr[in, bpf_btf_load], size len[arg]) fd_btf bpf$BPF_BTF_GET_FD_BY_ID(cmd const[BPF_BTF_GET_FD_BY_ID], arg ptr[in, bpf_btf_id], size len[arg]) fd_btf bpf$BPF_TASK_FD_QUERY(cmd const[BPF_TASK_FD_QUERY], arg ptr[inout, bpf_task_fd_query], size len[arg]) @@ -582,7 +583,7 @@ bpf_attach_arg { flags flags[bpf_attach_flags, int32] replace_bpf_fd fd_bpf_prog relative_obj id_or_fd - exp_revision int64 + exp_revision bpf_revision } bpf_detach_arg { @@ -592,7 +593,7 @@ bpf_detach_arg { flags flags[bpf_mprog_attach_flags, int32] replace_bpf_fd const[0, int32] relative_obj id_or_fd - exp_revision int64 + exp_revision bpf_revision } bpf_test_prog_arg { @@ -747,13 +748,17 @@ bpf_btf_info { } [align[8]] bpf_prog_query { - target_fd fd_cgroup + target_fd bpf_attach_targets attach_type flags[bpf_prog_query_attach_type, int32] query_flags flags[bpf_prog_query_flags, int32] attach_flags int32 prog_ids ptr64[out, array[int32]] prog_cnt len[prog_ids, int32] + pad const[0, int32] prog_attach_flags ptr64[out, array[int32]] + link_ids ptr64[out, array[int32]] + link_attach_flags ptr64[out, array[int32]] + revision bpf_revision (out) } [align[8]] bpf_btf_load { -- cgit mrf-deployment