summaryrefslogtreecommitdiffhomepage
path: root/tun
diff options
context:
space:
mode:
authorJames Tucker <james@tailscale.com>2023-09-27 14:52:21 -0700
committerJason A. Donenfeld <Jason@zx2c4.com>2023-10-10 15:37:17 +0200
commitec8f6f82c20c617a3ea94478f2b5e4d49c6d3c2c (patch)
treeadb403a01a3e2bcc0b821772bba3a8e20b281674 /tun
parent1ec454f253c068f74ba7a7aea34546c9819493c0 (diff)
tun: fix crash when ForceMTU is called after close
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>
Diffstat (limited to 'tun')
-rw-r--r--tun/tun_windows.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 0cb4ce1..34f2980 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -127,6 +127,9 @@ func (tun *NativeTun) MTU() (int, error) {
// TODO: This is a temporary hack. We really need to be monitoring the interface in real time and adapting to MTU changes.
func (tun *NativeTun) ForceMTU(mtu int) {
+ if tun.close.Load() {
+ return
+ }
update := tun.forcedMTU != mtu
tun.forcedMTU = mtu
if update {