Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(vpn/tunnel): cancel updater ticks on tunnel stop#16598

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/cancel-updater
Feb 19, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedFeb 18, 2025
edited
Loading

Closescoder/coder-desktop-macos#51.

The shutdown process for the VPN using the dylib is as follows:

  • The manager (Swift, C#) sends a stop request.
  • The tunnel receives the request & stops all tailnet goroutines usingconn.Close()
  • Once finished, the tunnel sends a stop response
  • The tunnel closes it's speaker'ssendCh.
  • The tunnel'sserdessendLoop discovers thesendCh is closed, and exits it'ssendLoop, which, in turn closes the file descriptor for writing on the tunnel's side.

We note that during this process, no contexts are cancelled. If we were to cancel contexts, it would introduce a race between the cancellation, and the stop response being sent - it would be possible for the stop response to never get sent. Unfortunately, there's one context in this process that we do need to cancel, and it's theupdater struct, whose context protects thesendCh from the ticker for periodically updating the manager with the network state of peers.

As we never cancelled the tunnel context (my bad!), it was possible for theupdater to attempt to write to thesendCh after it was closed, causing a panic in the dylib. Since we can't cancel the tunnel context, we'll just cancel the updater context.

This meant stopping the VPN, and then starting it before that timer fire would cause the VPN to fail to start, as the panic would happen on the old process and crash the new VPN instance. If you just stopped the VPN, no error would be reported as the panic wouldn't be noticed once the OS stops caring about the status of the VPN.

This was an issue in two scenarios:

  • Stopping and then quickly starting the VPN via the GUI.
  • When we tried to implement starting and stopping the tunnel on wake & sleep.

This patch fixes both of these scenarios.

@ethanndicksonGraphite App
Copy link
MemberAuthor

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@ethanndicksonethanndickson merged commit2a248b1 intomainFeb 19, 2025
57 checks passed
@ethanndicksonethanndickson deleted the ethan/cancel-updater branchFebruary 19, 2025 02:13
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 19, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@ThomasK33ThomasK33ThomasK33 approved these changes

@deansheatherdeansheatherAwaiting requested review from deansheather

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Tunnel can't be stopped and started while the NE is running
2 participants
@ethanndickson@ThomasK33

[8]ページ先頭

©2009-2025 Movatter.jp