Closed tjcw closed 2 years ago
I think I see a couple of problems. The 'fivetuple' was a struct of 13 bytes; when I added padding to make this 16 bytes the verifier got futher. The next problem seems to be that I am unconditonally dereferencing a pointer which may be NULL. I will change this and report what happens then.
Yes, with that fix I can load my eBPF. Closing.
I have put aside my attempt to inject packets into the kernel from userspace for the time being, and I working on the next stage. I am trying to set up my test case so that the first frame of a TCP flow gets pushed to user space, the user space code updates an eBPF map and discards the frame, and the client will timeout and resend the first frame which will then be passed to the kernel with XDP_PASS.
However when I try loading the eBPF, I get a verifier failure which I do not understand. My test case is under https://github.com/tjcw/xdp-tutorial/tree/master/ebpf-filter-snapshot-20221018 ; when I run it (the eBPF code has to be copied to libxdp and built there, and then you run the test case with "sudo ./run.sh") I get
Looking at the objdump of the eBPF shows
which I think is the region surrounding the verifier failure, and seems to be an indication that
is trying to access memory out of bounds. But I do not know if the problem is with the accept_map or with f, and I don't think either should give a problem. f is a 'five-tuple' struct of source IP, destination IP, source port, destination port, and protocol.
Can you throw any light on what is broken in my test case ? @tohojo @magnus-karlsson