Skip to content

Commit 2f6748d

Browse files
committed
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 <[email protected]> Link: tailscale/tailscale#9555 Signed-off-by: James Tucker <[email protected]>
1 parent 202a340 commit 2f6748d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tun/tun_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func (tun *NativeTun) MTU() (int, error) {
127127

128128
// TODO: This is a temporary hack. We really need to be monitoring the interface in real time and adapting to MTU changes.
129129
func (tun *NativeTun) ForceMTU(mtu int) {
130+
if tun.close.Load() {
131+
return
132+
}
130133
update := tun.forcedMTU != mtu
131134
tun.forcedMTU = mtu
132135
if update {

0 commit comments

Comments
 (0)