Closed martenwallewein closed 3 years ago
Hey! :)
I've seen this few times while writing eBPF programs, it is always hard to debug such issues. In general, remember that eBPF is very very small subset of C language and whatever compiler produces not always accepted by eBPF VM.
So, few tips to avoid problems:
// Usually you write...
if(eh->ether_type != htons(ETHERTYPE_IP))
// unwind it to __u16 ether_type_reversed = htons(ETHERTYPE_IP); if (ether_type_reversed != ETHERTYPE_IP)
// or ever better - pre-process all constants
if(eh->ether_type != ETHERTYPE_IP_REVERSED)
- Inline all functions with `static inline __attribute__((always_inline))`, however I don't know the exact difference between `inline` and `always_inline` it helped me several times.
Hello, you probably should use struct ethhdr
instead of struct ether_header
.
Hey guys, thanks a lot for the replies. I will try to implement the methods by myself and follow you ideas of unwinding the code.
Hey all, at first I want to thank for the great work you've done so far with this package, I really like the simple API and had a very easy quickstart with this.
At the moment, I struggle with having the error
LoadElf() failed: loadPrograms() failed: Invalid BPF instruction (at 144): &{133 0 1 0 4294967295}
with the following code:Since I'm new to ebpf, not sure if I'm doing something wrong, but loading the respective ELF file with another approach (https://github.com/xdp-project/xdp-tutorial) works as expected. A full setup to reproduce this can be found here: https://github.com/martenwallewein/goepf-repro.
It would be nice if you could have a look at this if I'm doing something wrong or if there is a bug in the loadPrograms function.
Best, Marten