microsoft / microsoft/ebpf-for-windows
bpf_map_lookup_batch map api: Fails to fetch all entries, when the next key is deleted in the hash map.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 311
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 21
Description
### Describe the bug
Concurrent test case:
- Delete an entry/key in the map while the entries are being looked up.
Problem:
The bpf_map_lookup_batch API fails to retrieve all the hash map entries during iteration when one of the next key is deleted. And also, returns ENOENT in the next iteration, when there are more entries.
### OS information
Windows 11 or above.
### Steps taken to reproduce bug
To retrieve entries in batches,
1. Set the batch size to be small.
2. Iterate until ENOENT.
3. Delete the next_key entry, before the next iteration, and continue.
### Expected behavior
All the entries in the hash map should be retrieved.
### Actual outcome
Please add below test case to https://github.com/microsoft/ebpf-for-windows/pull/3563.
TEST_CASE("libbpf hash map del batch", "[libbpf]") { _test_maps_batch(BPF_MAP_TYPE_HASH, **true**); }
```
C:\Users\xxx\ebpf-for-windows-2024\ebpf-for-windows\x64\Debug>unit_tests.exe "libbpf hash map del batch" -d yes
Filters: "libbpf hash map del batch"
Randomness seeded to: 1258998329
No more entries. End of map reached.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit_tests.exe is a Catch2 v3.6.0 host application.
Run with -? for options
-------------------------------------------------------------------------------
libbpf hash map del batch
-------------------------------------------------------------------------------
C:\Users\xxx\ebpf-for-windows-2024\ebpf-for-windows\tests\unit\libbpf_test.cpp(3443)
...............................................................................
C:\Users\xxx\ebpf-for-windows-2024\ebpf-for-windows\tests\unit\libbpf_test.cpp(3276): FAILED:
REQUIRE( returned_keys.size() == batch_size )
with expansion:
1998 (0x7ce) == 19999 (0x4e1f)
0.000 s: libbpf hash map del batch
===============================================================================
test cases: 1 | 0 passed | 1 failed
assertions: 15 | 14 passed | 1 failed
```
### Additional details
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.