Skip to content

examples: bpfman pre-load gate adapter#97

Merged
ErenAri merged 1 commit into
mainfrom
feat/bpfman-adapter
Jul 21, 2026
Merged

examples: bpfman pre-load gate adapter#97
ErenAri merged 1 commit into
mainfrom
feat/bpfman-adapter

Conversation

@ErenAri

@ErenAri ErenAri commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Companion to a proposed hook in bpfman: ErenAri/bpfman@preload-validation-gate.

Design

bpfman defines a tiny interface; we supply the implementation. bpfman takes no dependency on bpfcompat — that was the constraint worth designing around, since a hard dep would be an unreasonable ask of another project.

// in bpfman
type PreLoadValidator interface {
    ValidateBeforeLoad(ctx context.Context, objectPath string) error
}

// in the consumer's wiring
mgr = mgr.WithPreLoadValidator(bpfmangate.New())

Why the interface is shaped this way

It mirrors bpfman's existing ProgramValidator convention rather than inventing a new one. The two ask different questions: ProgramValidator is structural (do these program names exist in this object), this one is about the kernel (will the verifier accept it here). An object can name every program correctly and still be rejected for a missing helper, map type, or BTF relocation target.

The error is the product. bpfman surfaces it verbatim, so a refusal carries the classification code, the verifier's own reason, and the errno — instead of the bare EINVAL the loader produces today.

Verified

  • Builds with and without (the no-tag stub reports the feature is unavailable rather than silently passing).
  • On the bpfman side: their full manager suite passes with the patch, plus two new tests — a refusal blocks the load and leaves clean state, and the default nil validator is a no-op. (platform/image/oci fails there, but identically with my changes stashed — pre-existing.)

Adapts bpfcompat to the optional PreLoadValidator hook proposed in
bpfman (ErenAri/bpfman branch preload-validation-gate). bpfman defines
the interface and this supplies the implementation, so bpfman itself
never imports bpfcompat.

The error is the deliverable: bpfman surfaces it verbatim, so a refusal
carries the classification code, the verifier's reason and the errno
instead of the bare EINVAL the loader would otherwise produce.

Builds with and without the hostload tag; without it bpfcompat compiles
to a stub that reports the feature is unavailable rather than silently
passing objects.

Signed-off-by: ErenAri <erenari27@gmail.com>
Copilot AI review requested due to automatic review settings July 21, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ErenAri
ErenAri merged commit b487905 into main Jul 21, 2026
8 of 9 checks passed
@ErenAri
ErenAri deleted the feat/bpfman-adapter branch July 21, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants