uprobe_cookie.rs 557 B

12345678910111213141516171819202122
  1. #![no_std]
  2. #![no_main]
  3. #![expect(unused_crate_dependencies, reason = "used in other bins")]
  4. use aya_ebpf::{
  5. EbpfContext as _, helpers,
  6. macros::{map, uprobe},
  7. maps::RingBuf,
  8. programs::ProbeContext,
  9. };
  10. #[cfg(not(test))]
  11. extern crate ebpf_panic;
  12. #[map]
  13. static RING_BUF: RingBuf = RingBuf::with_byte_size(0, 0);
  14. #[uprobe]
  15. fn uprobe_cookie(ctx: ProbeContext) {
  16. let cookie = unsafe { helpers::bpf_get_attach_cookie(ctx.as_ptr()) };
  17. let cookie_bytes = cookie.to_le_bytes();
  18. let _res = RING_BUF.output::<[u8; 8]>(&cookie_bytes, 0);
  19. }