Debian Codegraph @

examples/fentry/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 "structs"
12
13 "github.com/cilium/ebpf"
14 )
15
16 type bpfEvent struct {
17 _ structs.HostLayout
18 Comm [16]uint8
19 Sport uint16
20 Dport uint16
21 Saddr uint32
22 Daddr uint32
23 }
24
25 // Names of all BPF objects in the ELF.
26 //
27 // Used for safe lookups in a Collection or CollectionSpec.
28 const (
29 bpfMapEvents = "events"
30 bpfProgTcpConnect = "tcp_connect"
31 )
32
33 // loadBpf returns the embedded CollectionSpec for bpf.
34 func loadBpf() (*ebpf.CollectionSpec, error) {
35 reader := bytes.NewReader(_BpfBytes)
36 spec, err := ebpf.LoadCollectionSpecFromReader(reader)
37 if err != nil {
38 return nil, fmt.Errorf("can't load bpf: %w", err)
39 }
40
41 return spec, err
42 }
43
44 // loadBpfObjects loads bpf and converts it into a struct.
45 //
46 // The following types are suitable as obj argument:
47 //
48 // *bpfObjects
49 // *bpfPrograms
50 // *bpfMaps
51 //
52 // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
53 func loadBpfObjects(obj any, opts *ebpf.CollectionOptions) error {
54 spec, err := loadBpf()
55 if err != nil {
56 return err
57 }
58
59 return spec.LoadAndAssign(obj, opts)
60 }
61
62 // bpfSpecs contains maps and programs before they are loaded into the kernel.
63 //
64 // It can be passed ebpf.CollectionSpec.Assign.
65 type bpfSpecs struct {
66 bpfProgramSpecs
67 bpfMapSpecs
68 bpfVariableSpecs
69 }
70
71 // bpfProgramSpecs contains programs before they are loaded into the kernel.
72 //
73 // It can be passed ebpf.CollectionSpec.Assign.
74 type bpfProgramSpecs struct {
75 TcpConnect *ebpf.ProgramSpec `ebpf:"tcp_connect"`
76 }
77
78 // bpfMapSpecs contains maps before they are loaded into the kernel.
79 //
80 // It can be passed ebpf.CollectionSpec.Assign.
81 type bpfMapSpecs struct {
82 Events *ebpf.MapSpec `ebpf:"events"`
83 }
84
85 // bpfVariableSpecs contains global variables before they are loaded into the kernel.
86 //
87 // It can be passed ebpf.CollectionSpec.Assign.
88 type bpfVariableSpecs struct {
89 }
90
91 // bpfObjects contains all objects after they have been loaded into the kernel.
92 //
93 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
94 type bpfObjects struct {
95 bpfPrograms
96 bpfMaps
97 bpfVariables
98 }
99
100 func (o *bpfObjects) Close() error {
101 return _BpfClose(
102 &o.bpfPrograms,
103 &o.bpfMaps,
104 )
105 }
106
107 // bpfMaps contains all maps after they have been loaded into the kernel.
108 //
109 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
110 type bpfMaps struct {
111 Events *ebpf.Map `ebpf:"events"`
112 }
113
114 func (m *bpfMaps) Close() error {
115 return _BpfClose(
116 m.Events,
117 )
118 }
119
120 // bpfVariables contains all global variables after they have been loaded into the kernel.
121 //
122 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
123 type bpfVariables struct {
124 }
125
126 // bpfPrograms contains all programs after they have been loaded into the kernel.
127 //
128 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
129 type bpfPrograms struct {
130 TcpConnect *ebpf.Program `ebpf:"tcp_connect"`
131 }
132
133 func (p *bpfPrograms) Close() error {
134 return _BpfClose(
135 p.TcpConnect,
136 )
137 }
138
139 func _BpfClose(closers ...io.Closer) error {
140 for _, closer := range closers {
141 if err := closer.Close(); err != nil {
142 return err
143 }
144 }
145 return nil
146 }
147
148 // Do not access this directly.
149 //
150 //go:embed bpf_bpfeb.o
151 var _BpfBytes []byte