Skip to content

fix(rust/gui-client/windows): read DNS servers before starting connlib#6455

Merged
ReactorScram merged 8 commits intomainfrom
fix/dns-issue-6453
Aug 27, 2024
Merged

fix(rust/gui-client/windows): read DNS servers before starting connlib#6455
ReactorScram merged 8 commits intomainfrom
fix/dns-issue-6453

Conversation

@ReactorScram
Copy link
Contributor

Closes #6453

@ReactorScram ReactorScram self-assigned this Aug 27, 2024
@vercel
Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 27, 2024 6:22pm

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Copy link
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

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

Just a couple comment suggestions otherwise LGTM

)
.map_err(|e| Error::PortalConnection(e.to_string()))?;

let dns = self.dns_controller.system_resolvers();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let dns = self.dns_controller.system_resolvers();
// Reading system_resolvers immediately after / during initializing the tun interface can result in an empty read, so read them here before.
let dns = self.dns_controller.system_resolvers();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, did we prove that? Did we see a log where we sent an empty resolver list to connlib?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, yeah maybe that's not the root bug. I think this is it:

  • We call set_dns before the interface is configured
  • update_dns_mapping is effectively a no-op if the interface isn't configured, leaving DNS unset
  • We never call set_dns after the tun interface is configured

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code kinda looks like calling set_dns first just buffers the resolvers for later. Also in the PR I call set_dns first and that appears to be fine? Although we didn't test ifconfig.net on that build.

Maybe we should have written down our hypotheses while we were testing

Copy link
Member

@jamilbk jamilbk Aug 27, 2024

Choose a reason for hiding this comment

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

Hm yeah. But if we never call set_dns after the tun interface is configured, they will be left unset, update_dns_mapping returns immediately and doesn't save them to its internal state.

See here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, the caller of that function does save it. I don't have a stack trace but I assume it flows through here:

pub(crate) fn update_system_resolvers(&mut self, new_dns: Vec<IpAddr>) {
self.system_resolvers = new_dns;
self.update_dns_mapping()
}

Copy link
Member

Choose a reason for hiding this comment

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

Ah, kk. Hmm maybe setting them in this order then just triggers a side effect combined with the path monitoring that results in empty resolvers somehow.

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
@ReactorScram ReactorScram added this pull request to the merge queue Aug 27, 2024
@jamilbk jamilbk changed the title fix(rust/gui-client/windows): read DNS servers before starting connlib fix(rust/gui-client/windows): set DNS servers before starting connlib Aug 27, 2024
@jamilbk jamilbk changed the title fix(rust/gui-client/windows): set DNS servers before starting connlib fix(rust/gui-client/windows): read DNS servers before starting connlib Aug 27, 2024
Merged via the queue into main with commit 2726e1d Aug 27, 2024
@ReactorScram ReactorScram deleted the fix/dns-issue-6453 branch August 27, 2024 19:05
ReactorScram added a commit that referenced this pull request Aug 27, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 27, 2024
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.

bug(rust/gui-client/windows): Default system resolvers not being read

2 participants