mbox series

[bpf-next,0/4] selftests: xsk: fix TEST_MODE_SKB in xdpxceiver

Message ID 20220629143458.934337-1-maciej.fijalkowski@intel.com (mailing list archive)
Headers show
Series selftests: xsk: fix TEST_MODE_SKB in xdpxceiver | expand

Message

Maciej Fijalkowski June 29, 2022, 2:34 p.m. UTC
Hi!

First of all, this might look incorrect as title has a 'fix' keyword and
is sent to bpf-next, but this is due to the fact that Andrii moved xsk
part of libbpf to selftests yesterday, so it's just not in the bpf tree
yet. Also, no new API to libbpf's xsk would be accepted, so that's the
only way to go with fixing xdpxceiver currently. Besides fixes (#2 and
#4), #1 is a small optimization to reduce times we query bpf_link
capability and #3 is a protection against the thing we're fixing here.

This set is about fixing TEST_MODE_SKB in xdpxceiver. Current function
for loading XDP prog independently from AF_XDP socket ignores the flags
from user, such as XDP_FLAGS_SKB_MODE, which makes it impossible to test
generic XDP.  TEST_MODE_SKB was running with XDP prog in native mode,
which is not a thing that we want.

Had it been correctly in the first place, we would see that
refcounting/deleting XSK socket had issues as well. We need to free BPF
resources only when context refcount drops to zero. If its higher then
it means that we should not touch prog/map as other sockets are still
active.

Thanks,
Maciej

Maciej Fijalkowski (4):
  selftests: xsk: avoid bpf_link probe for existing xsk
  selftests: xsk: introduce XDP prog load based on existing AF_XDP
    socket
  selftests: xsk: verify correctness of XDP prog attach point
  selftests: xsk: destroy BPF resources only when ctx refcount drops to
    0

 tools/testing/selftests/bpf/xdpxceiver.c | 19 ++++++++++++++++++-
 tools/testing/selftests/bpf/xsk.c        | 15 ++++++++++-----
 tools/testing/selftests/bpf/xsk.h        |  1 +
 3 files changed, 29 insertions(+), 6 deletions(-)