1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Benjamin Tissoires */
3 
4 #include ".output/vmlinux.h"
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
7 
8 #define HID_BPF_MAX_PROGS 1024
9 
10 extern void call_hid_bpf_prog_put_deferred(struct work_struct *work) __ksym;
11 
12 struct {
13 	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
14 	__uint(max_entries, HID_BPF_MAX_PROGS);
15 	__uint(key_size, sizeof(__u32));
16 	__uint(value_size, sizeof(__u32));
17 } hid_jmp_table SEC(".maps");
18 
19 SEC("fmod_ret/__hid_bpf_tail_call")
20 int BPF_PROG(hid_tail_call, struct hid_bpf_ctx *hctx)
21 {
22 	bpf_tail_call(ctx, &hid_jmp_table, hctx->index);
23 
24 	return 0;
25 }
26 
27 SEC("fentry/bpf_prog_put_deferred")
28 int BPF_PROG(hid_bpf_prog_put_deferred, struct work_struct *work)
29 {
30 	call_hid_bpf_prog_put_deferred(work);
31 	return 0;
32 }
33 
34 char LICENSE[] SEC("license") = "GPL";
35