Skip to content

B4/xsk#8973

Closed
bastien-curutchet wants to merge 18 commits intokernel-patches:bpf-next_basefrom
bastien-curutchet:b4/xsk
Closed

B4/xsk#8973
bastien-curutchet wants to merge 18 commits intokernel-patches:bpf-next_basefrom
bastien-curutchet:b4/xsk

Conversation

@bastien-curutchet
Copy link
Copy Markdown
Contributor

No description provided.

Kernel Patches Daemon and others added 18 commits May 19, 2025 09:31
Hi all,

This patch series continues the work to migrate the script tests into
prog_tests.

The test_xsk.sh script tests lots of AF_XDP use cases. The tests it uses
are defined in xksxceiver.c. As this script is used to test real
hardware, the goal here is to keep it as is and only integrate the
tests on veth peers into the test_progs framework.
Three tests are flaky on s390 so they won't be integrated to test_progs.

PATCH 2 extracts test_xsk[.c/.h] from xskxceiver[.c/.h] to make the
tests available to test_progs.
PATCH 3 to 6 fix small issues in the current test
PATCH 1 / 7 / 8 abstract the log behaviour. It allows to keep kselftest
in test_xsk.sh without conflicting with test_progs's framework.
PATCH 9 to 14 handle all errors to release resources instead of calling
exit() when any error occurs.
PATCH 15 isolates the flaky tests
PATCH 16 integrate the non-flaky tests to the test_progs framework

# Describe the purpose of this series. The information you put here
# will be used by the project maintainer to make a decision whether
# your patches should be reviewed, and in what priority order. Please be
# very detailed and link to any relevant discussions or sites that the
# maintainer can review to better understand your proposed changes. If you
# only have a single patch in your series, the contents of the cover
# letter will be appended to the "under-the-cut" portion of the patch.

# Lines starting with # will be removed from the cover letter. You can
# use them to add notes or reminders to yourself. If you want to use
# markdown headers in your cover letter, start the line with ">#".

# You can add trailers to the cover letter. Any email addresses found in
# these trailers will be added to the addresses specified/generated
# during the b4 send stage. You can also run "b4 prep --auto-to-cc" to
# auto-populate the To: and Cc: trailers based on the code being
# modified.

To: Björn Töpel <bjorn@kernel.org>
To: Magnus Karlsson <magnus.karlsson@intel.com>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Jonathan Lemon <jonathan.lemon@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>
To: Daniel Borkmann <daniel@iogearbox.net>
To: Andrii Nakryiko <andrii@kernel.org>
To: Martin KaFai Lau <martin.lau@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>
To: Song Liu <song@kernel.org>
To: Yonghong Song <yonghong.song@linux.dev>
To: John Fastabend <john.fastabend@gmail.com>
To: KP Singh <kpsingh@kernel.org>
To: Stanislav Fomichev <sdf@fomichev.me>
To: Hao Luo <haoluo@google.com>
To: Jiri Olsa <jolsa@kernel.org>
To: Mykola Lysenko <mykolal@fb.com>
To: Shuah Khan <shuah@kernel.org>
To: David S. Miller <davem@davemloft.net>
To: Jakub Kicinski <kuba@kernel.org>
To: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Alexis Lothore <alexis.lothore@bootlin.com>
Cc: netdev@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>

---
Changes in v2:
- Re-order patches to split xkxceiver sooner.
- Fix the bug reported by Maciej (PATCH 14).
- Fix verbose mode in test_xsk.sh
- Link to v1: https://lore.kernel.org/r/20250313-xsk-v1-0-7374729a93b9@bootlin.com

--- b4-submit-tracking ---
# This section is used internally by b4 prep for tracking purposes.
{
  "series": {
    "revision": 2,
    "change-id": "20250218-xsk-0cf90e975d14",
    "prefixes": [
      "bpf-next"
    ],
    "history": {
      "v1": [
        "20250313-xsk-v1-0-7374729a93b9@bootlin.com"
      ]
    }
  }
}
The print_verbose macro calls ksft_print_msg(). It isn't convenient if
you want to use the xksxceiver.h header without using kselftest.

Define a xsk_verbose function that is called by the print_verbose macro.
It is then up to the print_verbose caller to instantiate the verbose
behaviour.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
AF_XDP features are tested by the test_xsk.sh script but not by the
test_progs framework. The tests used by the script are defined in
xksxceiver.c which can't be integrated in the test_progs framework as is.

Extract these test definitions from xskxceiver{.c/.h} to put them in new
test_xsk{.c/.h} files.
Keep the main() function and its unshared dependencies in xksxceiver to
avoid impacting the test_xsk.sh script which is often used to test real
hardware.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
bitmap is used before being initialized.

Initialize it to zero before using it.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
Some tests introduce memory leaks by not freeing all the pkt_stream
objects they're creating.

Fix these memory leaks.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
The clean-up done at the end of a test in __testapp_validate_traffic()
isn't wrapped in a function. It isn't convenient if we want to use it
somewhere else in the code.

Wrap the clean-up in two new functions : the first deletes the sockets,
the second releases the umem.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
testapp_validate_traffic() doesn't release the sockets and the umem
created by the threads if the test isn't currently in its last step.
Thus, if the swap_xsk_resources() fails before the last step, the
created resources aren't cleaned up.

Clean the sockets and the umem in case of swap_xsk_resources() failure.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
test_xsk depends on kselftests. It prevents from integrating it into the
test_progs framework.

Wrap the ksft_*() calls behind macros to ease the future integration into
test_progs.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
test_xsk uses the kselftest framework for its logs. This isn't compatible
with the test_progs framework.

Create xks_{log/verbose/skip/fail} functions to handle logs. This way,
each test_xsk 'user' can define its own logging behaviour.
Define the functions in xskxceiver.c.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
init_iface() doesn't have any return value while it can fail. In case of
failure it calls exit_on_error() which will terminate the test
immediately.

Add a return value to init_iface() so errors can be handled more
smoothly.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
xsk_reattach_xdp calls exit_on_error() on failures. This exits the
program immediately and can lead to memory leaks.

Add a return value to the functions handling XDP attachments to handle
errors more smoothly.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
exit_on_error() is called when gettimeofday() fails. This exits the
program immediately and can lead to memory leaks.

Return TEST_FAILURE instead of calling exit_on_error().

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
TX and RX workers can fail in many places. These failures trigger a call
to exit_on_error() which exits the program immediately and can lead to
memory leak.

Add return value to functions that can fail.
Handle failures more smoothly through report_failure().

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
…ails

__testapp_validate_traffic() calls exit_on_error() on failures. This
exits the program immediately and can lead to memory leaks.

Return TEST_FAILURE instead of calling exit_on_error().
Release the resource of the 1st thread if a failure happens between its
creation and the creation of the second thread.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
If any allocation in the pkt_stream_*() helpers fail, exit_on_error() is
called. This terminates the program immediately and can lead to memory
leaks.

Return NULL in case of allocation failure.
Return TEST_FAILURE when something goes wrong in the packet generation.
Clean up the resources if a failure happens between two steps of a test.
Move exit_with_error() definition to xskxceiver.c as it isn't used
anymore by test_xsk.c

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
Some tests are flaky (especially on s390). So they don't fit in the CI.

Remove flaky tests from the tests table so they won't be run by the CI
in upcoming patch.
Create a flaky_tests table to hold them.
Use the flaky table in xskxceiver.c so the tests remain available for HW
in test_xsk.sh.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
test_xsk.c isn't part of the test_progs framework.

Integrate the tests defined by test_xsk.c into the test_progs framework
through a new file : prog_tests/xsk.c. ZeroCopy mode isn't tested in it
as veth peers don't support it.
Move test_xsk{.c/.h} to prog_tests/.
Add the find_bit library to test_progs sources in the Makefile as it is
is used by test_xsk.c

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf Bot force-pushed the bpf-next_base branch 9 times, most recently from e85324d to 61c8df2 Compare May 23, 2025 20:32
@kernel-patches-daemon-bpf
Copy link
Copy Markdown

Automatically cleaning up stale PR; feel free to reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant