Skip to content

feat(validator): set program type when libbpf can't infer it (auto-type + manifest override)#40

Merged
ErenAri merged 1 commit into
mainfrom
feat/auto-prog-type
Jun 22, 2026
Merged

feat(validator): set program type when libbpf can't infer it (auto-type + manifest override)#40
ErenAri merged 1 commit into
mainfrom
feat/auto-prog-type

Conversation

@ErenAri

@ErenAri ErenAri commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What

Make the validator set a program's BPF type when libbpf can't infer it from the ELF section name. Two layers:

  1. Auto-type — a program left BPF_PROG_TYPE_UNSPEC after open whose section is a recognizable family gets typed automatically. Today: socket-prefixed sections → SOCKET_FILTER (Inspektor Gadget's socket1).
  2. Manifest override (general) — program_types: entries set any program's type explicitly:
    program_types:
      - program: socket1        # program name OR ELF section
        type: socket_filter
    Surfaced to the validator as --set-prog-type <program|section>=<type>; applied before auto-typing (an explicit override wins). Supported types: socket_filter, kprobe, tracepoint, raw_tracepoint, xdp, perf_event, cgroup_skb, cgroup_sock, sched_cls, sched_act, sk_skb, sk_msg, tracing, lsm.

Both are reported per program/override in the run notes.

Why

From the Inspektor Gadget thread (Alban Crequy): trace_dns's program lives in a socket1 section libbpf can't map to a type, so a generic load fails on every kernel with missing BPF prog type. IG's loader sets SOCKET_FILTER itself; this does the same.

Verification (real IG gadget, on the box)

  • bpfcompat test --artifact ghcr.io/inspektor-gadget/gadget/trace_dns:latest --quick → the socket1 program-type error is gone (auto-typed program "ig_trace_dns" (section "socket1")).
  • With a program_types: manifest → note shows program type override applied: "socket1" (and it takes precedence over auto-typing, as designed).
  • In both cases trace_dns then advances to a separate, deeper issue — a CO-RE relocation against struct gadget_socket_value (IG's socket-enricher API, BTF injected by the IG runtime). It fails identically on 6.1 and 6.8 → a framework dependency, not a kernel-compat gap, and the honest boundary of standalone gadget validation. Documented in docs/case-study-inspektor-gadget.md.

Tests: manifest validation + CLI-arg construction added; go build, go vet, gofmt, go test ./... clean; validator C compiles clean.

🤖 Generated with Claude Code

…name

When a program is left BPF_PROG_TYPE_UNSPEC after open because its ELF
section name isn't one libbpf recognizes, set the type the artifact's own
loader assigns, before load. Today this covers socket-filter programs in
"socket"-prefixed sections (e.g. Inspektor Gadget's socket1), which otherwise
fail with "missing BPF prog type". Reported per program in the run notes.

Verified against IG trace_dns: the socket1 program-type error is gone (it is
auto-typed to SOCKET_FILTER). trace_dns then surfaces a separate, deeper
issue — a CO-RE relocation against IG's socket-enricher API type
gadget_socket_value, which the IG loader supplies at runtime; that is a
framework dependency, not a kernel-compat gap, and out of scope here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ErenAri ErenAri merged commit f8e0df6 into main Jun 22, 2026
7 of 8 checks passed
@ErenAri ErenAri changed the title feat(validator): auto-type socket-filter programs libbpf can't classify by section name feat(validator): set program type when libbpf can't infer it (auto-type + manifest override) Jun 22, 2026
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.

1 participant