mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
bpftool: Add support for subskeletons
Subskeletons are headers which require an already loaded program to operate. For example, when a BPF library is linked into a larger BPF object file, the library userspace needs a way to access its own global variables without requiring knowledge about the larger program at build time. As a result, subskeletons require a loaded bpf_object to open(). Further, they find their own symbols in the larger program by walking BTF type data at run time. At this time, programs, maps, and globals are supported through non-owning pointers. Signed-off-by: Delyan Kratunov <delyank@fb.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/ca8a48b4841c72d285ecce82371bef4a899756cb.1647473511.git.delyank@fb.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
430025e5dc
commit
00389c58ff
@@ -25,6 +25,7 @@ GEN COMMANDS
|
||||
|
||||
| **bpftool** **gen object** *OUTPUT_FILE* *INPUT_FILE* [*INPUT_FILE*...]
|
||||
| **bpftool** **gen skeleton** *FILE* [**name** *OBJECT_NAME*]
|
||||
| **bpftool** **gen subskeleton** *FILE* [**name** *OBJECT_NAME*]
|
||||
| **bpftool** **gen min_core_btf** *INPUT* *OUTPUT* *OBJECT* [*OBJECT*...]
|
||||
| **bpftool** **gen help**
|
||||
|
||||
@@ -150,6 +151,30 @@ DESCRIPTION
|
||||
(non-read-only) data from userspace, with same simplicity
|
||||
as for BPF side.
|
||||
|
||||
**bpftool gen subskeleton** *FILE*
|
||||
Generate BPF subskeleton C header file for a given *FILE*.
|
||||
|
||||
Subskeletons are similar to skeletons, except they do not own
|
||||
the corresponding maps, programs, or global variables. They
|
||||
require that the object file used to generate them is already
|
||||
loaded into a *bpf_object* by some other means.
|
||||
|
||||
This functionality is useful when a library is included into a
|
||||
larger BPF program. A subskeleton for the library would have
|
||||
access to all objects and globals defined in it, without
|
||||
having to know about the larger program.
|
||||
|
||||
Consequently, there are only two functions defined
|
||||
for subskeletons:
|
||||
|
||||
- **example__open(bpf_object\*)**
|
||||
Instantiates a subskeleton from an already opened (but not
|
||||
necessarily loaded) **bpf_object**.
|
||||
|
||||
- **example__destroy()**
|
||||
Frees the storage for the subskeleton but *does not* unload
|
||||
any BPF programs or maps.
|
||||
|
||||
**bpftool** **gen min_core_btf** *INPUT* *OUTPUT* *OBJECT* [*OBJECT*...]
|
||||
Generate a minimum BTF file as *OUTPUT*, derived from a given
|
||||
*INPUT* BTF file, containing all needed BTF types so one, or
|
||||
|
||||
@@ -1003,13 +1003,25 @@ _bpftool()
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
subskeleton)
|
||||
case $prev in
|
||||
$command)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
_bpftool_once_attr 'name'
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
min_core_btf)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
[[ $prev == $object ]] && \
|
||||
COMPREPLY=( $( compgen -W 'object skeleton help min_core_btf' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W 'object skeleton subskeleton help min_core_btf' -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user