Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ring-buffer map consumer pointer on multiple subscribe/unsubscribe. #3002

Merged
merged 15 commits into from
Nov 8, 2023

Conversation

gtrevi
Copy link
Collaborator

@gtrevi gtrevi commented Oct 25, 2023

Fixes #3001

Description

This PR fixes an initialization issue of the consumer pointer of the ring-buffer map, in multiple subscribe/unsubscribe scenarios.
When subscribing for the first time, the consumer_offset pointer index starts at 0, then by design it only increments. The issue is when a client quits and subscribes again, ebpfcore will subtract its current consumer offset index from a smaller offset from the client's request, therefore causing an arithmetic exception in ebpf_ring_buffer_map_return_buffer when attempting to return data from the buffer.
The fix now returns the actual consumer offset within the reply to each client subscription, so that the queries are in sync with the current ring-buffer's pointer.

Testing

Local, CI/CD

Documentation

n.a.

@gtrevi gtrevi changed the title fix initialization Fix ring-buffer map initialization. Oct 25, 2023
@gtrevi gtrevi changed the title Fix ring-buffer map initialization. Fix ring-buffer map consumer pointer on multiple subscribe/unsuscribe. Oct 27, 2023
@gtrevi gtrevi changed the title Fix ring-buffer map consumer pointer on multiple subscribe/unsuscribe. Fix ring-buffer map consumer pointer on multiple subscribe/unsubscribe. Oct 27, 2023
@rectified95
Copy link
Collaborator

rectified95 commented Oct 31, 2023

Can you write a bit more in the PR description about the ring buffer map, where we use it in eBPF, why it was broken and how it's fixed now?

matthewige
matthewige previously approved these changes Oct 31, 2023
libs/execution_context/ebpf_core.c Show resolved Hide resolved
libs/execution_context/ebpf_maps.c Show resolved Hide resolved
Alan-Jowett
Alan-Jowett previously approved these changes Nov 1, 2023
@Alan-Jowett Alan-Jowett added this pull request to the merge queue Nov 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 1, 2023
dthaler
dthaler previously approved these changes Nov 6, 2023
@gtrevi gtrevi added this pull request to the merge queue Nov 6, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 6, 2023
@gtrevi gtrevi added this pull request to the merge queue Nov 7, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2023
@gtrevi gtrevi added this pull request to the merge queue Nov 7, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2023
@gtrevi gtrevi enabled auto-merge November 7, 2023 23:14
@gtrevi gtrevi dismissed stale reviews from Alan-Jowett, matthewige, and dthaler via 0b49a4f November 7, 2023 23:53
@gtrevi gtrevi disabled auto-merge November 7, 2023 23:55
@Alan-Jowett Alan-Jowett added this pull request to the merge queue Nov 8, 2023
Merged via the queue into microsoft:main with commit cd2535d Nov 8, 2023
76 checks passed
@gtrevi gtrevi deleted the gtrevi/fix-rb-issue branch November 8, 2023 04:36
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.

The ring-buffer map will not trigger a UM callback after a first subscribe/unsubscribe.
7 participants