1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/tools/testing/selftests/bpf/progs/exceptions_ext.c
Kumar Kartikeya Dwivedi d2a93715bf selftests/bpf: Add tests for BPF exceptions
Add selftests to cover success and failure cases of API usage, runtime
behavior and invariants that need to be maintained for implementation
correctness.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230912233214.1518551-18-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-09-16 09:36:43 -07:00

72 lines
940 B
C

// 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";