Skip to content

Graceful feature probing

Step 5 of 8Concept
MISSING FIELD
fallback
DEAD CODE
pruned
ENUMS
BTF-hydrated
MIN KERNEL
5.5+ wide
  • compile / emit relocs
  • BTF offset patch
  • load verified ELF
BTF, CO-RE & Toolchains, step 5 of 8

What if a field does not exist yet on an older kernel—like kfree_skb.reason, added in Linux 5.17? bpf_core_field_exists(ctx->reason) evaluates to 0 at load time, and the verifier prunes the unused branch.

Loaders can also query btf__load_vmlinux_btf() for enum bit positions (such as ___GFP_HIGH_BIT) and hydrate .rodata before load, avoiding fragile #ifdef ladders.

Type to search…

↑↓ navigate↵ selectEsc close