Repository navigation
fix(connlib): clear pending sockets on DNS server re-creation - #9093
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue in the DNS over TCP implementation where stale socket handles can cause panics after DNS server re-creation by clearing pending sockets when new listen addresses are set.
- Introduces a new test to verify no panic occurs after calling set_listen_addresses with a different address set.
- Clears the pending sockets in the Server implementation to avoid referencing outdated SocketHandles.
- Adds conditions in the progress loop to check packet acceptance before processing.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rust/connlib/dns-over-tcp/tests/client_and_server.rs | Added test for verifying no panic on listen address changes and updated progress logic to check packet acceptance |
| rust/connlib/dns-over-tcp/src/server.rs | Clears pending socket mappings upon listen address re-creation |
|
Sentry Issue: APPLE-CLIENT-53 |
|
Sentry Issue: APPLE-CLIENT-52 |
|
Sentry Issue: GUI-CLIENT-4Y |
thomaseizinger
enabled auto-merge
May 12, 2025 09:37
jamilbk
approved these changes
May 12, 2025
This branch was successfully deployed
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.
Our DNS over TCP implementation uses
smoltcpwhich requires us to manage sockets individually, i.e. there is no such thing as a listening socket. Instead, we have to create multiple sockets and rotate through them.Whenever we receive new DNS servers from the host app, we throw away all of those sockets and create new ones.
The way we refer to these sockets internally is via
smoltcp'sSocketHandle. These are just indices into aVecand this access can panic when it is out of range. Normally that doesn't happen because such aSocketHandleis only created when the socket is created and therefore, eachSocketHandlein existence should be valid.What we overlooked is that these sockets get destroyed and re-created when we call
set_listen_addresseswhich happens when the host app tells us about new DNS servers. In that case, sockets that we had just received a query on and are waiting for a response have their handles stored in a temporaryHashMap. Attempting to send back a response for one of those queries will then either fail with an error that the socket is not in the right state or - worse - panic with an out of bounds error if the previously had more listen addresses than we have now.To fix this, we need to clear this map of pending queries every time we call
set_listen_addresses.