Skip to content

ebpf: defer batch API probe for batch lookup#2018

Open
arunsingh wants to merge 1 commit into
cilium:mainfrom
arunsingh:fix-batchlookup-feature-probe
Open

ebpf: defer batch API probe for batch lookup#2018
arunsingh wants to merge 1 commit into
cilium:mainfrom
arunsingh:fix-batchlookup-feature-probe

Conversation

@arunsingh
Copy link
Copy Markdown

@arunsingh arunsingh commented May 26, 2026

Fixes #2013.

BatchLookup() and BatchLookupAndDelete() previously called haveBatchAPI() before attempting the actual batch lookup syscall. The feature probe creates a temporary map, which can require CAP_BPF, so a process that only needs to read from an already-open map could fail before trying the operation that would otherwise succeed.

This defers the batch API feature probe until after a non-ENOENT lookup syscall failure, matching the existing BatchUpdate() and BatchDelete() behavior. The normal end-of-iteration ENOENT path remains unchanged.

The regression test creates maps while privileged, drops all effective capabilities, then verifies batch lookup, update, and delete through the existing map FDs.

Tested:

  • go test -exec sudo -run '^(TestHaveBatchAPI|TestMapBatch|TestMapBatchUnprivileged|TestMapBatchCursorReuse)$' .
  • git diff --check -- map.go map_test.go

@arunsingh arunsingh marked this pull request as ready for review May 26, 2026 19:03
@arunsingh arunsingh requested a review from a team as a code owner May 26, 2026 19:03
@arunsingh
Copy link
Copy Markdown
Author

Ready for review. I kept the change limited to BatchLookup/BatchLookupAndDelete via batchLookupCmd(), with ENOENT behavior unchanged. The focused regression and root package tests pass on a Linux VM; details are in the PR description.

Copy link
Copy Markdown
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Change seems good to me, just want to change the regression test.

Comment thread map_test.go Outdated
Signed-off-by: Arun Singh <arunsingh.in@gmail.com>
@arunsingh arunsingh force-pushed the fix-batchlookup-feature-probe branch from 9e63c4a to 20c3fb2 Compare May 27, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve haveBatchAPI() feature probing in BatchLookup()

2 participants