fix(srv6): synchronize pub/sub handler registrations#31
Merged
Conversation
RegisterHandler appends to pubSubHandlerRegistrations and SendEvent ranges it with no lock. The srv6egress SR-policy-liveness handler is registered after the route/prefix/peer/routing producers have started calling SendEvent, so the concurrent append+range is a data race that can drop the registration. Guard the slice with an RWMutex; SendEvent snapshots under the read lock and sends off-lock so a slow consumer can't stall a concurrent RegisterHandler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RegisterHandlerappends topubSubHandlerRegistrationsandSendEventranges it with no lock. The srv6egress SR-policy-liveness handler is registered after the route/prefix/peer/routing producers have started callingSendEvent, so the concurrent append+range is a data race that can drop the registration (steering liveness silently never wired).Fix
Guard the slice with an
RWMutex.SendEventsnapshots under the read lock and sends off-lock, so a slow consumer can't stall a concurrentRegisterHandler.Review finding
Low (concurrency) C2.
Test
GOOS=linux go vet ./calico-vpp-agent/common/...green.