Skip to content

Commit

Permalink
Retry wintun creation (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrownus authored Oct 16, 2023
1 parent c289c7a commit 5fccbb8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions overlay/tun_wintun_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ func newWinTun(l *logrus.Logger, deviceName string, cidr *net.IPNet, defaultMTU
return nil, fmt.Errorf("generate GUID failed: %w", err)
}

tunDevice, err := wintun.CreateTUNWithRequestedGUID(deviceName, guid, defaultMTU)
var tunDevice wintun.Device
tunDevice, err = wintun.CreateTUNWithRequestedGUID(deviceName, guid, defaultMTU)
if err != nil {
return nil, fmt.Errorf("create TUN device failed: %w", err)
// Windows 10 has an issue with unclean shutdowns not fully cleaning up the wintun device.
// Trying a second time resolves the issue.
l.WithError(err).Debug("Failed to create wintun device, retrying")
tunDevice, err = wintun.CreateTUNWithRequestedGUID(deviceName, guid, defaultMTU)
if err != nil {
return nil, fmt.Errorf("create TUN device failed: %w", err)
}
}

routeTree, err := makeRouteTree(l, routes, false)
Expand Down

0 comments on commit 5fccbb8

Please sign in to comment.