cilium / ebpf

ebpf-go is a pure-Go library to read, modify and load eBPF programs and attach them to various hooks in the Linux kernel.
https://ebpf-go.dev
MIT License
6.39k stars 699 forks source link

btf: move wire type definitions into sys #1218

Open lmb opened 1 year ago

lmb commented 1 year ago

btf_types.go contains a bunch of hand written structs that map to types defined in the kernel's UAPI. We should replace these with auto generated types in sys package and use those from btf. This guarantees that we match the kernel 1:1 and also ensures that there is no implicit padding present.

The changes need to be made here: https://github.com/cilium/ebpf/blob/0acd95c6c83cabeff32e94594cd4b7de6e7df4a2/internal/cmd/gentypes/main.go#L157-L208

amiremohamadi commented 11 months ago

I see bunch of helper functions and methods in btf_types.go. are we gonna keep them inside that file and just auto generate the structs inside sys package?

@lmb

lmb commented 10 months ago

We could move those into a separate file in sys. That way we can have manually written methods on auto generated types.