Thanks to those who came to check it out.
Now I'm having some problems. The ebpf program I was facing was an eBPF program written in go's cilium/ebpf library. There was no problem compiling, but there was a problem with the runtime and the bpf program would not load. The error is as follows:
root@ubuntu:/home/golang/go/src/xdp-nat# ./xdp-nat ens33 lo
2023/07/24 23:57:49 loading objects: field XdpNatInner2outerFunc: program xdp_nat_inner2outer_func: load program: permission denied: 554: (71) r1 = *(u8 *)(r8 +17): R8 invalid mem access ' inv' (506 line(s) omitted)
I wanted to debug it, but I found that when running with Go, I would report an error and couldn't find the symbols used in the cilium library.
golang@ubuntu:~/go/src/xdp-nat$ go run main.go
# command-line-arguments
./main.go:197:10: undefined: bpfObjects
./main.go:198:12: undefined: loadBpfObjects
So how should I debug an EBPF program if something goes wrong? He is a problem with the internal loading, I don't know the details. According to the error, I found 71 lines of the EBPF source code and found that it was just a member variable of the struct. What could be the problem?
root@ubuntu:/home/golang/go/src/xdp-nat# ./xdp-nat ens33 lo
if1 ok
if2 ok
2023/07/25 00:58:31 loading objects: field XdpNatInner2outerFunc: program xdp_nat_inner2outer_func: load program: permission denied: 554: (71) r1 = *(u8 *)(r8 +17): R8 invalid mem access ' inv' (506 line(s) omitted)
I think it might be a problem with the access of a member variable, but I can't find it, and I won't debug it a little bit, I don't know what the problem is. Some attempts are already on top.