MCPcopy
hub / github.com/cilium/ebpf / Module

Method Module

btf/kernel.go:190–221  ·  view source on GitHub ↗

Module is equivalent to [LoadKernelModuleSpec], except that repeated calls do not copy the spec. All modules also share the return value of [Kernel] as their base.

(name string)

Source from the content-addressed store, hash-verified

188//
189// All modules also share the return value of [Kernel] as their base.
190func (c *Cache) Module(name string) (*Spec, error) {
191 c.mu.RLock()
192 if spec := c.moduleTypes[name]; spec != nil {
193 c.mu.RUnlock()
194 return spec, nil
195 }
196 c.mu.RUnlock()
197
198 c.mu.Lock()
199 defer c.mu.Unlock()
200
201 if spec := c.moduleTypes[name]; spec != nil {
202 return spec, nil
203 }
204
205 if c.moduleTypes == nil {
206 c.moduleTypes = make(map[string]*Spec)
207 }
208
209 base, err := c.kernel()
210 if err != nil {
211 return nil, err
212 }
213
214 spec, err := loadKernelModuleSpec(name, base)
215 if err != nil {
216 return nil, err
217 }
218
219 c.moduleTypes[name] = spec
220 return spec, nil
221}
222
223// Modules returns a sorted list of all loaded modules.
224func (c *Cache) Modules() ([]string, error) {

Callers 4

TestCacheFunction · 0.95
findTargetInModuleFunction · 0.80
applyRelocationsFunction · 0.80

Calls 2

kernelMethod · 0.95
loadKernelModuleSpecFunction · 0.85

Tested by 2

TestCacheFunction · 0.76