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

Function structOpsFindInnerType

struct_ops.go:84–94  ·  view source on GitHub ↗

structOpsFindInnerType returns the "inner" struct inside a value struct_ops type. Given a value like: struct bpf_struct_ops_bpf_testmod_ops { struct bpf_struct_ops_common common; struct bpf_testmod_ops data; }; this function returns the *btf.Struct for "bpf_testmod_ops" along with the

(vType *btf.Struct)

Source from the content-addressed store, hash-verified

82// The inner struct name is derived by trimming the "bpf_struct_ops_" prefix
83// from the value's name.
84func structOpsFindInnerType(vType *btf.Struct) (*btf.Struct, uint32, error) {
85 innerName := strings.TrimPrefix(vType.Name, structOpsValuePrefix)
86
87 for _, m := range vType.Members {
88 if st, ok := btf.As[*btf.Struct](m.Type); ok && st.Name == innerName {
89 return st, m.Offset.Bytes(), nil
90 }
91 }
92
93 return nil, 0, fmt.Errorf("inner struct %q not found in %s", innerName, vType.Name)
94}
95
96// structOpsFindTarget resolves the kernel-side "value struct" for a struct_ops map.
97func structOpsFindTarget(userType *btf.Struct, cache *btf.Cache) (vType *btf.Struct, id btf.TypeID, module *btf.Handle, err error) {

Callers 1

populateStructOpsMethod · 0.85

Calls 1

BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…