1// SPDX-License-Identifier: GPL-2.0
2#include <vmlinux.h>
3#include <bpf/bpf_helpers.h>
4#include "bpf_experimental.h"
5
6SEC("?fentry")
7int pfentry(void *ctx)
8{
9 return 0;
10}
11
12SEC("?fentry")
13int throwing_fentry(void *ctx)
14{
15 bpf_throw(0);
16 return 0;
17}
18
19__noinline int exception_cb(u64 cookie)
20{
21 return cookie + 64;
22}
23
24SEC("?freplace")
25int extension(struct __sk_buff *ctx)
26{
27 return 0;
28}
29
30SEC("?freplace")
31__exception_cb(exception_cb)
32int throwing_exception_cb_extension(u64 cookie)
33{
34 bpf_throw(32);
35 return 0;
36}
37
38SEC("?freplace")
39__exception_cb(exception_cb)
40int throwing_extension(struct __sk_buff *ctx)
41{
42 bpf_throw(64);
43 return 0;
44}
45
46SEC("?fexit")
47int pfexit(void *ctx)
48{
49 return 0;
50}
51
52SEC("?fexit")
53int throwing_fexit(void *ctx)
54{
55 bpf_throw(0);
56 return 0;
57}
58
59SEC("?fmod_ret")
60int pfmod_ret(void *ctx)
61{
62 return 0;
63}
64
65SEC("?fmod_ret")
66int throwing_fmod_ret(void *ctx)
67{
68 bpf_throw(0);
69 return 0;
70}
71
72char _license[] SEC("license") = "GPL";
73

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