MCPcopy
hub / github.com/cilium/ebpf / LoadPinnedProgram

Function LoadPinnedProgram

prog.go:1114–1138  ·  view source on GitHub ↗

LoadPinnedProgram loads a Program from a pin (file) on the BPF virtual filesystem. Requires at least Linux 4.11.

(fileName string, opts *LoadPinOptions)

Source from the content-addressed store, hash-verified

1112//
1113// Requires at least Linux 4.11.
1114func LoadPinnedProgram(fileName string, opts *LoadPinOptions) (*Program, error) {
1115 fd, typ, err := sys.ObjGetTyped(&sys.ObjGetAttr{
1116 Pathname: sys.NewStringPointer(fileName),
1117 FileFlags: opts.Marshal(),
1118 })
1119 if err != nil {
1120 return nil, err
1121 }
1122
1123 if typ != sys.BPF_TYPE_PROG {
1124 _ = fd.Close()
1125 return nil, fmt.Errorf("%s is not a Program", fileName)
1126 }
1127
1128 p, err := newProgramFromFD(fd)
1129 if err == nil {
1130 p.pinnedPath = fileName
1131
1132 if haveObjName() != nil {
1133 p.name = filepath.Base(fileName)
1134 }
1135 }
1136
1137 return p, err
1138}
1139
1140// ProgramGetNextID returns the ID of the next eBPF program.
1141//

Callers 3

TestLoadWrongPinFunction · 0.85
TestProgramPinFunction · 0.85

Calls 5

ObjGetTypedFunction · 0.92
NewStringPointerFunction · 0.92
newProgramFromFDFunction · 0.85
CloseMethod · 0.65
MarshalMethod · 0.45

Tested by 3

TestLoadWrongPinFunction · 0.68
TestProgramPinFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…