Debian Codegraph @

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