]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Add tests for bucket resume logic in UDP socket iterators
authorJordan Rife <jordan@jrife.io>
Fri, 2 May 2025 16:15:26 +0000 (09:15 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Fri, 2 May 2025 19:07:53 +0000 (12:07 -0700)
commitc58dcc1dbe30d8edf1853be65eb13c3104faaae0
treeea93d1a5cd320ac7727d633bd638146fa5f802b8
parent4a0614e18c2d1f277a8dbd02c06f6a847e359eee
selftests/bpf: Add tests for bucket resume logic in UDP socket iterators

Introduce a set of tests that exercise various bucket resume scenarios:

* remove_seen resumes iteration after removing a socket from the bucket
  that we've already processed. Before, with the offset-based approach,
  this test would have skipped an unseen socket after resuming
  iteration. With the cookie-based approach, we now see all sockets
  exactly once.
* remove_unseen exercises the condition where the next socket that we
  would have seen is removed from the bucket before we resume iteration.
  This tests the scenario where we need to scan past the first cookie in
  our remembered cookies list to find the socket from which to resume
  iteration.
* remove_all exercises the condition where all sockets we remembered
  were removed from the bucket to make sure iteration terminates and
  returns no more results.
* add_some exercises the condition where a few, but not enough to
  trigger a realloc, sockets are added to the head of the current bucket
  between reads. Before, with the offset-based approach, this test would
  have repeated sockets we've already seen. With the cookie-based
  approach, we now see all sockets exactly once.
* force_realloc exercises the condition that we need to realloc the
  batch on a subsequent read, since more sockets than can be held in the
  current batch array were added to the current bucket. This exercies
  the logic inside bpf_iter_udp_realloc_batch that copies cookies into
  the new batch to make sure nothing is skipped or repeated.

Signed-off-by: Jordan Rife <jordan@jrife.io>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c