1*fae6e9adSlinfeng mod consts;
2*fae6e9adSlinfeng mod print;
3*fae6e9adSlinfeng
4*fae6e9adSlinfeng use crate::bpf::helper::print::trace_printf;
5*fae6e9adSlinfeng use crate::bpf::map::{BpfCallBackFn, BpfMap};
6*fae6e9adSlinfeng use crate::include::bindings::linux_bpf::BPF_F_CURRENT_CPU;
7*fae6e9adSlinfeng use crate::libs::lazy_init::Lazy;
8*fae6e9adSlinfeng use crate::smp::core::smp_get_processor_id;
9*fae6e9adSlinfeng use alloc::{collections::BTreeMap, sync::Arc};
10*fae6e9adSlinfeng use core::ffi::c_void;
11*fae6e9adSlinfeng use system_error::SystemError;
12*fae6e9adSlinfeng
13*fae6e9adSlinfeng type RawBPFHelperFn = fn(u64, u64, u64, u64, u64) -> u64;
14*fae6e9adSlinfeng type Result<T> = core::result::Result<T, SystemError>;
15*fae6e9adSlinfeng macro_rules! define_func {
16*fae6e9adSlinfeng ($name:ident) => {
17*fae6e9adSlinfeng core::mem::transmute::<usize, RawBPFHelperFn>($name as usize)
18*fae6e9adSlinfeng };
19*fae6e9adSlinfeng }
20*fae6e9adSlinfeng
21*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_lookup_elem/
raw_map_lookup_elem(map: *mut c_void, key: *const c_void) -> *const c_void22*fae6e9adSlinfeng unsafe fn raw_map_lookup_elem(map: *mut c_void, key: *const c_void) -> *const c_void {
23*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
24*fae6e9adSlinfeng let key_size = map.key_size();
25*fae6e9adSlinfeng let key = core::slice::from_raw_parts(key as *const u8, key_size);
26*fae6e9adSlinfeng let value = map_lookup_elem(&map, key);
27*fae6e9adSlinfeng // log::info!("<raw_map_lookup_elem>: {:x?}", value);
28*fae6e9adSlinfeng // warning: We need to keep the map alive, so we don't drop it here.
29*fae6e9adSlinfeng let _ = Arc::into_raw(map);
30*fae6e9adSlinfeng match value {
31*fae6e9adSlinfeng Ok(Some(value)) => value as *const c_void,
32*fae6e9adSlinfeng _ => core::ptr::null_mut(),
33*fae6e9adSlinfeng }
34*fae6e9adSlinfeng }
35*fae6e9adSlinfeng
map_lookup_elem(map: &Arc<BpfMap>, key: &[u8]) -> Result<Option<*const u8>>36*fae6e9adSlinfeng pub fn map_lookup_elem(map: &Arc<BpfMap>, key: &[u8]) -> Result<Option<*const u8>> {
37*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
38*fae6e9adSlinfeng let value = binding.lookup_elem(key);
39*fae6e9adSlinfeng match value {
40*fae6e9adSlinfeng Ok(Some(value)) => Ok(Some(value.as_ptr())),
41*fae6e9adSlinfeng _ => Ok(None),
42*fae6e9adSlinfeng }
43*fae6e9adSlinfeng }
44*fae6e9adSlinfeng
45*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_perf_event_output/
46*fae6e9adSlinfeng ///
47*fae6e9adSlinfeng /// See https://man7.org/linux/man-pages/man7/bpf-helpers.7.html
raw_perf_event_output( ctx: *mut c_void, map: *mut c_void, flags: u64, data: *mut c_void, size: u64, ) -> i6448*fae6e9adSlinfeng unsafe fn raw_perf_event_output(
49*fae6e9adSlinfeng ctx: *mut c_void,
50*fae6e9adSlinfeng map: *mut c_void,
51*fae6e9adSlinfeng flags: u64,
52*fae6e9adSlinfeng data: *mut c_void,
53*fae6e9adSlinfeng size: u64,
54*fae6e9adSlinfeng ) -> i64 {
55*fae6e9adSlinfeng // log::info!("<raw_perf_event_output>: {:x?}", data);
56*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
57*fae6e9adSlinfeng let data = core::slice::from_raw_parts(data as *const u8, size as usize);
58*fae6e9adSlinfeng let res = perf_event_output(ctx, &map, flags, data);
59*fae6e9adSlinfeng // warning: We need to keep the map alive, so we don't drop it here.
60*fae6e9adSlinfeng let _ = Arc::into_raw(map);
61*fae6e9adSlinfeng match res {
62*fae6e9adSlinfeng Ok(_) => 0,
63*fae6e9adSlinfeng Err(e) => e as i64,
64*fae6e9adSlinfeng }
65*fae6e9adSlinfeng }
66*fae6e9adSlinfeng
perf_event_output( ctx: *mut c_void, map: &Arc<BpfMap>, flags: u64, data: &[u8], ) -> Result<()>67*fae6e9adSlinfeng pub fn perf_event_output(
68*fae6e9adSlinfeng ctx: *mut c_void,
69*fae6e9adSlinfeng map: &Arc<BpfMap>,
70*fae6e9adSlinfeng flags: u64,
71*fae6e9adSlinfeng data: &[u8],
72*fae6e9adSlinfeng ) -> Result<()> {
73*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
74*fae6e9adSlinfeng let index = flags as u32;
75*fae6e9adSlinfeng let flags = (flags >> 32) as u32;
76*fae6e9adSlinfeng let key = if index == BPF_F_CURRENT_CPU as u32 {
77*fae6e9adSlinfeng smp_get_processor_id().data()
78*fae6e9adSlinfeng } else {
79*fae6e9adSlinfeng index
80*fae6e9adSlinfeng };
81*fae6e9adSlinfeng let fd = binding
82*fae6e9adSlinfeng .lookup_elem(&key.to_ne_bytes())?
83*fae6e9adSlinfeng .ok_or(SystemError::ENOENT)?;
84*fae6e9adSlinfeng let fd = u32::from_ne_bytes(fd.try_into().map_err(|_| SystemError::EINVAL)?);
85*fae6e9adSlinfeng crate::perf::perf_event_output(ctx, fd as usize, flags, data)?;
86*fae6e9adSlinfeng Ok(())
87*fae6e9adSlinfeng }
88*fae6e9adSlinfeng
89*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_probe_read/
raw_bpf_probe_read(dst: *mut c_void, size: u32, unsafe_ptr: *const c_void) -> i6490*fae6e9adSlinfeng fn raw_bpf_probe_read(dst: *mut c_void, size: u32, unsafe_ptr: *const c_void) -> i64 {
91*fae6e9adSlinfeng log::info!(
92*fae6e9adSlinfeng "raw_bpf_probe_read, dst:{:x}, size:{}, unsafe_ptr: {:x}",
93*fae6e9adSlinfeng dst as usize,
94*fae6e9adSlinfeng size,
95*fae6e9adSlinfeng unsafe_ptr as usize
96*fae6e9adSlinfeng );
97*fae6e9adSlinfeng let (dst, src) = unsafe {
98*fae6e9adSlinfeng let dst = core::slice::from_raw_parts_mut(dst as *mut u8, size as usize);
99*fae6e9adSlinfeng let src = core::slice::from_raw_parts(unsafe_ptr as *const u8, size as usize);
100*fae6e9adSlinfeng (dst, src)
101*fae6e9adSlinfeng };
102*fae6e9adSlinfeng let res = bpf_probe_read(dst, src);
103*fae6e9adSlinfeng match res {
104*fae6e9adSlinfeng Ok(_) => 0,
105*fae6e9adSlinfeng Err(e) => e as i64,
106*fae6e9adSlinfeng }
107*fae6e9adSlinfeng }
108*fae6e9adSlinfeng
109*fae6e9adSlinfeng /// For tracing programs, safely attempt to read size
110*fae6e9adSlinfeng /// bytes from kernel space address unsafe_ptr and
111*fae6e9adSlinfeng /// store the data in dst.
bpf_probe_read(dst: &mut [u8], src: &[u8]) -> Result<()>112*fae6e9adSlinfeng pub fn bpf_probe_read(dst: &mut [u8], src: &[u8]) -> Result<()> {
113*fae6e9adSlinfeng log::info!("bpf_probe_read: len: {}", dst.len());
114*fae6e9adSlinfeng dst.copy_from_slice(src);
115*fae6e9adSlinfeng Ok(())
116*fae6e9adSlinfeng }
117*fae6e9adSlinfeng
raw_map_update_elem( map: *mut c_void, key: *const c_void, value: *const c_void, flags: u64, ) -> i64118*fae6e9adSlinfeng unsafe fn raw_map_update_elem(
119*fae6e9adSlinfeng map: *mut c_void,
120*fae6e9adSlinfeng key: *const c_void,
121*fae6e9adSlinfeng value: *const c_void,
122*fae6e9adSlinfeng flags: u64,
123*fae6e9adSlinfeng ) -> i64 {
124*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
125*fae6e9adSlinfeng let key_size = map.key_size();
126*fae6e9adSlinfeng let value_size = map.value_size();
127*fae6e9adSlinfeng // log::info!("<raw_map_update_elem>: flags: {:x?}", flags);
128*fae6e9adSlinfeng let key = core::slice::from_raw_parts(key as *const u8, key_size);
129*fae6e9adSlinfeng let value = core::slice::from_raw_parts(value as *const u8, value_size);
130*fae6e9adSlinfeng let res = map_update_elem(&map, key, value, flags);
131*fae6e9adSlinfeng let _ = Arc::into_raw(map);
132*fae6e9adSlinfeng match res {
133*fae6e9adSlinfeng Ok(_) => 0,
134*fae6e9adSlinfeng Err(e) => e as _,
135*fae6e9adSlinfeng }
136*fae6e9adSlinfeng }
137*fae6e9adSlinfeng
map_update_elem(map: &Arc<BpfMap>, key: &[u8], value: &[u8], flags: u64) -> Result<()>138*fae6e9adSlinfeng pub fn map_update_elem(map: &Arc<BpfMap>, key: &[u8], value: &[u8], flags: u64) -> Result<()> {
139*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
140*fae6e9adSlinfeng let value = binding.update_elem(key, value, flags);
141*fae6e9adSlinfeng value
142*fae6e9adSlinfeng }
143*fae6e9adSlinfeng
144*fae6e9adSlinfeng /// Delete entry with key from map.
145*fae6e9adSlinfeng ///
146*fae6e9adSlinfeng /// The delete map element helper call is used to delete values from maps.
raw_map_delete_elem(map: *mut c_void, key: *const c_void) -> i64147*fae6e9adSlinfeng unsafe fn raw_map_delete_elem(map: *mut c_void, key: *const c_void) -> i64 {
148*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
149*fae6e9adSlinfeng let key_size = map.key_size();
150*fae6e9adSlinfeng let key = core::slice::from_raw_parts(key as *const u8, key_size);
151*fae6e9adSlinfeng let res = map_delete_elem(&map, key);
152*fae6e9adSlinfeng let _ = Arc::into_raw(map);
153*fae6e9adSlinfeng match res {
154*fae6e9adSlinfeng Ok(_) => 0,
155*fae6e9adSlinfeng Err(e) => e as i64,
156*fae6e9adSlinfeng }
157*fae6e9adSlinfeng }
158*fae6e9adSlinfeng
map_delete_elem(map: &Arc<BpfMap>, key: &[u8]) -> Result<()>159*fae6e9adSlinfeng pub fn map_delete_elem(map: &Arc<BpfMap>, key: &[u8]) -> Result<()> {
160*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
161*fae6e9adSlinfeng let value = binding.delete_elem(key);
162*fae6e9adSlinfeng value
163*fae6e9adSlinfeng }
164*fae6e9adSlinfeng
165*fae6e9adSlinfeng /// For each element in map, call callback_fn function with map, callback_ctx and other map-specific
166*fae6e9adSlinfeng /// parameters. The callback_fn should be a static function and the callback_ctx should be a pointer
167*fae6e9adSlinfeng /// to the stack. The flags is used to control certain aspects of the helper. Currently, the flags must
168*fae6e9adSlinfeng /// be 0.
169*fae6e9adSlinfeng ///
170*fae6e9adSlinfeng /// The following are a list of supported map types and their respective expected callback signatures:
171*fae6e9adSlinfeng /// - BPF_MAP_TYPE_HASH
172*fae6e9adSlinfeng /// - BPF_MAP_TYPE_PERCPU_HASH
173*fae6e9adSlinfeng /// - BPF_MAP_TYPE_LRU_HASH
174*fae6e9adSlinfeng /// - BPF_MAP_TYPE_LRU_PERCPU_HASH
175*fae6e9adSlinfeng /// - BPF_MAP_TYPE_ARRAY
176*fae6e9adSlinfeng /// - BPF_MAP_TYPE_PERCPU_ARRAY
177*fae6e9adSlinfeng ///
178*fae6e9adSlinfeng /// `long (*callback_fn)(struct bpf_map *map, const void key, void *value, void *ctx);`
179*fae6e9adSlinfeng ///
180*fae6e9adSlinfeng /// For per_cpu maps, the map_value is the value on the cpu where the bpf_prog is running.
raw_map_for_each_elem( map: *mut c_void, cb: *const c_void, ctx: *const c_void, flags: u64, ) -> i64181*fae6e9adSlinfeng unsafe fn raw_map_for_each_elem(
182*fae6e9adSlinfeng map: *mut c_void,
183*fae6e9adSlinfeng cb: *const c_void,
184*fae6e9adSlinfeng ctx: *const c_void,
185*fae6e9adSlinfeng flags: u64,
186*fae6e9adSlinfeng ) -> i64 {
187*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
188*fae6e9adSlinfeng let cb = *core::mem::transmute::<*const c_void, *const BpfCallBackFn>(cb);
189*fae6e9adSlinfeng let res = map_for_each_elem(&map, cb, ctx as _, flags);
190*fae6e9adSlinfeng let _ = Arc::into_raw(map);
191*fae6e9adSlinfeng match res {
192*fae6e9adSlinfeng Ok(v) => v as i64,
193*fae6e9adSlinfeng Err(e) => e as i64,
194*fae6e9adSlinfeng }
195*fae6e9adSlinfeng }
196*fae6e9adSlinfeng
map_for_each_elem( map: &Arc<BpfMap>, cb: BpfCallBackFn, ctx: *const u8, flags: u64, ) -> Result<u32>197*fae6e9adSlinfeng pub fn map_for_each_elem(
198*fae6e9adSlinfeng map: &Arc<BpfMap>,
199*fae6e9adSlinfeng cb: BpfCallBackFn,
200*fae6e9adSlinfeng ctx: *const u8,
201*fae6e9adSlinfeng flags: u64,
202*fae6e9adSlinfeng ) -> Result<u32> {
203*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
204*fae6e9adSlinfeng let value = binding.for_each_elem(cb, ctx, flags);
205*fae6e9adSlinfeng value
206*fae6e9adSlinfeng }
207*fae6e9adSlinfeng
208*fae6e9adSlinfeng /// Perform a lookup in percpu map for an entry associated to key on cpu.
209*fae6e9adSlinfeng ///
210*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_lookup_percpu_elem/
raw_map_lookup_percpu_elem( map: *mut c_void, key: *const c_void, cpu: u32, ) -> *const c_void211*fae6e9adSlinfeng unsafe fn raw_map_lookup_percpu_elem(
212*fae6e9adSlinfeng map: *mut c_void,
213*fae6e9adSlinfeng key: *const c_void,
214*fae6e9adSlinfeng cpu: u32,
215*fae6e9adSlinfeng ) -> *const c_void {
216*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
217*fae6e9adSlinfeng let key_size = map.key_size();
218*fae6e9adSlinfeng let key = core::slice::from_raw_parts(key as *const u8, key_size);
219*fae6e9adSlinfeng let value = map_lookup_percpu_elem(&map, key, cpu);
220*fae6e9adSlinfeng // warning: We need to keep the map alive, so we don't drop it here.
221*fae6e9adSlinfeng let _ = Arc::into_raw(map);
222*fae6e9adSlinfeng match value {
223*fae6e9adSlinfeng Ok(Some(value)) => value as *const c_void,
224*fae6e9adSlinfeng _ => core::ptr::null_mut(),
225*fae6e9adSlinfeng }
226*fae6e9adSlinfeng }
227*fae6e9adSlinfeng
map_lookup_percpu_elem( map: &Arc<BpfMap>, key: &[u8], cpu: u32, ) -> Result<Option<*const u8>>228*fae6e9adSlinfeng pub fn map_lookup_percpu_elem(
229*fae6e9adSlinfeng map: &Arc<BpfMap>,
230*fae6e9adSlinfeng key: &[u8],
231*fae6e9adSlinfeng cpu: u32,
232*fae6e9adSlinfeng ) -> Result<Option<*const u8>> {
233*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
234*fae6e9adSlinfeng let value = binding.lookup_percpu_elem(key, cpu);
235*fae6e9adSlinfeng match value {
236*fae6e9adSlinfeng Ok(Some(value)) => Ok(Some(value.as_ptr())),
237*fae6e9adSlinfeng _ => Ok(None),
238*fae6e9adSlinfeng }
239*fae6e9adSlinfeng }
240*fae6e9adSlinfeng /// Push an element value in map.
241*fae6e9adSlinfeng ///
242*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_push_elem/
raw_map_push_elem(map: *mut c_void, value: *const c_void, flags: u64) -> i64243*fae6e9adSlinfeng unsafe fn raw_map_push_elem(map: *mut c_void, value: *const c_void, flags: u64) -> i64 {
244*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
245*fae6e9adSlinfeng let value_size = map.value_size();
246*fae6e9adSlinfeng let value = core::slice::from_raw_parts(value as *const u8, value_size);
247*fae6e9adSlinfeng let res = map_push_elem(&map, value, flags);
248*fae6e9adSlinfeng let _ = Arc::into_raw(map);
249*fae6e9adSlinfeng match res {
250*fae6e9adSlinfeng Ok(_) => 0,
251*fae6e9adSlinfeng Err(e) => e as i64,
252*fae6e9adSlinfeng }
253*fae6e9adSlinfeng }
254*fae6e9adSlinfeng
map_push_elem(map: &Arc<BpfMap>, value: &[u8], flags: u64) -> Result<()>255*fae6e9adSlinfeng pub fn map_push_elem(map: &Arc<BpfMap>, value: &[u8], flags: u64) -> Result<()> {
256*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
257*fae6e9adSlinfeng let value = binding.push_elem(value, flags);
258*fae6e9adSlinfeng value
259*fae6e9adSlinfeng }
260*fae6e9adSlinfeng
261*fae6e9adSlinfeng /// Pop an element from map.
262*fae6e9adSlinfeng ///
263*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_pop_elem/
raw_map_pop_elem(map: *mut c_void, value: *mut c_void) -> i64264*fae6e9adSlinfeng unsafe fn raw_map_pop_elem(map: *mut c_void, value: *mut c_void) -> i64 {
265*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
266*fae6e9adSlinfeng let value_size = map.value_size();
267*fae6e9adSlinfeng let value = core::slice::from_raw_parts_mut(value as *mut u8, value_size);
268*fae6e9adSlinfeng let res = map_pop_elem(&map, value);
269*fae6e9adSlinfeng let _ = Arc::into_raw(map);
270*fae6e9adSlinfeng match res {
271*fae6e9adSlinfeng Ok(_) => 0,
272*fae6e9adSlinfeng Err(e) => e as i64,
273*fae6e9adSlinfeng }
274*fae6e9adSlinfeng }
275*fae6e9adSlinfeng
map_pop_elem(map: &Arc<BpfMap>, value: &mut [u8]) -> Result<()>276*fae6e9adSlinfeng pub fn map_pop_elem(map: &Arc<BpfMap>, value: &mut [u8]) -> Result<()> {
277*fae6e9adSlinfeng let mut binding = map.inner_map().lock();
278*fae6e9adSlinfeng let value = binding.pop_elem(value);
279*fae6e9adSlinfeng value
280*fae6e9adSlinfeng }
281*fae6e9adSlinfeng
282*fae6e9adSlinfeng /// Get an element from map without removing it.
283*fae6e9adSlinfeng ///
284*fae6e9adSlinfeng /// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_peek_elem/
raw_map_peek_elem(map: *mut c_void, value: *mut c_void) -> i64285*fae6e9adSlinfeng unsafe fn raw_map_peek_elem(map: *mut c_void, value: *mut c_void) -> i64 {
286*fae6e9adSlinfeng let map = Arc::from_raw(map as *const BpfMap);
287*fae6e9adSlinfeng let value_size = map.value_size();
288*fae6e9adSlinfeng let value = core::slice::from_raw_parts_mut(value as *mut u8, value_size);
289*fae6e9adSlinfeng let res = map_peek_elem(&map, value);
290*fae6e9adSlinfeng let _ = Arc::into_raw(map);
291*fae6e9adSlinfeng match res {
292*fae6e9adSlinfeng Ok(_) => 0,
293*fae6e9adSlinfeng Err(e) => e as i64,
294*fae6e9adSlinfeng }
295*fae6e9adSlinfeng }
296*fae6e9adSlinfeng
map_peek_elem(map: &Arc<BpfMap>, value: &mut [u8]) -> Result<()>297*fae6e9adSlinfeng pub fn map_peek_elem(map: &Arc<BpfMap>, value: &mut [u8]) -> Result<()> {
298*fae6e9adSlinfeng let binding = map.inner_map().lock();
299*fae6e9adSlinfeng let value = binding.peek_elem(value);
300*fae6e9adSlinfeng value
301*fae6e9adSlinfeng }
302*fae6e9adSlinfeng
303*fae6e9adSlinfeng pub static BPF_HELPER_FUN_SET: Lazy<BTreeMap<u32, RawBPFHelperFn>> = Lazy::new();
304*fae6e9adSlinfeng
305*fae6e9adSlinfeng /// Initialize the helper functions.
init_helper_functions()306*fae6e9adSlinfeng pub fn init_helper_functions() {
307*fae6e9adSlinfeng use consts::*;
308*fae6e9adSlinfeng let mut map = BTreeMap::new();
309*fae6e9adSlinfeng unsafe {
310*fae6e9adSlinfeng // Map helpers::Generic map helpers
311*fae6e9adSlinfeng map.insert(HELPER_MAP_LOOKUP_ELEM, define_func!(raw_map_lookup_elem));
312*fae6e9adSlinfeng map.insert(HELPER_MAP_UPDATE_ELEM, define_func!(raw_map_update_elem));
313*fae6e9adSlinfeng map.insert(HELPER_MAP_DELETE_ELEM, define_func!(raw_map_delete_elem));
314*fae6e9adSlinfeng map.insert(
315*fae6e9adSlinfeng HELPER_MAP_FOR_EACH_ELEM,
316*fae6e9adSlinfeng define_func!(raw_map_for_each_elem),
317*fae6e9adSlinfeng );
318*fae6e9adSlinfeng map.insert(
319*fae6e9adSlinfeng HELPER_MAP_LOOKUP_PERCPU_ELEM,
320*fae6e9adSlinfeng define_func!(raw_map_lookup_percpu_elem),
321*fae6e9adSlinfeng );
322*fae6e9adSlinfeng // map.insert(93,define_func!(raw_bpf_spin_lock);
323*fae6e9adSlinfeng // map.insert(94,define_func!(raw_bpf_spin_unlock);
324*fae6e9adSlinfeng // Map helpers::Perf event array helpers
325*fae6e9adSlinfeng map.insert(
326*fae6e9adSlinfeng HELPER_PERF_EVENT_OUTPUT,
327*fae6e9adSlinfeng define_func!(raw_perf_event_output),
328*fae6e9adSlinfeng );
329*fae6e9adSlinfeng // Probe and trace helpers::Memory helpers
330*fae6e9adSlinfeng map.insert(HELPER_BPF_PROBE_READ, define_func!(raw_bpf_probe_read));
331*fae6e9adSlinfeng // Print helpers
332*fae6e9adSlinfeng map.insert(HELPER_TRACE_PRINTF, define_func!(trace_printf));
333*fae6e9adSlinfeng
334*fae6e9adSlinfeng // Map helpers::Queue and stack helpers
335*fae6e9adSlinfeng map.insert(HELPER_MAP_PUSH_ELEM, define_func!(raw_map_push_elem));
336*fae6e9adSlinfeng map.insert(HELPER_MAP_POP_ELEM, define_func!(raw_map_pop_elem));
337*fae6e9adSlinfeng map.insert(HELPER_MAP_PEEK_ELEM, define_func!(raw_map_peek_elem));
338*fae6e9adSlinfeng }
339*fae6e9adSlinfeng BPF_HELPER_FUN_SET.init(map);
340*fae6e9adSlinfeng }
341