aya-ebpf: Add BPF_F_ADJ_ROOM_ENCAP_L2 macro

This macro is needed to properly add a L2 header when using
bpf_skb_adjust_room [1]. As it is originally a C macro, it isn't
automatically generated in the `bindings` crate

[1]: https://docs.ebpf.io/linux/helper-function/bpf_skb_adjust_room/
reviewable/pr1344/r1
Aurélien DEROIDE 2 weeks ago
parent 214fe3c367
commit eefeba6be2

@ -113,6 +113,16 @@ mod intrinsics {
#[cfg(target_arch = "bpf")]
pub use intrinsics::*;
// A reimplementation of the BPF_F_ADJ_ROOM_ENCAP_L2(len) macro of the kernel, to use to construct
// flags to pass to bpf_skb_adjust_room.
// https://elixir.bootlin.com/linux/v6.16.4/source/include/uapi/linux/bpf.h#L6149
#[inline(always)]
#[allow(non_snake_case)]
pub 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 as u64
}
/// Check if a value is within a range, using conditional forms compatible with
/// the verifier.
#[inline(always)]

Loading…
Cancel
Save