1 // SPDX-License-Identifier: GPL-2.0
3 #include <test_progs.h>
6 void test_raw_tp_writable_reject_nbd_invalid(void)
10 int bpf_fd = -1, tp_fd = -1;
12 const struct bpf_insn program[] = {
13 /* r6 is our tp buffer */
14 BPF_LDX_MEM(BPF_DW, BPF_REG_6, BPF_REG_1, 0),
15 /* one byte beyond the end of the nbd_request struct */
16 BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_6,
17 sizeof(struct nbd_request)),
21 struct bpf_load_program_attr load_attr = {
22 .prog_type = BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
25 .insns_cnt = sizeof(program) / sizeof(struct bpf_insn),
29 bpf_fd = bpf_load_program_xattr(&load_attr, error, sizeof(error));
30 if (CHECK(bpf_fd < 0, "bpf_raw_tracepoint_writable load",
31 "failed: %d errno %d\n", bpf_fd, errno))
34 tp_fd = bpf_raw_tracepoint_open("nbd_send_request", bpf_fd);
35 if (CHECK(tp_fd >= 0, "bpf_raw_tracepoint_writable open",
36 "erroneously succeeded\n"))