github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/trace/dns/tracer/dns_bpfel.go (about) 1 // Code generated by bpf2go; DO NOT EDIT. 2 //go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64 3 4 package tracer 5 6 import ( 7 "bytes" 8 _ "embed" 9 "fmt" 10 "io" 11 12 "github.com/cilium/ebpf" 13 ) 14 15 type dnsEventT struct { 16 Netns uint32 17 _ [4]byte 18 Timestamp uint64 19 MountNsId uint64 20 Pid uint32 21 Tid uint32 22 Uid uint32 23 Gid uint32 24 Task [16]uint8 25 SaddrV6 [16]uint8 26 DaddrV6 [16]uint8 27 Af uint16 28 Sport uint16 29 Dport uint16 30 DnsOff uint16 31 Proto uint8 32 PktType uint8 33 _ [6]byte 34 LatencyNs uint64 35 } 36 37 type dnsQueryKeyT struct { 38 PidTgid uint64 39 Id uint16 40 Pad [3]uint16 41 } 42 43 type dnsSocketsKey struct { 44 Netns uint32 45 Family uint16 46 Proto uint8 47 _ [1]byte 48 Port uint16 49 _ [2]byte 50 } 51 52 type dnsSocketsValue struct { 53 Mntns uint64 54 PidTgid uint64 55 UidGid uint64 56 Task [16]int8 57 Sock uint64 58 DeletionTimestamp uint64 59 Ipv6only int8 60 _ [7]byte 61 } 62 63 // loadDns returns the embedded CollectionSpec for dns. 64 func loadDns() (*ebpf.CollectionSpec, error) { 65 reader := bytes.NewReader(_DnsBytes) 66 spec, err := ebpf.LoadCollectionSpecFromReader(reader) 67 if err != nil { 68 return nil, fmt.Errorf("can't load dns: %w", err) 69 } 70 71 return spec, err 72 } 73 74 // loadDnsObjects loads dns and converts it into a struct. 75 // 76 // The following types are suitable as obj argument: 77 // 78 // *dnsObjects 79 // *dnsPrograms 80 // *dnsMaps 81 // 82 // See ebpf.CollectionSpec.LoadAndAssign documentation for details. 83 func loadDnsObjects(obj interface{}, opts *ebpf.CollectionOptions) error { 84 spec, err := loadDns() 85 if err != nil { 86 return err 87 } 88 89 return spec.LoadAndAssign(obj, opts) 90 } 91 92 // dnsSpecs contains maps and programs before they are loaded into the kernel. 93 // 94 // It can be passed ebpf.CollectionSpec.Assign. 95 type dnsSpecs struct { 96 dnsProgramSpecs 97 dnsMapSpecs 98 } 99 100 // dnsSpecs contains programs before they are loaded into the kernel. 101 // 102 // It can be passed ebpf.CollectionSpec.Assign. 103 type dnsProgramSpecs struct { 104 IgTraceDns *ebpf.ProgramSpec `ebpf:"ig_trace_dns"` 105 } 106 107 // dnsMapSpecs contains maps before they are loaded into the kernel. 108 // 109 // It can be passed ebpf.CollectionSpec.Assign. 110 type dnsMapSpecs struct { 111 Events *ebpf.MapSpec `ebpf:"events"` 112 GadgetSockets *ebpf.MapSpec `ebpf:"gadget_sockets"` 113 QueryMap *ebpf.MapSpec `ebpf:"query_map"` 114 } 115 116 // dnsObjects contains all objects after they have been loaded into the kernel. 117 // 118 // It can be passed to loadDnsObjects or ebpf.CollectionSpec.LoadAndAssign. 119 type dnsObjects struct { 120 dnsPrograms 121 dnsMaps 122 } 123 124 func (o *dnsObjects) Close() error { 125 return _DnsClose( 126 &o.dnsPrograms, 127 &o.dnsMaps, 128 ) 129 } 130 131 // dnsMaps contains all maps after they have been loaded into the kernel. 132 // 133 // It can be passed to loadDnsObjects or ebpf.CollectionSpec.LoadAndAssign. 134 type dnsMaps struct { 135 Events *ebpf.Map `ebpf:"events"` 136 GadgetSockets *ebpf.Map `ebpf:"gadget_sockets"` 137 QueryMap *ebpf.Map `ebpf:"query_map"` 138 } 139 140 func (m *dnsMaps) Close() error { 141 return _DnsClose( 142 m.Events, 143 m.GadgetSockets, 144 m.QueryMap, 145 ) 146 } 147 148 // dnsPrograms contains all programs after they have been loaded into the kernel. 149 // 150 // It can be passed to loadDnsObjects or ebpf.CollectionSpec.LoadAndAssign. 151 type dnsPrograms struct { 152 IgTraceDns *ebpf.Program `ebpf:"ig_trace_dns"` 153 } 154 155 func (p *dnsPrograms) Close() error { 156 return _DnsClose( 157 p.IgTraceDns, 158 ) 159 } 160 161 func _DnsClose(closers ...io.Closer) error { 162 for _, closer := range closers { 163 if err := closer.Close(); err != nil { 164 return err 165 } 166 } 167 return nil 168 } 169 170 // Do not access this directly. 171 // 172 //go:embed dns_bpfel.o 173 var _DnsBytes []byte