Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2022 Facebook */
0003 
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include <bpf/bpf_tracing.h>
0007 
0008 const volatile int my_pid;
0009 
0010 bool abc1_called;
0011 bool abc2_called;
0012 bool custom1_called;
0013 bool custom2_called;
0014 bool kprobe1_called;
0015 bool xyz_called;
0016 
0017 SEC("abc")
0018 int abc1(void *ctx)
0019 {
0020     abc1_called = true;
0021     return 0;
0022 }
0023 
0024 SEC("abc/whatever")
0025 int abc2(void *ctx)
0026 {
0027     abc2_called = true;
0028     return 0;
0029 }
0030 
0031 SEC("custom")
0032 int custom1(void *ctx)
0033 {
0034     custom1_called = true;
0035     return 0;
0036 }
0037 
0038 SEC("custom/something")
0039 int custom2(void *ctx)
0040 {
0041     custom2_called = true;
0042     return 0;
0043 }
0044 
0045 SEC("kprobe")
0046 int kprobe1(void *ctx)
0047 {
0048     kprobe1_called = true;
0049     return 0;
0050 }
0051 
0052 SEC("xyz/blah")
0053 int xyz(void *ctx)
0054 {
0055     int whatever;
0056 
0057     /* use sleepable helper, custom handler should set sleepable flag */
0058     bpf_copy_from_user(&whatever, sizeof(whatever), NULL);
0059     xyz_called = true;
0060     return 0;
0061 }
0062 
0063 char _license[] SEC("license") = "GPL";