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
bpf: inline test functions with ctx as input #24662
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to missing kernel patch e5069b9c "bpf: Support pointers in global func args".
This patch shouldn't be needed. As its commit message says, this patch adds support for pointer types different from PTR_TO_CTX, and PTR_TO_CTX used to be supported before. The pointer in scope of your commit is PTR_TO_CTX.
I believe the real root cause of the error you see is btf_vmlinux is malformed
. When it happens, the verifier can't determine the type of the context pointer and treats struct __ctx_buff *ctx
as PTR instead of PTR_TO_CTX.
Regarding btf_vmlinux is malformed
, I'm not entirely sure why it happens, but a brief search hints that it might be because something was wrong with pahole or gcc during kernel compilation.
Thanks for the quick reply!
I see! This makes sense.
I am also not sure why it happens, but inline the functions do fix the problem and make the test runnable on those kernels. Fixing Ubuntu kernel seem to the right approach, but considering it's not going to happen anytime soon. Do you think this patch can be accepted? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an acceptable change, but the rationale needs to be updated in the commit description as per Maxim's comment. Other than that, LGTM.
Run ebpf test on kernel v5.11 in Ubuntu 20.04 will raise the following error: ``` Validating build_packet() func#1... btf_vmlinux is malformed Arg#0 type PTR in build_packet() is not supported yet. ``` Due to some unknown reason, when running on these kernels, verifier cannot correctly recognize the function argument is PTR_TO_CTX, instead of PTR. PTR as global function's argument is only supported after e5069b9c. This patch inlines those test functions in question, which makes it possible to run ebpf unit test on kernel prior to v5.11. Signed-off-by: Yongkun Gui <ygui@google.com>
Thanks @pchaigno Re-worded the commit message. |
Yes, agreed. Making these function always inline should also improve support for older kernels without BPF-to-BPF support (not that we are currently running the suite on those versions). |
Thanks everyone! |
Run ebpf test on kernel v5.11 will raise the following error:
It's due to missing kernel patch e5069b9c "bpf: Support pointers in global func args". Inline those functions so the ebpf test can also run on v5.11 and older kernels.
Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXX
line if the commit addresses a particularGitHub issue.
Fixes: <commit-id>
tag, thenplease add the commit author[s] as reviewer[s] to this issue.