libbpf: Fix compatibility for kernels without need_wakeup
authorMagnus Karlsson <magnus.karlsson@intel.com>
Fri, 25 Oct 2019 09:17:15 +0000 (11:17 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 29 Oct 2019 03:25:32 +0000 (20:25 -0700)
commit94ff9ebb49a546b7f009ed840bafa235c96d4c4b
tree1a97e6d684786f2d07fb002652143f8fb3f74af9
parente93d99180abdaaa362bb02427a84266cd61bfd30
libbpf: Fix compatibility for kernels without need_wakeup

When the need_wakeup flag was added to AF_XDP, the format of the
XDP_MMAP_OFFSETS getsockopt was extended. Code was added to the
kernel to take care of compatibility issues arrising from running
applications using any of the two formats. However, libbpf was
not extended to take care of the case when the application/libbpf
uses the new format but the kernel only supports the old
format. This patch adds support in libbpf for parsing the old
format, before the need_wakeup flag was added, and emulating a
set of static need_wakeup flags that will always work for the
application.

v2 -> v3:
* Incorporated code improvements suggested by Jonathan Lemon

v1 -> v2:
* Rebased to bpf-next
* Rewrote the code as the previous version made you blind

Fixes: a4500432c2587cb2a ("libbpf: add support for need_wakeup flag in AF_XDP part")
Reported-by: Eloy Degen <degeneloy@gmail.com>
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Link: https://lore.kernel.org/bpf/1571995035-21889-1-git-send-email-magnus.karlsson@intel.com
tools/lib/bpf/xsk.c