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/r5
Aurélien DEROIDE 4 weeks ago
parent 214fe3c367
commit 0c2cc1f85b

@ -113,6 +113,15 @@ 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 & u64::from(bindings::BPF_ADJ_ROOM_ENCAP_L2_MASK)) << bindings::BPF_ADJ_ROOM_ENCAP_L2_SHIFT
}
/// Check if a value is within a range, using conditional forms compatible with
/// the verifier.
#[inline(always)]

Loading…
Cancel
Save