[BPF] Remove support for kernels without BPF CO-RE#12128
Open
tomastigera wants to merge 5 commits intoprojectcalico:masterfrom
Open
[BPF] Remove support for kernels without BPF CO-RE#12128tomastigera wants to merge 5 commits intoprojectcalico:masterfrom
tomastigera wants to merge 5 commits intoprojectcalico:masterfrom
Conversation
With minimum kernel support moving to 5.10+, all supported kernels have BTF/CO-RE support. This removes legacy BPF compilation, runtime CO-RE detection, and legacy cgroup attach fallback. Halves compiled BPF objects from 172 to 90. Stage 1 of legacy BPF removal - stage 2 will remove #ifdef BPF_CORE_SUPPORTED conditionals from C code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fe00415 to
9b8d3d1
Compare
3 tasks
Stage 2: with CO-RE always available, remove all #ifdef BPF_CORE_SUPPORTED conditionals from BPF C code, keeping only the CO-RE paths. Delete fib_legacy.h entirely. Remove -DBPF_CORE_SUPPORTED from build scripts since it's no longer checked. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Now that legacy (non-CO-RE) objects no longer exist, the _co-re filename distinction is unnecessary. Remove it from all object names, build rules, and Go filename generation. Also remove the dead CO-RE fallback logic in hook/map.go. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes Felix’s legacy (non-CO-RE) eBPF build/runtime paths, assuming a minimum kernel baseline where BTF/CO-RE is always available, and correspondingly simplifies object selection, attachment logic, and related tests/build scripts.
Changes:
- Drop runtime CO-RE/BTF detection and remove legacy fallback logic for object loading and cgroup attachment/detachment.
- Rename/simplify BPF object naming (removing
_co-revariants) and update loaders/tests/scripts accordingly. - Remove legacy BPF C code paths and headers (e.g.,
fib_legacy.h) and simplify compile flags/build rules.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| felix/dataplane/linux/vxlan_mgr.go | Simplifies VXLAN flow-based enablement condition to depend only on BPF enablement. |
| felix/dataplane/linux/int_dataplane.go | Removes BTFEnabled gating for VXLAN-related BPF-mode behavior in dataplane setup. |
| felix/bpf/utils/utils.go | Removes runtime BTF detection and replaces with a constant. |
| felix/bpf/ut/precompilation_test.go | Updates expected precompiled object set to match new naming scheme (no _co-re). |
| felix/bpf/ut/bpf_prog_test.go | Updates unit-test object naming logic to remove _co-re suffix handling. |
| felix/bpf/ut/attach_test.go | Removes legacy CTLB attach unit test. |
| felix/bpf/tc/defs/defs.go | Simplifies ProgFilename by removing the btf parameter and _co-re name component. |
| felix/bpf/nat/connecttime.go | Removes CTLB legacy attach/detach fallback paths and _co-re filename selection. |
| felix/bpf/libbpf/libbpf_stub.go | Removes legacy-attach related stubs. |
| felix/bpf/libbpf/libbpf_api.h | Removes C helper functions used only for legacy CTLB detach/attach. |
| felix/bpf/libbpf/libbpf.go | Removes Go legacy CTLB detach/attach implementations. |
| felix/bpf/hook/map.go | Removes runtime fallback from CO-RE object load to non-CO-RE object load. |
| felix/bpf/hook/load.go | Updates object filename initialization to match new naming and ProgFilename signature. |
| felix/bpf/conntrack/bpf_scanner.go | Updates conntrack cleanup object filename to new naming (no _co-re). |
| felix/bpf-gpl/tc.c | Removes #ifndef BPF_CORE_SUPPORTED fragmentation denial path. |
| felix/bpf-gpl/skb.h | Removes BPF_CORE_SUPPORTED conditional compilation branches. |
| felix/bpf-gpl/parsing.h | Removes BPF_CORE_SUPPORTED conditional compilation around XDP helper selection. |
| felix/bpf-gpl/log.h | Removes legacy bpf_log formatting branch; keeps CO-RE style. |
| felix/bpf-gpl/list-ut-objs | Updates UT object list generation to match new filenames (no _co-re). |
| felix/bpf-gpl/list-objs | Updates object list generation to only emit new filenames (no _co-re variants). |
| felix/bpf-gpl/ip_v4_fragment.h | Removes BPF_CORE_SUPPORTED guards around fragment handling helpers. |
| felix/bpf-gpl/fib_legacy.h | Deletes legacy FIB implementation header. |
| felix/bpf-gpl/fib.h | Removes conditional include; always includes CO-RE FIB implementation. |
| felix/bpf-gpl/connect_balancer_v6.c | Removes BPF_CORE_SUPPORTED conditional debug formatting. |
| felix/bpf-gpl/connect_balancer_v46.c | Removes BPF_CORE_SUPPORTED conditional debug formatting. |
| felix/bpf-gpl/calculate-flags | Stops defining BPF_CORE_SUPPORTED based on filename/test builds. |
| felix/bpf-gpl/bpf.h | Removes BPF_CORE_SUPPORTED conditional debug formatting macros. |
| felix/bpf-gpl/Makefile | Removes _co-re build rules and stops defining BPF_CORE_SUPPORTED in dependency generation/UT flags. |
| felix/CLAUDE.md | Updates documentation to remove references to removed legacy header(s). |
Comments suppressed due to low confidence (1)
felix/bpf-gpl/ip_v4_fragment.h:196
- The comment has a typo: "woul dnot" should be "would not".
* verifier would not verify the code correctly and woul dnot accept it.
*/
- Remove unused udpNotSeen/excludeUDP params from attachProgram() - Remove unused ipv4Enabled/cgroupv2 params and numLinksDetached from detachCtlbPrograms() - Remove dead BTFEnabled constant from bpf/utils Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a BPF program is rejected by the kernel verifier (e.g. kernel too old), cache the error and stop retrying. Report a clear health message: "program rejected by kernel BPF verifier. Calico eBPF dataplane requires kernel 5.10+." - Add ErrPermanentLoadFailure sentinel and IsPermanentLoadFailure() classifier in hook/map.go (transient: ENOMEM/EAGAIN/EBUSY; all else permanent) - Cache permanent errors in program struct; return immediately on subsequent LoadObj calls - In bpf_ep_mgr: detect permanent failure, remove interface from dirty set, report not-ready health with actionable message - Add unit tests for data interface and workload interface paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With minimum kernel support moving to 5.10+, all supported kernels have BTF/CO-RE. This PR removes the legacy/CO-RE distinction entirely.
Legacy BPF removal:
SupportsBTF(),BTFEnabled)AttachCGroupLegacy,DetachCTLBProgramsLegacy)config.BPFEnabled && bpfutils.BTFEnabled→config.BPFEnabled#ifdef BPF_CORE_SUPPORTEDconditionals from BPF C codefib_legacy.hand remove-DBPF_CORE_SUPPORTEDfrom build scripts_co-resuffix from all BPF object filenamesPermanent load failure handling:
Test plan
🤖 Generated with Claude Code