1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 #include <test_progs.h>
5 /* x86-64 fits 55 JITed and 43 interpreted progs into half page */
8 void test_fexit_stress(void)
10 char test_skb
[128] = {};
11 int fexit_fd
[CNT
] = {};
12 int link_fd
[CNT
] = {};
16 int err
, i
, filter_fd
;
18 const struct bpf_insn trace_program
[] = {
19 BPF_MOV64_IMM(BPF_REG_0
, 0),
23 struct bpf_load_program_attr load_attr
= {
24 .prog_type
= BPF_PROG_TYPE_TRACING
,
26 .insns
= trace_program
,
27 .insns_cnt
= sizeof(trace_program
) / sizeof(struct bpf_insn
),
28 .expected_attach_type
= BPF_TRACE_FEXIT
,
31 const struct bpf_insn skb_program
[] = {
32 BPF_MOV64_IMM(BPF_REG_0
, 0),
36 struct bpf_load_program_attr skb_load_attr
= {
37 .prog_type
= BPF_PROG_TYPE_SOCKET_FILTER
,
40 .insns_cnt
= sizeof(skb_program
) / sizeof(struct bpf_insn
),
43 err
= libbpf_find_vmlinux_btf_id("bpf_fentry_test1",
44 load_attr
.expected_attach_type
);
45 if (CHECK(err
<= 0, "find_vmlinux_btf_id", "failed: %d\n", err
))
47 load_attr
.attach_btf_id
= err
;
49 for (i
= 0; i
< CNT
; i
++) {
50 fexit_fd
[i
] = bpf_load_program_xattr(&load_attr
, error
, sizeof(error
));
51 if (CHECK(fexit_fd
[i
] < 0, "fexit loaded",
52 "failed: %d errno %d\n", fexit_fd
[i
], errno
))
54 link_fd
[i
] = bpf_raw_tracepoint_open(NULL
, fexit_fd
[i
]);
55 if (CHECK(link_fd
[i
] < 0, "fexit attach failed",
56 "prog %d failed: %d err %d\n", i
, link_fd
[i
], errno
))
60 filter_fd
= bpf_load_program_xattr(&skb_load_attr
, error
, sizeof(error
));
61 if (CHECK(filter_fd
< 0, "test_program_loaded", "failed: %d errno %d\n",
65 err
= bpf_prog_test_run(filter_fd
, 1, test_skb
, sizeof(test_skb
), 0,
70 for (i
= 0; i
< CNT
; i
++) {