Debian Codegraph @

examples/xdp_live_frame/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 bpfProgXdpProgPass = "xdp_prog_pass"
20 bpfProgXdpProgTx = "xdp_prog_tx"
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 XdpProgPass *ebpf.ProgramSpec `ebpf:"xdp_prog_pass"`
66 XdpProgTx *ebpf.ProgramSpec `ebpf:"xdp_prog_tx"`
67 }
68
69 // bpfMapSpecs contains maps before they are loaded into the kernel.
70 //
71 // It can be passed ebpf.CollectionSpec.Assign.
72 type bpfMapSpecs struct {
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 }
102
103 func (m *bpfMaps) Close() error {
104 return _BpfClose()
105 }
106
107 // bpfVariables contains all global variables after they have been loaded into the kernel.
108 //
109 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
110 type bpfVariables struct {
111 }
112
113 // bpfPrograms contains all programs after they have been loaded into the kernel.
114 //
115 // It can be passed to loadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.
116 type bpfPrograms struct {
117 XdpProgPass *ebpf.Program `ebpf:"xdp_prog_pass"`
118 XdpProgTx *ebpf.Program `ebpf:"xdp_prog_tx"`
119 }
120
121 func (p *bpfPrograms) Close() error {
122 return _BpfClose(
123 p.XdpProgPass,
124 p.XdpProgTx,
125 )
126 }
127
128 func _BpfClose(closers ...io.Closer) error {
129 for _, closer := range closers {
130 if err := closer.Close(); err != nil {
131 return err
132 }
133 }
134 return nil
135 }
136
137 // Do not access this directly.
138 //
139 //go:embed bpf_bpfeb.o
140 var _BpfBytes []byte