
This is to check if runc 1.0.0 (to be released shortly) works with k8s. The commands used were (roughly): hack/pin-dependency.sh github.com/opencontainers/runc v1.0.0 hack/lint-dependencies.sh # Follow its recommendations. hack/pin-dependency.sh github.com/cilium/ebpf v0.6.1 hack/pin-dependency.sh github.com/opencontainers/selinux v1.8.2 hack/pin-dependency.sh github.com/sirupsen/logrus v1.8.1 # Recheck. hack/lint-dependencies.sh GO111MODULE=on go mod edit -dropreplace github.com/willf/bitset hack/update-vendor.sh # Recheck. hack/lint-dependencies.sh hack/update-internal-modules.sh # Recheck. hack/lint-dependencies.sh [v2: rebased, updated runc 3a0234e1fe2e82 -> 2f8e8e9d977500] [v3: testing master + runc pr 3019] [v4: updated to 93a01cd4d0b7a0f08a] [v5: updated to f093cca13d3cf8a484] [v6: rebased] [v7: updated to runc v1.0.0] [v8: rebased] 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", prog)
|
|
//
|
|
// 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,
|
|
typ: tracepointEvent,
|
|
}
|
|
|
|
if err := pe.attach(prog); err != nil {
|
|
pe.Close()
|
|
return nil, err
|
|
}
|
|
|
|
return pe, nil
|
|
}
|