diff --git a/ebpf/aya-ebpf/src/lib.rs b/ebpf/aya-ebpf/src/lib.rs index b0e4e344..7ce671b1 100644 --- a/ebpf/aya-ebpf/src/lib.rs +++ b/ebpf/aya-ebpf/src/lib.rs @@ -113,6 +113,18 @@ mod intrinsics { } } +/// Builds a flag for [`SkBuffContext::adjust_room`] that defines L2 encapsulation, +/// using `len` as the inner MAC header length. +/// +/// Equivalent to the [`BPF_F_ADJ_ROOM_ENCAP_L2`][uapi-bpf-adj-room-encap-l2] macro +/// in the Linux user-space API. +/// +/// [uapi-bpf-adj-room-encap-l2]: https://github.com/torvalds/linux/blob/v6.17/include/uapi/linux/bpf.h#L6181 +#[inline(always)] +pub const fn bpf_f_adj_room_encap_l2(len: u64) -> u64 { + (len & bindings::BPF_ADJ_ROOM_ENCAP_L2_MASK as u64) << bindings::BPF_ADJ_ROOM_ENCAP_L2_SHIFT +} + /// Check if a value is within a range, using conditional forms compatible with /// the verifier. #[inline(always)] diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index b8e672ee..0a125ef4 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -2991,4 +2991,5 @@ impl aya_ebpf::EbpfContext for aya_ebpf::programs::tracepoint::TracePointContext pub fn aya_ebpf::programs::tracepoint::TracePointContext::as_ptr(&self) -> *mut core::ffi::c_void impl aya_ebpf::EbpfContext for aya_ebpf::programs::xdp::XdpContext pub fn aya_ebpf::programs::xdp::XdpContext::as_ptr(&self) -> *mut core::ffi::c_void +pub const fn aya_ebpf::bpf_f_adj_room_encap_l2(len: u64) -> u64 pub fn aya_ebpf::check_bounds_signed(value: i64, lower: i64, upper: i64) -> bool