func()

in pkg/maps/loader.go [355:386]


func (m *BpfMap) GetNextMapEntry(key, nextKey uintptr) error {

	mapFD, err := utils.GetMapFDFromID(int(m.MapID))
	if err != nil {
		log.Errorf("unable to GetMapFDfromID and ret %d and err %s", int(mapFD), err)
		return fmt.Errorf("unable to get FD: %s", err)
	}
	defer unix.Close(mapFD)

	attr := utils.BpfMapAttr{
		MapFD: uint32(mapFD),
		Key:   uint64(key),
		Value: uint64(nextKey),
	}
	ret, _, errno := unix.Syscall(
		unix.SYS_BPF,
		uintptr(constdef.BPF_MAP_GET_NEXT_KEY),
		uintptr(unsafe.Pointer(&attr)),
		unsafe.Sizeof(attr),
	)
	if errors.Is(errno, unix.ENOENT) {
		log.Errorf("last entry read done")
		return errno
	}
	if errno != 0 {
		log.Errorf("unable to get next map entry and ret %d and err %s", int(ret), errno)
		return fmt.Errorf("unable to get next map entry: %s", errno)
	}

	log.Infof("Got next map entry with fd : %d and err %s", int(ret), errno)
	return nil
}