Debian Codegraph @

examples/kprobe/bpf_bpfeb.go

raw symbols SCIP
1 // Code generated by bpf2go; DO NOT EDIT.
2 //go:build (mips || mips64 || ppc64 || s390x) && linux
3
4 package main
5
6 import (
7 "bytes"
8 _ "embed"
9 "fmt"
10 "io"
11
12 "github.com/cilium/ebpf"
13 )
14
15 // Names of all BPF objects in the ELF.
16 //
17 // Used for safe lookups in a Collection or CollectionSpec.
18 const (
19 bpfMapKprobeMap = "kprobe_map"
20 bpfProgKprobeExecve = "kprobe_execve"
21 )
22
23 // loadBpf returns the embedded CollectionSpec for bpf.
24 func loadBpf() (*ebpf.CollectionSpec, error) {
25 reader := bytes.NewReader(_BpfBytes)
26 spec, err := ebpf.LoadCollectionSpecFromReader(reader)
27 if err != nil {
28 return nil, fmt.Errorf("can't load bpf: %w", err)
29 }
30
31 return spec, err
32 }
33
34 // loadBpfObjects loads bpf and converts it into a struct.
35 //
36 // The following types are suitable as obj argument:
37 //
38 // *bpfObjects
39 // *bpfPrograms
40 // *bpfMaps
41 //
42 // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
43 func loadBpfObjects(obj any, opts *ebpf.CollectionOptions) error {
44 spec, err := loadBpf()
45 if err != nil {
46 return err
47 }
48
49 return spec.LoadAndAssign(obj, opts)
50 }
51
52 // bpfSpecs contains maps and programs before they are loaded into the kernel.
53 //
54 // It can be passed ebpf.CollectionSpec.Assign.
55 type bpfSpecs struct {
56 bpfProgramSpecs
57 bpfMapSpecs
58 bpfVariableSpecs
59 }
60
61 // bpfProgramSpecs contains programs before they are loaded into the kernel.
62 //
63 // It can be passed ebpf.CollectionSpec.Assign.
64 type bpfProgramSpecs struct {
65 KprobeExecve *ebpf.ProgramSpec `ebpf:"kprobe_execve"`
66 }
67
68 // bpfMapSpecs contains maps before they are loaded into the kernel.
69 //
70 // It can be passed ebpf.CollectionSpec.Assign.
71 type bpfMapSpecs struct {
72 KprobeMap *ebpf.MapSpec `ebpf:"kprobe_map"`
73 }
74
75 // bpfVariableSpecs contains global variables before they are loaded into the kernel.
76 //
77 // It can be passed ebpf.CollectionSpec.Assign.
78 type bpfVariableSpecs struct {
79 }
80
81 // bpfObjects contains all objects after they have been loaded into the kernel.
82 //
83 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
84 type bpfObjects struct {
85 bpfPrograms
86 bpfMaps
87 bpfVariables
88 }
89
90 func (o *bpfObjects) Close() error {
91 return _BpfClose(
92 &o.bpfPrograms,
93 &o.bpfMaps,
94 )
95 }
96
97 // bpfMaps contains all maps after they have been loaded into the kernel.
98 //
99 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
100 type bpfMaps struct {
101 KprobeMap *ebpf.Map `ebpf:"kprobe_map"`
102 }
103
104 func (m *bpfMaps) Close() error {
105 return _BpfClose(
106 m.KprobeMap,
107 )
108 }
109
110 // bpfVariables contains all global variables after they have been loaded into the kernel.
111 //
112 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
113 type bpfVariables struct {
114 }
115
116 // bpfPrograms contains all programs after they have been loaded into the kernel.
117 //
118 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
119 type bpfPrograms struct {
120 KprobeExecve *ebpf.Program `ebpf:"kprobe_execve"`
121 }
122
123 func (p *bpfPrograms) Close() error {
124 return _BpfClose(
125 p.KprobeExecve,
126 )
127 }
128
129 func _BpfClose(closers ...io.Closer) error {
130 for _, closer := range closers {
131 if err := closer.Close(); err != nil {
132 return err
133 }
134 }
135 return nil
136 }
137
138 // Do not access this directly.
139 //
140 //go:embed bpf_bpfeb.o
141 var _BpfBytes []byte