xdp-loader not finding xdp_dispatcher by default
hhoffstaette opened this issue · comments
I apologize for the barrage of bug reports, but that's just what I do 🤡
My first steps with XDP are all about trying to load a simple packet dropper based on the Ethernet frame type. As first step I used ip
to load it, and it works fine: the frames are dropped correctly. \o/
Now with xdp-tools installed, xdp-loader shows that the program is indeed loaded:
$ip link set dev eth0 xdp obj /usr/local/lib/bpf/homeplug_av_drop.o sec .text
$xdp-loader status eth0
CURRENT XDP PROGRAM STATUS:
Interface Prio Program name Mode ID Tag Chain actions
--------------------------------------------------------------------------------------
eth0 skb 125 fbd415544de357c1
I can also unload the program:
$xdp-loader unload eth0 -i 125
$xdp-loader status eth0
CURRENT XDP PROGRAM STATUS:
Interface Prio Program name Mode ID Tag Chain actions
--------------------------------------------------------------------------------------
eth0 <No XDP program loaded!>
So basically the tools work.
Now I want to use the loader to actually load. I understand that it wants to use an xdp_dispatcher for loading/handling multiple programs, but something is not right:
xdp-loader load eth0 /usr/local/lib/bpf/homeplug_av_drop.o
libxdp: Couldn't find a BPF file with name xdp-dispatcher.o
libxdp: Couldn't open BPF file xdp-dispatcher.o
Couldn't attach XDP program on iface 'eth0': No such file or directory(-2)
Let's see with -vv:
xdp-loader load -vv eth0 /usr/local/lib/bpf/homeplug_av_drop.o
Current rlimit 8388608 already >= minimum 1048576
Loading 1 files on interface 'eth0'.
libbpf: loading /usr/local/lib/bpf/homeplug_av_drop.o
libbpf: elf: section(2) .text, size 136, link 0, flags 6, type=1
libbpf: sec '.text': found program 'dropper' at insn offset 0 (0 bytes), code size 17 insns (136 bytes)
libbpf: elf: section(3) license, size 4, link 0, flags 3, type=1
libbpf: license of /usr/local/lib/bpf/homeplug_av_drop.o is GPL
libbpf: elf: section(13) .BTF, size 778, link 0, flags 0, type=1
libbpf: elf: section(15) .BTF.ext, size 192, link 0, flags 0, type=1
libbpf: elf: section(23) .symtab, size 360, link 1, flags 0, type=2
libbpf: looking for externs among 15 symbols...
libbpf: collected 0 externs total
libbpf: prog 'dropper': unrecognized ELF section name '.text'
libxdp: DATASEC '.xdp_run_config' not found.
XDP program 0: Run prio: 50. Chain call actions: XDP_PASS
libxdp: Generating multi-prog dispatcher for 1 programs
libxdp: Checking for kernel frags support
libxdp: Looking for '/usr/local/lib/bpf/xdp-dispatcher.o'
libxdp: Couldn't find a BPF file with name xdp-dispatcher.o
libxdp: Couldn't open BPF file xdp-dispatcher.o
Couldn't attach XDP program on iface 'eth0': No such file or directory(-2)
Why would it want to load the dispatcher from my private directory?
I can see that the dispatcher is installed:
$locate xdp-dispatcher
/usr/lib/bpf/xdp-dispatcher.o
So I copy it into the expected directory and try again:
xdp-loader load -v eth0 /usr/local/lib/bpf/homeplug_av_drop.o
Current rlimit 8388608 already >= minimum 1048576
Loading 1 files on interface 'eth0'.
XDP program 0: Run prio: 50. Chain call actions: XDP_PASS
libxdp: Error attaching XDP program to ifindex 2: Operation not supported
libxdp: XDP mode not supported; try using SKB mode
Attaching XDP program in native mode not supported - try SKB mode.
Looks like my laptop NIC is too cheap and ip
used skb mode automatically, so..
xdp-loader load -v -m skb eth0 /usr/local/lib/bpf/homeplug_av_drop.o
Current rlimit 8388608 already >= minimum 1048576
Loading 1 files on interface 'eth0'.
XDP program 0: Run prio: 50. Chain call actions: XDP_PASS
root>xdp-loader status eth0
CURRENT XDP PROGRAM STATUS:
Interface Prio Program name Mode ID Tag Chain actions
--------------------------------------------------------------------------------------
eth0 xdp_dispatcher skb 173 90f686eb86991928
=> 50 dropper 182 fbd415544de357c1 XDP_PASS
🎉
So while I could get it to work, I'm confused - is this some kind of misconfiguration or a bug?
Obviously I find a hint right after sending..
In lib/defines.mk I see:
PREFIX?=/usr/local
LIBDIR?=$(PREFIX)/lib
BPF_OBJECT_DIR ?=$(LIBDIR)/bpf
and while we override PREFIX for installation, we apparently don't override it for building - successfully compiling the wrong search path into libxdp. This seems to be the problem.
This is clearly a packaging problem in Gentoo, so closing this. Sorry for the long story.