xdp-project / xdp-tools

Utilities and example programs for use with XDP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libxdp: xsk_def_xdp_prog_5.3 does not work for kernel <=5.2

cloftus opened this issue · comments

The XDP program used for kernels 5.3 and older uses bpf_map_lookup_elem().
The verifier only permits use of this function for xskmaps since the following kernel commit which is not present in v5.2:
fada7fdc83c0 ("bpf: Allow bpf_map_lookup_elem() on an xskmap")
As a result, the program fails to load. Logs pasted below.

libbpf: load bpf program failed: Argument list too long
libbpf: failed to load program 'xdp_pass'
libbpf: failed to load object '/usr/local/lib/bpf/xdp-dispatcher.o'
libxdp: Compatibility check for dispatcher program failed: Argument list too long
libxdp: Falling back to loading single prog without dispatcher
libbpf: load bpf program failed: Invalid argument
libbpf: -- BEGIN DUMP LOG ---
libbpf:
; int index = ctx->rx_queue_index;
0: (61) r1 = *(u32 *)(r1 +16)
; int index = ctx->rx_queue_index;
1: (63) *(u32 *)(r10 -4) = r1
2: (bf) r2 = r10
;
3: (07) r2 += -4
; if (bpf_map_lookup_elem(&xsks_map, &index))
4: (18) r1 = 0xffff8a97eba7dd00
6: (85) call bpf_map_lookup_elem#1
cannot pass map_type 17 into func bpf_map_lookup_elem#1
processed 6 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0

libbpf: -- END LOG --
libbpf: failed to load program 'xsk_def_prog'
libbpf: failed to load object '/usr/local/lib/bpf/xsk_def_xdp_prog_5.3.o'

Thanks for spotting this. Did some investigation and the AF_XDP support got into libbpf in 5.1, and it had a longer more complicated default XDP program before 5.3 and the commit you refer to. The same compatibility problem exists in libbpf too, and since no one has raised any concerns about this, I would say it is not an issue worth fixing. Let us instead document the Linux version requirement to be 5.3 and onwards. What do you think?

+1 Sounds good to me, thanks for investigating.