bpf: Extend BPF syscall with common attributes support#10690
bpf: Extend BPF syscall with common attributes support#10690kernel-patches-daemon-bpf[bot] wants to merge 9 commits intobpf-next_basefrom
Conversation
|
Upstream branch: 5714ca8 |
1a6c4b2 to
695292f
Compare
|
Upstream branch: 9c1a352 |
bed1c82 to
c1242eb
Compare
695292f to
020dffd
Compare
|
Upstream branch: 9c1a352 |
c1242eb to
a1fa4e6
Compare
020dffd to
71b3aa7
Compare
|
Upstream branch: 7af3339 |
a1fa4e6 to
22e0d5f
Compare
71b3aa7 to
9a92374
Compare
|
Upstream branch: da4ab5d |
22e0d5f to
65d0d13
Compare
9a92374 to
f7c018a
Compare
|
Upstream branch: c9c9f6b |
65d0d13 to
de24049
Compare
f7c018a to
393bcc0
Compare
|
Upstream branch: b9da173 |
de24049 to
29c5d32
Compare
5fad8c5 to
f61cb76
Compare
|
Upstream branch: 9a403a4 |
35532c2 to
8e96be1
Compare
f61cb76 to
91752c7
Compare
|
Upstream branch: 934d974 |
8e96be1 to
9b8d32c
Compare
91752c7 to
8958bae
Compare
|
Upstream branch: 2acbd05 |
9b8d32c to
442d3e0
Compare
8958bae to
66b50de
Compare
Extend the BPF syscall to support a set of common attributes shared
across all BPF commands:
1. 'log_buf': User-provided buffer for storing logs.
2. 'log_size': Size of the log buffer.
3. 'log_level': Log verbosity level.
4. 'log_true_size': The size of log reported by kernel.
These common attributes are passed as the 4th argument to the BPF
syscall, with the 5th argument specifying the size of this structure.
To indicate the use of these common attributes from userspace, a new flag
'BPF_COMMON_ATTRS' ('1 << 16') is introduced. This flag is OR-ed into the
'cmd' field of the syscall.
When 'cmd & BPF_COMMON_ATTRS' is set, the kernel will copy the common
attributes from userspace into kernel space for use.
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
To support the extended BPF syscall introduced in the previous commit, introduce the following internal APIs: * 'sys_bpf_ext()' * 'sys_bpf_ext_fd()' They wrap the raw 'syscall()' interface to support passing extended attributes. * 'probe_sys_bpf_ext()' Check whether current kernel supports the extended attributes. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
The next commit will add support for reporting logs via extended common attributes, including 'log_true_size'. To prepare for that, refactor the 'log_true_size' reporting logic by introducing a new struct bpf_log_attr to encapsulate log-related behavior: * bpf_prog_load_log_attr_init(): initialize the log fields, which will support extended common attributes in the next commit. * bpf_log_attr_finalize(): handle log finalization and write back 'log_true_size' to userspace. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
The log buffer of common attributes would be confusing with the one in 'union bpf_attr' for BPF_PROG_LOAD. In order to clarify the usage of these two log buffers, they both can be used for logging if: * They are same, including 'log_buf', 'log_level' and 'log_size'. * One of them is missing, then another one will be used for logging. If they both have 'log_buf' but they are not same totally, return -EUSERS. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
In the next commit, it will be able to report logs via extended common attributes, which will report 'log_true_size' via the extended common attributes meanwhile. Therefore, refactor the way of 'btf_log_true_size' reporting in order to report 'log_true_size' via the extended common attributes easily. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Since bpf_log_attr_init() now supports struct bpf_common_attr, pass the common attributes to it to enable syscall common attributes support for BPF_BTF_LOAD. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Currently, many BPF_MAP_CREATE failures return -EINVAL without providing any explanation to userspace. With extended BPF syscall support, detailed error messages can now be reported via the log buffer, allowing users to understand the specific reason for a failed map creation. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
With the previous commit adding common attribute support for BPF_MAP_CREATE, users can now retrieve detailed error messages when map creation fails via the log_buf field. Introduce struct bpf_syscall_common_attr_opts with the following fields: log_buf, log_size, log_level, and log_true_size. Extend bpf_map_create_opts with a new field common_attr_opts, allowing users to capture and inspect log messages on map creation failures. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Add tests to verify that the kernel reports the expected error messages when map creation fails. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
|
Upstream branch: 1700147 |
442d3e0 to
ecdf1a4
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1041255 expired. Closing PR. |
Pull request for series with
subject: bpf: Extend BPF syscall with common attributes support
version: 5
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1041255