Comments (7)
How about declaring hd as volatile?
from p4c-xdp.
then it uses only 136 byte
But volatile generates too large program, so verifier says:
"BPF program is too large. Proccessed 65537 insn"
from p4c-xdp.
That is weird, you would not expect this program to be so large.
Maybe you can play more with volatile; perhaps instead of a second structure hd__ you can just use a volatile pointer to hd and use to make a read between the parser and the deparser.
from p4c-xdp.
OK.
Actually the program size (number of instructions in the program) with and without volatile is roughly the same. Then it's weird that BPF verifier fails.
from p4c-xdp.
I actually like the generated with volatile. With volatile, the compile spills the ethernet src/dst to stack using 1 byte instead of 8 byte, so it uses much less stack. However, there is no reordering at all, it's easier to read, but maybe have some performance overhead?
At lease when reading out the hd.x.y, it will read it from the stack and with the right size (no longer fixed to 8 byte).
With volatile, the size is 1232 line of instructions
Without volatile, it is 1363.
Now I suspect there might be an issue in verifier.
from p4c-xdp.
Hi,
I using p4c-xdp to compile xdp7.p4 to get .c and .h files. And if I just compile the xdp7.c using clang directly,there's an error that
invalid stack off=-600 size=8
But when I add volatile before struct Headers hd in the xdp7.c , it would be no problem to load.
If there are any other ways to generate .c file with volatile from .p4 file using p4c-xdp compiler?
Otherwise I must add volatile before hd for ervery .c files which cannot be loaded into the kernel due to the hitting BPF stack.
Could you give me some advices?
from p4c-xdp.
@williamtu did you find the suitable solution for this problem ? We're also facing it in our uBPF backend. The volatile
keyword helps to overcome BPF stack size problem, but the verifier doesn't allow to inject program then.
from p4c-xdp.
Related Issues (20)
- Unexpected behavior when running xdp3.o HOT 6
- how to implement a forwoading function using XDP_TX based on xdp7.p4 HOT 1
- What is the difference between bpf_obj_get() in libbpf.h and BPF_OBJ_GET() in init_tables() HOT 3
- Could this compiler support XDP_REDIRECT HOT 16
- changing reject to accept introduce stack increaseing HOT 9
- compiler support for lpm HOT 5
- compiler support for range lookup HOT 10
- invalid indirect read from stack off HOT 3
- ebpf_ipv4_checksum Not working HOT 1
- Compiler support for htons, htonl, htonll HOT 2
- Compiler support for registers and hash functions HOT 3
- [doc] Vagrant image name HOT 2
- [Q] Vagrant image HOT 1
- Resource Leak
- Using XDP with clang/llvm version 9 HOT 3
- How to include ebpf_xdp.h HOT 3
- Adding PERCPU_ARRAY Question HOT 2
- p4x-xdp support for PSA HOT 9
- Test 17 fails HOT 1
- XDP metadata support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p4c-xdp.