test_custom_sec_handlers.c (935B)
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2022 Facebook */ 3 4#include "vmlinux.h" 5#include <bpf/bpf_helpers.h> 6#include <bpf/bpf_tracing.h> 7 8const volatile int my_pid; 9 10bool abc1_called; 11bool abc2_called; 12bool custom1_called; 13bool custom2_called; 14bool kprobe1_called; 15bool xyz_called; 16 17SEC("abc") 18int abc1(void *ctx) 19{ 20 abc1_called = true; 21 return 0; 22} 23 24SEC("abc/whatever") 25int abc2(void *ctx) 26{ 27 abc2_called = true; 28 return 0; 29} 30 31SEC("custom") 32int custom1(void *ctx) 33{ 34 custom1_called = true; 35 return 0; 36} 37 38SEC("custom/something") 39int custom2(void *ctx) 40{ 41 custom2_called = true; 42 return 0; 43} 44 45SEC("kprobe") 46int kprobe1(void *ctx) 47{ 48 kprobe1_called = true; 49 return 0; 50} 51 52SEC("xyz/blah") 53int xyz(void *ctx) 54{ 55 int whatever; 56 57 /* use sleepable helper, custom handler should set sleepable flag */ 58 bpf_copy_from_user(&whatever, sizeof(whatever), NULL); 59 xyz_called = true; 60 return 0; 61} 62 63char _license[] SEC("license") = "GPL";