summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/exceptions_ext.c
blob: 743c05185d9b3ba31222353bd51a6dda4a7069b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: GPL-2.0
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include "bpf_experimental.h"

SEC("?fentry")
int pfentry(void *ctx)
{
	return 0;
}

SEC("?fentry")
int throwing_fentry(void *ctx)
{
	bpf_throw(0);
	return 0;
}

__noinline int exception_cb(u64 cookie)
{
	return cookie + 64;
}

SEC("?freplace")
int extension(struct __sk_buff *ctx)
{
	return 0;
}

SEC("?freplace")
__exception_cb(exception_cb)
int throwing_exception_cb_extension(u64 cookie)
{
	bpf_throw(32);
	return 0;
}

SEC("?freplace")
__exception_cb(exception_cb)
int throwing_extension(struct __sk_buff *ctx)
{
	bpf_throw(64);
	return 0;
}

SEC("?fexit")
int pfexit(void *ctx)
{
	return 0;
}

SEC("?fexit")
int throwing_fexit(void *ctx)
{
	bpf_throw(0);
	return 0;
}

SEC("?fmod_ret")
int pfmod_ret(void *ctx)
{
	return 0;
}

SEC("?fmod_ret")
int throwing_fmod_ret(void *ctx)
{
	bpf_throw(0);
	return 0;
}

char _license[] SEC("license") = "GPL";