Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For supporting custom pinning behaviours in Cilium, we're looking to extend the MapSpec.Pinning flag and treat it as a bitfield internally. libbpf and ebpf-go currently only support LIBBPF_PIN_BY_NAME and ebpf.PinByName respectively, which has a value of 1, so it's still up in the air whether or not this could officially evolve into a bitfield in the future, since doing so can be done while maintaining backwards compatibility. In Cilium's case, we reserve the lower 4 bits for the upstream enum values and mask out the remaining bits before calling NewCollection. The upper bits are used for specifying flags to request specific behaviours, e.g. to ignore a pinned map during loading, and explicitly overwriting its pin at a later stage, when the entrypoint program(s) were successfully attached. Useful for working with prog arrays that need to remain pinned. We want to keep using the existing ebpf.PinType type for this, but defining masks using a signed type needs to be done with care, so ideally PinType would be unsigned. A few more data points on why this change is warranted: - bpf_elf_map always had 'unsigned int' fields only, including 'pinning' - libbpf reads the BTF map def 'pinning' field into a __u32 - Realistically, `enum libbpf_pin_type` will not acquire any negative values Signed-off-by: Timo Beckers <timo@isovalent.com>
- Loading branch information