os-eBPF icon indicating copy to clipboard operation
os-eBPF copied to clipboard

[FAQ]load bpf script run error log, need guidance

Open gaowayne opened this issue 3 years ago • 1 comments

[root@ch7-smc-2407 bpf]# ./load.sh

  • set -e
  • sudo mount -t bpf bpf /sys/fs/bpf/
  • clang -O2 -g -target bpf -c bpf_sockops.c -o bpf_sockops.o
  • sudo bpftool prog load bpf_sockops.o /sys/fs/bpf/bpf_sockops libbpf: elf: skipping unrecognized data section(8) .rodata.str1.1 libbpf: elf: skipping unrecognized data section(18) .eh_frame libbpf: elf: skipping relo section(19) .rel.eh_frame for section(18) .eh_frame
  • sudo bpftool cgroup attach /sys/fs/cgroup/unified/ sock_ops pinned /sys/fs/bpf/bpf_sockops Error: can't open cgroup /sys/fs/cgroup/unified/ [root@ch7-smc-2407 bpf]#

gaowayne avatar Oct 22 '22 14:10 gaowayne

if I do not need test inside cgroup, which steps I can skip to run very basic function of socket redirection. if I only want to intercept this for loopback NIC, what kind of code I should change?

gaowayne avatar Oct 22 '22 14:10 gaowayne