-
Notifications
You must be signed in to change notification settings - Fork 442
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
ebpf-kernel/length_ebpf.p4 test fails to pass eBPF verifier #4158
Comments
I believe the eBPF back end has no dedicated maintainer. It might take some time until this bug is fixed. |
The ebpf backend contributors have been usually very responsive. |
I believe the problem is related to classic eBPF only (filter model). Packet length is calculated here: p4c/backends/ebpf/ebpfProgram.cpp Lines 245 to 246 in 27b7171
which generates aforementioned problematic code. This is not used for PSA architecture. As a side note, PSA architecture has its own method to calculate packet length here: p4c/backends/ebpf/psa/ebpfPipeline.cpp Lines 164 to 171 in 27b7171
|
It's not immediately apparent to me why the PSA target backend seems to duplicate so much logic. Probably because I'm not very familiar with the compiler. In any case the fix is fairly straightforward by just copying the strategy which @tatry helpfully points out. With the patch in PR #4159 the test is now passing. |
* backends/ebpf: Change packet length calc to pass kernel verifier (#4158) * backends/ebpf: Fix #4098 by renaming conflicting write_partial macro. * backends/bmv2: Only run test using sudo if not already root. This avoids the 'root is not in the sudoers file' error. * gtestp4c: Don't assume that build/ is in the p4c source dir. * backends/ebpf: Don't emit duplicate 'goto start' instruction. The same instruction is already emitted in EBPFParser::emit(). * backends/ebpf: Don't emit deparsing writes twice. As things stand, when using the ebpf backend (not PSA or TC), the emitDeparserExternCalls() causes the deparsing code to be emitted before any variables are initialised. This is obviously incorrect however wasn't noticed since the only users of the deparser code currently override this method. * backends/ebpf: Support XDP hook in kernel tests. * testdata: Golden outputs for new XDP tests. * backends/ebpf: Add support for XDP model. * [fixup] lint python code too * [fixup] use BUG for invalid model.arch values Should fix macOS compilation error.
Fix pushed. Copying this from the PR for reference:
|
With p4c
555029d03
, running Ubuntu 20.04 with kernel 5.4.0-144, I see the above test fail:Note that kernel tests need to be run by root, and are skipped otherwise. The simplest way to reproduce is, from your
build
directory:The actual C instruction which causes the issue is:
which I believe is used to support the
packet.length()
call used in the program's parser. I suspect that, since no other test program uses this method, the variable is usually optimised out. (The only other uses are for trace messages which again are generally disabled.)The text was updated successfully, but these errors were encountered: