summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_windows.go
AgeCommit message (Collapse)Author
2023-12-11tun: fix Device.Read() buf length assumption on WindowsJordan Whited
The length of a packet read from the underlying TUN device may exceed the length of a supplied buffer when MTU exceeds device.MaxMessageSize. Reviewed-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-10-10tun: fix crash when ForceMTU is called after closeJames Tucker
Close closes the events channel, resulting in a panic from send on closed channel. Reported-By: Brad Fitzpatrick <brad@tailscale.com> Signed-off-by: James Tucker <james@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-13global: buff -> bufJason A. Donenfeld
This always struck me as kind of weird and non-standard. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-03-10conn, device, tun: implement vectorized I/O plumbingJordan Whited
Accept packet vectors for reading and writing in the tun.Device and conn.Bind interfaces, so that the internal plumbing between these interfaces now passes a vector of packets. Vectors move untouched between these interfaces, i.e. if 128 packets are received from conn.Bind.Read(), 128 packets are passed to tun.Device.Write(). There is no internal buffering. Currently, existing implementations are only adjusted to have vectors of length one. Subsequent patches will improve that. Also, as a related fixup, use the unix and windows packages rather than the syscall package when possible. Co-authored-by: James Tucker <james@tailscale.com> Signed-off-by: James Tucker <james@tailscale.com> Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-09tun: guard Device.Events() against chan writesJordan Whited
Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-07global: bump copyright yearJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-09-20global: bump copyright yearJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-09-04all: use Go 1.19 and its atomic typesBrad Fitzpatrick
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-12-09global: apply gofumptJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-11-04tun: move wintun to its own repoJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-12wintun: use new swdevice-based API for upcoming Wintun 0.14Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-07tun: windows: set event before waitingJason A. Donenfeld
In 097af6e ("tun: windows: protect reads from closing") we made sure no functions are running when End() is called, to avoid a UaF. But we still need to kick that event somehow, so that Read() is allowed to exit, in order to release the lock. So this commit calls SetEvent, while moving the closing boolean to be atomic so it can be modified without locks, and then moves to a WaitGroup for the RCU-like pattern. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-07tun: windows: rearrange struct to avoid alignment trap on 32bitJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-05-05tun: windows: send MTU update when forced MTU changesJason A. Donenfeld
Otherwise the padding doesn't get updated. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-04-26tun: windows: protect reads from closingJason A. Donenfeld
The code previously used the old errors channel for checking, rather than the simpler boolean, which caused issues on shutdown, since the errors channel was meaningless. However, looking at this exposed a more basic problem: Close() and all the other functions that check the closed boolean can race. So protect with a basic RW lock, to ensure that Close() waits for all pending operations to complete. Reported-by: Joshua Sjoding <joshua.sjoding@scjalliance.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-22tun: make NativeTun.Close well behaved, not crash on double closeBrad Fitzpatrick
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-01-28global: bump copyrightJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-07tun: make customization of WintunPool and requested GUID more obviousJason A. Donenfeld
Persnickety consumers can now do: func init() { tun.WintunPool, _ = wintun.MakePool("Flurp") tun.WintunStaticRequestedGUID, _ = windows.GUIDFromString("{5ae2716f-0b3e-4dc4-a8b5-48eba11a6e16}") } Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-25wintun: log when reboot is suggested by WindowsSimon Rozman
Which really shouldn't happen. But it is a useful information for troubleshooting. Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-25wintun: keep original error when Wintun session start failsSimon Rozman
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-11-07global: switch to using %w instead of %v for ErrorfJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-07wintun: ring management moved to wintun.dllSimon Rozman
Signed-off-by: Simon Rozman <simon@rozman.si> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-07wintun: migrate to wintun.dll APISimon Rozman
Rather than having every application using Wintun driver reinvent the wheel, the Wintun device/adapter/interface management has been moved from wireguard-go to wintun.dll deployed with Wintun itself. Signed-off-by: Simon Rozman <simon@rozman.si>
2020-05-02global: update header comments and modulesJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-01-07tun: windows: serialize write callsJason A. Donenfeld
2019-11-22wintun: manage ring memory manuallyJason A. Donenfeld
It's large and Go's garbage collector doesn't deal with it especially well.
2019-10-17tun: match windows CreateTUN signature to the Linux variantAvery Pennarun
Signed-off-by: Avery Pennarun <apenwarr@gmail.com> [zx2c4: fix default value]
2019-10-08wintun: expose versionJason A. Donenfeld
2019-09-08tun: windows: unify error message formatJason A. Donenfeld
2019-08-30wintun: take mutex so that deletion uses the right nameJason A. Donenfeld
2019-08-29wintun: move ring constants into moduleJason A. Donenfeld
2019-08-29wintun: Wintun->InterfaceJason A. Donenfeld
2019-08-29wintun: introduce adapter poolsSimon Rozman
This makes wintun package reusable for non-WireGuard applications. Signed-off-by: Simon Rozman <simon@rozman.si>
2019-08-24wintun: make description consistent across fieldsJason A. Donenfeld
2019-08-19tun: windows: don't spin unless we really need itJason A. Donenfeld
2019-08-03tun: windows: spin for only a millisecond/80Jason A. Donenfeld
Performance stays the same as before.
2019-07-23tun: windows: styleJason A. Donenfeld
2019-07-22tun: windows: close event handle on shutdownJason A. Donenfeld
2019-07-19tun: windows: get rid of retry logicJason A. Donenfeld
Things work fine on Windows 8.
2019-07-19tun: windows: use specific IOCTL codeJason A. Donenfeld
2019-07-18tun: windows: open file at startup timeJason A. Donenfeld
2019-07-18tun: windows: silently drop packet when ring is fullJason A. Donenfeld
2019-07-18tun: windows: switch to NDIS device objectJason A. Donenfeld
2019-07-18tun: windows: spin for a bit before falling back to event objectJason A. Donenfeld
2019-07-17tun: windows: implement ring buffersSimon Rozman
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-07-05tun: windows: registration of write buffer no longer requiredJason A. Donenfeld
2019-07-05tun: windows: decrease alignment to 4Jason A. Donenfeld
2019-07-04tun: windows: delay initial writeJason A. Donenfeld
Otherwise we provoke Wintun 0.3.
2019-07-01tun: windows: packetNum is unusedJason A. Donenfeld
2019-06-26tun: windows: inform wintun of maximum buffer length for writesJason A. Donenfeld