4
0

test.rs 644 B

12345678910111213141516171819202122232425262728293031
  1. #![no_std]
  2. #![no_main]
  3. use aya_bpf::{
  4. bindings::xdp_action,
  5. macros::{kprobe, xdp},
  6. programs::{ProbeContext, XdpContext},
  7. };
  8. #[xdp(name = "test_unload_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. // truncated name to match bpftool output
  20. pub fn test_unload_kpr(_ctx: ProbeContext) -> u32 {
  21. 0
  22. }
  23. #[panic_handler]
  24. fn panic(_info: &core::panic::PanicInfo) -> ! {
  25. unsafe { core::hint::unreachable_unchecked() }
  26. }