mbox series

[bpf-next,v3,0/4] selftests/bpf: migrate and remove cgroup/tracing related tests

Message ID 20241011044847.51584-1-danieltimlee@gmail.com (mailing list archive)
Headers show
Series selftests/bpf: migrate and remove cgroup/tracing related tests | expand

Message

Daniel T. Lee Oct. 11, 2024, 4:48 a.m. UTC
The BPF testing framework has evolved significantly over time. However,
some legacy tests in the samples/bpf directory have not kept up with
these changes. These outdated tests can cause confusion and increase
maintenance efforts.

This patchset focuses on migrating outdated cgroup and tracing-related
tests from samples/bpf to selftests/bpf, ensuring the BPF test suite
remains current and efficient. Tests that are already covered by
selftests/bpf are removed, while those not yet covered are migrated.
This includes cgroup sock create tests for setting socket attributes
and blocking socket creation, as well as the removal of redundant
cgroup and tracing tests that have been replaced by newer tests.

This patchset covers the following cgroup/tracing tests:
- test_overhead: tests the overhead of BPF programs with task_rename,
  now covered by selftests and benchmark tests (rename-*). [1]

- test_override_return: tests the return override functionality, now
  handled by kprobe_multi_override in selftests.

- test_probe_write_user: tests the probe_write_user functionality,
  now replaced by the probe_user test in selftests.

- test_cgrp2_sock: tests cgroup BPF's ability to set sk_bound_dev_if,
  mark, and priority during socket creation. Migrated to selftests as
  'sock_create' since no existing tests fully cover this.

- test_cgrp2_sock2: tests blocking socket creation for specific types
  (AF_INET{6}, SOCK_DGRAM, IPPROTO_ICMP{V6}). Migrated to selftests
  in 'sock_create' test for coverage.

- test_current_task_under_cgroup: tests bpf_current_task_under_cgroup()
  to check if a task belongs to a cgroup. Already covered by
  task_under_cgroup at selftest and other cgroup ID tests.

- test_cgrp2_tc: tests bpf_skb_under_cgroup() to filter packets based
  on cgroup. This behavior is now validated by cgroup_skb_sk_lookup,
  which uses bpf_skb_cgroup_id, making this test redundant.

[1]: https://patchwork.kernel.org/cover/13759916

---
Changes in v2:
- commit message fix
Changes in v3:
- Makefile fix

Daniel T. Lee (4):
  selftests/bpf: migrate cgroup sock create test for setting
    iface/mark/prio
  selftests/bpf: migrate cgroup sock create test for prohibiting sockets
  samples/bpf: remove obsolete cgroup related tests
  samples/bpf: remove obsolete tracing related tests

 samples/bpf/Makefile                          |  25 --
 samples/bpf/sock_flags.bpf.c                  |  47 ---
 samples/bpf/test_cgrp2_array_pin.c            | 106 ------
 samples/bpf/test_cgrp2_attach.c               | 177 ----------
 samples/bpf/test_cgrp2_sock.c                 | 296 ----------------
 samples/bpf/test_cgrp2_sock.sh                | 137 -------
 samples/bpf/test_cgrp2_sock2.c                |  95 -----
 samples/bpf/test_cgrp2_sock2.sh               | 103 ------
 samples/bpf/test_cgrp2_tc.bpf.c               |  56 ---
 samples/bpf/test_cgrp2_tc.sh                  | 187 ----------
 .../bpf/test_current_task_under_cgroup.bpf.c  |  43 ---
 .../bpf/test_current_task_under_cgroup_user.c | 115 ------
 samples/bpf/test_overhead_kprobe.bpf.c        |  41 ---
 samples/bpf/test_overhead_raw_tp.bpf.c        |  17 -
 samples/bpf/test_overhead_tp.bpf.c            |  23 --
 samples/bpf/test_overhead_user.c              | 225 ------------
 samples/bpf/test_override_return.sh           |  16 -
 samples/bpf/test_probe_write_user.bpf.c       |  52 ---
 samples/bpf/test_probe_write_user_user.c      | 108 ------
 samples/bpf/tracex7.bpf.c                     |  15 -
 samples/bpf/tracex7_user.c                    |  56 ---
 .../selftests/bpf/prog_tests/sock_create.c    | 333 ++++++++++++++++++
 22 files changed, 333 insertions(+), 1940 deletions(-)
 delete mode 100644 samples/bpf/sock_flags.bpf.c
 delete mode 100644 samples/bpf/test_cgrp2_array_pin.c
 delete mode 100644 samples/bpf/test_cgrp2_attach.c
 delete mode 100644 samples/bpf/test_cgrp2_sock.c
 delete mode 100755 samples/bpf/test_cgrp2_sock.sh
 delete mode 100644 samples/bpf/test_cgrp2_sock2.c
 delete mode 100755 samples/bpf/test_cgrp2_sock2.sh
 delete mode 100644 samples/bpf/test_cgrp2_tc.bpf.c
 delete mode 100755 samples/bpf/test_cgrp2_tc.sh
 delete mode 100644 samples/bpf/test_current_task_under_cgroup.bpf.c
 delete mode 100644 samples/bpf/test_current_task_under_cgroup_user.c
 delete mode 100644 samples/bpf/test_overhead_kprobe.bpf.c
 delete mode 100644 samples/bpf/test_overhead_raw_tp.bpf.c
 delete mode 100644 samples/bpf/test_overhead_tp.bpf.c
 delete mode 100644 samples/bpf/test_overhead_user.c
 delete mode 100755 samples/bpf/test_override_return.sh
 delete mode 100644 samples/bpf/test_probe_write_user.bpf.c
 delete mode 100644 samples/bpf/test_probe_write_user_user.c
 delete mode 100644 samples/bpf/tracex7.bpf.c
 delete mode 100644 samples/bpf/tracex7_user.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_create.c

--
2.43.0

Comments

patchwork-bot+netdevbpf@kernel.org Oct. 11, 2024, 5 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Fri, 11 Oct 2024 04:48:43 +0000 you wrote:
> The BPF testing framework has evolved significantly over time. However,
> some legacy tests in the samples/bpf directory have not kept up with
> these changes. These outdated tests can cause confusion and increase
> maintenance efforts.
> 
> This patchset focuses on migrating outdated cgroup and tracing-related
> tests from samples/bpf to selftests/bpf, ensuring the BPF test suite
> remains current and efficient. Tests that are already covered by
> selftests/bpf are removed, while those not yet covered are migrated.
> This includes cgroup sock create tests for setting socket attributes
> and blocking socket creation, as well as the removal of redundant
> cgroup and tracing tests that have been replaced by newer tests.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/4] selftests/bpf: migrate cgroup sock create test for setting iface/mark/prio
    https://git.kernel.org/bpf/bpf-next/c/ec6c4be07323
  - [bpf-next,v3,2/4] selftests/bpf: migrate cgroup sock create test for prohibiting sockets
    https://git.kernel.org/bpf/bpf-next/c/64a4658d6f76
  - [bpf-next,v3,3/4] samples/bpf: remove obsolete cgroup related tests
    https://git.kernel.org/bpf/bpf-next/c/5ea68f0493d1
  - [bpf-next,v3,4/4] samples/bpf: remove obsolete tracing related tests
    https://git.kernel.org/bpf/bpf-next/c/118740b87015

You are awesome, thank you!