MCPcopy Index your code
hub / github.com/cilium/ebpf / structOpsPopulateValue

Function structOpsPopulateValue

struct_ops.go:121–138  ·  view source on GitHub ↗

structOpsPopulateValue writes a `prog FD` which references to `p` into the struct_ops value buffer `kernVData` at byte offset `dstOff` corresponding to the member `km`.

(km btf.Member, kernVData []byte, p *Program)

Source from the content-addressed store, hash-verified

119// struct_ops value buffer `kernVData` at byte offset `dstOff` corresponding to
120// the member `km`.
121func structOpsPopulateValue(km btf.Member, kernVData []byte, p *Program) error {
122 if err := structOpsFuncPtrMember(km); err != nil {
123 return err
124 }
125
126 layout, err := newStructOpsMemberLayout(km)
127 if err != nil {
128 return err
129 }
130
131 dst, err := layout.bytes(kernVData)
132 if err != nil || len(dst) != 8 {
133 return fmt.Errorf("member %q: value buffer too small for func ptr", km.Name)
134 }
135
136 internal.NativeEndian.PutUint64(dst, uint64(p.FD()))
137 return nil
138}
139
140// structOpsValidateMemberPair checks whether `m` can be copied into `km`.
141func structOpsValidateMemberPair(m, km btf.Member) (int, error) {

Callers 1

populateStructOpsMethod · 0.85

Calls 4

structOpsFuncPtrMemberFunction · 0.85
newStructOpsMemberLayoutFunction · 0.85
bytesMethod · 0.80
FDMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…