Skip to content

Commit f64c1a4

Browse files
author
Benjamin Tissoires
committed
selftests/hid: disable struct_ops auto-attach
Since commit 08ac454 ("libbpf: Auto-attach struct_ops BPF maps in BPF skeleton"), libbpf automatically calls bpf_map__attach_struct_ops() on every struct_ops it sees in the bpf object. The problem is that our test bpf object has many of them but only one should be manually loaded at a time, or we end up locking the syscall. Link: https://patch.msgid.link/20240723-fix-6-11-bpf-v1-2-b9d770346784@kernel.org Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent ff9fbca commit f64c1a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/testing/selftests/hid/hid_bpf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ static void load_programs(const struct test_program programs[],
532532
FIXTURE_DATA(hid_bpf) * self,
533533
const FIXTURE_VARIANT(hid_bpf) * variant)
534534
{
535+
struct bpf_map *iter_map;
535536
int err = -EINVAL;
536537

537538
ASSERT_LE(progs_count, ARRAY_SIZE(self->hid_links))
@@ -564,6 +565,13 @@ static void load_programs(const struct test_program programs[],
564565
*ops_hid_id = self->hid_id;
565566
}
566567

568+
/* we disable the auto-attach feature of all maps because we
569+
* only want the tested one to be manually attached in the next
570+
* call to bpf_map__attach_struct_ops()
571+
*/
572+
bpf_object__for_each_map(iter_map, *self->skel->skeleton->obj)
573+
bpf_map__set_autoattach(iter_map, false);
574+
567575
err = hid__load(self->skel);
568576
ASSERT_OK(err) TH_LOG("hid_skel_load failed: %d", err);
569577

0 commit comments

Comments
 (0)