Skip to content

consomme: add support for dns over tcp - #2807

Merged
Daman Mulye (damanm24) merged 26 commits into
microsoft:mainfrom
damanm24:dns_tcp
Mar 10, 2026
Merged

Daman Mulye (damanm24) merged 26 commits into
microsoft:mainfrom
damanm24:dns_tcp

Conversation

@damanm24

Copy link
Copy Markdown
Contributor

This PR adds support for DNS over TCP.

If a TCP connection is being initiated (by the guest), addressed to consommé's gateway IP on port 53, consommé's TCP module will intercept the request and instead of creating a socket on the host it will submit the DNS query on behalf of the guest using the resolver implementation that was introduced in #2633.

@damanm24
Daman Mulye (damanm24) requested a review from a team as a code owner February 13, 2026 20:15
Copilot AI review requested due to automatic review settings February 13, 2026 20:15
@github-actions github-actions Bot added the unsafe Related to unsafe code label Feb 13, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds DNS over TCP support to the consomme network stack, complementing the existing DNS over UDP functionality introduced in PR #2633. When a guest initiates a TCP connection to the gateway IP on port 53, consomme intercepts the connection and handles DNS queries using platform-specific system resolvers (DnsQueryRaw on Windows, res_nsend on Unix) instead of creating a real host socket.

Changes:

  • Implements virtual TCP DNS handler that processes DNS queries over TCP without real sockets
  • Adds TCP transport support to platform-specific DNS resolver backends (RES_USEVC flag for Unix, DNS_PROTOCOL_TCP for Windows)
  • Refactors DNS backend to use Arc instead of Box to enable sharing between UDP and TCP handlers

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vm/devices/net/net_consomme/consomme/src/lib.rs Defines DNS_PORT constant at crate level for reuse
vm/devices/net/net_consomme/consomme/src/udp.rs Updates UDP DNS handler to include transport type in DnsFlow
vm/devices/net/net_consomme/consomme/src/tcp/ring.rs Removes test-only attribute from is_empty() method (now used in production)
vm/devices/net/net_consomme/consomme/src/tcp.rs Adds TcpBackend enum, DNS TCP connection handling, and poll_dns_backend method
vm/devices/net/net_consomme/consomme/src/dns_resolver/mod.rs Adds DnsTransport enum and changes backend from Box to Arc for sharing
vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs New module implementing DNS TCP framing and message handling per RFC 1035
vm/devices/net/net_consomme/consomme/src/dns_resolver/windows/mod.rs Adds DNS_PROTOCOL_TCP support to Windows resolver backend
vm/devices/net/net_consomme/consomme/src/dns_resolver/unix/glibc.rs Adds RES_USEVC flag support for TCP queries and refactors ResState structure

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
@github-actions

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/unix/glibc.rs
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/tcp.rs Outdated
@github-actions

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/unix/glibc.rs
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs
Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

vm/devices/net/net_consomme/consomme/src/dns_resolver/unix/glibc.rs:227

  • This test comment says “With RES_USEVC set, this should use TCP instead of UDP”, but the test doesn’t actually assert anything about transport selection (it only calls send_query and ignores the result). Consider either renaming the test to reflect what it verifies (options bit manipulation) or adding a deterministic assertion; otherwise it adds extra resolver I/O without validating the intended behavior.
        // With RES_USEVC set, this should use TCP instead of UDP.
        let _answer_len = state.send_query(&sample_dns_query());

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/dns_tcp.rs
Comment thread vm/devices/net/net_consomme/consomme/src/tcp.rs

@benhillis Ben Hillis (benhillis) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

Comment thread vm/devices/net/net_consomme/consomme/src/dns_resolver/unix/glibc.rs
@damanm24
Daman Mulye (damanm24) merged commit 6005b8c into microsoft:main Mar 10, 2026
84 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants