selftests/bpf: Add a test with bpf_timer in inner map.
authorAlexei Starovoitov <ast@kernel.org>
Thu, 15 Jul 2021 00:54:17 +0000 (17:54 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 15 Jul 2021 20:31:11 +0000 (22:31 +0200)
commit61f71e746c72f07097b759809c36e814387bc24f
treeaa1cea02d78063f25858cd2f30d5b12f9dd3793d
parent3540f7c6b96a62b581da5aa3d4c5af9408927bef
selftests/bpf: Add a test with bpf_timer in inner map.

Check that map-in-map supports bpf timers.

Check that indirect "recursion" of timer callbacks works:
timer_cb1() { bpf_timer_set_callback(timer_cb2); }
timer_cb2() { bpf_timer_set_callback(timer_cb1); }

Check that
  bpf_map_release
    htab_free_prealloced_timers
      bpf_timer_cancel_and_free
        hrtimer_cancel
works while timer cb is running.
"while true; do ./test_progs -t timer_mim; done"
is a great stress test. It caught missing timer cancel in htab->extra_elems.

timer_mim_reject.c is a negative test that checks
that timer<->map mismatch is prevented.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20210715005417.78572-12-alexei.starovoitov@gmail.com
tools/testing/selftests/bpf/prog_tests/timer_mim.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/timer_mim.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/timer_mim_reject.c [new file with mode: 0644]