1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
3
4#include "vmlinux.h"
5#include <bpf/bpf_helpers.h>
6#include <bpf/bpf_tracing.h>
7
8#include "bpf_misc.h"
9
10char _license[] SEC("license") = "GPL";
11
12SEC("struct_ops.s/test_2")
13__failure __msg("attach to unsupported member test_2 of struct bpf_dummy_ops")
14int BPF_PROG(test_unsupported_field_sleepable,
15 struct bpf_dummy_ops_state *state, int a1, unsigned short a2,
16 char a3, unsigned long a4)
17{
18 /* Tries to mark an unsleepable field in struct bpf_dummy_ops as sleepable. */
19 return 0;
20}
21
22SEC(".struct_ops")
23struct bpf_dummy_ops dummy_1 = {
24 .test_1 = NULL,
25 .test_2 = (void *)test_unsupported_field_sleepable,
26 .test_sleepable = (void *)NULL,
27};
28

source code of linux/tools/testing/selftests/bpf/progs/dummy_st_ops_fail.c