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

Function ExampleProgram_unmarshalFromMap

prog_test.go:1044–1073  ·  view source on GitHub ↗

It's possible to read a program directly from a ProgramArray.

()

Source from the content-addressed store, hash-verified

1042
1043// It's possible to read a program directly from a ProgramArray.
1044func ExampleProgram_unmarshalFromMap() {
1045 progArray, err := LoadPinnedMap("/path/to/map", nil)
1046 if err != nil {
1047 panic(err)
1048 }
1049 defer progArray.Close()
1050
1051 // Load a single program
1052 var prog *Program
1053 if err := progArray.Lookup(uint32(0), &prog); err != nil {
1054 panic(err)
1055 }
1056 defer prog.Close()
1057
1058 fmt.Println("first prog:", prog)
1059
1060 // Iterate all programs
1061 var (
1062 key uint32
1063 entries = progArray.Iterate()
1064 )
1065
1066 for entries.Next(&key, &prog) {
1067 fmt.Println(key, "is", prog)
1068 }
1069
1070 if err := entries.Err(); err != nil {
1071 panic(err)
1072 }
1073}
1074
1075func ExampleProgramSpec_Compatible() {
1076 spec := &ProgramSpec{

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
LoadPinnedMapFunction · 0.85
CloseMethod · 0.65
LookupMethod · 0.45
IterateMethod · 0.45
NextMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…