-
Notifications
You must be signed in to change notification settings - Fork 5
bpf: Extend bpf syscall with common attributes support #6084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
kernel-patches-daemon-bpf-rc
wants to merge
10
commits into
bpf-next_base
from
series/1008052=>bpf-next
Closed
bpf: Extend bpf syscall with common attributes support #6084
kernel-patches-daemon-bpf-rc
wants to merge
10
commits into
bpf-next_base
from
series/1008052=>bpf-next
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>
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 <[email protected]>
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 'log_true_size' reporting in order to report 'log_true_size' via the extended common attributes easily. Signed-off-by: Leon Hwang <[email protected]>
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 <[email protected]>
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 <[email protected]>
The log buffer of common attributes would be confusing with the one in 'union bpf_attr' for BPF_BTF_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 <[email protected]>
In next commit, it will report users the reason of -EINVAL in map_create. However, as for the check of '!ops' and '!ops->map_mem_usage', it shouldn't report the reason as they would be internal bugs. Instead, add WARN_ON_ONCE to them. Then, it is able to check dmesg to get the error details. Signed-off-by: Leon Hwang <[email protected]>
Currently, many 'BPF_MAP_CREATE' failures return '-EINVAL' without providing any explanation to user space. With the extended BPF syscall support, detailed error messages can now be reported. This allows users to understand the specific reason for a failed map creation, rather than just receiving a generic '-EINVAL'. Signed-off-by: Leon Hwang <[email protected]>
With the previous commit adding common attribute support for BPF_MAP_CREATE, it is now possible to retrieve detailed error messages when map creation fails by using the 'log_buf' field from the common attributes. Extend 'bpf_map_create_opts' with these new fields, 'log_buf', 'log_size' , 'log_level' and 'log_true_size', allowing users to capture and inspect those log messages. Signed-off-by: Leon Hwang <[email protected]>
As kernel is able to report log when fail to create map, add test cases to check those logs. Signed-off-by: Leon Hwang <[email protected]>
Author
|
Upstream branch: 4ef77dd |
Author
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1008052 expired. Closing PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: bpf: Extend bpf syscall with common attributes support
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1008052