pass.rs 495 B

123456789101112131415161718192021
  1. #![no_std]
  2. #![no_main]
  3. use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext};
  4. #[xdp(name = "pass", frags = "true")]
  5. pub fn pass(ctx: XdpContext) -> u32 {
  6. match unsafe { try_pass(ctx) } {
  7. Ok(ret) => ret,
  8. Err(_) => xdp_action::XDP_ABORTED,
  9. }
  10. }
  11. unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
  12. Ok(xdp_action::XDP_PASS)
  13. }
  14. #[panic_handler]
  15. fn panic(_info: &core::panic::PanicInfo) -> ! {
  16. unsafe { core::hint::unreachable_unchecked() }
  17. }