
One notable change is cgroup manager's Set now accept Resources rather than Cgroup (see https://github.com/opencontainers/runc/pull/2906). Modify the code accordingly. Also update runc dependencies (as hinted by hack/lint-depdendencies.sh): github.com/cilium/ebpf v0.5.0 github.com/containerd/console v1.0.2 github.com/coreos/go-systemd/v22 v22.3.1 github.com/godbus/dbus/v5 v5.0.4 github.com/moby/sys/mountinfo v0.4.1 golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 github.com/google/go-cmp v0.5.4 github.com/kr/pretty v0.2.1 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package link
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cilium/ebpf"
|
|
)
|
|
|
|
// Tracepoint attaches the given eBPF program to the tracepoint with the given
|
|
// group and name. See /sys/kernel/debug/tracing/events to find available
|
|
// tracepoints. The top-level directory is the group, the event's subdirectory
|
|
// is the name. Example:
|
|
//
|
|
// Tracepoint("syscalls", "sys_enter_fork")
|
|
//
|
|
// Note that attaching eBPF programs to syscalls (sys_enter_*/sys_exit_*) is
|
|
// only possible as of kernel 4.14 (commit cf5f5ce).
|
|
func Tracepoint(group, name string, prog *ebpf.Program) (Link, error) {
|
|
if group == "" || name == "" {
|
|
return nil, fmt.Errorf("group and name cannot be empty: %w", errInvalidInput)
|
|
}
|
|
if prog == nil {
|
|
return nil, fmt.Errorf("prog cannot be nil: %w", errInvalidInput)
|
|
}
|
|
if !rgxTraceEvent.MatchString(group) || !rgxTraceEvent.MatchString(name) {
|
|
return nil, fmt.Errorf("group and name '%s/%s' must be alphanumeric or underscore: %w", group, name, errInvalidInput)
|
|
}
|
|
if prog.Type() != ebpf.TracePoint {
|
|
return nil, fmt.Errorf("eBPF program type %s is not a Tracepoint: %w", prog.Type(), errInvalidInput)
|
|
}
|
|
|
|
tid, err := getTraceEventID(group, name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
fd, err := openTracepointPerfEvent(tid)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pe := &perfEvent{
|
|
fd: fd,
|
|
tracefsID: tid,
|
|
group: group,
|
|
name: name,
|
|
progType: ebpf.TracePoint,
|
|
}
|
|
|
|
if err := pe.attach(prog); err != nil {
|
|
pe.Close()
|
|
return nil, err
|
|
}
|
|
|
|
return pe, nil
|
|
}
|