-
Notifications
You must be signed in to change notification settings - Fork 0
/
rake_bpfeb.go
140 lines (122 loc) · 3.51 KB
/
rake_bpfeb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Code generated by bpf2go; DO NOT EDIT.
//go:build arm64be || armbe || mips || mips64 || mips64p32 || ppc64 || s390 || s390x || sparc || sparc64
// +build arm64be armbe mips mips64 mips64p32 ppc64 s390 s390x sparc sparc64
package socklimit
import (
"bytes"
_ "embed"
"fmt"
"io"
"github.com/cilium/ebpf"
)
// loadRake returns the embedded CollectionSpec for rake.
func loadRake() (*ebpf.CollectionSpec, error) {
reader := bytes.NewReader(_RakeBytes)
spec, err := ebpf.LoadCollectionSpecFromReader(reader)
if err != nil {
return nil, fmt.Errorf("can't load rake: %w", err)
}
return spec, err
}
// loadRakeObjects loads rake and converts it into a struct.
//
// The following types are suitable as obj argument:
//
// *rakeObjects
// *rakePrograms
// *rakeMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadRakeObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
spec, err := loadRake()
if err != nil {
return err
}
return spec.LoadAndAssign(obj, opts)
}
// rakeSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type rakeSpecs struct {
rakeProgramSpecs
rakeMapSpecs
}
// rakeSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type rakeProgramSpecs struct {
FilterIpv4 *ebpf.ProgramSpec `ebpf:"filter_ipv4"`
FilterIpv6 *ebpf.ProgramSpec `ebpf:"filter_ipv6"`
TestEwma *ebpf.ProgramSpec `ebpf:"test_ewma"`
TestFpCmp *ebpf.ProgramSpec `ebpf:"test_fp_cmp"`
TestIpv4 *ebpf.ProgramSpec `ebpf:"test_ipv4"`
TestIpv6 *ebpf.ProgramSpec `ebpf:"test_ipv6"`
}
// rakeMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type rakeMapSpecs struct {
Countmin *ebpf.MapSpec `ebpf:"countmin"`
Stats *ebpf.MapSpec `ebpf:"stats"`
TestSingleResult *ebpf.MapSpec `ebpf:"test_single_result"`
}
// rakeObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadRakeObjects or ebpf.CollectionSpec.LoadAndAssign.
type rakeObjects struct {
rakePrograms
rakeMaps
}
func (o *rakeObjects) Close() error {
return _RakeClose(
&o.rakePrograms,
&o.rakeMaps,
)
}
// rakeMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadRakeObjects or ebpf.CollectionSpec.LoadAndAssign.
type rakeMaps struct {
Countmin *ebpf.Map `ebpf:"countmin"`
Stats *ebpf.Map `ebpf:"stats"`
TestSingleResult *ebpf.Map `ebpf:"test_single_result"`
}
func (m *rakeMaps) Close() error {
return _RakeClose(
m.Countmin,
m.Stats,
m.TestSingleResult,
)
}
// rakePrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadRakeObjects or ebpf.CollectionSpec.LoadAndAssign.
type rakePrograms struct {
FilterIpv4 *ebpf.Program `ebpf:"filter_ipv4"`
FilterIpv6 *ebpf.Program `ebpf:"filter_ipv6"`
TestEwma *ebpf.Program `ebpf:"test_ewma"`
TestFpCmp *ebpf.Program `ebpf:"test_fp_cmp"`
TestIpv4 *ebpf.Program `ebpf:"test_ipv4"`
TestIpv6 *ebpf.Program `ebpf:"test_ipv6"`
}
func (p *rakePrograms) Close() error {
return _RakeClose(
p.FilterIpv4,
p.FilterIpv6,
p.TestEwma,
p.TestFpCmp,
p.TestIpv4,
p.TestIpv6,
)
}
func _RakeClose(closers ...io.Closer) error {
for _, closer := range closers {
if err := closer.Close(); err != nil {
return err
}
}
return nil
}
// Do not access this directly.
//go:embed rake_bpfeb.o
var _RakeBytes []byte