test.rs 737 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #![no_std]
  2. #![no_main]
  3. use aya_bpf::{
  4. bindings::xdp_action,
  5. macros::{kprobe, tracepoint, uprobe, xdp},
  6. programs::{ProbeContext, TracePointContext, XdpContext},
  7. };
  8. #[xdp]
  9. pub fn pass(ctx: XdpContext) -> u32 {
  10. match unsafe { try_pass(ctx) } {
  11. Ok(ret) => ret,
  12. Err(_) => xdp_action::XDP_ABORTED,
  13. }
  14. }
  15. unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
  16. Ok(xdp_action::XDP_PASS)
  17. }
  18. #[kprobe]
  19. pub fn test_kprobe(_ctx: ProbeContext) -> u32 {
  20. 0
  21. }
  22. #[tracepoint]
  23. pub fn test_tracepoint(_ctx: TracePointContext) -> u32 {
  24. 0
  25. }
  26. #[uprobe]
  27. pub fn test_uprobe(_ctx: ProbeContext) -> u32 {
  28. 0
  29. }
  30. #[cfg(not(test))]
  31. #[panic_handler]
  32. fn panic(_info: &core::panic::PanicInfo) -> ! {
  33. loop {}
  34. }