test.ebpf.rs 578 B

1234567891011121314151617181920212223242526
  1. //! ```cargo
  2. //! [dependencies]
  3. //! aya-bpf = { path = "../../../../bpf/aya-bpf" }
  4. //! ```
  5. #![no_std]
  6. #![no_main]
  7. use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext};
  8. #[xdp(name = "test_unload")]
  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. #[panic_handler]
  19. fn panic(_info: &core::panic::PanicInfo) -> ! {
  20. unsafe { core::hint::unreachable_unchecked() }
  21. }