in pkg/maps/loader.go [322:348]
func (m *BpfMap) DeleteMapEntry(key uintptr) error {
mapFD, err := utils.GetMapFDFromID(int(m.MapID))
if err != nil {
log.Errorf("unable to GetMapFDfromID and ID %d and err %s", int(m.MapID), err)
return fmt.Errorf("unable to get FD: %s", err)
}
defer unix.Close(mapFD)
attr := utils.BpfMapAttr{
MapFD: uint32(mapFD),
Key: uint64(key),
}
ret, _, errno := unix.Syscall(
unix.SYS_BPF,
uintptr(constdef.BPF_MAP_DELETE_ELEM),
uintptr(unsafe.Pointer(&attr)),
unsafe.Sizeof(attr),
)
if errno != 0 {
log.Errorf("unable to delete map entry and ret %d and err %s", int(ret), errno)
return fmt.Errorf("unable to update map: %s", errno)
}
log.Infof("Delete map entry done with fd : %d and err %s", int(ret), errno)
return nil
}