Files
runc/vendor/github.com/cilium/ebpf
Sebastiaan van Stijn f28a8cc28c ebpf: replace deprecated prog.Attach/prog.Detach
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>
2021-04-13 12:27:39 +02:00
..
2021-04-02 09:58:23 +02:00
2020-11-09 15:14:23 +09:00
2020-11-09 15:14:23 +09:00
2020-03-07 09:29:29 +01:00
2020-11-09 15:14:23 +09:00
2021-04-02 09:58:23 +02:00
2021-04-02 09:58:23 +02:00
2021-04-02 09:58:23 +02:00
2021-04-02 09:58:23 +02:00
2021-04-02 09:58:23 +02:00
2021-04-02 09:58:23 +02:00
2020-11-09 15:14:23 +09:00
2021-04-02 09:58:23 +02:00

eBPF

PkgGoDev

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

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