
runc rc95 contains a fix for CVE-2021-30465. runc rc94 provides fixes and improvements. 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>
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package link
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cilium/ebpf"
|
|
)
|
|
|
|
// NetNsInfo contains metadata about a network namespace link.
|
|
type NetNsInfo struct {
|
|
RawLinkInfo
|
|
}
|
|
|
|
// NetNsLink is a program attached to a network namespace.
|
|
type NetNsLink struct {
|
|
*RawLink
|
|
}
|
|
|
|
// AttachNetNs attaches a program to a network namespace.
|
|
func AttachNetNs(ns int, prog *ebpf.Program) (*NetNsLink, error) {
|
|
var attach ebpf.AttachType
|
|
switch t := prog.Type(); t {
|
|
case ebpf.FlowDissector:
|
|
attach = ebpf.AttachFlowDissector
|
|
case ebpf.SkLookup:
|
|
attach = ebpf.AttachSkLookup
|
|
default:
|
|
return nil, fmt.Errorf("can't attach %v to network namespace", t)
|
|
}
|
|
|
|
link, err := AttachRawLink(RawLinkOptions{
|
|
Target: ns,
|
|
Program: prog,
|
|
Attach: attach,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &NetNsLink{link}, nil
|
|
}
|
|
|
|
// LoadPinnedNetNs loads a network namespace link from bpffs.
|
|
func LoadPinnedNetNs(fileName string, opts *ebpf.LoadPinOptions) (*NetNsLink, error) {
|
|
link, err := LoadPinnedRawLink(fileName, NetNsType, opts)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &NetNsLink{link}, nil
|
|
}
|
|
|
|
// Info returns information about the link.
|
|
func (nns *NetNsLink) Info() (*NetNsInfo, error) {
|
|
info, err := nns.RawLink.Info()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &NetNsInfo{*info}, nil
|
|
}
|