selftests/xsk: automatically switch XDP programs
authorMagnus Karlsson <magnus.karlsson@intel.com>
Wed, 11 Jan 2023 09:35:26 +0000 (10:35 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 12 Jan 2023 02:16:52 +0000 (18:16 -0800)
commit7d8319a7cc668607aa054ea2da0bb730538a510b
tree9a900d101429e4a0135b423c644af6c275f19102
parente67b2554f301b3e12322230ebb81ac7b7892f1a4
selftests/xsk: automatically switch XDP programs

Implement automatic switching of XDP programs and execution modes if
needed by a test. This makes it much simpler to write a test as it
only has to say what XDP program it needs if it is not the default
one. This also makes it possible to remove the initial explicit
attachment of the XDP program as well as the explicit mode switch in
the code. These are now handled by the same code that just checks if a
switch is necessary, so no special cases are needed.

The default XDP program for all tests is one that sends all packets to
the AF_XDP socket. If you need another one, please use the new
function test_spec_set_xdp_prog() to specify what XDP programs and
maps to use for this test.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20230111093526.11682-16-magnus.karlsson@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/xsk.c
tools/testing/selftests/bpf/xsk.h
tools/testing/selftests/bpf/xskxceiver.c
tools/testing/selftests/bpf/xskxceiver.h