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

Method batchUpdate

map.go:1412–1438  ·  view source on GitHub ↗
(count int, keys any, valuePtr sys.Pointer, opts *BatchOptions)

Source from the content-addressed store, hash-verified

1410}
1411
1412func (m *Map) batchUpdate(count int, keys any, valuePtr sys.Pointer, opts *BatchOptions) (int, error) {
1413 keyPtr, err := marshalMapSyscallInput(keys, count*int(m.keySize))
1414 if err != nil {
1415 return 0, err
1416 }
1417
1418 attr := sys.MapUpdateBatchAttr{
1419 MapFd: m.fd.Uint(),
1420 Keys: keyPtr,
1421 Values: valuePtr,
1422 Count: uint32(count),
1423 }
1424 if opts != nil {
1425 attr.ElemFlags = opts.ElemFlags
1426 attr.Flags = opts.Flags
1427 }
1428
1429 err = sys.MapUpdateBatch(&attr)
1430 if err != nil {
1431 if haveFeatErr := haveBatchAPI(); haveFeatErr != nil {
1432 return 0, haveFeatErr
1433 }
1434 return int(attr.Count), fmt.Errorf("batch update: %w", wrapMapError(err))
1435 }
1436
1437 return int(attr.Count), nil
1438}
1439
1440func (m *Map) batchUpdatePerCPU(keys, values any, opts *BatchOptions) (int, error) {
1441 count, err := sliceLen(keys)

Callers 2

BatchUpdateMethod · 0.95
batchUpdatePerCPUMethod · 0.95

Calls 4

MapUpdateBatchFunction · 0.92
marshalMapSyscallInputFunction · 0.85
wrapMapErrorFunction · 0.85
UintMethod · 0.80

Tested by

no test coverage detected