mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
f28a8cc28c
Caught by golangci-lint when enabling golint:
libcontainer/cgroups/ebpf/ebpf.go:35:12: SA1019: prog.Attach is deprecated: use link.RawAttachProgram instead. (staticcheck)
if err := prog.Attach(dirFD, ebpf.AttachCGroupDevice, unix.BPF_F_ALLOW_MULTI); err != nil {
^
libcontainer/cgroups/ebpf/ebpf.go:39:13: SA1019: prog.Detach is deprecated: use link.RawDetachProgram instead. (staticcheck)
if err := prog.Detach(dirFD, ebpf.AttachCGroupDevice, unix.BPF_F_ALLOW_MULTI); err != nil {
^
Worth noting that we currently call prog.Detach() with unix.BPF_F_ALLOW_MULTI;
https://github.com/golang/sys/blob/22da62e12c0cd9c1da93581e1113ca4d82a5be14/unix/zerrors_linux.go#L178
BPF_F_ALLOW_MULTI = 0x2
Looking at the source code for prog.Detach(); https://github.com/cilium/ebpf/blob/v0.4.0/prog.go#L579-L581,
this would _always_ produce an error:
if flags != 0 {
return errors.New("flags must be zero")
}
Note that the flags parameter is not used (except for that validation)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
eBPF
eBPF is a pure Go library that provides utilities for loading, compiling, and debugging eBPF programs. It has minimal external dependencies and is intended to be used in long running processes.
- asm contains a basic assembler
- link allows attaching eBPF to various hooks
- perf allows reading from a
PERF_EVENT_ARRAY - cmd/bpf2go allows embedding eBPF in Go
The library is maintained by Cloudflare and Cilium. Feel free to join the #libbpf-go channel on Slack.
Current status
The package is production ready, but the API is explicitly unstable right now. Expect to update your code if you want to follow along.
Requirements
- A version of Go that is supported by upstream
- Linux 4.9, 4.19 or 5.4 (versions in-between should work, but are not tested)
Useful resources
- eBPF.io (recommended)
- Cilium eBPF documentation (recommended)
- Linux documentation on BPF
- eBPF features by Linux version
Regenerating Testdata
Run make in the root of this repository to rebuild testdata in all
subpackages. This requires Docker, as it relies on a standardized build
environment to keep the build output stable.
The toolchain image build files are kept in testdata/docker/.
License
MIT