summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/sock_destroy_prog_fail.c
blob: dd6850b58e2590b27830b85d953d20c09c14679e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: GPL-2.0

#include "vmlinux.h"
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_helpers.h>

#include "bpf_misc.h"

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

int bpf_sock_destroy(struct sock_common *sk) __ksym;

SEC("tp_btf/tcp_destroy_sock")
__failure __msg("calling kernel function bpf_sock_destroy is not allowed")
int BPF_PROG(trace_tcp_destroy_sock, struct sock *sk)
{
	/* should not load */
	bpf_sock_destroy((struct sock_common *)sk);

	return 0;
}